torque Torque Game Engine Documentation
CVS Revision Label 1.3.x

InteriorInstance Class Reference

#include <interiorInstance.h>

Inheritance diagram for InteriorInstance:

SceneObject NetObject Container::Link SimObject ConsoleObject

Vertex Lighting

Vertex lighting is the alternative to lightmapped interiors

void rebuildVertexColors ()
 Rebuilds the vertex colors for alarm and normal states for all detail levels.
Vector< ColorI > * getVertexColorsNormal (U32 detail)
 Returns the normal vertex lighting colors for a detail level.
Vector< ColorI > * getVertexColorsAlarm (U32 detail)
 Returns the alarm vertex lighting colors for a detail level.
Vector< Vector< ColorI > * > mVertexColorsNormal
 Vertex colors under normal lighting per detail level.
Vector< Vector< ColorI > * > mVertexColorsAlarm
 Vertex colors under alarm lighting per detail level.

Public Member Functions

 InteriorInstance ()
 ~InteriorInstance ()
bool buildPolyList (AbstractPolyList *polyList, const Box3F &box, const SphereF &sphere)
 Builds a list of polygons which intersect a bounding volume.
bool castRay (const Point3F &start, const Point3F &end, RayInfo *info)
 Casts a ray and obtain collision information, returns true if RayInfo is modified.
virtual void setTransform (const MatrixF &mat)
 Sets the Object -> World transform.
void buildConvex (const Box3F &box, Convex *convex)
 Builds a convex hull for this object.
void renewOverlays ()
 Reloads material information if the interior skin changes.
void setSkinBase (const char *newBase)
 Sets the interior skin to something different.
 DECLARE_CONOBJECT (InteriorInstance)
bool readLightmaps (GBitmap ****lightmaps)
 Reads the lightmaps of the interior into the provided pointer.
void addChildren ()
 Not yet implemented.
LM_HANDLE getLMHandle ()
 Returns the Light Manager handle.
AudioProfilegetAudioProfile ()
 Returns the audio profile.
AudioEnvironmentgetAudioEnvironment ()
 Returns the audio environment.
bool getPointInsideScale (const Point3F &pos, F32 *pScale)
 This is used to determine just how 'inside' a point is in an interior.
Resource< InteriorResource > & getResource ()
 Returns the interior resource.
U32 getCRC ()
 Returns the CRC for validation.
Lighting control
bool inAlarmState ()
 This returns true if the interior is in an alarm state.
void setAlarmMode (const bool alarm)
 This sets the alarm mode of the interior.
void activateLight (const char *pLightName)
 Activates a light with the given name on all detail levels of the interior.
void deactivateLight (const char *pLightName)
 Deactivates a light with the given name on all detail levels of the interior.
void echoTriggerableLights ()
 Echos out all the lights in the interior, starting with triggerable then animated lights.
Subobject access interface
U32 getNumDetailLevels ()
 Returns the number of detail levels for an object.
InteriorgetDetailLevel (const U32 level)
 Gets the interior associated with a particular detail level.
void setDetailLevel (S32 level=-1)
 Sets the detail level to render manually.

Static Public Member Functions

static void init ()
static void destroy ()
static void initPersistFields ()
 Register dynamic fields in a subclass of ConsoleObject.
static void consoleInit ()
 Register global constant variables and do other one-time initialization tasks in a subclass of ConsoleObject.
static bool getRenderDynamicLights ()
 Returns true if the interiors are rendering dynamic lighting.
static void setRenderDynamicLights (bool val)
 Turns on or off dynamic lighting of interiors.

Static Public Attributes

static bool smDontRestrictOutside
static F32 smDetailModification

Protected Member Functions

bool onAdd ()
 Called when the object is added to the sim.
void onRemove ()
 Called when the object is removed from the sim.
void inspectPreApply ()
 Called before any property of the object is changed in the world editor.
void inspectPostApply ()
 Called after any property of the object is changed in the world editor.
void setLightUpdatedTime (const U32)
U32 getLightUpdatedTime () const
bool onSceneAdd (SceneGraph *graph)
 Called when this is added to the SceneGraph.
void onSceneRemove ()
 Called when this is removed from the SceneGraph.
U32 getPointZone (const Point3F &p)
 Returns the zone containing p.
bool getOverlappingZones (SceneObject *obj, U32 *zones, U32 *numZones)
 If an object exists in multiple zones, this method will give you the number and indices of these zones (storing them in the provided variables).
U32 calcDetailLevel (SceneState *, const Point3F &)
bool prepRenderImage (SceneState *state, const U32 stateKey, const U32 startZone, const bool modifyBaseZoneState)
 Called when the SceneGraph is ready for the registration of RenderImages.
void renderObject (SceneState *state, SceneRenderImage *image)
 Called when the object is supposed to render itself.
bool scopeObject (const Point3F &rootPosition, const F32 rootDistance, bool *zoneScopeState)
 This is called on a zone managing object to scope all the zones managed.

Protected Attributes

U32 mLightUpdatedTime

Static Protected Attributes

static U32 smLightUpdatePeriod
static bool smRenderDynamicLights

Private Types

typedef SceneObject Parent
enum  UpdateMaskBits {
  InitMask = BIT(0),
  TransformMask = BIT(1),
  AlarmMask = BIT(2),
  _lightupdate0 = BIT(3),
  _lightupdate1 = BIT(4),
  _lightupdate2 = BIT(5),
  _lightupdate3 = BIT(6),
  _lightupdate4 = BIT(7),
  _lightupdate5 = BIT(8),
  _lightupdate6 = BIT(9),
  _lightupdate7 = BIT(10),
  SkinBaseMask = BIT(11),
  AudioMask = BIT(12),
  NextFreeMask = BIT(13)
}
enum  Constants {
  LightUpdateBitStart = 3,
  LightUpdateBitEnd = 10
}
enum  AlarmState {
  Normal = 0,
  Alarm = 1
}

Private Member Functions

U32 packUpdate (NetConnection *conn, U32 mask, BitStream *stream)
 Instructs this object to pack its state for transfer over the network.
void unpackUpdate (NetConnection *conn, BitStream *stream)
 Instructs this object to read state data previously packed with packUpdate.
void createTriggerTransform (const InteriorResTrigger *trigger, MatrixF *transform)
 Creates a transform based on an trigger area.
Light utility methods
These should not be called directly. Use the public activateLight(const char *) method instead because unless the detail level is rendering and it's much easier to not manage the lights on a per-detail level basis.

void activateLight (const U32 detail, const U32 lightIndex)
 Activates a specific light for a detail level.
void deactivateLight (const U32 detail, const U32 lightIndex)
 Deactivates a specific light for a detail level.
Animated light functions
void updateLightTime (const U32 detail, const U32 lightIndex, const U32 ms)
 Steps the animated light simulation by a delta.
void downloadLightmaps (SceneState *state, Interior *pInterior, LightInfo &rLightInfo)
 This loops through all the surfaces in an interior and calls updateLightMap on them.
void installLight (const U32 detail, const U32 lightIndex)
 This will set up a particular light in a particular detail level.
void updateLoopingLight (Interior *interior, LightInfo::Light &light, const U32 lightIndex, const U32 ms)
 Called by updateLightTime to update a light with a looping animation.
void updateFlickerLight (Interior *interior, LightInfo::Light &light, const U32 lightIndex, const U32 ms)
 Called by updateLightTime to update a light with a flicker animation.
void updateRampLight (Interior *interior, LightInfo::Light &light, const U32 lightIndex, const U32 ms)
 Called by updateLightTime to update a light with a fade-up (ramp) animation light.
void updateAllLights (const U32 ms)
 Updates the animation for all lights.
void updateLightMap (Interior *pInterior, LightInfo &rLightInfo, const U32 surfaceIndex)
 Takes the original lightmap and adds the animated lights to it and then binds the texture to it.
void intensityMapMerge (U8 *lightMap, const U32 width, const U32 height, const U8 *intensityMap, const ColorI &color)
 lightMap is a 24-bit RGB texture, intensityMap is an 8 bit intensity map.

Static Private Member Functions

Light Grouper
This is for managing light updates across the network

static U32 makeUpdateKey (const U32 detail, const U32 lightIndex)
 Creates an update key for the LightGrouper.
static U32 detailFromUpdateKey (const U32 key)
 Takes an update key and returns the detail level part of it.
static U32 indexFromUpdateKey (const U32 key)
 Takes an update key and returns the light index part of it 2param key Update key.

Private Attributes

ConvexmConvexList
StringTableEntry mInteriorFileName
 File name of the interior this instance encapuslates.
U32 mInteriorFileHash
 Hash for interior file name, used for sorting.
Resource< InteriorResourcemInteriorRes
 Interior managed by resource manager.
Vector< MaterialList * > mMaterialMaps
 Materials for this interior.
StringTableEntry mSkinBase
 Skin for this interior.
Vector< Vector< InteriorSubObject * > > mInteriorSubObjects
 Sub objects of this interior.
bool mShowTerrainInside
 Enables or disables terrain showing through the interior.
LM_HANDLE mLMHandle
 Handle to the light manager.
AudioProfilemAudioProfile
 Audio profile.
AudioEnvironmentmAudioEnvironment
 Audio environment.
S32 mForcedDetailLevel
 Forced LOD, if -1 auto LOD.
U32 mCRC
 CRC for the interior.
bool mAlarmState
 Alarm state of the interior.
Vector< LightInfomLightInfo
 Light info, one per detail level.
LightUpdateGroupermUpdateGrouper
 Designed to group net updates for lights to reduce traffic.

Friends

class SceneLighting
class FloorPlan

Data Structures

struct  LightInfo

Member Typedef Documentation

typedef SceneObject InteriorInstance::Parent [private]
 

Reimplemented from SceneObject.


Member Enumeration Documentation

enum InteriorInstance::UpdateMaskBits [private]
 

Enumeration values:
InitMask 
TransformMask 
AlarmMask 
_lightupdate0 
_lightupdate1 
_lightupdate2 
_lightupdate3 
_lightupdate4 
_lightupdate5 
_lightupdate6 
_lightupdate7 
SkinBaseMask 
AudioMask 
NextFreeMask 

enum InteriorInstance::Constants [private]
 

Enumeration values:
LightUpdateBitStart 
LightUpdateBitEnd 

enum InteriorInstance::AlarmState [private]
 

Enumeration values:
Normal 
Alarm 


Constructor & Destructor Documentation

InteriorInstance::InteriorInstance  ) 
 

InteriorInstance::~InteriorInstance  ) 
 


Member Function Documentation

static void InteriorInstance::init  )  [static]
 

static void InteriorInstance::destroy  )  [static]
 

bool InteriorInstance::buildPolyList AbstractPolyList polyList,
const Box3F box,
const SphereF sphere
[virtual]
 

Builds a list of polygons which intersect a bounding volume.

This will use either the sphere or the box, not both, the SceneObject implimentation ignores sphere.

See also:
AbstractPolyList
Parameters:
polyList Poly list build (out)
box Box bounding volume
sphere Sphere bounding volume

Reimplemented from SceneObject.

bool InteriorInstance::castRay const Point3F start,
const Point3F end,
RayInfo info
[virtual]
 

Casts a ray and obtain collision information, returns true if RayInfo is modified.

Parameters:
start Start point of ray
end End point of ray
info Collision information obtained (out)

Reimplemented from SceneObject.

virtual void InteriorInstance::setTransform const MatrixF mat  )  [virtual]
 

Sets the Object -> World transform.

Parameters:
mat New transform matrix

Reimplemented from SceneObject.

void InteriorInstance::buildConvex const Box3F box,
Convex convex
[virtual]
 

Builds a convex hull for this object.

Think of a convex hull as a low-res mesh which covers, as tightly as possible, the object mesh, and is used as a collision mesh.

Parameters:
box 
convex Convex mesh generated (out)

Reimplemented from SceneObject.

bool InteriorInstance::inAlarmState  )  [inline]
 

This returns true if the interior is in an alarm state.

Alarm state will put different lighting into the interior and also possibly have an audio element also.

void InteriorInstance::setAlarmMode const bool  alarm  ) 
 

This sets the alarm mode of the interior.

Parameters:
alarm If true the interior will be in an alarm state next frame

void InteriorInstance::activateLight const char *  pLightName  ) 
 

Activates a light with the given name on all detail levels of the interior.

Parameters:
pLightName Name of the light

void InteriorInstance::deactivateLight const char *  pLightName  ) 
 

Deactivates a light with the given name on all detail levels of the interior.

Parameters:
pLightName Name of the light

void InteriorInstance::echoTriggerableLights  ) 
 

Echos out all the lights in the interior, starting with triggerable then animated lights.

U32 InteriorInstance::getNumDetailLevels  ) 
 

Returns the number of detail levels for an object.

Interior* InteriorInstance::getDetailLevel const U32  level  ) 
 

Gets the interior associated with a particular detail level.

Parameters:
level Detail level

void InteriorInstance::setDetailLevel S32  level = -1  )  [inline]
 

Sets the detail level to render manually.

Parameters:
level Detail level to force

void InteriorInstance::renewOverlays  ) 
 

Reloads material information if the interior skin changes.

void InteriorInstance::setSkinBase const char *  newBase  ) 
 

Sets the interior skin to something different.

Parameters:
newBase New base skin

InteriorInstance::DECLARE_CONOBJECT InteriorInstance   ) 
 

static void InteriorInstance::initPersistFields  )  [static]
 

Register dynamic fields in a subclass of ConsoleObject.

See also:
addField(), addFieldV(), addDepricatedField(), addGroup(), endGroup()

Reimplemented from SceneObject.

static void InteriorInstance::consoleInit  )  [static]
 

Register global constant variables and do other one-time initialization tasks in a subclass of ConsoleObject.

Deprecated:
You should use ConsoleMethod and ConsoleFunction, not this, to register methods or commands.
See also:
console

Reimplemented from ConsoleObject.

bool InteriorInstance::readLightmaps GBitmap ****  lightmaps  ) 
 

Reads the lightmaps of the interior into the provided pointer.

Parameters:
lightmaps Lightmaps in the interior (out)

bool InteriorInstance::onAdd  )  [protected, virtual]
 

Called when the object is added to the sim.

Reimplemented from SceneObject.

void InteriorInstance::onRemove  )  [protected, virtual]
 

Called when the object is removed from the sim.

Reimplemented from SceneObject.

void InteriorInstance::inspectPreApply  )  [protected, virtual]
 

Called before any property of the object is changed in the world editor.

The calling order here is:

Reimplemented from SimObject.

void InteriorInstance::inspectPostApply  )  [protected, virtual]
 

Called after any property of the object is changed in the world editor.

See also:
inspectPreApply

Reimplemented from SceneObject.

void InteriorInstance::setLightUpdatedTime const   U32  )  [inline, protected]
 

U32 InteriorInstance::getLightUpdatedTime  )  const [inline, protected]
 

bool InteriorInstance::onSceneAdd SceneGraph graph  )  [protected, virtual]
 

Called when this is added to the SceneGraph.

Parameters:
graph SceneGraph this is getting added to

Reimplemented from SceneObject.

void InteriorInstance::onSceneRemove  )  [protected, virtual]
 

Called when this is removed from the SceneGraph.

Reimplemented from SceneObject.

U32 InteriorInstance::getPointZone const Point3F p  )  [protected, virtual]
 

Returns the zone containing p.

Parameters:
p Point to test.

Reimplemented from SceneObject.

bool InteriorInstance::getOverlappingZones SceneObject obj,
U32 zones,
U32 numZones
[protected, virtual]
 

If an object exists in multiple zones, this method will give you the number and indices of these zones (storing them in the provided variables).

Parameters:
obj Object in question.
zones Indices of zones containing the object. (out)
numZones Number of elements in the returned array. (out)

Reimplemented from SceneObject.

U32 InteriorInstance::calcDetailLevel SceneState ,
const Point3F
[protected]
 

bool InteriorInstance::prepRenderImage SceneState state,
const U32  stateKey,
const U32  startZone,
const bool  modifyBaseZoneState
[protected, virtual]
 

Called when the SceneGraph is ready for the registration of RenderImages.

See also:
SceneState
Parameters:
state SceneState
stateKey State key of the current SceneState
startZone Base zone index
modifyBaseZoneState If true, the object needs to modify the zone state.

Reimplemented from SceneObject.

void InteriorInstance::renderObject SceneState state,
SceneRenderImage image
[protected, virtual]
 

Called when the object is supposed to render itself.

Parameters:
state Current rendering state.
See also:
SceneState
Parameters:
image Image associated with this object to render.
See also:
SceneRenderImage

Reimplemented from SceneObject.

bool InteriorInstance::scopeObject const Point3F rootPosition,
const F32  rootDistance,
bool *  zoneScopeState
[protected, virtual]
 

This is called on a zone managing object to scope all the zones managed.

Parameters:
rootPosition Camera position
rootDistance Camera visible distance
zoneScopeState Array of booleans which line up with the collection of zones, marked true if that zone is scoped (out)

Reimplemented from SceneObject.

void InteriorInstance::addChildren  ) 
 

Not yet implemented.

static bool InteriorInstance::getRenderDynamicLights  )  [inline, static]
 

Returns true if the interiors are rendering dynamic lighting.

static void InteriorInstance::setRenderDynamicLights bool  val  )  [inline, static]
 

Turns on or off dynamic lighting of interiors.

Parameters:
val If true dynamic lighting is enabled

void InteriorInstance::activateLight const U32  detail,
const U32  lightIndex
[private]
 

Activates a specific light for a detail level.

Parameters:
detail Detail level
lightIndex Index of light in light list

void InteriorInstance::deactivateLight const U32  detail,
const U32  lightIndex
[private]
 

Deactivates a specific light for a detail level.

Parameters:
detail Detail level
lightIndex Index of light in the light list

U32 InteriorInstance::packUpdate NetConnection conn,
U32  mask,
BitStream stream
[private, virtual]
 

Instructs this object to pack its state for transfer over the network.

Parameters:
conn Net connection being used
mask Mask indicating fields to transmit.
stream Bitstream to pack data to
Returns:
Any bits which were not dealt with. The value is stored by the networking system. Don't set bits you weren't passed.

Reimplemented from NetObject.

void InteriorInstance::unpackUpdate NetConnection conn,
BitStream stream
[private, virtual]
 

Instructs this object to read state data previously packed with packUpdate.

Parameters:
conn Net connection being used
stream stream to read from

Reimplemented from NetObject.

LM_HANDLE InteriorInstance::getLMHandle  )  [inline]
 

Returns the Light Manager handle.

AudioProfile* InteriorInstance::getAudioProfile  )  [inline]
 

Returns the audio profile.

AudioEnvironment* InteriorInstance::getAudioEnvironment  )  [inline]
 

Returns the audio environment.

bool InteriorInstance::getPointInsideScale const Point3F pos,
F32 pScale
 

This is used to determine just how 'inside' a point is in an interior.

This is used by the environmental audio code for audio properties and the function always returns true.

Parameters:
pos Point to test
pScale How inside is the point 0 = totally outside, 1 = totally inside (out)

Resource<InteriorResource>& InteriorInstance::getResource  )  [inline]
 

Returns the interior resource.

U32 InteriorInstance::getCRC  )  [inline]
 

Returns the CRC for validation.

void InteriorInstance::rebuildVertexColors  ) 
 

Rebuilds the vertex colors for alarm and normal states for all detail levels.

Vector< ColorI > * InteriorInstance::getVertexColorsNormal U32  detail  )  [inline]
 

Returns the normal vertex lighting colors for a detail level.

Parameters:
detail Detail level

Vector< ColorI > * InteriorInstance::getVertexColorsAlarm U32  detail  )  [inline]
 

Returns the alarm vertex lighting colors for a detail level.

Parameters:
detail Detail level

U32 InteriorInstance::makeUpdateKey const U32  detail,
const U32  lightIndex
[inline, static, private]
 

Creates an update key for the LightGrouper.

Parameters:
detail Detail level
lightIndex Index of light in the interior

U32 InteriorInstance::detailFromUpdateKey const U32  key  )  [inline, static, private]
 

Takes an update key and returns the detail level part of it.

Parameters:
key Update key

U32 InteriorInstance::indexFromUpdateKey const U32  key  )  [inline, static, private]
 

Takes an update key and returns the light index part of it 2param key Update key.

void InteriorInstance::updateLightTime const U32  detail,
const U32  lightIndex,
const U32  ms
[private]
 

Steps the animated light simulation by a delta.

Parameters:
detail Detail level of interior
lightIndex Index of light to work on
ms Time delta from last update in miliseconds

void InteriorInstance::downloadLightmaps SceneState state,
Interior pInterior,
LightInfo rLightInfo
[private]
 

This loops through all the surfaces in an interior and calls updateLightMap on them.

Parameters:
state SceneState - Not used
pInterior Interior to operate on
rLightInfo Light to use

void InteriorInstance::installLight const U32  detail,
const U32  lightIndex
[private]
 

This will set up a particular light in a particular detail level.

Parameters:
detail Detail level
lightIndex Light to install

void InteriorInstance::updateLoopingLight Interior interior,
LightInfo::Light light,
const U32  lightIndex,
const U32  ms
[private]
 

Called by updateLightTime to update a light with a looping animation.

Parameters:
interior Interior to work on
light Light to update
lightIndex Index of animated light
ms Time delta from last update in miliseconds

void InteriorInstance::updateFlickerLight Interior interior,
LightInfo::Light light,
const U32  lightIndex,
const U32  ms
[private]
 

Called by updateLightTime to update a light with a flicker animation.

Parameters:
interior Interior to work on