VR-Forces 5.0.2 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) 2022 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 
123  virtual bool intrinsicTick(DtLifeformStaticPosture post,
124  double speed,DtWeaponState weapon, DtString & demeanor);
125 
127  virtual bool tickWhileDestroyed() const;
128 
131  virtual void setCurrentAnimation(const DtDiGuyAnimation * animation,bool overridePosture = false);
132 
135  virtual void sendSetPosture(DtLifeformState post);
136 
138  static void setCharacteristicsCallback( DtSimMessage* msg, void* usr );
139  virtual void processSetCharacterCharacteristics( DtSimMessage* msg );
140 
142  static void setAppearanceCallback( DtSimMessage* msg, void* usr );
143  virtual void processSetCharacterAppearance( DtSimMessage* msg );
144 
146  static void setHandItemCallback( DtSimMessage* msg, void* usr );
147  virtual void processSetCharacterHandItem( DtSimMessage* msg );
148 
150  static void setHeadCallback( DtSimMessage* msg, void* usr );
151  virtual void processSetCharacterHead( DtSimMessage* msg );
152 
154  static void setUnitPatchesCallback( DtSimMessage* msg, void* usr );
155  virtual void processSetUnitPatches( DtSimMessage* msg );
156 
158  static void setRankPatchCallback( DtSimMessage* msg, void* usr );
159  virtual void processSetRankPatch( DtSimMessage* msg );
160 
162  static void setNametagCallback( DtSimMessage* msg, void* usr );
163  virtual void processSetNametag( DtSimMessage* msg );
164 
165  static void setRestoreCallback( DtSimMessage* msg, void* usrData );
166  virtual void processSetRestore( DtSimMessage* msg );
167 
169  static void setAdjustDemeanorCallback(DtSimMessage * msg, void * usrData);
170  virtual void processSetAdjustDemeanor(DtSimMessage* msg);
171 
172  static void animationTaskCallback(DtSimMessage * msg, void * usrData);
173  virtual void processAnimationTask(DtSimMessage * msg);
174 
177  virtual void clearTask();
178  virtual void taskComplete(bool success = true);
179  virtual void reset();
180 
182  virtual double lookupTimeToStop( DtLifeformStaticPosture post, double heading,
183  DtWeaponState weaponState, const DtString& demeanor ) const;
184 
186  virtual const DtDiGuyAnimation* chooseAnimation( DtLifeformStaticPosture post, double heading,
187  double speed, DtWeaponState weaponState, const DtString& demeanor, bool debug = true ) const;
188 
190  virtual void updateAnimationState( DtLifeformStaticPosture post,
191  double speed, DtWeaponState weapon, const DtString& demeanor );
192 
194  virtual DtDiGuyDirectionType directionStringToEnum(const DtString & direction);
195 
199 
200 
202  bool isAnimationAvailable(const std::string& animation) const;
203 
205  bool isAppearanceAvailable(const std::string& appearance) const;
206 
208  bool isHandItemAvailable(const std::string& item) const;
209 
212  bool isHeadAvailable(const std::string& head) const;
213 
215  bool isGestureAvailable(const std::string& gesture) const;
216 
218 
221  virtual void bindLuaFunctions(lua_State* L);
222  virtual void bindLuaGlobals(lua_State* L);
223 
227  static DtSimComponent* creator( const DtString& name, DtLocalObject* owner, DtSimulationServices* simManager,
228  DtComponentDescriptor* desc = 0, DtReaderWriterRegistry* parentRegistry = 0 );
229 
230 protected:
231 
233  virtual void registerRadioMessageCallbacks();
234 
236  virtual void registerDiGuyTasks();
237 
240  virtual void determineInitialHandItem();
241 
242  virtual DtVector groundClamp(double heading, const DtVector& location) const;
243 
244 protected:
245 
248 
250  DtDiGuyController( const DtDiGuyController& orig );
251 
253  const DtDiGuyController & operator = ( const DtDiGuyController& orig );
254 
256  virtual bool createPortGroups();
257 
259  virtual bool createPorts();
260 
263  virtual bool createCollisionPort();
264  virtual bool createAimDirectionPort();
265  virtual bool createOrderedAnimationPort();
266  virtual bool createOrderedHandItemPort();
267  virtual bool createEtaToDestinationInputPort();
268  virtual bool createChangingPosturePort();
269  virtual bool createNegateSpeedPort();
270 
273  void checkAndSetDefaultPatches();
274 
275  virtual DtString determineDemeanor( DtWeaponState weaponState,
276  DtLifeformStaticPosture posture );
277 
279  virtual void determineDirection();
280 
281  virtual DtString chooseRandomAppearance();
282 
284  virtual void updatePosition(const DtTime & dT,DtTaitBryan & localOrientation);
285 
286  virtual DtString selectDamageAnimation(const DtRwNLengthStringVector& animations);
287 
288  virtual void initializeAdjustedDemeanorMap();
289 
290  //virtual void initializePostureTransitionsMap();
291 
292  //virtual double getPostureTransitionTime(DtLifeformStaticPosture from, DtLifeformStaticPosture to);
293 
295  virtual double diGuyHeading() const;
296 
297 protected:
298 
300 
307  DtTaitBryan myTaskedOrientation;
308 
311  DtDamageState myCurrentDamageState;
314 
317  mutable std::pair<DtString,double> myLastTimeToStop;
318 
326 
331 
335 
343 
351 
357 
362 
368 
374 
382 
385 
388 
391 
396 
400 
402 
404 
407 
408 };
#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:356
Definition: diGuyController.h:49
double myCurrentAnimationSpeed
Definition: diGuyController.h:313
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:317
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:334
bool myNeedUpdate
Definition: diGuyController.h:398
const DtDiGuyAnimation * myDefaultAnimation
Definition: diGuyController.h:303
DtUpdateRepositoryOutputPortGroup * myUpdateRepositoryOutputPortGroup
Used to update repository with any movement data. As long as this controller has control of this port...
Definition: diGuyController.h:395
const DtDiGuyAnimation * myCurrentAnimation
Definition: diGuyController.h:309
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:367
DtRwNLengthStringVector is a named, readable/writable vector of strings of arbitrary length...
Definition: rwNLengthStringVector.h:28
Instances of DtBooleanOutputPort are output ports through which data producers can send boolean data...
Definition: boolIOPort.h:45
Definition: diGuyController.h:47
DtLifeformStaticPosture myDefaultAnimationPosture
Definition: diGuyController.h:304
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:20
virtual void bindLuaFunctions(lua_State *)=0
Override to bind lua functions.
bool myAmRotating
Definition: diGuyController.h:325
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:299
bool myTickWhileDead
Definition: diGuyController.h:397
Definition: readerWriterRegistry.h:39
virtual const char * type() const =0
Returns a string identifies the class type of component. Type values are defined in compTypes...
Definition: bindableLuaComponent.h:53
DtTime myTimeElapsed
Definition: diGuyController.h:324
DtTaitBryan myTaskedOrientation
Definition: diGuyController.h:307
double myTransitionTime
The remaining time for the current posture transition. Gets decremented in tick() ...
Definition: diGuyController.h:387
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...
virtual void clearTask()
If component is currently tasked, calls clearPendingSubtasks(), sets the tasked flag to false...
DtVrfMovingObjectStateRepository * myLocalState
Definition: diGuyController.h:302
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:306
DtAnalogInputPort * myAimDirectionPort
Input Port Name: aim-direction Input Port Description: Specifies the heading in which the entity shou...
Definition: diGuyController.h:350
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:361
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:301
bool myTaskInterrupted
Definition: diGuyController.h:305
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:381
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:311
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:323
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:90
The DtSimComponent class is the base class for the entire simulation model component hierarchy...
Definition: simComponent.h:70
DtWeaponState myCurrentAnimationWeaponState
Definition: diGuyController.h:310
int myLastPosition
Definition: diGuyController.h:401
Definition: diGuyController.h:48
const DtTaskControllerComponent & operator=(const DtTaskControllerComponent &orig)
assignment operator
DtDemeanorToRankMap myDemeanorRankMap
Definition: diGuyController.h:403
DT_DLL_DEBUGDRAWRENDERER void init(makVrv::DtDe &de)
Work function for the plugin initialization.
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:312
DtBooleanOutputPort * myIsChangingPosturePort
Output Port Name: is-changing-posture Output Port Description: Indicates that the DI Guy character is...
Definition: diGuyController.h:373
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:390
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:384
bool myAmOrdered
Definition: diGuyController.h:399
double myDirectionOfMovement
This is an angle, in radians, relative to the current heading (a value of PI represents &quot;backwards&quot;)...
Definition: diGuyController.h:330
Definition: diGuyController.h:44
DtHumanLocalObjectFacade myHumanLocalObjectFacade
Member to allow for access to human specific data.
Definition: diGuyController.h:406
DtBooleanInputPort * myCollisionPort
Input Port Name: collision Input Port Description: Checks to see if we&#39;re avoiding a collision...
Definition: diGuyController.h:342
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 Sun Dec 4 20:22:03 EST 2022 from SVN revision 249613
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)