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) 2023 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();
87 
90  virtual const char* type() const;
91 
94  virtual bool init();
95 
101  virtual bool createPSR();
102 
106  virtual void preFirstTickInit();
107 
109  virtual void tick();
110 
114  virtual void taskedTick( DtTime& dT );
115 
118  virtual bool intrinsicOverride();
119 
121  virtual bool tickWhileDestroyed() const;
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();
172  virtual void taskComplete( bool success = true );
173  virtual void reset();
174 
184 
188  virtual bool intrinsicTick( DtWeaponState weaponState, DtDamageState damageState,
189  DtLifeformStaticPosture& posture, DtString& demeanor, double speed );
190 
192  virtual double lookupTimeToStop( DtWeaponState weaponState, DtDamageState damageState,
193  DtLifeformStaticPosture post, const DtString& demeanor, double heading ) const;
194 
196  virtual const DtDiGuyAnimation* chooseAnimation( DtWeaponState weaponState, DtDamageState damageState,
197  DtLifeformStaticPosture post, const DtString& demeanor, double speed, double heading, bool debug = true ) const;
198 
200  virtual void updateAnimationState( DtWeaponState weapon, DtDamageState damageState,
201  DtLifeformStaticPosture posture, const DtString& demeanor, double speed );
202 
204 
206  virtual DtDiGuyDirectionType directionStringToEnum( const DtString& direction );
207 
212 
214  bool isAnimationAvailable( const std::string& animation ) const;
215 
217  bool isAppearanceAvailable( const std::string& appearance ) const;
218 
220  bool isHandItemAvailable( const std::string& item ) const;
221 
224  bool isHeadAvailable( const std::string& head ) const;
225 
227  bool isGestureAvailable( const std::string& gesture ) const;
228 
230 
233  virtual void bindLuaFunctions( lua_State* L );
234  virtual void bindLuaGlobals( lua_State* L );
235 
239  static DtSimComponent* creator( const DtString& name, DtLocalObject* owner, DtSimulationServices* simManager,
240  DtComponentDescriptor* desc = 0, DtReaderWriterRegistry* parentRegistry = 0 );
241 
242 protected:
243 
245  virtual void registerRadioMessageCallbacks();
246 
248  virtual void registerDiGuyTasks();
249 
252  virtual void determineInitialHandItem();
253 
254  virtual DtVector groundClamp( double heading, const DtVector& location ) const;
255 
256 protected:
257 
260 
262  DtDiGuyController( const DtDiGuyController& orig );
263 
265  const DtDiGuyController& operator = ( const DtDiGuyController& orig );
266 
268  virtual bool createPortGroups();
269 
271  virtual bool createPorts();
272 
275  virtual bool createCollisionPort();
276  virtual bool createAimDirectionPort();
277  virtual bool createOrderedAnimationPort();
278  virtual bool createOrderedHandItemPort();
279  virtual bool createEtaToDestinationInputPort();
280  virtual bool createChangingPosturePort();
281  virtual bool createNegateSpeedPort();
282 
285  void checkAndSetDefaultPatches();
286 
288  virtual void updateDemeanorAndPosture( DtWeaponState weaponState, DtDamageState damageState,
289  DtLifeformStaticPosture& posture, DtString& demeanor );
290 
292  virtual void determineDirection();
293 
294  virtual DtString chooseRandomAppearance();
295 
297  virtual void updatePosition(const DtTime & dT,DtTaitBryan & localOrientation);
298 
299  virtual DtString selectDamageAnimation(const DtRwNLengthStringVector& animations);
300 
301  virtual void initializeAdjustedDemeanorMap();
302 
303  //virtual void initializePostureTransitionsMap();
304 
305  //virtual double getPostureTransitionTime(DtLifeformStaticPosture from, DtLifeformStaticPosture to);
306 
308  virtual double diGuyHeading() const;
309 
310 protected:
311 
313 
320  DtTaitBryan myTaskedOrientation;
321 
324  DtDamageState myCurrentDamageState;
327 
330  mutable std::pair<DtString,double> myLastTimeToStop;
331 
339 
344 
348 
356 
364 
370 
375 
381 
387 
395 
398 
401 
404 
409 
413 
415 
417 
420 
422 
423 };
#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:369
Definition: diGuyController.h:49
double myCurrentAnimationSpeed
Definition: diGuyController.h:326
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:330
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:347
bool myNeedUpdate
Definition: diGuyController.h:411
const DtDiGuyAnimation * myDefaultAnimation
Definition: diGuyController.h:316
DtUpdateRepositoryOutputPortGroup * myUpdateRepositoryOutputPortGroup
Used to update repository with any movement data. As long as this controller has control of this port...
Definition: diGuyController.h:408
const DtDiGuyAnimation * myCurrentAnimation
Definition: diGuyController.h:322
Description: This repository holds all information that is common to all the forms of all objects wit...
Definition: vrfMovingObjectStateRepository.h:31
DtAnalogInputPort * myEtaToDestinationInputPort
Input Port Name: eta-to-last-vertex Input Port Description: Specifies the eta to reach the last verte...
Definition: diGuyController.h:380
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:421
DtLifeformStaticPosture myDefaultAnimationPosture
Definition: diGuyController.h:317
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:338
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:312
bool myTickWhileDead
Definition: diGuyController.h:410
Definition: readerWriterRegistry.h:39
Definition: bindableLuaComponent.h:53
DtTime myTimeElapsed
Definition: diGuyController.h:337
DtTaitBryan myTaskedOrientation
Definition: diGuyController.h:320
double myTransitionTime
The remaining time for the current posture transition. Gets decremented in tick() ...
Definition: diGuyController.h:400
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:315
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:319
DtAnalogInputPort * myAimDirectionPort
Input Port Name: aim-direction Input Port Description: Specifies the heading in which the entity shou...
Definition: diGuyController.h:363
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:374
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:314
bool myTaskInterrupted
Definition: diGuyController.h:318
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:394
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:324
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:336
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:95
The DtSimComponent class is the base class for the entire simulation model component hierarchy...
Definition: simComponent.h:91
DtWeaponState myCurrentAnimationWeaponState
Definition: diGuyController.h:323
int myLastPosition
Definition: diGuyController.h:414
Definition: diGuyController.h:48
const DtTaskControllerComponent & operator=(const DtTaskControllerComponent &orig)
assignment operator
DtDemeanorToRankMap myDemeanorRankMap
Definition: diGuyController.h:416
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:325
DtBooleanOutputPort * myIsChangingPosturePort
Output Port Name: is-changing-posture Output Port Description: Indicates that the DI Guy character is...
Definition: diGuyController.h:386
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:403
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:397
bool myAmOrdered
Definition: diGuyController.h:412
double myDirectionOfMovement
This is an angle, in radians, relative to the current heading (a value of PI represents &quot;backwards&quot;)...
Definition: diGuyController.h:343
Definition: diGuyController.h:44
DtHumanLocalObjectFacade myHumanLocalObjectFacade
Member to allow for access to human specific data.
Definition: diGuyController.h:419
DtBooleanInputPort * myCollisionPort
Input Port Name: collision Input Port Description: Checks to see if we&#39;re avoiding a collision...
Definition: diGuyController.h:355
A locally simulated VRF object. Holds all internal and external data for the object, and provides access to both the current frame and next frame state data for the object. All current frame data is read-only, and next-frame data can be written to. No thread safety guarantees are made on this object during the simulation frame and it should only be accessed by the thread that is simulating the object.
Definition: localObject.h:86

Document ID: Generated on Tue Sep 24 19:28:17 EDT 2024 from SVN revision 269799
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)