This blog series is a part of the write-up assignments of our Game Engineering II class in the Master of Entertainment Arts & Engineering program at University of Utah.

This update shows the progress I made during the past week

# Quaternion Vector Rotation

This is not really necessary for this particular project, but I just want to have a better view over my scene. So I added some functionalities to our quaternion class, and the most important part is probably performing rotation on vectors, which is shown below.

eae6320::Math::sVector eae6320::Math::cQuaternion::Rotate(consteae6320::Math::sVector& i_vector) const { eae6320::Math::sVector vectorPart(m_x, m_y, m_z); eae6320::Math::sVector ret; // Quaternion rotation formula ret = vectorPart * 2.0f * eae6320::Math::Dot(vectorPart, i_vector) + (m_w * m_w - eae6320::Math::Dot(vectorPart, vectorPart)) * i_vector + eae6320::Math::Cross(vectorPart, i_vector) * 2.0f * m_w; return ret; }

The result looks okay, there are some jitters when we reach the pitch threshold values,. The problem lies in how we are running the simulation, and I will try to fix it later on.

# Lua File

I created a Lua file format that specifies a graph. I chose to have numbers representing different nodes so that the nodes can be pair up with the adjacency array easier. This file will then be built into my own binary format, which I will show in the next update.

# Interfaces

I have set up the interfaces for graph node and navigation agent, which look like below now.

class cNavigationGraphNode { public: // Constructor/Destructor // ================== cNavigationGraphNode(const Math::sVector & i_position, const std::vector & i_reachableNodes); ~cNavigationGraphNode(); // Getters // ================== const Math::sVector GetPosition() const; const std::vector GetReachableNodes() const; const uint8_t GetId()const; private: // the pointers to the nodes that this node can reach std::vector m_reachableNodes; // the position of this node in the world Math::sVector m_position; // the ID for this node uint8_t m_nodeId; };

class cNavigationGraphAgent { public: // update function of this agent void Update(const float i_dt); // move to a node given the node id. void MoveTo(const uint8_t i_nodeId); // move to a node that is closest to the given position. void MoveTo(const Math::sVector & i_position); // interrupt this agent's current task void Interrupt(); void SetMoveSpeed(float i_speed); float GetMoveSpeed() const; private: // The rigid body that is controlled by this agent Physics::sRigidBodyState* m_rigidBody; // how fast this agent moves float m_moveSpeed; // which node this agent is standing on uint8_t m_occupiedNode; };