I'm a gameplay programmer
focused on developing
engaging and unique experiences!

My Resume Learn more

Assignment 05

One of the core concepts of a game is the idea of a camera object that acts as the player's view into the simulated game world. This assignment had us create such a concept by utilizing a basic physics structure to simulate movement. The result is a small demo where you can move the camera forward/backward by using the Up/Down Arrows and Left/Right using the Left/Right Arrows. You can also move the white square Up/Down using the W/S keys and Left/Right using the A/D keys. Finally, you can also switch out the white square to a white triangle by holding the Shift Key. Try it out here!

This image demonstrates moving the white square around a reference point with WASD.

This image demonstrates moving the white square to another position also using WASD.

This images shows switching out the white square with a white triangle with Shift.

Game Object Class

Another concept in most modern game engines is the idea of a core class that almost all entities in a game derive off of. The class I've implemented to take on this role is a cGameObject with the following representation:

class cGameObject
		cGameObject(eae6320::Math::sVector i_position, eae6320::Math::cQuaternion i_orientation);
		void CleanUp();
		void Update(const float i_elapsedSecondCount_sinceLastUpdate);

		void SetVelocity(eae6320::Math::sVector i_velocity);

		void SetMeshAndEffect(eae6320::Graphics::cMesh* i_mesh, eae6320::Graphics::cEffect* i_effect);
		eae6320::Graphics::cMesh* GetMesh();
		eae6320::Graphics::cEffect* GetEffect();

		eae6320::Math::cMatrix_transformation GetTransform(const float i_elapsedSecondCount_sinceLastSimulationUpdate);

		eae6320::Physics::sRigidBodyState m_rigidBody;

		eae6320::Graphics::cMesh* m_mesh;
		eae6320::Graphics::cEffect* m_effect;

The main data that is stored in a cGameObject is a rigid body state, a mesh, and an effect. The rigid body state holds the physics state of the game object including its position and rotation. These are useful in determining how the cGameObject should be rendered on the screen. The mesh and effect are data that indicate what should be rendered. This allows any object in our game to have the basic components for placement in our game and visibility.

Submitting game objects to be rendered also use a slightly different interface now that they can move in the simulated world. The call now looks like this:

void eae6320::cMyGame::SubmitDataToBeRendered(const float i_elapsedSecondCount_systemTime, const float i_elapsedSecondCount_sinceLastSimulationUpdate)
eae6320::Graphics::SubmitGameObject(m_object->GetMesh(), m_object->GetEffect(), m_object->GetTransform(i_elapsedSecondCount_sinceLastSimulationUpdate));

The core difference is that a cMatrix_transformation is being passed along with the mesh and effect to indicate how they should be rendered. Something notable about the transform that is passed in is that it is a extrapolated result based on the simulation update time and the game object's physics. This is necessary because our render and game threads are updating at different intervals. With any jumps that happen with game logic, the render thread is extrapolating so that visual movement is smooth. To demonstrate this, the game is actually only updating at 15 FPS, however visually our game is still smooth despite the low update rate on the simulation side.

For Direct3D, the size of sDataRequiredToRenderAFRame is now 328 bytes. For OpenGL it is 308 bytes. This is a notable increase as now for every mesh we also need to cache a transform along with it.

No Comments Yet.

Leave a comment