VR-Forces 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>
22 
23 class DtLocalObject;
24 class DtDeadReckoner;
25 
30 
32 {
33 public:
34 
36  {
37  public:
38 
39  AnimationChange( const DtString& );
40 
41  virtual ~AnimationChange() override;
42 
43  public:
44 
50 
51  };
52 
54  {
55  public:
56 
58  virtual ~AnimationChangeList() override;
59 
60  virtual void addAnimationChange(int row, int change, const DtVector& vector, const DtTaitBryan& orientation, double timeDelta);
61 
62  virtual DtlObjPtr getData(DtlObjPtr args, const DtReaderWriter::SearchPaths& searchPaths,
63  const DtVariableBindingsList& variableBindings) override;
64  };
65 
66 public:
67 
69  DtAnimationModel( DtLocalObject*, const DtString& rwName = DtString::nullString(),
70  DtReaderWriterRegistry* parentRegistry = 0 );
71 
73  DtAnimationModel( const DtAnimationModel& orig, const DtString& rwName = DtString::nullString(),
74  DtReaderWriterRegistry* parentRegistry = 0 );
75 
78 
80  virtual ~DtAnimationModel() override;
81 
84  virtual void setTimeScale( double d );
85  virtual double timeScale() const;
87 
91  virtual void setReferencePoint(const DtVector&);
92  virtual DtVector referencePoint() const;
94 
98  virtual void setReferenceOrientation(const DtTaitBryan&);
99  virtual DtTaitBryan referenceOrientation() const;
101 
107  virtual void setTarget(const DtUUID&);
108 
110  virtual DtSimObjectReference target() const;
112 
115  virtual void setForceAutomaticOrientation(bool forceAuto);
116  virtual const bool forceAutomaticOrientation() const;
118 
122  virtual void setMoveOutHeading(double);
123  virtual double moveOutHeading() const;
125 
128  virtual void setScriptedMovementFile(const DtString&);
129  virtual const DtString& scriptedMovementFile() const;
131 
141  virtual void setClampType(int);
142  virtual int clampType() const;
144 
152  virtual void setCompletionRule(int);
153  virtual int completionRule() const;
155 
161  virtual void setSpeedNegated( bool enable );
162  virtual bool isSpeedNegated() const;
164 
168  virtual void setFileConfiguration( const DtString& );
169  virtual const DtString& fileConfiguration() const;
171 
174  virtual double calculateOrientation(int frame, double dt, DtTaitBryan&, DtVector& rotationalVelocity) const;
175 
177  virtual DtVector calculateLocation(int frameA, int frameB = -1, double timePastFrameA = 0) const;
178 
181  virtual void calculateSpeed(int frame, DtVector& velocity) const;
182 
184  virtual DtVector targetPosition() const;
185 
187  virtual DtVector localReferencePosition() const;
188 
190  virtual DtTaitBryan targetOrientation() const;
191 
193  virtual DtVector groundClamp(const DtVector&) const;
194 
196  virtual DtVector bodyOffsetVector(int frame) const;
197 
199  virtual DtTaitBryan orientationOffset(int frame) const;
200 
204  virtual bool groundClampHighFidelity(const DtVector& location, double heading, DtTaitBryan& newLocalOrienationTb, DtVector& newLocalLocation) const;
205 
207  virtual DtVector velocityForFrame(int frame) const;
208 
210  virtual DtVector calculateRotationalVelocity(int frame, double dt) const;
211 
213  virtual DtVector calculateRotationalVelocity(const DtTaitBryan& currentFrame, int frame) const;
214 
216  virtual DtVector heightAdjustedLocation(const DtVector&) const;
217 
219  virtual DtTaitBryan orientationForFrame(int frame, double& heading) const;
220 
222  virtual bool canBeAnimated() const;
223 
226  virtual int animationRow(double, int frameHint = 0) const;
227 
229  virtual int animationRows() const;
230 
232  virtual double deltaTimeForFrame(int frame) const;
233 
235  virtual void resetAnimationVariables();
236 
238  virtual void reset() override;
239 
241  virtual bool setupForAnimation();
242 
244  virtual double simulationTime(int) const;
245 
247  virtual void setFrameTime(double);
248 
251  virtual double frameTime() const;
252 
254  virtual void setAnimationFrame(int);
255  virtual int animationFrame() const;
256 
258  virtual void setNeedsSetup(bool);
259  virtual bool needsSetup() const;
260 
263  virtual bool simulate(double simulateFor, DtVector& newLocation, DtTaitBryan& newOrientation,
264  DtVector& newVelocity, DtVector& newRotationalVelocity, bool debug = false);
265 
267  virtual void setElapsedAnimationTime(double);
268  virtual double elapsedAnimationTime() const;
269 
272  virtual void setTransitionSpeed(double);
273  virtual double transitionSpeed() const;
274 
280  virtual int setObjectOffsetLocation(int row, const DtVector&);
281 
284  virtual int setObjectOffsetOrientation(int row, const DtTaitBryan&);
285 
287  virtual void setTimeDeltaFromPreviousRow(int forRow, double timeDelta);
288 
293  virtual int addAnimationRow(double deltaTime, double lateral, double range, double altitude,
294  double headingOffset = 0, double pitchOffset = 0, double rollOffset = 0);
295 
297  virtual void removeRow(int);
299 
300  virtual void setEntity(DtLocalObject*);
301  virtual const DtLocalObject* entity() const;
302  virtual DtLocalObject* entity();
303  virtual const char* readerWriterType() const override;
304 
306  virtual int frameToTravelSpeed(int base, double speed) const;
307 
309  virtual double lastSimulationTime() const;
310 
312  virtual bool isFinished() const;
313 
314 protected:
315 
318  void createDeadReckoner();
319 
320  virtual void processObjectAboutToBeRemoved(const DtSimObject*);
321 
323  virtual void putSelf(std::string& fp, int indentLevel, bool writeUnspecified, const DtFilename& path) override;
324 
326  virtual void getSelf(DtlObjPtr args, const DtReaderWriter::SearchPaths& searchPaths,
327  const DtVariableBindingsList& variableBindings) override;
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 
356  DtVector vector;
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;
394  DtVector myLastLocation;
397  DtVector myLastVelocity;
398 
401 
404 
405  DtDeadReckoner* myDeadReckoner;
406 
408  boost::signals2::scoped_connection myDeleteObjectConnection;
410 
411 };
UUID is a unique ID wrapper class.
Definition: uuid.h:59
DtRwTaitBryan myOrientation
Definition: animationModel.h:48
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:47
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:45
DtDeadReckoner * myDeadReckoner
Definition: animationModel.h:405
DtRwBoolean myForceAutomaticOrientation
Definition: animationModel.h:386
DtRwReal myTimeScale
Definition: animationModel.h:370
DtVector myLastRotationalVelocity
Definition: animationModel.h:395
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:49
Definition: animationModel.h:53
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:272
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: rwSimObjectReference.h:21
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:35
DtTaitBryan myLastOrientation
Definition: animationModel.h:393
DtRwInt myChange
Definition: animationModel.h:46
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:31
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:80
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.
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)