home *** CD-ROM | disk | FTP | other *** search
/ Game Programming in C++ - Start to Finish / GameProgrammingS.iso / developer_install / ReplicaNetFreewareV5_4.exe / data1.cab / Program_Executable_Files / Example9 / Dolphin.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2005-10-30  |  1.3 KB  |  54 lines

  1. /* START_LICENSE_HEADER
  2.  
  3. Copyright (C) 2000 Martin Piper, original design and program code
  4. Copyright (C) 2001-2005 Replica Software
  5.  
  6. This program file is copyright (C) Replica Software and can only be used under license.
  7. For more information visit: http://www.replicanet.com/
  8. Or email: info@replicanet.com
  9.  
  10. END_LICENSE_HEADER */
  11. /*
  12. The Dolphin game object. Every tick the dolphin will move a little using a sin/cos algorithm.
  13. */
  14. #include "Dolphin.h"
  15. #include "RNReplicaNet/Inc/ReplicaNet.h"
  16. #include <math.h>
  17.  
  18. extern CD3DMesh*     gpDolphinMesh;
  19. extern CD3DMesh*     gpAirplaneMesh;
  20.  
  21. Dolphin::Dolphin()
  22. {
  23.     mReplica = this;        // Setup our forward reference pointer
  24.     mMesh = gpDolphinMesh;
  25. //    mMesh = gpAirplaneMesh;
  26.     mPosition = D3DXVECTOR4(0,0,0,0);
  27.     mRotation = D3DXVECTOR4(0,D3DXToRadian(180),0,0);
  28.  
  29. //    mShadow = new ShadowVolume();
  30. }
  31.  
  32. Dolphin::~Dolphin()
  33. {
  34. }
  35.  
  36. void Dolphin::PollIt(void)
  37. {
  38.     // Only run the "physics" if we are a master object
  39.     if (!IsMaster())
  40.     {
  41.         return;
  42.     }
  43.  
  44.     D3DXVECTOR4 velocity = D3DXVECTOR4(0,0,-0.05f,0);
  45.     mRotation.y -= D3DXToRadian(0.1f);
  46.  
  47.     // Calculate the velocity movement
  48.     D3DXMatrixRotationYawPitchRoll(&m_matObjectMatrix,mRotation.y,mRotation.x,mRotation.z);
  49.     D3DXVECTOR4 trans;
  50.     D3DXVec4Transform(&trans,&velocity,&m_matObjectMatrix);
  51.     mPosition += trans;
  52. }
  53.  
  54.