VR-Forces 4.5 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
List of all members | Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Types | Protected Member Functions | Protected Attributes | Friends
makVrv::DtInstanceManager Class Reference

Manages data for instanced rendering system and kicks off DtInstanceProcessors to update instance state. More...

Inheritance diagram for makVrv::DtInstanceManager:
Inheritance graph
[legend]

Classes

class  AlwaysCull
 Callback to always cull out a drawable. More...
struct  DofAnimation
 Per instanced DOF animation data. More...
struct  Eyepoint
 Eyepoint for a view. More...
struct  Frustum
 Internal frustum record for culling. More...
struct  GeometryRenderList
 List of transforms for visible instances of a drawable. More...
struct  InstanceBuffer
 Per view buffer of instances. More...
struct  InstancedDof
 Per-instance DOF data. More...
struct  InstancedLight
 Per-instance light source data. More...
struct  InstancedLod
 Specifies an instanced LOD by min/max visible ranges and effected drawable range. More...
struct  InstancedSequence
 Specifies a per-instance flipbook sequence. More...
struct  InstancedSwitch
 Specifies a per-instance switch. More...
struct  InstanceTemplate
 Template data for an instance of a model. More...
struct  InstancingHit
 Instancing hit data structure. More...
struct  LightSource
struct  ModelTypeDofData
 DOF data that is constant across all instances of a model type. More...
struct  RenderState
 Transform matrix for an instanced drawable to render with. More...

Public Types

typedef std::vector
< osg::ref_ptr< osg::Geometry > > 
GeometryVec
typedef std::vector< charBoolVec
typedef std::vector< charByteVec
typedef std::map< osg::ref_ptr
< osgEarth::VirtualProgram >
, osg::ref_ptr
< osgEarth::VirtualProgram > > 
VpMap
typedef std::vector
< osg::ref_ptr
< osgEarth::VirtualProgram > > 
VpRefList
typedef std::vector< ArrayRangeDrawableRangeVec
typedef std::vector< osg::Vec2f > TextureCoordinateVec
typedef std::vector< float > FloatVec
typedef std::vector
< InstanceTemplate
InstanceTemplateVec
typedef std::vector< LightSourceLightSourceVec
typedef std::vector
< ModelTypeDofData
PerDofDataVec
typedef std::vector
< InstancedSwitch
InstancedSwitchVec
typedef std::vector
< InstancedSequence
InstancedSequenceVec
typedef std::vector< DofAnimationDofAnimations
typedef std::vector< osg::Node * > NodeVec
typedef std::vector
< InstancedSwitch * > 
SwitchVec
typedef std::vector
< InstancedSequence * > 
SequenceVec
typedef std::vector
< InstancedLod * > 
LodVec
typedef std::vector
< DtInstanceState
InstanceStateVec
typedef std::vector< InstancedLodInstancedLodVec
typedef std::vector< InstancedDofInstancedDofVec
typedef std::vector
< InstanceCullData
InstanceCullDataVec
typedef std::vector
< InstanceMatrix
InstanceMatrixVec
typedef std::vector< float > InstanceScaleVec
typedef std::vector< DtElementIDInstanceElementIdVec
typedef std::vector
< InstancedLight
InstancedLightVec

Public Member Functions

bool intersect (const osg::Vec3d &start, const osg::Vec3d &end, const osg::Vec3d &reference, DtOsgIntersectorResult &result, std::list< DtUniqueID > *ignoreList=0)
 Find the closest instance intersection to the reference point along the line segment from start to end.
bool intersect (const osg::Vec3d &start, const osg::Vec3d &end, std::vector< DtOsgIntersectorResult > &results, std::list< DtUniqueID > *ignoreList=0)
 Find the instance intersections to the start point along a line segment.
void setElementId (DtUniqueID id, DtUniqueID elementId)
 Set the element ID for an instanced model.
 DtInstanceManager (DtDe &de)
 CTOR.
virtual ~DtInstanceManager ()
 DTOR.
virtual void reset ()
 Clear everything in the instance manager.
virtual osg::Node * instanceRoot ()
 Get the root node containing all instanced geometry.
bool isRegistered (const std::string &modelType)
 Check whether a model is registered and ready for instancing.
void registerModel (const std::string &modelType, GeometryVec &drawables, LodVec &lods, SwitchVec &switches, SequenceVec &sequences, PerDofDataVec &perDofData, LightSourceVec &lightSources, float boundingRadius, const DtVector &boundingCenter, unsigned int nodeMask, osg::ref_ptr< osg::StateSet > rootNodeSS, bool daylightControlledLights=false)
 Register a model for instancing.
osg::Geode * setupModelGeode (const std::string &modelType, unsigned int nodeMask)
 Set up a geode to contain instances of a model.
void allocateImage (const osg::View *view)
 Allocate an instance texture for the specified view.
void freeInstance (DtUniqueID id)
 Free the instance with the specified ID.
bool newInstance (const std::string &modelType, DtUniqueID id, DtElementID elementId, osg::Node *rootNode)
 Set up a new instance of the specified model.
DtInstanceStatefindInstanceState (DtUniqueID id)
 Find the specified instance's state.
InstanceCullDatafindInstanceCullData (DtUniqueID id)
 Find the culling data for the specified instance.
void setPosition (DtUniqueID uniqueID, const DtVector &vPosition)
 Set Position and orientation off of Dt types.
void setOrientation (DtUniqueID uniqueID, const DtTaitBryan &orientation)
void setPosition (DtUniqueID uniqueID, const osg::Vec3d &vPosition)
 Set Position and orientation off of osg types.
void setOrientation (DtUniqueID uniqueID, const osg::Quat &orientation)
void setVisible (DtUniqueID uniqueID, bool bVisible)
 Set visibility.
void setBlendColor (DtUniqueID uniqueID, float r, float g, float b, float a)
 Set the blending color.
void setModelScaling (DtUniqueID uniqueID, bool bModelScaling, float scale)
 Set the model scaling /param uniqueID the ID of the model /param bModelScaling if global modelScaling is enabled /param scale the individual scale from the model definition, seperate from the global scale.
void setCullParameters (DtUniqueID uniqueID, short modelSet, unsigned int nodeMask, bool visible)
 Set the various culling parameters.
InstanceElementIdVecelementIds ()
 Element IDs of instances.
InstanceScaleVecinstanceScales ()
 Scale of instances.
ByteVecinstanceVisibleSet ()
 Visibility of instances in current view.
InstanceMatrixVecdrawableInstanceMatrix ()
 Spatial state of instanced drawables in current view.
InstanceCullDataVecinstanceCullData ()
 Per instance cull data.
InstanceStateVecinstances ()
 State of active instances.
TextureCoordinateVecuvOffsets ()
 UV Offset state of drawable instances.
InstanceTemplateVecinstanceTemplates ()
 Per model definition templates for creating instances.
std::vector< float > & distanceToEye ()
 Per-instance distances to eyepoint for the current camera.
DofAnimationsdofAnimations ()
 Array of DOF animation data.
doublelastUpdateTime ()
 Last time the instances were updated.
const DtOsgCullVisitorParameterslastCullParameters ()
 Last cull parameters from the renderer.
unsigned int visibleSetStride ()
 Stride between each instance's drawable visibility state in the myVisibleSet.
BoolVecvisibleSet ()
 Per instanced drawable visibility.
osg::Vec3d & cameraPosition ()
 Camera position of the most recent camera that called update.
const osg::View * lastView ()
 View that most recently called update.
const osg::Camera * lastCamera ()
 Camera that was most recently used to udate.
unsigned int drawableIndex (unsigned int instanceIx)
 Get the start index of the drawable spatial data for the specified instance.
void reloadShaders ()
 Reload instancing shaders.
GeometryVecdrawables ()
virtual bool isDaylight ()
 Returns whether or not the light level for this frame counts as daylight.
void setSequenceMode (const DtInstanceState &instance, unsigned int sequenceIndex, InstancedSequence::SequenceMode mode)
void setSequenceSpeed (const DtInstanceState &instance, unsigned int sequenceIndex, float speed)
 Set the playback speed for the specified sequence.
void setSequencePlayTime (const DtInstanceState &instance, unsigned int sequenceIndex, float loopTime)
 Set the time the specified sequence should play for, starting now.
InstanceMatrix dofState (const DtInstanceState &instanceState, unsigned int partIndex)
void setDofState (InstanceMatrix &m, const DtInstanceState &state, unsigned int partIndex)
void setDofAnimation (osg::Vec3f &hpr, const osg::Vec3f &hprVel, const DtInstanceState &state, unsigned int partIndex)
 Set the DOF animation state for the specified instanced DOF.
void setDofTranslation (osg::Vec3f &trans, osg::Vec3f &transVel, const DtInstanceState &state, unsigned int partIndex)
 Set the DOF translation state for the specified instanced DOF.
void setSwitchState (const DtInstanceState &instance, unsigned int partIndex, unsigned int childIndex, bool state)
void setUVOffset (DtUniqueID id, unsigned int drawableIx, osg::Vec2f uvOffset)
void setUserDefined (DtUniqueID id, float userDefined)
Instanced scene graph accessors
InstancedLodVecinstancedLods ()
InstancedSwitchVecinstancedSwitches ()
InstancedSequenceVecinstancedSequences ()
InstancedDofVecinstancedDofs ()
- Public Member Functions inherited from makVrv::DtVirtualBaseClass
 DtVirtualBaseClass ()
 Do nothing constructor.
virtual ~DtVirtualBaseClass ()
 Virtual do nothing destructor.
- Public Member Functions inherited from makVrv::DtSignalConnectionManager
 DtSignalConnectionManager ()
 CTOR.
virtual ~DtSignalConnectionManager ()
 DTOR.
void manageConnection (const boost::signalslib::connection &conn)
 Connect a signal.
DtSignalConnectionManageroperator+= (const boost::signalslib::connection &conn)
 Connect a signal.
int numberOfConnections () const
 Get the number of connections.
void disconnectSignals ()
 Disconnect all signals.
bool blockConnections (bool blocked)
 Blocks/unblocks connections.
bool blockConnection (int index, bool blocked)
 Blocks/unblocks connections.
bool connectionsBlocked () const
 check whether connections are blocked.
bool connectionBlocked (int index) const
 check whether connections are blocked.

Static Public Member Functions

static DtInstanceManagerinstance (DtDe &de)
 Get an instance of the instance manager.

Public Attributes

Signals
boost::signal< void(const
std::string &)> 
signal_modelTypeRegistered
 Emitted when a new model type is registered with the instancing system.
boost::signal< void(const
std::string &, DtUniqueID,
DtElementID, osg::Node *)> 
signal_instanceCreated
 Emitted when a new instance of a model is added to the scene.
boost::signal< void(const
CullSet &)> 
signal_updateFinished
 Emitted when instance update is complete.

Static Public Attributes

static const unsigned int NumVec4PerInstance = 8
 Number of vec4 slots per instance in the instance data buffer.

Protected Types

typedef std::vector< RenderStateRenderStateVec
 List of transform matrices that will be used to render instances of a particular drawable.
typedef std::vector
< GeometryRenderList
RenderList
 Per drawable list of visible instance transforms.
typedef boost::unordered_map
< DtUniqueID, unsigned int
InstanceStateMap
 Map from instance unique ID to the index into myInstances for that instance.
typedef std::vector
< InstanceBuffer
InstanceBufferVec
 Vector of per-view instance data buffers.
typedef boost::unordered_map
< std::string, int
modelTypeToTemplateMap
 Map from model type names to template index.
typedef std::vector
< DtInstanceProcessor * > 
InstanceProcessorVec
 Vector of instance processors.
typedef std::vector< osg::View * > ViewVec
 List of active views.
typedef boost::unordered_map
< const osg::View
*, osg::ref_ptr
< DtViewSpecificGroup > > 
ViewToGroup
 Map from views to the group node that activates their instance buffer.
typedef boost::unordered_map
< osg::Geometry
*, osg::ref_ptr
< DtPerViewUniformCallback > > 
GeometryToCallback
 Map from geometry (drawable) to the callback that updates its start index uniform.
- Protected Types inherited from makVrv::DtSignalConnectionManager
typedef std::vector
< boost::signalslib::connection > 
Connections
 A collection of signals.

Protected Member Functions

void update (double simTime, const osg::View *view, const osg::Camera *camera, const DtOsgCullVisitorParameters *params, unsigned int nodeMask, bool suppressLastUpdateTime=false)
 Update the instances.
void registerGeometry (unsigned int templateIx, osg::Geometry *geometry, VpMap &vpMap)
 Set up a geometry object for instanced rendering.
float computeDistanceToEye (const Eyepoint &eye, const osg::Vec3d &pos) const
 Compute the distance from an eyepoint to a point.
void updateDistancesToEye (const Eyepoint &eye)
 Update the insances' distance from the eye point.
void _updateDistancesToEye (const Eyepoint &eye, unsigned int instanceOffset, unsigned int numInstances)
 Update the insances' distance from the eye point.
void allocateRenderList ()
 Resize myRenderList to fit the current set of instances and drawables.
unsigned int updateBuffers (const osg::View *view, DtGLTextureBufferObject *tbo, const ArrayRange &drawableRange, unsigned int bufferOffset, osg::Vec4 *bufferStorage)
 Update the instance texture for the specified view.
unsigned int updateRenderList (const Eyepoint &eye, const osg::Matrixd &viewMat, unsigned int nodeMask)
 Update the per-drawable render lists using the computed visibility and instance spatial data.
void updateLights (const osg::View *view)
void resizeBuffersIfNecessary (const osg::View *view, unsigned int visibleCount)
void updateBuffers (const osg::View *view)
void allocateInstanceData ()
 Allocate space for instance data that isn't contained in the instance struct itself, for the current number of instances.
unsigned int fillRenderList (unsigned visibleSetStride, unsigned int instanceOffset, unsigned int numInstances)
 Fill the render list with data from the specified range of instances.
void cullRange (const Eyepoint &eye, const std::vector< osg::Vec4d > &planes, bool useScale, unsigned int nodeMask, unsigned int instanceOffset, unsigned int instanceCount)
 Frustum cull the specified range of instances.
void slot_channelAdded (DtChannelManager *mgr, DtChannel *channel)
 Update per-view resources when a channel is added.
void slot_channelRemoved (DtChannelManager *mgr, DtChannel *channel)
 Clean up per-view resources when a channel is removed.
void createHitList (const osg::Vec3d &end, const osg::Vec3d &start, std::vector< InstancingHit > &hitList)
 Support function for intersect for generating list of hits.
void loadInstanceShaders (osg::ref_ptr< osgEarth::VirtualProgram > vp)
 reads the instance shaders from disk and attaches them to vp
bool isOnExcludeList (DtUniqueID elementId, const std::list< DtUniqueID > &ignoreList)
void addInstanceRootToSceneGraphIfNecessary (void)
void processNewInstanceLights (const InstanceTemplate &instanceTemplate)
void processNewInstanceDOFs (const InstanceTemplate &instanceTemplate)
void processNewInstanceSwitches (const InstanceTemplate &instanceTemplate)
void processNewInstanceSequences (const InstanceTemplate &instanceTemplate)
void preCull (unsigned int maxChunkSize)
void frustumCull (const osg::View *view, const Eyepoint &eye, unsigned int nodeMask)
void postCull (unsigned int maxChunkSize)
void _fillRenderList (bool globalScaling, unsigned int instanceOffset, unsigned int numInstances)

Protected Attributes

BoolVec myVisibleSet
 Per instanced drawable visibility state.
ByteVec myInstanceVisibleSet
 Per instance visibility state.
TextureCoordinateVec myUVOffsets
 Per instance UV offsets.
InstanceMatrixVec myDrawableInstanceMatrix
 Spatial data for drawables in myDrawables.
InstanceCullDataVec myInstanceCullData
 Array of per-instance culling data.
InstanceScaleVec myInstanceScales
 Array of per-instance model scale factors.
InstanceElementIdVec myElementIds
 Array of per-instance element IDs.
FloatVec myInstanceUserDefined
 Array of per-instance user-defined floats.
InstanceTemplateVec myInstanceTemplates
 Per model definition templates for creating instances.
std::vector< float > myDistanceToEye
 Per-instance distances to eyepoint for the current camera.
DofAnimations myDofAnimations
 Array of DOF animation data.
double myLastUpdateTime
 Last time the instances were updated.
unsigned int myLastNodeMask
 Nodemask used for last update.
unsigned int myVisibleSetStride
 Stride between each instance's drawable visibility state in the myVisibleSet.
osg::Vec3d myCameraPosition
 Camera position of the most recent camera that called update.
const osg::View * myLastView
 Reference to view that most recently called update.
const osg::Camera * myLastCamera
 Reference to the camera that most recently was used.
CullSet myCullSet
 Storage for per-view cull set calculation.
bool myIsDaylight
osg::Vec4 * myDynamicBufferData
unsigned int myDynamicBufferDataSz
RenderList myRenderList
bool myRenderListDirty
 True when myRenderList needs to be resized.
InstanceStateMap myIdToInstances
 Map model DtUniqueID to instance index into myInstances array.
InstanceBufferVec myInstanceBuffers
modelTypeToTemplateMap myModelTypeToTemplate
 Map model definition to its template index.
DtDemyDe
GeometryVec myDrawables
 Drawables in registered instance templates.
unsigned int myRequiredUvOffsets
 Number of UV offsets required by current allocated instances.
osg::ref_ptr< AlwaysCullmyAlwaysCullCallback
osg::ref_ptr< DtInstanceNodemyInstanceRoot
InstanceProcessorVec myPostCullInstanceProcessors
 Processors run after frustum culling.
InstanceProcessorVec myPreCullInstanceProcessors
 Processors run before frustum culling.
ViewVec myKnownViews
ViewToGroup myViewToGroup
GeometryToCallback myGeometryToCallback
osg::ref_ptr< const
DtOsgCullVisitorParameters
myLastCullParameters
 Most recent active cull vistor parameters.
std::vector< osg::Vec4d > vecScratchPadPlanes
DtAtomicScalar< intmyVisibleCount
Instanced scene graph

Array of active instances

InstanceStateVec myInstances
InstancedLodVec myInstancedLods
InstancedSwitchVec myInstancedSwitches
InstancedSequenceVec myInstancedSequences
InstancedDofVec myInstancedDofs
InstancedLightVec myInstancedLights
Instance processor thread data

Number of threads to use for processing instances during update

unsigned int myNumThreads
local VirtualProgram cache
VpMap myVpMap
VpRefList myVpRefs
- Protected Attributes inherited from makVrv::DtSignalConnectionManager
Connections myConnections
 The connected signals.
bool myConnectionsBlocked
bool myIndiviualConnectionedBlocked

Friends

class DtInstanceNode

Per-template buffer size tracking

Map from template index to count of something

typedef boost::unordered_map
< unsigned int, unsigned int
PerTemplateCount
PerTemplateCount myTemplateMaxInstances
 Map maximum number of instances for each template that we've allocated space for.
PerTemplateCount myTemplateActiveInstances
 Map number of active instances per template.

Detailed Description

Manages data for instanced rendering system and kicks off DtInstanceProcessors to update instance state.

Use instance processor objects to modify instance spatial data/visibility

Member Typedef Documentation

typedef std::vector<osg::ref_ptr<osg::Geometry> > makVrv::DtInstanceManager::GeometryVec
typedef std::map<osg::ref_ptr< osgEarth::VirtualProgram >, osg::ref_ptr<osgEarth::VirtualProgram> > makVrv::DtInstanceManager::VpMap
typedef std::vector<osg::ref_ptr<osgEarth::VirtualProgram> > makVrv::DtInstanceManager::VpRefList
typedef std::vector<osg::Vec2f> makVrv::DtInstanceManager::TextureCoordinateVec
typedef std::vector<float> makVrv::DtInstanceManager::FloatVec
typedef std::vector<osg::Node*> makVrv::DtInstanceManager::NodeVec
typedef std::vector<float> makVrv::DtInstanceManager::InstanceScaleVec

List of transform matrices that will be used to render instances of a particular drawable.

Per drawable list of visible instance transforms.

typedef boost::unordered_map<DtUniqueID, unsigned int> makVrv::DtInstanceManager::InstanceStateMap
protected

Map from instance unique ID to the index into myInstances for that instance.

Vector of per-view instance data buffers.

typedef boost::unordered_map<std::string, int> makVrv::DtInstanceManager::modelTypeToTemplateMap
protected

Map from model type names to template index.

typedef boost::unordered_map<unsigned int, unsigned int> makVrv::DtInstanceManager::PerTemplateCount
protected

Vector of instance processors.

Processors are run in order once per frame to update instance visibility/spatial data

typedef std::vector<osg::View*> makVrv::DtInstanceManager::ViewVec
protected

List of active views.

Used to decide what buffers we need allocated/updated

typedef boost::unordered_map<const osg::View*, osg::ref_ptr<DtViewSpecificGroup> > makVrv::DtInstanceManager::ViewToGroup
protected

Map from views to the group node that activates their instance buffer.

typedef boost::unordered_map<osg::Geometry*, osg::ref_ptr<DtPerViewUniformCallback> > makVrv::DtInstanceManager::GeometryToCallback
protected

Map from geometry (drawable) to the callback that updates its start index uniform.

Constructor & Destructor Documentation

makVrv::DtInstanceManager::DtInstanceManager ( DtDe de)

CTOR.

virtual makVrv::DtInstanceManager::~DtInstanceManager ( )
virtual

DTOR.

Member Function Documentation

bool makVrv::DtInstanceManager::intersect ( const osg::Vec3d &  start,
const osg::Vec3d &  end,
const osg::Vec3d &  reference,
DtOsgIntersectorResult result,
std::list< DtUniqueID > *  ignoreList = 0 
)

Find the closest instance intersection to the reference point along the line segment from start to end.

bool makVrv::DtInstanceManager::intersect ( const osg::Vec3d &  start,
const osg::Vec3d &  end,
std::vector< DtOsgIntersectorResult > &  results,
std::list< DtUniqueID > *  ignoreList = 0 
)

Find the instance intersections to the start point along a line segment.

void makVrv::DtInstanceManager::setSequenceMode ( const DtInstanceState instance,
unsigned int  sequenceIndex,
InstancedSequence::SequenceMode  mode 
)

Set the playback mode for the specified sequence

void makVrv::DtInstanceManager::setSequenceSpeed ( const DtInstanceState instance,
unsigned int  sequenceIndex,
float  speed 
)

Set the playback speed for the specified sequence.

void makVrv::DtInstanceManager::setSequencePlayTime ( const DtInstanceState instance,
unsigned int  sequenceIndex,
float  loopTime 
)

Set the time the specified sequence should play for, starting now.

InstanceMatrix makVrv::DtInstanceManager::dofState ( const DtInstanceState instanceState,
unsigned int  partIndex 
)

Get the current transform matrix of an instanced articulated part

void makVrv::DtInstanceManager::setDofState ( InstanceMatrix m,
const DtInstanceState state,
unsigned int  partIndex 
)

Set the transform for the specified instanced DOF

void makVrv::DtInstanceManager::setDofAnimation ( osg::Vec3f &  hpr,
const osg::Vec3f &  hprVel,
const DtInstanceState state,
unsigned int  partIndex 
)

Set the DOF animation state for the specified instanced DOF.

void makVrv::DtInstanceManager::setDofTranslation ( osg::Vec3f &  trans,
osg::Vec3f &  transVel,
const DtInstanceState state,
unsigned int  partIndex 
)

Set the DOF translation state for the specified instanced DOF.

void makVrv::DtInstanceManager::setSwitchState ( const DtInstanceState instance,
unsigned int  partIndex,
unsigned int  childIndex,
bool  state 
)

Set the state of an instanced switch

void makVrv::DtInstanceManager::setUVOffset ( DtUniqueID  id,
unsigned int  drawableIx,
osg::Vec2f  uvOffset 
)

Set the UV coordinate offset for a drawable

void makVrv::DtInstanceManager::setUserDefined ( DtUniqueID  id,
float  userDefined 
)

Set the user defined float for a drawable

void makVrv::DtInstanceManager::setElementId ( DtUniqueID  id,
DtUniqueID  elementId 
)

Set the element ID for an instanced model.

static DtInstanceManager& makVrv::DtInstanceManager::instance ( DtDe de)
static

Get an instance of the instance manager.

virtual void makVrv::DtInstanceManager::reset ( )
virtual

Clear everything in the instance manager.

Deletes all current instances and instance templates

virtual osg::Node* makVrv::DtInstanceManager::instanceRoot ( )
virtual

Get the root node containing all instanced geometry.

bool makVrv::DtInstanceManager::isRegistered ( const std::string &  modelType)

Check whether a model is registered and ready for instancing.

void makVrv::DtInstanceManager::registerModel ( const std::string &  modelType,
GeometryVec drawables,
LodVec lods,
SwitchVec switches,
SequenceVec sequences,
PerDofDataVec perDofData,
LightSourceVec lightSources,
float  boundingRadius,
const DtVector boundingCenter,
unsigned int  nodeMask,
osg::ref_ptr< osg::StateSet >  rootNodeSS,
bool  daylightControlledLights = false 
)

Register a model for instancing.

osg::Geode* makVrv::DtInstanceManager::setupModelGeode ( const std::string &  modelType,
unsigned int  nodeMask 
)

Set up a geode to contain instances of a model.

void makVrv::DtInstanceManager::allocateImage ( const osg::View *  view)

Allocate an instance texture for the specified view.

void makVrv::DtInstanceManager::freeInstance ( DtUniqueID  id)

Free the instance with the specified ID.

bool makVrv::DtInstanceManager::newInstance ( const std::string &  modelType,
DtUniqueID  id,
DtElementID  elementId,
osg::Node *  rootNode 
)

Set up a new instance of the specified model.

modelType should match a model that was registered previously with registerModel and id should be the id of the distributed object controlling the instance

DtInstanceState* makVrv::DtInstanceManager::findInstanceState ( DtUniqueID  id)

Find the specified instance's state.

Instance states may be rearranged in memory during allocation/deallocation, so this pointer is only valid for immediate use

InstanceCullData* makVrv::DtInstanceManager::findInstanceCullData ( DtUniqueID  id)

Find the culling data for the specified instance.

Cull data may be rearranged in memory during allocation/deallocation, so this pointer is only valid for immediate use

void makVrv::DtInstanceManager::setPosition ( DtUniqueID  uniqueID,
const DtVector vPosition 
)

Set Position and orientation off of Dt types.

void makVrv::DtInstanceManager::setOrientation ( DtUniqueID  uniqueID,
const DtTaitBryan &  orientation 
)
void makVrv::DtInstanceManager::setPosition ( DtUniqueID  uniqueID,
const osg::Vec3d &  vPosition 
)

Set Position and orientation off of osg types.

void makVrv::DtInstanceManager::setOrientation ( DtUniqueID  uniqueID,
const osg::Quat &  orientation 
)
void makVrv::DtInstanceManager::setVisible ( DtUniqueID  uniqueID,
bool  bVisible 
)

Set visibility.

void makVrv::DtInstanceManager::setBlendColor ( DtUniqueID  uniqueID,
float  r,
float  g,
float  b,
float  a 
)

Set the blending color.

void makVrv::DtInstanceManager::setModelScaling ( DtUniqueID  uniqueID,
bool  bModelScaling,
float  scale 
)

Set the model scaling /param uniqueID the ID of the model /param bModelScaling if global modelScaling is enabled /param scale the individual scale from the model definition, seperate from the global scale.

void makVrv::DtInstanceManager::setCullParameters ( DtUniqueID  uniqueID,
short  modelSet,
unsigned int  nodeMask,
bool  visible 
)

Set the various culling parameters.

InstanceElementIdVec& makVrv::DtInstanceManager::elementIds ( )
inline

Element IDs of instances.

InstanceScaleVec& makVrv::DtInstanceManager::instanceScales ( )
inline

Scale of instances.

ByteVec& makVrv::DtInstanceManager::instanceVisibleSet ( )
inline

Visibility of instances in current view.

InstanceMatrixVec& makVrv::DtInstanceManager::drawableInstanceMatrix ( )
inline

Spatial state of instanced drawables in current view.

InstanceCullDataVec& makVrv::DtInstanceManager::instanceCullData ( )
inline

Per instance cull data.

InstanceStateVec& makVrv::DtInstanceManager::instances ( )
inline

State of active instances.

TextureCoordinateVec& makVrv::DtInstanceManager::uvOffsets ( )
inline

UV Offset state of drawable instances.

InstancedLodVec& makVrv::DtInstanceManager::instancedLods ( )
inline
InstancedSwitchVec& makVrv::DtInstanceManager::instancedSwitches ( )
inline
InstancedSequenceVec& makVrv::DtInstanceManager::instancedSequences ( )
inline
InstancedDofVec& makVrv::DtInstanceManager::instancedDofs ( )
inline
InstanceTemplateVec& makVrv::DtInstanceManager::instanceTemplates ( )
inline

Per model definition templates for creating instances.

std::vector<float>& makVrv::DtInstanceManager::distanceToEye ( )
inline

Per-instance distances to eyepoint for the current camera.

DofAnimations& makVrv::DtInstanceManager::dofAnimations ( )
inline

Array of DOF animation data.

double& makVrv::DtInstanceManager::lastUpdateTime ( )
inline

Last time the instances were updated.

const DtOsgCullVisitorParameters* makVrv::DtInstanceManager::lastCullParameters ( )
inline

Last cull parameters from the renderer.

unsigned int makVrv::DtInstanceManager::visibleSetStride ( )
inline

Stride between each instance's drawable visibility state in the myVisibleSet.

BoolVec& makVrv::DtInstanceManager::visibleSet ( )
inline

Per instanced drawable visibility.

osg::Vec3d& makVrv::DtInstanceManager::cameraPosition ( )
inline

Camera position of the most recent camera that called update.

const osg::View* makVrv::DtInstanceManager::lastView ( )
inline

View that most recently called update.

const osg::Camera* makVrv::DtInstanceManager::lastCamera ( )
inline

Camera that was most recently used to udate.

unsigned int makVrv::DtInstanceManager::drawableIndex ( unsigned int  instanceIx)
inline

Get the start index of the drawable spatial data for the specified instance.

void makVrv::DtInstanceManager::reloadShaders ( )

Reload instancing shaders.

GeometryVec& makVrv::DtInstanceManager::drawables ( )
inline
virtual bool makVrv::DtInstanceManager::isDaylight ( )
virtual

Returns whether or not the light level for this frame counts as daylight.

void makVrv::DtInstanceManager::update ( double  simTime,
const osg::View *  view,
const osg::Camera *  camera,
const DtOsgCullVisitorParameters params,
unsigned int  nodeMask,
bool  suppressLastUpdateTime = false 
)
protected

Update the instances.

Must be called once per frame per view for correct rendering. Updates in camera-relative coordinates, so the resulting drawables should be rendered with the view matrix's translation set to (0, 0, 0). The suppressLastUpdateTime parameter is used by intersect() to insure that myLastUpdateTime flag is not set for an intersect call that happens before the channels are updated (which would prevent updated camera-relative conversions for the new views).

void makVrv::DtInstanceManager::registerGeometry ( unsigned int  templateIx,
osg::Geometry *  geometry,
VpMap vpMap 
)
protected

Set up a geometry object for instanced rendering.

float makVrv::DtInstanceManager::computeDistanceToEye ( const Eyepoint eye,
const osg::Vec3d &  pos 
) const
protected

Compute the distance from an eyepoint to a point.

void makVrv::DtInstanceManager::updateDistancesToEye ( const Eyepoint eye)
protected

Update the insances' distance from the eye point.

void makVrv::DtInstanceManager::_updateDistancesToEye ( const Eyepoint eye,
unsigned int  instanceOffset,
unsigned int  numInstances 
)
protected

Update the insances' distance from the eye point.

void makVrv::DtInstanceManager::allocateRenderList ( )
protected

Resize myRenderList to fit the current set of instances and drawables.

unsigned int makVrv::DtInstanceManager::updateBuffers ( const osg::View *  view,
DtGLTextureBufferObject tbo,
const ArrayRange drawableRange,
unsigned int  bufferOffset,
osg::Vec4 *  bufferStorage 
)
protected

Update the instance texture for the specified view.

unsigned int makVrv::DtInstanceManager::updateRenderList ( const Eyepoint eye,
const osg::Matrixd &  viewMat,
unsigned int  nodeMask 
)
protected

Update the per-drawable render lists using the computed visibility and instance spatial data.

Returns the number of visible drawable instances for the current view

void makVrv::DtInstanceManager::updateLights ( const osg::View *  view)
protected
void makVrv::DtInstanceManager::resizeBuffersIfNecessary ( const osg::View *  view,
unsigned int  visibleCount 
)
protected
void makVrv::DtInstanceManager::updateBuffers ( const osg::View *  view)
protected
void makVrv::DtInstanceManager::allocateInstanceData ( )
protected

Allocate space for instance data that isn't contained in the instance struct itself, for the current number of instances.

Includes visibility set, scale factors, user defined floats, etc.

unsigned int makVrv::DtInstanceManager::fillRenderList ( unsigned  visibleSetStride,
unsigned int  instanceOffset,
unsigned int  numInstances 
)
protected

Fill the render list with data from the specified range of instances.

Returns the number of visible drawable instances for the current view

void makVrv::DtInstanceManager::cullRange ( const Eyepoint eye,
const std::vector< osg::Vec4d > &  planes,
bool  useScale,
unsigned int  nodeMask,
unsigned int  instanceOffset,
unsigned int  instanceCount 
)
protected

Frustum cull the specified range of instances.

void makVrv::DtInstanceManager::slot_channelAdded ( DtChannelManager mgr,
DtChannel channel 
)
protected

Update per-view resources when a channel is added.

void makVrv::DtInstanceManager::slot_channelRemoved ( DtChannelManager mgr,
DtChannel channel 
)
protected

Clean up per-view resources when a channel is removed.

void makVrv::DtInstanceManager::createHitList ( const osg::Vec3d &  end,
const osg::Vec3d &  start,
std::vector< InstancingHit > &  hitList 
)
protected

Support function for intersect for generating list of hits.

void makVrv::DtInstanceManager::loadInstanceShaders ( osg::ref_ptr< osgEarth::VirtualProgram >  vp)
protected

reads the instance shaders from disk and attaches them to vp

bool makVrv::DtInstanceManager::isOnExcludeList ( DtUniqueID  elementId,
const std::list< DtUniqueID > &  ignoreList 
)
protected
void makVrv::DtInstanceManager::addInstanceRootToSceneGraphIfNecessary ( void  )
protected
void makVrv::DtInstanceManager::processNewInstanceLights ( const InstanceTemplate instanceTemplate)
protected
void makVrv::DtInstanceManager::processNewInstanceDOFs ( const InstanceTemplate instanceTemplate)
protected
void makVrv::DtInstanceManager::processNewInstanceSwitches ( const InstanceTemplate instanceTemplate)
protected
void makVrv::DtInstanceManager::processNewInstanceSequences ( const InstanceTemplate instanceTemplate)
protected
void makVrv::DtInstanceManager::preCull ( unsigned int  maxChunkSize)
protected
void makVrv::DtInstanceManager::frustumCull ( const osg::View *  view,
const Eyepoint eye,
unsigned int  nodeMask 
)
protected
void makVrv::DtInstanceManager::postCull ( unsigned int  maxChunkSize)
protected
void makVrv::DtInstanceManager::_fillRenderList ( bool  globalScaling,
unsigned int  instanceOffset,
unsigned int  numInstances 
)
protected

Friends And Related Function Documentation

friend class DtInstanceNode
friend

Member Data Documentation

const unsigned int makVrv::DtInstanceManager::NumVec4PerInstance = 8
static

Number of vec4 slots per instance in the instance data buffer.

boost::signal<void (const std::string&)> makVrv::DtInstanceManager::signal_modelTypeRegistered

Emitted when a new model type is registered with the instancing system.

boost::signal<void (const std::string&, DtUniqueID, DtElementID, osg::Node *)> makVrv::DtInstanceManager::signal_instanceCreated

Emitted when a new instance of a model is added to the scene.

boost::signal<void (const CullSet&)> makVrv::DtInstanceManager::signal_updateFinished

Emitted when instance update is complete.

BoolVec makVrv::DtInstanceManager::myVisibleSet
protected

Per instanced drawable visibility state.

ByteVec makVrv::DtInstanceManager::myInstanceVisibleSet
protected

Per instance visibility state.

TextureCoordinateVec makVrv::DtInstanceManager::myUVOffsets
protected

Per instance UV offsets.

InstanceMatrixVec makVrv::DtInstanceManager::myDrawableInstanceMatrix
protected

Spatial data for drawables in myDrawables.

Computed in camera relative coordinates per view

InstanceCullDataVec makVrv::DtInstanceManager::myInstanceCullData
protected

Array of per-instance culling data.

InstanceScaleVec makVrv::DtInstanceManager::myInstanceScales
protected

Array of per-instance model scale factors.

InstanceElementIdVec makVrv::DtInstanceManager::myElementIds
protected

Array of per-instance element IDs.

FloatVec makVrv::DtInstanceManager::myInstanceUserDefined
protected

Array of per-instance user-defined floats.

InstanceStateVec makVrv::DtInstanceManager::myInstances
protected
InstancedLodVec makVrv::DtInstanceManager::myInstancedLods
protected
InstancedSwitchVec makVrv::DtInstanceManager::myInstancedSwitches
protected
InstancedSequenceVec makVrv::DtInstanceManager::myInstancedSequences
protected
InstancedDofVec makVrv::DtInstanceManager::myInstancedDofs
protected
InstancedLightVec makVrv::DtInstanceManager::myInstancedLights
protected
InstanceTemplateVec makVrv::DtInstanceManager::myInstanceTemplates
protected

Per model definition templates for creating instances.

std::vector<float> makVrv::DtInstanceManager::myDistanceToEye
protected

Per-instance distances to eyepoint for the current camera.

DofAnimations makVrv::DtInstanceManager::myDofAnimations
protected

Array of DOF animation data.

double makVrv::DtInstanceManager::myLastUpdateTime
protected

Last time the instances were updated.

unsigned int makVrv::DtInstanceManager::myLastNodeMask
protected

Nodemask used for last update.

unsigned int makVrv::DtInstanceManager::myVisibleSetStride
protected

Stride between each instance's drawable visibility state in the myVisibleSet.

osg::Vec3d makVrv::DtInstanceManager::myCameraPosition
protected

Camera position of the most recent camera that called update.

const osg::View* makVrv::DtInstanceManager::myLastView
protected

Reference to view that most recently called update.

const osg::Camera* makVrv::DtInstanceManager::myLastCamera
protected

Reference to the camera that most recently was used.

CullSet makVrv::DtInstanceManager::myCullSet
protected

Storage for per-view cull set calculation.

bool makVrv::DtInstanceManager::myIsDaylight
protected
osg::Vec4* makVrv::DtInstanceManager::myDynamicBufferData
protected
unsigned int makVrv::DtInstanceManager::myDynamicBufferDataSz
protected
RenderList makVrv::DtInstanceManager::myRenderList
protected
bool makVrv::DtInstanceManager::myRenderListDirty
protected

True when myRenderList needs to be resized.

InstanceStateMap makVrv::DtInstanceManager::myIdToInstances
protected

Map model DtUniqueID to instance index into myInstances array.

InstanceBufferVec makVrv::DtInstanceManager::myInstanceBuffers
protected
modelTypeToTemplateMap makVrv::DtInstanceManager::myModelTypeToTemplate
protected

Map model definition to its template index.

DtDe& makVrv::DtInstanceManager::myDe
protected
GeometryVec makVrv::DtInstanceManager::myDrawables
protected

Drawables in registered instance templates.

unsigned int makVrv::DtInstanceManager::myRequiredUvOffsets
protected

Number of UV offsets required by current allocated instances.

unsigned int makVrv::DtInstanceManager::myNumThreads
protected
PerTemplateCount makVrv::DtInstanceManager::myTemplateMaxInstances
protected

Map maximum number of instances for each template that we've allocated space for.

PerTemplateCount makVrv::DtInstanceManager::myTemplateActiveInstances
protected

Map number of active instances per template.

VpMap makVrv::DtInstanceManager::myVpMap
protected
VpRefList makVrv::DtInstanceManager::myVpRefs
protected
osg::ref_ptr<AlwaysCull> makVrv::DtInstanceManager::myAlwaysCullCallback
protected
osg::ref_ptr<DtInstanceNode> makVrv::DtInstanceManager::myInstanceRoot
protected
InstanceProcessorVec makVrv::DtInstanceManager::myPostCullInstanceProcessors
protected

Processors run after frustum culling.

InstanceProcessorVec makVrv::DtInstanceManager::myPreCullInstanceProcessors
protected

Processors run before frustum culling.

ViewVec makVrv::DtInstanceManager::myKnownViews
protected
ViewToGroup makVrv::DtInstanceManager::myViewToGroup
protected
GeometryToCallback makVrv::DtInstanceManager::myGeometryToCallback
protected
osg::ref_ptr<const DtOsgCullVisitorParameters> makVrv::DtInstanceManager::myLastCullParameters
protected

Most recent active cull vistor parameters.

std::vector<osg::Vec4d> makVrv::DtInstanceManager::vecScratchPadPlanes
protected
DtAtomicScalar<int> makVrv::DtInstanceManager::myVisibleCount
protected

The documentation for this class was generated from the following file:

Document ID: Generated on Thu Mar 23 18:54:12 EDT 2017 from SVN revision 174804
Copyright © 2005-2017 VT MÄK. All Rights Reserved (www.mak.com)