home *** CD-ROM | disk | FTP | other *** search
- /*
- Company: Sensaura
- Copyright: (C) 1999
-
- File Name: object3d.h
- File Description: Header file for definition of base classes for D3DRM objects with sounds
- attached
- Author: Adam Philp
- File Version: 1.03.000
- Last Update: 19-APR-00
-
- Target Compiler: Microsoft Visual C++ Version 5.0
- */
-
- #ifndef __object3d_h // Sentry, only use file if not already included
- #define __object3d_h
-
- /////////////////////// Included files ////////////////////////////////////////////////////////////
-
- #include <d3drmwin.h>
- #include <dsound.h>
-
- /////////////////////// Forward declarations //////////////////////////////////////////////////////
-
- class DirectXWorld;
-
- /////////////////////// Enumerators ///////////////////////////////////////////////////////////////
-
- enum D3DRMCOLLISION // Enumerate an object's shape for collision checking
- {
- D3DRMCOLLISION_BOX,
- D3DRMCOLLISION_SPHERE
- };
-
- enum D3DRMOBJECTFLAG // D3DRM object properties
- {
- D3DRMOBJECT_MORTAL = 0x00000001,
- D3DRMOBJECT_SOUNDLOOPING = 0x00000002,
- D3DRMOBJECT_KILLWITHSOUND = 0x00000004,
- D3DRMOBJECT_DONTMOVESOUND = 0x00000008
- };
-
- /*
- Class: D3DRMObject
- Description: Abstract base class from which all 3D objects are derived. A D3DRMObject
- represents an object in the DirectX world which you can see and/or hear.
- It can have a 3D or stereo sound attached which is automatically moved when
- the object is moved.
- */
-
- class D3DRMObject : public D3DRMBOX
- {
- public: // Public constructor & destructor
- D3DRMObject(DirectXWorld*,
- DWORD,
- LPDIRECT3DRMMESHBUILDER,
- DWORD,
- DWORD dwLifeTime = 0,
- D3DRMCOLLISION collision = D3DRMCOLLISION_BOX);
- virtual ~D3DRMObject();
-
- public: // Public member functions
- bool AttachSound(LPCSTR);
- void DetachSound();
- virtual bool Update(D3DVALUE);
- void Kill();
-
- bool Collided(LPDIRECT3DRMFRAME, D3DVALUE);
- DWORD GetAge() const { return m_dwAge; }
- DWORD GetID() const { return m_dwId; }
- LPCSTR GetSound() const { return m_pSound; }
- bool IsMortal() const { return m_dwFlags & D3DRMOBJECT_MORTAL ? true : false; }
- bool IsDead() const { return m_bKilled; }
- bool IsAlive() const { return !IsDead(); }
- bool IsSoundPlaying() const { return m_pBuffer ? true : false; }
-
- public: // Public data members
- LPDIRECT3DRMFRAME2 m_pFrame;
-
- protected: // Protected member functions
- virtual bool CheckCollision(const D3DVECTOR&) = 0;
- virtual D3DVALUE GetCollisionSize() const { return 0; }
-
- protected: // Protected data members
- DirectXWorld* m_pWorld;
- D3DRMCOLLISION m_Collision; // Type of object for collision detection
- DWORD m_dwLifeTime; // Object is killed if dwAge >= dwLifeTime and object
- DWORD m_dwAge; // is mortal. Values in ms
- DWORD m_dwId; // Identifier
- DWORD m_dwFlags; // D3DRMOBJECT_XXX flags
- bool m_bKilled; // true if object has been killed
-
- private: // Private member functions
- bool UpdateSound(DWORD);
- bool UpdateSound3D(DWORD);
- bool UpdateSound2D();
-
- private: // Private data members
- LPCSTR m_pSound;
- LPDIRECTSOUNDBUFFER m_pBuffer;
- LPDIRECTSOUND3DBUFFER m_p3dBuffer;
- };
-
- typedef D3DRMObject* LPD3DRMOBJECT;
-
- /*
- Class: D3DRMBoxObject
- Description: Derived from D3DRMObject. Object is in shape of a box for collision
- detection purposes.
- */
-
- class D3DRMBoxObject : public D3DRMObject
- {
- public: // Constructor and destructor
- D3DRMBoxObject (DirectXWorld*,
- DWORD,
- LPDIRECT3DRMMESHBUILDER,
- DWORD, DWORD);
- ~D3DRMBoxObject () {};
-
- protected: // Overloaded collision detection functions
- virtual bool CheckCollision (const D3DVECTOR&);
- virtual D3DVALUE GetCollisionSize () const;
- };
-
- /*
- Class: D3DRMSphereObject
- Description: Derived from D3DRMObject. Object is in shape of a sphere for collision
- detection purposes.
- */
-
- class D3DRMSphereObject : public D3DRMObject
- {
- public: // Constructor and destructor
- D3DRMSphereObject(DirectXWorld*,
- DWORD,
- LPDIRECT3DRMMESHBUILDER,
- DWORD, DWORD);
- ~D3DRMSphereObject() {};
-
- protected: // Overloaded collision detection functions
- virtual bool CheckCollision(const D3DVECTOR&);
- virtual D3DVALUE GetCollisionSize () const;
- };
-
- /*
- Class: D3DRMObjectList
- Description: Double-linked list of 3D objects.
- */
-
- struct D3DRMNODE
- {
- D3DRMNODE* pNext;
- LPD3DRMOBJECT pObject;
- };
-
- typedef struct D3DRMNODE* LPD3DRMNODE;
-
- class D3DRMObjectList
- {
-
- public:
- D3DRMObjectList();
- virtual ~D3DRMObjectList();
-
- LPD3DRMNODE Insert(LPD3DRMOBJECT);
- LPD3DRMNODE Remove(LPD3DRMNODE);
-
- LPD3DRMNODE InsertHead(LPD3DRMOBJECT);
- LPD3DRMNODE RemoveHead();
-
- LPD3DRMNODE First(DWORD);
- LPD3DRMNODE Last(DWORD);
-
- public:
- LPD3DRMNODE m_pHead;
- LPD3DRMNODE m_pTail;
- int m_nObjects;
- };
-
- #endif // End of sentry
-