3D Game Development – Intro to Game Engines Engines Jay Urbain, Ph.D. SE3250 • OpenGL Programming Guide: http://www.glprogramming.com/red/ • http://people.msoe.edu/~urbain/cs421/index.html • http://jmonkeyengine.org
Game engine • System designed for the creation and development of video games. • Software framework for developers. • Core functionality: – rendering engine for 2D or 3D graphics rendering engine for 2D or 3D graphics – physics engine for collision detection/response – Sound – Scripting – Animation – AI – Networking, streaming, memory management, threading, localization support, and a scene graph.
Game engine • The process of game development is often economized, in large part, by reusing/adapting the same game engine to create different games. • Select appropriate Game Engine from engine attributes (previous slide). (previous slide). • Use Java Monkey (jME3) as exemplar.
jMonkeyEngine (jME) • Game engine made for 3D development. • Uses shader technology extensively. • jMonkeyEngine is written in Java and uses LWJGL as its default renderer. • OpenGL 2 through OpenGL 4 is fully supported. OpenGL 2 through OpenGL 4 is fully supported. • jMonkeyEngine is a collection of libraries , making it a low- level game development tool. • Coupled with an IDE like the official jMonkeyEngine 3 SDK it becomes a higher level game development environment with multiple graphical components (NetBeans).
3D Graphics and Audio • OpenGL is the Open Graphics Library, a platform-independent specification for rendering 2D/3D computer graphics. • Alternatively, Microsoft XNA is a set of tools and runtime environment for video game development and management. – XNA is based on .NET Compact Framework 2.0 for Xbox 360 development and .NET Framework 2.0 on Windows. development and .NET Framework 2.0 on Windows. • For Java, there are two implementations of OpenGL-based renderers: – Lightweight Java Game Library (LWJGL) – jme3 uses lwjgl. – Java OpenGL (JOGL) • OpenAL is the Open Audio Library, a platform-independent 3D audio API.
jME -Context, Display, Renderer • Context makes settings, renderer, timer, input and event listeners, display system, accessible to a game. • Display System is what draws the custom JME window (instead of Java Swing). • The Input System is the component that lets you respond to • The Input System is the component that lets you respond to user input: Mouse clicks and movements, keyboard presses, and joystick motions. • The Renderer is what does all the work of calculating how to draw the 3D scenegraph to the 2D screen. • The Shader is a programmable part of the rendering pipeline.
Scene Graph • Objects in a virtual space. • Virtual space where your game appears. • Objects in the scene graph are called spatials . • Spacials have a translation (location), rotation, and scale. • Locations in the scene graph are defined using X, Y, and Z Locations in the scene graph are defined using X, Y, and Z coordinates.
Three Dimensions
Translation
Rotation
Rotation
Geometry • A geometry is the type of spatial that is visible on the screen. • A geometry has a mesh to define its form and a material to define its appearance. a material to define its appearance.
Geometry • A geometry is the type of spatial that is visible on the screen. • A geometry has a mesh to define its form and a material to define its appearance. • Geometry with and without material color.
Nodes Spacial that can have other spatials as children, i.e., a collection. • Children of the node are moved and rotated relative to their parent node. • The scene graph uses a base root node that all spatials are connected to. •
Nodes Spacial that can have other spatials as children, i.e., a collection. • Children of the node are moved and rotated relative to their parent node. • The scene graph uses a base root node that all spatials are connected to. •
Nodes and Geometries
Translate Geometry
Child Geometry Relative to Node
Translate Node
Translate Node
Rotate Node
Rotate Geometry (child object)
Rotate Geometry
Rotate Node about Z-Axis
Scale Node
Scale Node
Scale Child
Scale Child
Organizing with Nodes
Geometry - Polygon, Mesh, Vertex Most visible objects in a 3D scene are made up of polygon meshes – game • characters, terrains, buildings, etc. A mesh is a grid-like structure that represents a complex shape. • Mathematically simple to render in real time, and detailed enough to be • recognizable. Every shape is reduced to a number of connected polygons , usually Every shape is reduced to a number of connected polygons , usually • triangles; including round surfaces. Polygons' corner points are called vertices . • Every vertex is positioned at a coordinate , all vertices together describe • the outline of the shape. Create 3D meshes in tools called mesh editors, e.g in Blender, Maya. • jME can load finished meshes (models) and arrange them in scenes. •
Materials: Color, Lighting/Shading “ Color " is part of an object's light reflection. • Our brain uses shading and reflecting properties to infer an object's shape • and material. Differentiate chalk & milk, skin & paper, water & plastic. • Ambient color • – The uniform base color of the mesh – what it looks like when not The uniform base color of the mesh – what it looks like when not influenced by any light source. – Usually similar to the Diffuse color. – Min. color you need for an object to be visible. Diffuse color • – Base color of the mesh plus shattered light and shadows that are caused by a light source. – Usually similar to the Ambient color.
Ambient Lighting No light source – material color •
Light Sources - Emissive color Emissive color • – The color of light emitted by a light source or glowing material. – Only glowing materials such as lights have an emissive color, normal objects don't have this property. – Often white (sun light).
Light Sources - Reflections Reflections: Shininess • – Degree of shininess of a surface. – Shiny objects have small, clearly outlined specular highlights . (E.g. glass, water, silver) – Normal objects have wide, blurry specular highlights. (E.g. metal, plastic, stone, polished highlights. (E.g. metal, plastic, stone, polished materials). – Uneven objects are not shiny and have no specular highlights. (E.g. cloth, paper, wood, snow) .
Light Sources - Reflections Reflections: Specular Color • – If the material is shiny, then the Specular Color is the color of the reflected highlights. – Usually the same as the emissive color of the light source (e.g. white). – You can use colors to achieve special specular effects, such as metallic or iridescent reflections. or iridescent reflections. – Non-shiny objects have a black specular color.
Materials: Textures Simplest case: object has one texture, the Color Map, loaded from one • image file. The more information you provide to the Color Map, the higher the • degree of detail and realism. Whether you want photo-realistic rendering or "toon" rendering (Cel • Shading), everything depends on the quality of your materials and Shading), everything depends on the quality of your materials and textures. Modern 3D graphics use several layers of information to describe one • material, each mapped layer is a texture.
Color Map / Diffuse Map • A plain image file or a procedural texture that describes an object's visible surface. • The image can have alpha channels for transparency. • A Color Map is the minimum texture. You can map more textures as optional improvements. textures as optional improvements. • Color Maps are unshaded. The same is called Diffuse Map in a Phong-illuminated material, because this texture defines the basic colors of light that are diffused by this object.
Recommend
More recommend