|
VR-Engage
2.2
|
PATTERN: VR-Forces Actuator Components Actuator components execute simulation-side logic on entities, controlling their behavior, appearance, and state. They are the simulation engine counterpart to player station components (DtPlayerComponent).
Common Actuator Component Types:
Actuator Lifecycle:
DI-Guy Articulated Parts: DI-Guy human characters use a skeletal system with named joints (articulated parts). Each joint can be controlled via:
This Example: Animates the left shoulder joint with a sinusoidal motion, demonstrating:
REUSABLE: This class structure applies to any actuator that needs to control human character articulation. Replace the joint identifier and animation logic to control different joints or implement different motion patterns.
#include <exampleHumanArtPartActuator.h>
Public Member Functions | |
| DtExampleHumanArtPartActuator (const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc=nullptr, DtReaderWriterRegistry *parentRegistry=nullptr) | |
| DtExampleHumanArtPartActuator ()=delete | |
| DtExampleHumanArtPartActuator (const DtExampleHumanArtPartActuator &orig)=delete | |
| const DtExampleHumanArtPartActuator & | operator= (const DtExampleHumanArtPartActuator &orig)=delete |
| virtual | ~DtExampleHumanArtPartActuator () override |
| virtual bool | init () override |
| virtual const char * | type () const override |
| virtual void | tick () override |
Static Public Member Functions | |
| static DtSimComponent * | creator (const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc=nullptr, DtReaderWriterRegistry *parentRegistry=nullptr) |
Protected Attributes | |
| DtPlatformLocalObjectFacade | myPlatformLocalObjectFacade |
| makVrf::DtArticulatedPartStateRepository * | myLeftShoulder |
| double | myAnimationInterval |
| double | myTimeInInterval |
| makVre::DtExampleHumanArtPartActuator::DtExampleHumanArtPartActuator | ( | const DtString & | name, |
| DtLocalObject * | owner, | ||
| DtSimulationServices * | simManager, | ||
| DtComponentDescriptor * | desc = nullptr, | ||
| DtReaderWriterRegistry * | parentRegistry = nullptr ) |
Constructor - Initialize actuator component for an entity.
PATTERN: VR-Forces Component Construction VR-Forces components are constructed with references to:
The owner provides access to entity state and other components. The DtPlatformLocalObjectFacade helper class simplifies access to platform-specific features like articulated parts.
| name | Component instance name |
| owner | Owning entity |
| simManager | Simulation services access |
| desc | Component descriptor with configuration parameters |
| parentRegistry | Parent registry for parameter serialization |
Referenced by DtExampleHumanArtPartActuator(), and operator=().
|
delete |
Default constructor - deleted (components require owner and services)
|
delete |
Copy constructor - deleted (components are not copyable)
References DtExampleHumanArtPartActuator().
|
overridevirtual |
Destructor - cleanup component resources.
|
delete |
Assignment operator - deleted (components are not assignable)
References DtExampleHumanArtPartActuator().
|
overridevirtual |
Initialize component after construction.
PATTERN: VR-Forces Component Initialization The init() method is called once after construction to perform initialization that may depend on other components or simulation state. Always call the base class init() first to ensure proper initialization order.
This Example: Performs only base class initialization. Articulated part lookup is deferred to the first tick() call to ensure the entity's articulated part system is fully initialized.
|
overridevirtual |
Return component type identifier string.
Used by VR-Forces factory system to identify component type for instantiation and serialization. Must match the type string used in component registration.
|
overridevirtual |
Update component state for one simulation frame.
PATTERN: Articulated Part Animation This method demonstrates the complete pattern for animating DI-Guy joints:
Smooth Animation: Setting both the target angle and the angular rate produces smooth interpolated motion. VR-Forces/DI-Guy interpolates between the current and target angles using the provided rate.
Animation Pattern Used: Sinusoidal motion from 0 to π/2 radians over myAnimationInterval seconds:
REUSABLE: This animation pattern can be adapted for:
|
static |
Static factory creator method for component instantiation.
PATTERN: VR-Forces Component Factory VR-Forces uses factory methods to instantiate components from entity definitions. This static method must match the signature expected by the component factory and return a new instance of this component class.
Registered in plugin initialization: componentFactory()->addCreatorFcn(DtExampleHumanArtPartActuatorType, &DtExampleHumanArtPartActuator::creator);
REUSABLE: This exact signature is required for all VR-Forces components.
| name | Component instance name |
| owner | Owning entity |
| simManager | Simulation services access |
| desc | Component descriptor with configuration |
| parentRegistry | Parent registry for parameters |
|
protected |
Facade providing convenient access to platform-specific entity features Simplifies access to articulated parts, sensors, weapons, and other platform subsystems.
|
protected |
Pointer to the left shoulder articulated part state Null until first tick() call, then cached for efficient subsequent access.
|
protected |
Animation cycle duration in seconds The joint will complete one full motion cycle (0 to max angle and back) in this time.
|
protected |
Current time within the animation cycle (0 to myAnimationInterval) Accumulated each tick to calculate the current phase of the animation.