The DrawableBSP Class

Superclasses:

DrawableObject

Other Subclasses DrawableTracer, DrawableTrail, Drawable2D, DrawableBridge ,   DrawablePlatform ,   DrawablePoint, ddoc-4-draw-overcast
Def:
Implementation: <inline>

DrawableBSP

Subclasses:DrawableShadowed , DrawablePuffDawablePoled DrawableGroundvehicle  and DrawableBuilding

Implementation:
 public:
 DrawableBSP( int type, const Tpoint *pos, const Trotation *rot, float scale = 1.0f );
 virtual ~DrawableBSP();
  protected:
 // This constructor is used only by derived classes who do their own setup
 DrawableBSP( float s, int ID ): DrawableObject( s ), instance(ID) { inhibitDraw = FALSE; labelLen = 0; id = ID; radius = instance.Radius(); };

  public:
 void Update( const Tpoint *pos, const Trotation *rot );

 BOOL IsLegalEmptySlot( int slotNumber ) { return (slotNumber < instance.ParentObject->nSlots) && (instance.SlotChildren) && (instance.SlotChildren[slotNumber] == NULL); };

 int GetNumSlots( void )    { return instance.ParentObject->nSlots; };
 int GetNumDOFs( void )    { return instance.ParentObject->nDOFs; };
 int GetNumSwitches( void )   { return instance.ParentObject->nSwitches; };
 int GetNumDynamicVertices( void ) { return instance.ParentObject->nDynamicCoords; };

 void AttachChild( DrawableBSP *child, int slotNumber );
 void DetachChild( DrawableBSP *child, int slotNumber );
 void GetChildOffset( int slotNumber, Tpoint *offset );

 void SetDOFangle( int DOF, float radians );
 void SetDOFoffset( int DOF, float offset );
 void SetDynamicVertex( int vertID, float dx, float dy, float dz );
 void SetSwitchMask( int switchNumber, UInt32 mask );
 void SetTextureSet( UInt32 set ) { instance.SetTextureSet( set ); };

 float GetDOFangle( int DOF );
 float GetDOFoffset( int DOF );
 void GetDynamicVertex( int vertID, float *dx, float *dy, float *dz );
 UInt32 GetSwitchMask( int switchNumber );
 UInt32 GetTextureSet( void) { return instance.TextureSet; };

 char *Label()           { return label; }
 DWORD LabelColor()          { return labelColor; }
 virtual void SetLabel( char *labelString, DWORD color );
 virtual void SetInhibitFlag( BOOL state )    { inhibitDraw = state; };

 virtual BOOL GetRayHit( const Tpoint *from, const Tpoint *vector, Tpoint *collide, float boxScale = 1.0f );

 virtual void Draw( class RenderOTW *renderer, int LOD );
 virtual void Draw( class Render3D *renderer );

 int  GetID( void )   { return id; };

 // These two functions are used to handle preloading BSP objects for quick drawing later
 static void LockAndLoad( int id )  { TheObjectList[id].ReferenceWithFetch(); };
 static void Unlock( int id )   { TheObjectList[id].Release();  };

 // get object's bounding box
 void GetBoundingBox( Tpoint *minB, Tpoint *maxB );

 // This one is for internal use only.  Don't use it or you'll break things...
 void ForceZ( float z )  { position.z = z; };

  public:
 Trotation   orientation;
 static BOOL   drawLabels;  // Shared by ALL drawable BSPs

  protected:
 int     id;    // TODO: With the new BSP lib, this id could go...
 ObjectInstance  instance;

 BOOL    inhibitDraw; // When TRUE, the Draw function just returns

 char    label[32];
 int     labelLen;
 DWORD    labelColor;

 // Handle time of day notifications
 static void TimeUpdateCallback( void *unused );

  public:
 static void SetupTexturesOnDevice( DWORD rc );
 static void ReleaseTexturesOnDevice( DWORD rc );
 

  protected:
 void DrawBoundingBox( class Render3D *renderer );

#ifdef USE_SH_POOLS
  public:
 // Overload new/delete to use a SmartHeap fixed size pool
 void *operator new(size_t size) { ShiAssert( size == sizeof(DrawableBSP) ); return MemAllocFS(pool); };
 void operator delete(void *mem) { if (mem) MemFreeFS(mem); };
 static void InitializeStorage() { pool = MemPoolInitFS( sizeof(DrawableBSP), 50, 0 ); };
 static void ReleaseStorage() { MemPoolFree( pool ); };
 static MEM_POOL pool;
#endif