VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
diGuyController.h
Go to the documentation of this file.
1 /****************************************************************************
2  * Copyright (c) 2025 MAK Technologies, Inc.
3  * All rights reserved.
4  ****************************************************************************/
5 
9 
10 #pragma once
11 
13 
16 #include "vrfobjcore/boolIOPort.h"
17 
19 #include "vrfutil/simClock.h"
20 
21 #include <vl/hostStructs.h>
22 
23 #include <map>
24 
26 class DtSimMessage;
28 class DtDiGuyAnimation;
33 class DtInputPortGroup;
34 class DtAnalogInputPort;
35 class DtBooleanInputPort;
36 class DtStringInputPort;
39 class DtAnalogOutputPort;
40 
42 {
50 };
51 
52 typedef std::map<DtString,unsigned int> DtDemeanorToRankMap;
53 
71  public DtBindableLuaComponent < DtDiGuyController >
72 {
73 public:
74 
75  //typedef std::map<DtLifeformStaticPosture,double> DtPostureTransitionTimeMap;
76  //typedef std::map<DtLifeformStaticPosture,DtPostureTransitionTimeMap> DtPostureTransitionsMap;
77 
78 public:
79 
82  DtDiGuyController(const DtString& name, DtLocalObject* owner,
83  DtSimulationServices* simManager, DtComponentDescriptor* desc = 0, DtReaderWriterRegistry* parentRegistry = 0);
84 
86  virtual ~DtDiGuyController() override;
87 
90  virtual const char* type() const override;
91 
94  virtual bool init() override;
95 
101  virtual bool createPSR();
102 
106  virtual void preFirstTickInit() override;
107 
109  virtual void tick() override;
110 
114  virtual void taskedTick( DtTime& dT );
115 
118  virtual bool intrinsicOverride();
119 
121  virtual bool tickWhileDestroyed() const override;
122 
125  virtual void setCurrentAnimation( const DtDiGuyAnimation* animation );
126 
129  virtual void sendSetPosture( DtLifeformState post );
130 
132  static void setCharacteristicsCallback( DtSimMessage* msg, void* usr );
133  virtual void processSetCharacterCharacteristics( DtSimMessage* msg );
134 
136  static void setAppearanceCallback( DtSimMessage* msg, void* usr );
137  virtual void processSetCharacterAppearance( DtSimMessage* msg );
138 
140  static void setHandItemCallback( DtSimMessage* msg, void* usr );
141  virtual void processSetCharacterHandItem( DtSimMessage* msg );
142 
144  static void setHeadCallback( DtSimMessage* msg, void* usr );
145  virtual void processSetCharacterHead( DtSimMessage* msg );
146 
148  static void setUnitPatchesCallback( DtSimMessage* msg, void* usr );
149  virtual void processSetUnitPatches( DtSimMessage* msg );
150 
152  static void setRankPatchCallback( DtSimMessage* msg, void* usr );
153  virtual void processSetRankPatch( DtSimMessage* msg );
154 
156  static void setNametagCallback( DtSimMessage* msg, void* usr );
157  virtual void processSetNametag( DtSimMessage* msg );
158 
159  static void setRestoreCallback( DtSimMessage* msg, void* usrData );
160  virtual void processSetRestore( DtSimMessage* msg );
161 
163  static void setAdjustDemeanorCallback( DtSimMessage* msg, void* usrData );
164  virtual void processSetAdjustDemeanor( DtSimMessage* msg );
165 
166  static void animationTaskCallback( DtSimMessage* msg, void* usrData );
167  virtual void processAnimationTask( DtSimMessage* msg );
168 
171  virtual void clearTask() override;
172  virtual void taskComplete(bool success = true) override;
173  virtual void reset() override;
174 
184 
189  virtual bool intrinsicTick( DtWeaponState weaponState, DtDamageState damageState,
190  DtLifeformStaticPosture& posture, DtString& demeanor, double speed );
191 
193  virtual double lookupTimeToStop( DtWeaponState weaponState, DtDamageState damageState,
194  DtLifeformStaticPosture post, const DtString& demeanor, double heading ) const;
195 
197  virtual const DtDiGuyAnimation* chooseAnimation( DtWeaponState weaponState, DtDamageState damageState,
198  DtLifeformStaticPosture post, const DtString& demeanor, double speed, double heading, bool debug = true ) const;
199 
210  virtual void updateAnimationState( DtWeaponState weapon, DtDamageState damageState,
211  DtLifeformStaticPosture posture, const DtString& demeanor, double speed );
212 
214 
216  virtual DtDiGuyDirectionType directionStringToEnum( const DtString& direction );
217 
221 
223  bool isAnimationAvailable( const std::string& animation, bool checkCompatible = false ) const;
224 
226  bool isAppearanceAvailable( const std::string& appearance ) const;
227 
229  bool isHandItemAvailable( const std::string& item ) const;
230 
233  bool isHeadAvailable( const std::string& head ) const;
234 
236  bool isGestureAvailable( const std::string& gesture ) const;
237 
239 
242  virtual void bindLuaFunctions(lua_State* L) override;
243  virtual void bindLuaGlobals(lua_State* L) override;
244 
248  static DtSimComponent* creator( const DtString& name, DtLocalObject* owner, DtSimulationServices* simManager,
249  DtComponentDescriptor* desc = 0, DtReaderWriterRegistry* parentRegistry = 0 );
250 
251 protected:
252 
254  virtual void registerRadioMessageCallbacks();
255 
257  virtual void registerDiGuyTasks();
258 
261  virtual void determineInitialHandItem();
262 
263  virtual DtVector groundClamp( double heading, const DtVector& location ) const;
264 
265 protected:
266 
269 
271  DtDiGuyController( const DtDiGuyController& orig );
272 
274  const DtDiGuyController& operator = ( const DtDiGuyController& orig );
275 
277  virtual bool createPortGroups() override;
278 
280  virtual bool createPorts() override;
281 
284  virtual bool createCollisionPort();
285  virtual bool createAimDirectionPort();
286  virtual bool createOrderedAnimationPort();
287  virtual bool createOrderedHandItemPort();
288  virtual bool createEtaToDestinationInputPort();
289  virtual bool createChangingPosturePort();
290  virtual bool createNegateSpeedPort();
291 
294  void checkAndSetDefaultPatches();
295 
297  virtual void updateDemeanorAndPosture( DtWeaponState weaponState, DtDamageState damageState,
298  DtLifeformStaticPosture& posture, DtString& demeanor );
299 
301  virtual void determineDirection();
302 
303  virtual DtString chooseRandomAppearance();
304 
306  virtual void updatePosition(const DtTime & dT,DtTaitBryan & localOrientation);
307 
308  virtual DtString selectDamageAnimation(const DtRwNLengthStringVector& animations);
309 
310  virtual void initializeAdjustedDemeanorMap();
311 
312  //virtual void initializePostureTransitionsMap();
313 
314  //virtual double getPostureTransitionTime(DtLifeformStaticPosture from, DtLifeformStaticPosture to);
315 
317  virtual double diGuyHeading() const;
318 
319 protected:
320 
322 
329  DtTaitBryan myTaskedOrientation;
330 
333  DtDamageState myCurrentDamageState;
336 
339  mutable std::pair<DtString,double> myLastTimeToStop;
340 
348 
353 
357 
365 
373 
379 
384 
393 
399 
407 
410 
413 
416 
421 
425 
428 
430 
433 
435 
436 };
#define DT_DLL_vrfmodel
This file is used to determine how to build.
Definition: vrfmodelDefines.h:24
Stores data representing all the possible appearances, animations, hand items, heads, etc. that are available to a particular character type. It is used by the sim engine at runtime. Populated from both DI-Guy instance and character_animations_table.mtl file.
Definition: diGuyCharacterData.h:63
DtStringInputPort * myOrderedAnimationPort
Input Port Name: ordered-animation Input Port Description: Specifies an animation to be used as long ...
Definition: diGuyController.h:378
Definition: diGuyController.h:49
double myCurrentAnimationSpeed
Definition: diGuyController.h:335
std::pair< DtString, double > myLastTimeToStop
Cached time required to stop from current action. Lookup method is const, but we want to be able to c...
Definition: diGuyController.h:339
Definition: diGuyControllerDescriptor.h:19
DtDiGuyControllerPSR * myProcessState
Container for state data associated with this component. This state is saved and restored as part of ...
Definition: diGuyController.h:356
bool myNeedUpdate
Definition: diGuyController.h:423
const DtDiGuyAnimation * myDefaultAnimation
Definition: diGuyController.h:325
DtUpdateRepositoryOutputPortGroup * myUpdateRepositoryOutputPortGroup
Used to update repository with any movement data. As long as this controller has control of this port...
Definition: diGuyController.h:420
const DtDiGuyAnimation * myCurrentAnimation
Definition: diGuyController.h:331
Description: This repository holds all information that is common to all the forms of all objects wit...
Definition: vrfMovingObjectStateRepository.h:31
DtString myLastDemeanor
Definition: diGuyController.h:426
DtAnalogInputPort * myEtaToDestinationInputPort
Input Port Name: eta-to-last-vertex Input Port Description: Specifies the eta to reach the last verte...
Definition: diGuyController.h:392
DtRwNLengthStringVector is a named, readable/writable vector of strings of arbitrary length...
Definition: rwNLengthStringVector.h:28
virtual const char * type() const override=0
Returns a string identifies the class type of component. Type values are defined in compTypes...
Instances of DtBooleanOutputPort are output ports through which data producers can send boolean data...
Definition: boolIOPort.h:45
Definition: diGuyController.h:47
bool myForceAnimationUpdate
Definition: diGuyController.h:434
DtLifeformStaticPosture myDefaultAnimationPosture
Definition: diGuyController.h:326
virtual void preFirstTickInit()
This function can be overridden to initialize a component before it is ticked for the first time...
This class provides a base class for all controllers that are capable of executing a DtSimTask...
Definition: singleTaskControllerComponent.h:22
virtual void bindLuaFunctions(lua_State *)=0
Override to bind lua functions.
bool myAmRotating
Definition: diGuyController.h:347
Contains class declarations for DtStringInputPort, DtStringOutputPort, and DtStringPortData.
Definition: stringIOPort.h:27
A readable, writable type whose name is the name of a component and that has a list of component name...
Definition: componentDescriptor.h:49
const DtDiGuyControllerDescriptor * myDiGuyDescriptor
Definition: diGuyController.h:321
bool myTickWhileDead
Definition: diGuyController.h:422
Definition: readerWriterRegistry.h:39
Definition: bindableLuaComponent.h:53
DtTime myTimeElapsed
Definition: diGuyController.h:346
DtTaitBryan myTaskedOrientation
Definition: diGuyController.h:329
double myTransitionTime
The remaining time for the current posture transition. Gets decremented in tick() ...
Definition: diGuyController.h:412
Definition: diGuyController.h:43
virtual void taskComplete(bool success=true)
If we are currently tasked, this will cause us to notify the entity that we&#39;re done and delete the ta...
DtVrfMovingObjectStateRepository * myLocalState
Definition: diGuyController.h:324
virtual void reset()
For those reader/writer items that support it, resets the reader/writer value to original state Defau...
const DtDiGuyAnimation * myTaskedAnimation
Definition: diGuyController.h:328
DtAnalogInputPort * myAimDirectionPort
Input Port Name: aim-direction Input Port Description: Specifies the heading in which the entity shou...
Definition: diGuyController.h:372
Definition: diGuyController.h:46
DtStringInputPort * myOrderedHandItemPort
Input Port Name: ordered-hand-item Input Port Description: Specifies a hand item to be used...
Definition: diGuyController.h:383
Instances of DtAnalogOutputPort are input ports through which data producers can send real numbers...
Definition: analogIOPort.h:45
The DtDiGuyAnimation class is a class that stores the DI-Guy animation information that is used to en...
Definition: diGuyAnimation.h:29
const DtDiGuyCharacterData * myCharacterData
Definition: diGuyController.h:323
bool myTaskInterrupted
Definition: diGuyController.h:327
DtLifeformStaticPosture
These are the available static postures for lifeform (human) entities. Static postures are equivalent...
Definition: lifeformStaticPostures.h:22
DtBooleanInputPort * myNegateSpeedPort
Input Port Name: is-action-speed-negated Input Port Description: Indicates that the speed used for ac...
Definition: diGuyController.h:406
std::map< DtString, unsigned int > DtDemeanorToRankMap
Definition: diGuyController.h:52
DtDiGuyDirectionType
Definition: diGuyController.h:41
File: simMsg.h.
Definition: simMessage.h:35
File: vlClock.h.
Contains the DtLifeformStaticPosture enumeration declaration.
virtual void tick()
This gives the thread of control to the component. The component is ticked once each simulation from ...
DtDamageState myCurrentDamageState
Definition: diGuyController.h:333
Contains class declarations for DtBooleanInputPort, DtBooleanOutputPort, and DtBooleanPortData.
Definition: boolIOPort.h:25
virtual bool tickWhileDestroyed() const
If the component returns true here, it will be ticked regardless of the destroyed state of the host e...
double myAnimationDuration
These values are stored in the PSR Do we want this animation to be performed only once...
Definition: diGuyController.h:345
virtual bool createPorts()
Called by init. Derived classes should override this method to create all their input/output ports an...
Definition: diGuyController.h:45
virtual bool createPortGroups()
Called by init. Derived classes should override this method to create all their input/output port gro...
Central access point of all non-object-specific the services and managers that are available for use ...
Definition: simulationServices.h:96
The DtSimComponent class is the base class for the entire simulation model component hierarchy...
Definition: simComponent.h:89
DtWeaponState myCurrentAnimationWeaponState
Definition: diGuyController.h:332
int myLastPosition
Definition: diGuyController.h:427
Definition: diGuyController.h:48
const DtTaskControllerComponent & operator=(const DtTaskControllerComponent &orig)
assignment operator
DtDemeanorToRankMap myDemeanorRankMap
Definition: diGuyController.h:429
DT_DLL_DEBUGDRAWRENDERER void init(makVrv::DtDe &de)
Work function for the plugin initialization.
virtual void clearTask() override
If component is currently tasked, calls clearPendingSubtasks(), sets the tasked flag to false...
DtInputPortGroup is a data port group of a data consumer. It may contain any number of DtInputPorts a...
Definition: inputPortGroup.h:35
Instances of DtCollisionInputPort are input ports through which data consumers can receive informatio...
Definition: collisionIOPort.h:29
Contains class declarations for DtAnalogInputPort, DtAnalogOutputPort, and DtAnalogPortData.
Definition: analogIOPort.h:25
Definition: diGuyControllerPSR.h:33
DtLifeformStaticPosture myCurrentAnimationPosture
Definition: diGuyController.h:334
DtBooleanOutputPort * myIsChangingPosturePort
Output Port Name: is-changing-posture Output Port Description: Indicates that the DI Guy character is...
Definition: diGuyController.h:398
virtual void bindLuaGlobals(lua_State *)=0
Override to bind lua globals.
double myCurrentHeading
The last heading for the entity. Will be used when setting animation for rotating on the spot...
Definition: diGuyController.h:415
DtUpdateRepositoryOutputPortGroup is a data port group of a data consumer that contains methods and p...
Definition: updateRepositoryOutputPortGroup.h:31
Controls appearances and animations for an entity that is represented by a DI-Guy 3D visual represent...
Definition: diGuyController.h:70
bool myAmTransitioningPosture
Local flag for we know we&#39;re changing posture.
Definition: diGuyController.h:409
bool myAmOrdered
Definition: diGuyController.h:424
double myDirectionOfMovement
This is an angle, in radians, relative to the current heading (a value of PI represents &quot;backwards&quot;)...
Definition: diGuyController.h:352
Definition: diGuyController.h:44
DtHumanLocalObjectFacade myHumanLocalObjectFacade
Member to allow for access to human specific data.
Definition: diGuyController.h:432
DtBooleanInputPort * myCollisionPort
Input Port Name: collision Input Port Description: Checks to see if we&#39;re avoiding a collision...
Definition: diGuyController.h:364
A locally simulated VRF object.
Definition: localObject.h:98

Document ID: Generated on Thu Oct 23 22:29:17 EDT 2025 from SVN revision 280951
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)