VR-Engage  2.2
Loading...
Searching...
No Matches
makVre::DtSceneObjectMimicUpdater Class Reference

Detailed Description

The DtSceneObjectMimicUpdater allows one scene object to follow another's position and orientation with an optional offset. This updater is responsible for connecting to the parent scene object, tracking its position, and updating the child scene object accordingly. It also handles special cases like DiGuy character models and configures the child object's rendering properties.

Common use cases include:

  • First-person view models (cockpit interiors, weapon models)
  • Attached equipment (backpacks, tools, accessories)
  • Character models that need to follow another entity

#include <DtSceneObjectMimicUpdater.h>

Inheritance diagram for makVre::DtSceneObjectMimicUpdater:
[legend]

Public Member Functions

 DtSceneObjectMimicUpdater (DtDe &de, DtUniqueID id)
 
virtual ~DtSceneObjectMimicUpdater () override
 
virtual void update (DtTime tNow) override
 
virtual void setParentSceneObject (DtUniqueID id)
 
virtual void setModelOffset (const DtVector &offset)
 

Protected Member Functions

virtual void checkModel ()
 
virtual void initModel (DtModelInstance *modelInstance)
 
virtual void setupOsgNodes (DtOsgModelInstance *osgModelInstance)
 
virtual void setupOsgNode (osg::Node *node)
 
virtual void updatePosition (DtTime tNow)
 
virtual void slot_parentSceneObjectToBeDeleted (const DtUniqueID &id)
 

Protected Attributes

DtSceneObject * myParentSceneObject
 
DtModelInstance * myModelInstance
 
DtVector myModelOffset
 
double myLinearSpeed
 
double myYawSpeed
 

Constructor & Destructor Documentation

◆ DtSceneObjectMimicUpdater()

makVre::DtSceneObjectMimicUpdater::DtSceneObjectMimicUpdater ( DtDe & de,
DtUniqueID id )

Constructor for DtSceneObjectMimicUpdater.

Initializes the updater with default values (no parent object, null model instance, and zero speeds).

Parameters
deReference to the dynamic environment
idUnique identifier for this updater

References de().

◆ ~DtSceneObjectMimicUpdater()

virtual makVre::DtSceneObjectMimicUpdater::~DtSceneObjectMimicUpdater ( )
overridevirtual

Virtual destructor for DtSceneObjectMimicUpdater.

Clears the parent scene object reference to avoid dangling pointers.

Member Function Documentation

◆ update()

virtual void makVre::DtSceneObjectMimicUpdater::update ( DtTime tNow)
overridevirtual

Updates the scene object's position and orientation.

Called each frame to update the scene object's position and orientation based on the parent scene object. Performs model checking and position updating.

Parameters
tNowCurrent simulation time

◆ setParentSceneObject()

virtual void makVre::DtSceneObjectMimicUpdater::setParentSceneObject ( DtUniqueID id)
virtual

Sets the parent scene object to copy position from.

Establishes a connection to the specified scene object and sets up a signal/slot to handle parent object deletion. If a previous parent was set, disconnects from it.

Parameters
idUnique identifier of the parent scene object

◆ setModelOffset()

virtual void makVre::DtSceneObjectMimicUpdater::setModelOffset ( const DtVector & offset)
virtual

Sets the offset from the parent object.

Defines a local offset vector to apply when positioning this object relative to the parent. The offset is applied in the parent's local coordinate system.

Parameters
offsetVector offset to apply (typically in meters)

◆ checkModel()

virtual void makVre::DtSceneObjectMimicUpdater::checkModel ( )
protectedvirtual

Checks if the model instance has changed.

Verifies if the current scene object's model instance has changed since the last update. If it has, initializes the new model instance by calling initModel().

◆ initModel()

virtual void makVre::DtSceneObjectMimicUpdater::initModel ( DtModelInstance * modelInstance)
protectedvirtual

Initializes a new model instance.

Sets up a new model instance, detecting if it's an OSG model instance and configuring it accordingly.

Parameters
modelInstancePointer to the model instance to initialize

Reimplemented in makVre::DtFpsFirstPersonUpdater.

◆ setupOsgNodes()

virtual void makVre::DtSceneObjectMimicUpdater::setupOsgNodes ( DtOsgModelInstance * osgModelInstance)
protectedvirtual

Sets up OSG nodes for an OSG model instance.

Retrieves the root node from the OSG model instance and sets it up.

Parameters
osgModelInstancePointer to the OSG model instance to configure

◆ setupOsgNode()

virtual void makVre::DtSceneObjectMimicUpdater::setupOsgNode ( osg::Node * node)
protectedvirtual

Configures an OSG node.

Sets up rendering properties for the node, including:

  • Disabling intersection testing (making the model not selectable)
  • Disabling shadow casting
  • Setting the render bin to ensure proper rendering order
Parameters
nodePointer to the OSG node to configure

Reimplemented in makVre::DtFpsFirstPersonUpdater.

◆ updatePosition()

virtual void makVre::DtSceneObjectMimicUpdater::updatePosition ( DtTime tNow)
protectedvirtual

Updates the position and orientation.

Calculates and applies the position and orientation based on the parent object. Handles special cases like DiGuy character models.

Parameters
tNowCurrent simulation time

Reimplemented in makVre::DtFpsFirstPersonUpdater.

◆ slot_parentSceneObjectToBeDeleted()

virtual void makVre::DtSceneObjectMimicUpdater::slot_parentSceneObjectToBeDeleted ( const DtUniqueID & id)
protectedvirtual

Signal handler for parent scene object deletion.

Called when the parent scene object is about to be deleted. Clears the reference to avoid dangling pointers.

Parameters
idThe unique ID of the scene object being deleted

Member Data Documentation

◆ myParentSceneObject

DtSceneObject* makVre::DtSceneObjectMimicUpdater::myParentSceneObject
protected

Pointer to the parent scene object being mimicked.

This is the scene object whose position and orientation are being copied.

◆ myModelInstance

DtModelInstance* makVre::DtSceneObjectMimicUpdater::myModelInstance
protected

Pointer to the current model instance.

The model instance for the scene object being updated.

◆ myModelOffset

DtVector makVre::DtSceneObjectMimicUpdater::myModelOffset
protected

Offset vector to apply when positioning.

Local offset to apply from the parent object's position.

◆ myLinearSpeed

double makVre::DtSceneObjectMimicUpdater::myLinearSpeed
protected

Smoothed linear speed.

Cached and smoothed linear speed value for animation purposes.

◆ myYawSpeed

double makVre::DtSceneObjectMimicUpdater::myYawSpeed
protected

Smoothed yaw rotation speed.

Cached and smoothed yaw rotation speed value for animation purposes.


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