lecture 0 n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Lecture 0 PowerPoint Presentation
play fullscreen
1 / 38

Lecture 0

142 Views Download Presentation
Download Presentation

Lecture 0

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. Lecture 0 Shop ‘til you drop! Projects Course Mechanics Warmup Welcome

  2. Welcome to CS195U! • Formally, “Topics in 3D Game Engine Development” • For computers, not consoles • Centered around developing multiple 3D game engines from scratch • Engines implement various 3D game technologies covered in class • Three individual projects • Open-ended final group project • Prerequisites: CS123, one of CS32 or CS195N (latter recommended)

  3. Course topics DOES focus on Does NOT focus on Using existing 3D game engines (Unity, UDK, XNA…) Advanced 3D rendering techniques (try CS224) Realistic physics (rigid body, ragdoll, fluid) Advanced AI*, networking*, game design* • Building a 3D game engine from scratch • Using OpenGL to display 3D environments • Collision detection and response • Game object movement and interaction

  4. What is a 3D game engine? • Core set of components that facilitate game creation • Rendering • Physics • Sound • User input • Artificial intelligence • Networking • No such thing as an engine that can support every typeof game

  5. Real-time strategy (RTS) engines • Large number of low-detail game units • Multiple levels of AI (individual units as well as computer players) • Client/server networking with some lag tolerance • Lockstep protocol • Heightmap-based terrain

  6. Vehicle simulation engines • Low number of high-detail models • Level-of-detail (LOD) management • Minimal latency networking • Advanced realistic physical forces

  7. Lecture 0 Pretty demo time! Projects Course Mechanics Warmup Welcome

  8. Warmup • One-week starter assignment • First-person movement • OpenGL texture loading • Practice using support code, Qt, OpenGL

  9. Demo!

  10. Minecraft(the real game) • Indie game that made millions • Procedurally-generated block world (voxel-based) • Simple, pixelated graphics • Undirected multiplayer gameplay • Players manipulate the shape of the world

  11. Video!

  12. Minecraft(the class project) • Procedural noise for terrain generation • Simple voxel-based collision detection and response • View frustum culling • “Infinite” in all directions

  13. Video!

  14. Platformer • Ellipsoid-mesh collision detection and response • Advanced level representation • Arbitrary 3D levels • Pathfindingover navigation meshes • In-game UI

  15. Video!

  16. Final project • Group project with 1-3 other classmates • Your own idea, developed and implemented • Advanced engine features required • Playtesting with the general public • Polish will be important! • You own your creation

  17. Lecture 0 Bureaucracy is fun! Projects Course Mechanics Warmup Welcome

  18. Project checkpoints • Although there are only four projects, there are weekly checkpoints • Due at 11:59:59pm Tuesdays • Each checkpoint has well-defined objectives • Requirements are minimal, but you get out what you put in • If handin is on-time and meets requirements, it is “complete” • Otherwise, “incomplete”

  19. Fixing incompletes Start • “Retry” within a week • Hand in a late or fixed version, new grade replaces old • 2 extra retries • Allow you to retry a previous retry • Only consumed if complete • A successful retry results in full credit • You will need working versions of all of your checkpoints by the end of the semester • Email the TAs after handing in Full credit Complete? Yes Yes No Use retry? Can use retry? Yes No No credit No

  20. Final grades • Final grades determined solely by number of no-credits by the end of the semester • There is no curve • Do the work, get an A!

  21. Weeklies & playtesting • In-class project components • Have to be made up if missed • Weeklies: 2-3 minute demo by each student briefly stating progress • Non-final weeks of each project • Playtesting: Playing other students’ games and filling out feedback forms • Final week of each project • Exception: Warmup

  22. Collaboration Policies

  23. Lecture 0 Ignore at your peril! Projects Course Mechanics Warmup Welcome

  24. Overview • Build beginnings of engine from minimal starter code • Set up game loop • Create app/screen framework • Become familiar with QtCreator • Practice simple OpenGL calls • First-person movement • Orient camera with mouse • Move player with keyboard

  25. Starter code • Based on Qt framework • Huge, cross-platform framework • Qt handles application loop • Your code resides in callbacks • See comments in method stubs for more details • We strongly recommend separating your engine from QGLWidget (view.cpp)

  26. Game loop refresher • Separate logical steps that happen not necessarily in sync: • Handle user input • Read/write network data • Tick game state • Draw game state • Some games max out CPU, spinning as fast as possible • Don’t do this if not needed (wasteful, kills laptop batteries) • Starter code uses timer to target 60 updates/second

  27. Screens • Rather than have “modes” in view.cpp, abstract out into “screens” • Screens have the same game loop functions • Your application (view.cpp) holds an “active” screen, forwards events (tick, draw, input) to it • Makes menus, different game modes and UI more modular

  28. Coordinate systems y • Different game engines define coordinate systems differently • Most of you will probably use the OpenGL coordinate system • TAs will strive to be coordinate-system independent • “Horizontal plane” • Plane parallel to the ground (in OpenGL, the xz-plane) • “Up-axis” • Axis perpendicular to horizontal plane (in OpenGL, the y-axis) x z z z y x x y

  29. Horizontal player movement • Simple trigonometry for horizontal movement • Player is rotated (yawed) around the up-axis at some angle • Get vector of forward velocity in horizontal plane • Multiply velocity by time since last tick and add to position • Strafing • Same as above, but use angle 90° left or right from the player’s facing direction

  30. Vertical player movement • Acceleration due to gravity • (a reasonable negative constant) • Collision with ground • After previous step: • = 0

  31. OpenGL matrix transformations Vertex • Not the same as the five matrices from CS123 • OpenGL conflates them into two matrices (projection, modelview) • Stored in column-major order rather than row-major • Modelview matrix • Transforms object space to camera space, usually changes every frame • Projection matrix • Has camera parameters (aspect ratio, field of view), usually only changes on window resize Object space Modelview matrix Camera space Projectionmatrix Clip space Perspective division Normalized device space Viewport transformation Screen space

  32. First-person camera glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(fov, ratio, near, far); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(eye, center, up); • ratio is aspect ratio (width/height of screen) • fovshould be between 0 and 180 • gluLookAt() takes 9 arguments, 3 for each vector

  33. Texture loading • Easiest to leverage Qt framework: • Remember to delete textures! QImageimg(path); img = img.mirrored(false, true); unsigned intid; id = view.bindTexture(img, GL_TEXTURE_2D, GL_RGBA,QGLContext::MipMapBindOption|QGLContext::LinearFilteringBindOption);

  34. Texture loading • If you’d rather use straight GL calls: QImageimg(path); img = QGLWidget::convertToGLFormat(img); unsigned intid; glGenTextures(1, &id); glBindTexture(GL_TEXTURE_2D, id); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, img.width(), img.height(),0, GL_RGBA, GL_UNSIGNED_BYTE, img.bits());

  35. Drawing geometry • For this week, you can just use immediate mode: glBindTexture(GL_TEXTURE_2D, id); glEnable(GL_TEXTURE_2D); glBegin(GL_QUADS); glTexCoord2f(0,0); glVertex3f(0,0,0); // remember winding order! glTexCoord2f(1,0); glVertex3f(1,0,0); glTexCoord2f(1,1); glVertex3f(1,1,0); glTexCoord2f(0,1); glVertex3f(0,1,0); glEnd(); glDisable(GL_TEXTURE_2D);

  36. C++ tip of the week • Helpful Qt data structures! • classQList<T> • Like std::vector but much easier to use and usually faster, overrides += and << for quick manipulations • classQHash<K,V> • Useful, general hashtable implementation. Overload the global qHash() function to return int hash for new key types • classQPair<A,B> • A tuple of two types, comes in handy for hash table keys.

  37. C++ tip of the week • Qtforeach loop macro: #include <QtGlobal> QList<int> ints; ints << 1 << 2 << 3; foreach (inti, ints) { cout << i << endl; // Value is a copy } foreach (constint &i, ints) { cout << i << endl; // Value is a reference }

  38. Good Luck!Remember, warmup is due next week!