1/51
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
Update function (to update all game objects), Render function (each object renders itself), Collision checking, and Transform functions for placement and rendering.
What are the four primitive requirements of a game engine?
Iterates through all objects and calls each one's update() function, then destroys any objects marked for removal and performs housekeeping.
What is the purpose of UpdateAll() in a game engine?
Called AFTER UpdateAll(). Erases the screen, draws the background, then calls each object's render() function.
What is the purpose of RenderAll() in a game engine?
VisualObjects (render/physics only), SolidObjects (act as blockers), and TriggerObjects (cause events on collision).
What are the three object arrays in the primitive game engine?
Deleting from a regular array leaves a null/hole at that index. Deleting from an associative array leaves no holes in the data.
Why use associative arrays instead of regular arrays for game objects?
An associative array that holds pointers to the object types (classes) that can be spawned/created.
What is a 'prefab' in the game engine context?
loc (x,y,z position), rot (Euler rotation), collisionRadius, velocity, angVelocity, name, id, and prefabID.
What properties does a GameObject have?
By concatenating "ID" with the current object counter (e.g., "ID0", "ID1", etc.).
How is an object's ID derived in the game engine?
Total Range = radius1 + radius2. Collision if (|obj2.x - obj1.x| < Total Range && |obj2.y - obj1.y| < Total Range). Add Z axis for cube.
What is the formula for a square/cube collider collision check?
Distance = sqrt((x2-x1)² + (y2-y1)² + (z2-z1)²). Collision if Distance < (radius1 + radius2).
What is the formula for a circle/sphere collider?
Only the MOVING objects check for collision — stationary objects do not.
Which objects are responsible for checking collisions?
To check for collisions first before committing the move, preventing screen shake if blocked by a solid object.
Why should you calculate the NEXT position before updating an object's x/y/z?
Type (0 = visual, 1 = solid, 2 = trigger) and location/rotation. The object's class is also passed in.
What is the convention for CreateObject() parameters?
KeyD (calls main instance's KeyDown), MouseH (calls main instance's MouseClick), and MainLoop (the requestAnimationFrame driver).
What static functions does the Main class have?
1) Work in application units, 2) Position camera independently, 3) Define clipping volume in app units, 4) Support parallel or perspective projection.
What are the four requirements for viewing in WebGL?
It doesn't — instead, the inverse of the camera transformations is applied to the entire world.
How does WebGL actually 'move the camera'?
| 1 0 0 -X | | 0 1 0 -Y | | 0 0 1 -Z | | 0 0 0 1 | (negative values applied to world)
What is the camera translation matrix for moving the camera by (X, Y, Z)?
| 1/r 0 0 0 | | 0 1/t 0 0 | | 0 0 1 0 | | 0 0 0 1 | where r=right, t=top
What is the simplified Orthographic Projection matrix (centered at origin)?
| N/R 0 0 0 | | 0 N/T 0 0 | | 0 0 -(F+N)/(F-N) -2FN/(F-N) | | 0 0 -1 0 |
What is the full (simplified) Perspective matrix you need to know?
N must be > 0. For no distortion with aspect ratio 1, N must equal L must equal T.
What constraint must N (near plane) satisfy in a perspective matrix?
| Rx Ux Fx Tx | | Ry Uy Fy Ty | | Rz Uz Fz Tz | | 0 0 0 1 | where R, U, F are normalized right/up/forward vectors.
What is the LookAt matrix?
They are in terms of the NEW coordinate frame. Apply translation BEFORE LookAt if you want movement in global space.
What is the rule for the translation values (Tx, Ty, Tz) in the LookAt matrix?
gl.enable(gl.DEPTH_TEST) for depth test; gl.enable(gl.CULL_FACE) + gl.cullFace(gl.BACK or gl.FRONT) for culling.
How do you enable hidden surface removal and face culling in WebGL?
The Law of Conservation of Energy — some light is absorbed and some is reflected when hitting a surface.
What is the law that light must follow?
It models infinite scattering and absorption globally (shadows, multiple reflections), which is computationally impossible in real-time.
Why is the Rendering Equation not solvable in real-time graphics?
Point source, Distant/Directional light (parallel, like sunlight), Spotlight (restricted angle point light), and Ambient light (uniform everywhere).
What are the four types of simplified light sources?
Diffuse, Specular, and Ambient.
What are the three components of the Phong lighting model?
To Source (light direction), To Viewer (view direction), Normal (surface normal), and Perfect Reflector (ideal reflection vector).
What are the four vectors used in the Phong model?
r = 2(l · n)n - l where l is the light direction and n is the surface normal.
What is the formula for the ideal reflector vector?
It is a perfectly diffuse reflector — light scatters equally in all directions; brightness is proportional to the cosine of the angle of incidence.
What does a Lambertian surface do?
Higher values (100–200) = metal-like tight highlight; lower values (5–10) = plastic-like broad highlight.
How does the shininess coefficient affect specular reflection?
Directional light is assumed to be infinitely far away, so all rays are parallel and strike every surface at the same angle.
Why is the position of a directional light not important?
Normalize both the surface normal and the light direction vector, then take their dot product. Clamp the minimum to 0.
How do you calculate intensity for a directional light?
For each vertex, calculate the specific direction from that vertex to the light source, since it differs for every vertex.
What extra calculation is needed for a point light vs. a directional light?
Multiply the dot product result by (Intensity / distance from light), which reduces the effect at greater distances.
How can you limit the range of a point light?
A spotlight limits the angles it illuminates, using an additional dot product to restrict the cone of light.
What is the key difference between a point light and a spotlight?
1) Specify texture in texture object, 2) Set filter, 3) Set texture function, 4) Set wrap mode, 5) Set perspective correction hint, 6) Bind texture object, 7) Enable texturing, 8) Supply texture coordinates per vertex.
What are the 8 steps for using textures in WebGL?
gl.CLAMP (clamps values to edge color) and gl.REPEAT (tiles the texture). There is also mirrored repeat.
What are the two texture wrapping modes?
When one texel (texture pixel) covers MORE than one screen pixel — the texture is being stretched.
What is Magnification in texturing?
When more than one texel maps to a single screen pixel — the texture is being compressed.
What is Minification in texturing?
Parametric coordinates, Texture coordinates (s,t), Object/World coordinates, and Window coordinates.
What are the four coordinate systems involved in texture mapping?
First mapping the texture onto a simple intermediate surface (like a cylinder, sphere, or box), then mapping from that intermediate shape to the actual object.
What is Two-Part Mapping?
A technique that pre-generates texture maps at multiple (decreasing) resolutions to reduce interpolation errors for small/distant textured objects.
What is Mipmapping?
A technique to simulate highly reflective surfaces without ray-tracing by mapping the surrounding scene onto a simple intermediate shape (cube, sphere, cylinder) and using it as a texture.
What is Environment (Reflection) Mapping?
textureCube(mycube, texcoord) with 3D texture coordinates (usually the vertex position).
What cube map sampler does WebGL use?
Assumes environment is very far; objects can't be concave (no self-reflection); no reflection between objects; needs a new map per object and per viewer position change.
What are the limitations of Environment Mapping?
A technique that perturbs the surface normals at each fragment to simulate surface roughness/bumps under lighting, without actually changing the geometry.
What is Bump Mapping?
As a 2D array (texture image) of normal perturbation values, applied in the fragment shader to alter normals before lighting calculations.
How is a bump map stored and applied?
Point sampling picks the nearest texel; linear filtering averages surrounding texels. Linear filtering reduces aliasing artifacts.
What is the difference between point sampling and linear filtering in texturing?
Images and geometry flow through SEPARATE pipelines that only join at the fragment processor, allowing them to run in parallel.
Why does texture complexity not affect geometry transform performance?
FALSE. An object appears red because it REFLECTS red wavelengths and absorbs all other colors.
T/F: When an object appears red, it is absorbing red light.
An approximation of light reflected everywhere in the scene. It is most useful when directional/point light is very low. It is a scalar < 1 multiplied by the object's RGB color.
What is ambient light and when is it needed?