TAILIEUCHUNG - Character Animation with Direct3D- P17

Character Animation with Direct3D- P17:This book is primarily aimed at teaching indie and hobby game developers how to create character animation with Direct3D. Also, the seasoned professional game developer may find some interesting things in this book. You will need a solid understanding of the C++ programming language as well as general object-oriented programming skills. | 306 Character Animation with Direct3D On the surface this class also looks like a straight port from the Flock class and in most senses it is. However later I ll add more stuff to this class including world obstacles etc. The only really special code worth looking at in the upcoming example is the Update method of the CrowdEntityclass which implements the few current steering behaviors void CrowdEntity Update float deltaTime const float ENTITY_INFLUENCE_RADIUS const float NEIGHBOR_REPULSION const float ENTITY_SPEED const float ENTITY_SIZE Force toward goal D3DXVECTOR3 forceToGoal m_goal - m_position Has goal been reached if D3DXVec3Length forceToGoal ENTITY_INFLUENCE_RADIUS Pick a new random goal m_goal GetRandomLocation D3DXVec3Normalize forceToGoal forceToGoal Get neighbors vector CrowdEntity neighbors m_pCrowd- GetNeighbors this ENTITY_INFLUENCE_RADIUS neighbors Avoid bumping into close neighbors D3DXVECTOR3 forceAvoidNeighbors for int i 0 i int i D3DXVECTOR3 toNeighbor toNeighbor neighbors i - m_position - m_position float distToNeighbor D3DXVec3Length toNeighbor float force distToNeighbor ENTITY_INFLUENCE_RADIUS forceAvoidNeighbors -toNeighbor NEIGHBOR_REPULSION force Force move intersecting entities if distToNeighbor ENTITY_SIZE lease purchase PDF Split-Merge on to remove this watermark. Chapter 13 Crowd Simulation 307 D3DXVECTOR3 center m_position neighbors i - m_position D3DXVECTOR3 dir center - m_position D3DXVec3Normalize dir dir Force move both entities m_position center - dir ENTITY_SIZE neighbors i - m_position center dir ENTITY_SIZE Sum up forces D3DXVECTOR3 acc forceToGoal forceAvoidNeighbors D3DXVec3Normalize acc acc Update velocity position m_velocity acc deltaTime D3DXVec3Normalize m_velocity m_velocity m_position m_velocity ENTITY_SPEED deltaTime Update animation m_pAnimController- AdvanceTime deltaTime NULL There is a very simple .