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 / Example4 / Camera.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-10-30  |  1.8 KB  |  74 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 camera object. Typically this object is very simple so it does not require a cpp file
  13. */
  14. #ifndef __CAMERA_H__
  15. #define __CAMERA_H__
  16.  
  17. #include "d3dfile.h"
  18.  
  19. #include "GameObject.h"
  20. #include "_RO_Camera.h"
  21. //#include "DebugSupport.h"
  22.  
  23. class Camera : _RO_DO_PUBLIC_RO(Camera) , public GameObject
  24. {
  25. public:
  26.     Camera()
  27.     {
  28.         SetReplicaObject(this);        // Setup our forward reference pointer
  29.         mPosition = D3DXVECTOR4(0,0,0,0);
  30.     }
  31.  
  32.     virtual ~Camera()
  33.     {
  34.     }
  35.  
  36.     void PollIt(void)
  37.     {
  38. //        dprintf("Camera $%x: Master(%d) uniqieID %d sessid %d Pos %f,%f,%f\n",(int)this,IsMaster(),GetUniqueID(),GetSessionID(),mPosition.x,mPosition.y,mPosition.z);
  39.     }
  40.  
  41.     bool GetPosition(D3DXVECTOR4 &input)
  42.     {
  43.         input = mPosition;
  44.         return true;
  45.     }
  46.  
  47.     D3DXVECTOR4 GetPosition(void)
  48.     {
  49.         return mPosition;
  50.     }
  51.  
  52.     D3DXVECTOR4 mPosition;
  53.  
  54.     /**
  55.      * This member function is from the ReplicaObject::GetOpaquePointer() virtual function.
  56.      */
  57.     void *GetOpaquePointer(void *data = 0)
  58.     {
  59.         return (GameObject *)(this);
  60.     }
  61.  
  62.     /*
  63.     This virtual callback from the ReplicaObject class is used by the distance based prediction to calculate the distance to another object in our game
  64.     */
  65.     float CalculateDistanceToObject(RNReplicaNet::ReplicaObject *object)
  66.     {
  67.         // Since the OpaquePointer is always inherited from the GameObject pointer for each object we can do this cast safely
  68.         GameObject *gameobject = (GameObject *) object->GetOpaquePointer();
  69.         return GameObject::CalculateDistanceToObject(gameobject);
  70.     }
  71. };
  72.  
  73. #endif
  74.