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();
42 
43  public:
44 
50 
51  };
52 
54  {
55  public:
56 
58  virtual ~AnimationChangeList();
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);
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();
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();
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;
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,
324  const DtFilename& path);
325 
327  virtual void getSelf(DtlObjPtr args, const DtReaderWriter::SearchPaths& searchPaths,
328  const DtVariableBindingsList& variableBindings);
329 
331  virtual void initializeReferenceObject();
332 
334  virtual int nextFrameToMaintainSpeed(int frame, double speed) const;
335 
337  virtual void deadReckon(double overTime, DtVector& newWorldLocation,
338  DtTaitBryan& newLocalOrientation, DtVector& newVelocity,
339  DtVector& newRotationalVelocity) const;
340 
341 protected:
342 
344  {
345  LocalAnimationChange() : change(0), timeDelta(0) {};
346  LocalAnimationChange(const LocalAnimationChange& orig) : change(orig.change),
347  vector(orig.vector), orientation(orig.orientation), timeDelta(orig.timeDelta) {};
348  virtual ~LocalAnimationChange() {};
349 
354  int change;
355 
358 
360  DtTaitBryan orientation;
361 
362  double timeDelta;
363  };
364 
365 protected:
366 
368 
370 
388 
391  typedef std::map<int,LocalAnimationChange> AnimationChanges;
393 
394  DtTaitBryan myLastOrientation;
399 
402 
405 
406  DtDeadReckoner* myDeadReckoner;
407 
409  boost::signals2::scoped_connection myDeleteObjectConnection;
411 
412 };
UUID is a unique ID wrapper class.
Definition: uuid.h:59
DtRwTaitBryan myOrientation
Definition: animationModel.h:48
DtRwInt myCompletionRule
Definition: animationModel.h:378
DtLocalObject * myEntity
Definition: animationModel.h:369
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:391
AnimationChanges myAnimationChanges
Definition: animationModel.h:392
DtRwVector myVector
Definition: animationModel.h:47
DtRwInt myClampType
Definition: animationModel.h:377
DtRwString myScriptedMovementFile
Definition: animationModel.h:376
DtVector myLastRelativeVelocity
Definition: animationModel.h:397
DtVector myLastVelocity
Definition: animationModel.h:398
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:406
DtRwBoolean myForceAutomaticOrientation
Definition: animationModel.h:387
DtRwReal myTimeScale
Definition: animationModel.h:371
DtVector myLastRotationalVelocity
Definition: animationModel.h:396
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:345
Description: Readable, Writable DtTaitBryan.
Definition: rwTaitBryan.h:20
Definition: readerWriterRegistry.h:39
DtRwBoolean mySpeedNegatedFlag
Definition: animationModel.h:379
DtRwReal myTimeDelta
Definition: animationModel.h:49
Definition: animationModel.h:53
DtTaitBryan myOriginalOrientation
Definition: animationModel.h:401
double timeDelta
Definition: animationModel.h:362
DtRwTaitBryan myReferenceOrientation
Definition: animationModel.h:373
DtMovementLocalObjectFacade * myMovementLocalObjectFacade
Definition: animationModel.h:410
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: rwSimObjectReference.h:21
Definition: animationModel.h:343
DtRwSimObjectReference myTarget
Definition: animationModel.h:374
#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:372
DtVector myLastLocation
Definition: animationModel.h:395
Description: Readable, Writable int.
Definition: rwInt.h:25
virtual ~LocalAnimationChange()
Definition: animationModel.h:348
std::vector< DtFilename > SearchPaths
Definition: readerWriter.h:92
bool myIsEmbarked
Definition: animationModel.h:408
Definition: animationModel.h:35
DtTaitBryan myLastOrientation
Definition: animationModel.h:394
DtRwInt myChange
Definition: animationModel.h:46
DtRwBoolean myLastFrameWasAnimated
Definition: animationModel.h:383
DtRwReal myElapsedAnimationTime
Definition: animationModel.h:385
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:409
DtRwBoolean myNeedsSetup
Definition: animationModel.h:404
Description: Readable, Writable DtReal (double)
Definition: rwReal.h:27
DtRwString myFileConfiguration
Definition: animationModel.h:380
DtMovementFile myMovementFile
Definition: animationModel.h:367
DtRwReal myFrameTime
Definition: animationModel.h:381
DtRwInt myAnimationFrame
Definition: animationModel.h:382
double myLastSimulationTime
Definition: animationModel.h:403
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:88
DtRwReal myMoveOutHeading
Definition: animationModel.h:375
Description: Readable, Writable bool.
Definition: rwBoolean.h:26
DtVector myOriginalLocation
Definition: animationModel.h:400
LocalAnimationChange(const LocalAnimationChange &orig)
Definition: animationModel.h:346
const DtReaderWriter & operator=(const DtReaderWriter &orig)
assignment operator
DtVector vector
Vector in body coordinates.
Definition: animationModel.h:357
DtTaitBryan orientation
Orientation in topographic change from reference orientation.
Definition: animationModel.h:360
DtRwReal myLastAnimationFrameTime
Definition: animationModel.h:386
DtRwReal myTransitionSpeed
Definition: animationModel.h:384
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 Wed Mar 27 22:49:11 EDT 2024 from SVN revision 264633
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)