VR-Forces 5.0.1 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
animationModel.h
Go to the documentation of this file.
1 /****************************************************************************
2  * Copyright (c) 2022 MAK Technologies, Inc.
3  * All rights reserved.
4  ****************************************************************************/
5 
6 #pragma once
7 
9 #include "vrfobjcore/simObject.h"
10 #include <readerWriter/rwReal.h>
11 #include <readerWriter/rwString.h>
12 #include <readerWriter/rwInt.h>
13 #include <readerWriter/rwBoolean.h>
14 #include "vrfutil/rwTaitBryan.h"
15 #include "readerWriter/rwVector.h"
17 #include "vrfutil/movementFile.h"
19 #include <readerWriter/rwList.h>
20 #include <boost/signals2.hpp>
21 
22 class DtLocalObject;
23 class DtDeadReckoner;
24 
29 
31 {
32 public:
33 
35  {
36  public:
37 
38  AnimationChange( const DtString& );
39 
40  virtual ~AnimationChange();
41 
42  public:
43 
49 
50  };
51 
53  {
54  public:
55 
57  virtual ~AnimationChangeList();
58 
59  virtual void addAnimationChange(int row, int change, const DtVector& vector, const DtTaitBryan& orientation, double timeDelta);
60 
61  virtual DtlObjPtr getData(DtlObjPtr args, const DtReaderWriter::SearchPaths& searchPaths,
62  const DtVariableBindingsList& variableBindings);
63  };
64 
65 public:
66 
68  DtAnimationModel( DtLocalObject*, const DtString& rwName = DtString::nullString(),
69  DtReaderWriterRegistry* parentRegistry = 0 );
70 
72  DtAnimationModel( const DtAnimationModel& orig, const DtString& rwName = DtString::nullString(),
73  DtReaderWriterRegistry* parentRegistry = 0 );
74 
77 
79  virtual ~DtAnimationModel();
80 
83  virtual void setTimeScale( double d );
84  virtual double timeScale() const;
86 
90  virtual void setReferencePoint(const DtVector&);
91  virtual DtVector referencePoint() const;
93 
97  virtual void setReferenceOrientation(const DtTaitBryan&);
98  virtual DtTaitBryan referenceOrientation() const;
100 
106  virtual void setTarget(const DtUUID&);
107 
109  virtual DtSimObjectReference target() const;
111 
114  virtual void setForceAutomaticOrientation(bool forceAuto);
115  virtual const bool forceAutomaticOrientation() const;
117 
121  virtual void setMoveOutHeading(double);
122  virtual double moveOutHeading() const;
124 
127  virtual void setScriptedMovementFile(const DtString&);
128  virtual const DtString& scriptedMovementFile() const;
130 
140  virtual void setClampType(int);
141  virtual int clampType() const;
143 
151  virtual void setCompletionRule(int);
152  virtual int completionRule() const;
154 
160  virtual void setSpeedNegated( bool enable );
161  virtual bool isSpeedNegated() const;
163 
167  virtual void setFileConfiguration( const DtString& );
168  virtual const DtString& fileConfiguration() const;
170 
173  virtual double calculateOrientation(int frame, double dt, DtTaitBryan&, DtVector& rotationalVelocity) const;
174 
176  virtual DtVector calculateLocation(int frameA, int frameB = -1, double timePastFrameA = 0) const;
177 
180  virtual void calculateSpeed(int frame, DtVector& velocity) const;
181 
183  virtual DtVector targetPosition() const;
184 
186  virtual DtVector localReferencePosition() const;
187 
189  virtual DtTaitBryan targetOrientation() const;
190 
192  virtual DtVector groundClamp(const DtVector&) const;
193 
195  virtual DtVector bodyOffsetVector(int frame) const;
196 
198  virtual DtTaitBryan orientationOffset(int frame) const;
199 
203  virtual bool groundClampHighFidelity(const DtVector& location, double heading, DtTaitBryan& newLocalOrienationTb, DtVector& newLocalLocation) const;
204 
206  virtual DtVector velocityForFrame(int frame) const;
207 
209  virtual DtVector calculateRotationalVelocity(int frame, double dt) const;
210 
212  virtual DtVector calculateRotationalVelocity(const DtTaitBryan& currentFrame, int frame) const;
213 
215  virtual DtVector heightAdjustedLocation(const DtVector&) const;
216 
218  virtual DtTaitBryan orientationForFrame(int frame, double& heading) const;
219 
221  virtual bool canBeAnimated() const;
222 
225  virtual int animationRow(double, int frameHint = 0) const;
226 
228  virtual int animationRows() const;
229 
231  virtual double deltaTimeForFrame(int frame) const;
232 
234  virtual void resetAnimationVariables();
235 
237  virtual void reset();
238 
240  virtual bool setupForAnimation();
241 
243  virtual double simulationTime(int) const;
244 
246  virtual void setFrameTime(double);
247 
250  virtual double frameTime() const;
251 
253  virtual void setAnimationFrame(int);
254  virtual int animationFrame() const;
255 
257  virtual void setNeedsSetup(bool);
258  virtual bool needsSetup() const;
259 
262  virtual bool simulate(double simulateFor, DtVector& newLocation, DtTaitBryan& newOrientation,
263  DtVector& newVelocity, DtVector& newRotationalVelocity, bool debug = false);
264 
266  virtual void setElapsedAnimationTime(double);
267  virtual double elapsedAnimationTime() const;
268 
271  virtual void setTransitionSpeed(double);
272  virtual double transitionSpeed() const;
273 
279  virtual int setObjectOffsetLocation(int row, const DtVector&);
280 
283  virtual int setObjectOffsetOrientation(int row, const DtTaitBryan&);
284 
286  virtual void setTimeDeltaFromPreviousRow(int forRow, double timeDelta);
287 
292  virtual int addAnimationRow(double deltaTime, double lateral, double range, double altitude,
293  double headingOffset = 0, double pitchOffset = 0, double rollOffset = 0);
294 
296  virtual void removeRow(int);
298 
299  virtual void setEntity(DtLocalObject*);
300  virtual const DtLocalObject* entity() const;
301  virtual DtLocalObject* entity();
302  virtual const char* readerWriterType() const;
303 
305  virtual int frameToTravelSpeed(int base, double speed) const;
306 
308  virtual double lastSimulationTime() const;
309 
311  virtual bool isFinished() const;
312 
313 protected:
314 
317  void createDeadReckoner();
318 
319  virtual void processObjectAboutToBeRemoved(const DtSimObject*);
320 
322  virtual void putSelf(std::string& fp, int indentLevel, bool writeUnspecified,
323  const DtFilename& path);
324 
326  virtual void getSelf(DtlObjPtr args, const DtReaderWriter::SearchPaths& searchPaths,
327  const DtVariableBindingsList& variableBindings);
328 
330  virtual void initializeReferenceObject();
331 
333  virtual int nextFrameToMaintainSpeed(int frame, double speed) const;
334 
336  virtual void deadReckon(double overTime, DtVector& newWorldLocation,
337  DtTaitBryan& newLocalOrientation, DtVector& newVelocity,
338  DtVector& newRotationalVelocity) const;
339 
340 protected:
341 
343  {
344  LocalAnimationChange() : change(0), timeDelta(0) {};
345  LocalAnimationChange(const LocalAnimationChange& orig) : change(orig.change),
346  vector(orig.vector), orientation(orig.orientation), timeDelta(orig.timeDelta) {};
347  virtual ~LocalAnimationChange() {};
348 
353  int change;
354 
357 
359  DtTaitBryan orientation;
360 
361  double timeDelta;
362  };
363 
364 protected:
365 
367 
369 
387 
390  typedef std::map<int,LocalAnimationChange> AnimationChanges;
392 
393  DtTaitBryan myLastOrientation;
398 
401 
404 
405  DtDeadReckoner* myDeadReckoner;
406 
408  boost::signals2::scoped_connection myDeleteObjectConnection;
410 
411 };
UUID is a unique ID wrapper class.
Definition: rwUUID.h:226
DtRwTaitBryan myOrientation
Definition: animationModel.h:47
DtRwInt myCompletionRule
Definition: animationModel.h:377
DtLocalObject * myEntity
Definition: animationModel.h:368
virtual const char * readerWriterType() const
Used to supply a string type that this reader writer type is. This can be used in place of dynamic-ca...
std::map< int, LocalAnimationChange > AnimationChanges
Map, by row, of changes to the animation file. When read back in will be applied to the movement file...
Definition: animationModel.h:390
AnimationChanges myAnimationChanges
Definition: animationModel.h:391
DtRwVector myVector
Definition: animationModel.h:46
DtRwInt myClampType
Definition: animationModel.h:376
DtRwString myScriptedMovementFile
Definition: animationModel.h:375
DtVector myLastRelativeVelocity
Definition: animationModel.h:396
DtVector myLastVelocity
Definition: animationModel.h:397
A Readable, Writable version of DtList. This class cannot be used directly, but must be inherited to ...
Definition: rwList.h:26
DtRwInt myRow
Definition: animationModel.h:44
DtDeadReckoner * myDeadReckoner
Definition: animationModel.h:405
DtRwBoolean myForceAutomaticOrientation
Definition: animationModel.h:386
DtRwReal myTimeScale
Definition: animationModel.h:370
DtVector myLastRotationalVelocity
Definition: animationModel.h:395
The DtSimObjectReference is a shared pointer that can be used amongst many object for access to the u...
Definition: simObjectReference.h:26
Definition: readerWriter.h:85
Description: Readable, Writable DtString Variable substitutions are done on this object when it is re...
Definition: rwString.h:20
LocalAnimationChange()
Definition: animationModel.h:344
Description: Readable, Writable DtTaitBryan.
Definition: rwTaitBryan.h:20
Definition: readerWriterRegistry.h:39
DtRwBoolean mySpeedNegatedFlag
Definition: animationModel.h:378
DtRwReal myTimeDelta
Definition: animationModel.h:48
Definition: animationModel.h:52
DtTaitBryan myOriginalOrientation
Definition: animationModel.h:400
double timeDelta
Definition: animationModel.h:361
DtRwTaitBryan myReferenceOrientation
Definition: animationModel.h:372
DtMovementLocalObjectFacade * myMovementLocalObjectFacade
Definition: animationModel.h:409
This class will load in and return data from a movement file.
Definition: movementFile.h:273
Contains the DtRwTaitBryan class declaration.
Definition: rwVector.h:23
virtual void reset()
For those reader/writer items that support it, resets the reader/writer value to original state Defau...
Specialized reader/writer version of the shared object reference that will encapsulate the actual sha...
Definition: simObjectReference.h:74
Definition: animationModel.h:342
DtRwSimObjectReference myTarget
Definition: animationModel.h:373
#define DT_DLL_vrfobjcore
This file is used to determine how to build.
Definition: vrfobjcoreDefines.h:24
std::list< const DtRwVariableBindings * > DtVariableBindingsList
Definition: readerWriterRegistry.h:29
DtRwVector myReferencePoint
Definition: animationModel.h:371
DtVector myLastLocation
Definition: animationModel.h:394
Description: Readable, Writable int.
Definition: rwInt.h:25
virtual ~LocalAnimationChange()
Definition: animationModel.h:347
std::vector< DtFilename > SearchPaths
Definition: readerWriter.h:92
bool myIsEmbarked
Definition: animationModel.h:407
Definition: animationModel.h:34
DtTaitBryan myLastOrientation
Definition: animationModel.h:393
DtRwInt myChange
Definition: animationModel.h:45
DtRwBoolean myLastFrameWasAnimated
Definition: animationModel.h:382
DtRwReal myElapsedAnimationTime
Definition: animationModel.h:384
virtual void getSelf(DtlObjPtr args, const DtReaderWriter::SearchPaths &searchPaths=SearchPaths(), const DtVariableBindingsList &variableBindings=nullVariableReference())
Top level to read itself from an input stream. searchPath is passed down to all DtReaderWriter member...
virtual void putSelf(std::string &fp, int indentLevel=0, bool writeUnspecified=false, const DtFilename &path=DtFilename::nullFilename())
Top level call to write itself to file. If write unspecified is true, will write entries that are uns...
The DtAnimationModel class will contain the interface allow for animated movement via an external fil...
Definition: animationModel.h:30
boost::signals2::scoped_connection myDeleteObjectConnection
Definition: animationModel.h:408
DtRwBoolean myNeedsSetup
Definition: animationModel.h:403
Description: Readable, Writable DtReal (double)
Definition: rwReal.h:27
DtRwString myFileConfiguration
Definition: animationModel.h:379
DtMovementFile myMovementFile
Definition: animationModel.h:366
DtRwReal myFrameTime
Definition: animationModel.h:380
DtRwInt myAnimationFrame
Definition: animationModel.h:381
double myLastSimulationTime
Definition: animationModel.h:402
Represents a single simulation object in the exercise. Object may be VRF simulation, or non-VRF simulated, and may be simulated by the local sim engine, or by a remote sim engine. Only public (external) state of the object is available. All data is read-only. All access to data of the object is thread safe within the simulation frame.
Definition: simObject.h:79
DtRwReal myMoveOutHeading
Definition: animationModel.h:374
Description: Readable, Writable bool.
Definition: rwBoolean.h:26
DtVector myOriginalLocation
Definition: animationModel.h:399
LocalAnimationChange(const LocalAnimationChange &orig)
Definition: animationModel.h:345
const DtReaderWriter & operator=(const DtReaderWriter &orig)
assignment operator
DtVector vector
Vector in body coordinates.
Definition: animationModel.h:356
DtTaitBryan orientation
Orientation in topographic change from reference orientation.
Definition: animationModel.h:359
DtRwReal myLastAnimationFrameTime
Definition: animationModel.h:385
DtRwReal myTransitionSpeed
Definition: animationModel.h:383
File: rwVector.h.
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 Mon Jun 20 00:38:30 EDT 2022 from SVN revision 244029
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)