6 #include <scene/Scene.h>
7 #include <scene/StaticScene.h>
8 #include <scene/dynamic/DynObject.h>
9 #include <sim/tools/NonVoidStepLoop.h>
12 using std::shared_ptr;
33 friend class boost::serialization::access;
42 template <
class Archive>
43 void serialize(Archive &ar,
const unsigned int version){
44 boost::serialization::split_member(ar, *
this, version);
51 template <
class Archive>
52 void save(Archive &ar,
const unsigned int version)
const {
53 boost::serialization::void_cast_register<DynScene, StaticScene>();
54 ar &boost::serialization::base_object<StaticScene>(*
this);
64 template <
class Archive>
65 void load(Archive &ar,
const unsigned int version){
66 boost::serialization::void_cast_register<DynScene, StaticScene>();
67 ar &boost::serialization::base_object<StaticScene>(*
this);
118 stepLoop(stepInterval, [&] () -> bool{return doStep();})
126 stepLoop(stepInterval, [&] () -> bool{return doStep();})
152 bool doSimStep()
override;
168 virtual void makeStepLoop(
int const stepInterval);
178 dynObjs.push_back(dynobj);
179 updated.push_back(
true);
187 {
return dynObjs[index];}
193 inline void setDynObject(
size_t const index, shared_ptr<DynObject> dynobj){
194 dynObjs[index] = dynobj;
195 updated[index] =
true;
202 dynObjs.erase(dynObjs.begin()+index);
203 updated.erase(updated.begin()+index);
222 {
return updated[index];}
248 void writeObject(std::string path)
override;
254 static DynScene *readObject(std::string path);
Dynamic scene base implementation.
Definition: DynScene.h:29
void clearDynObjects()
Remove all dynamic objects from the dynamic scene.
Definition: DynScene.h:208
void removeDynObject(size_t const index)
Remove dynamic object at given index.
Definition: DynScene.h:201
void setDynObject(size_t const index, shared_ptr< DynObject > dynobj)
Set dynamic object at given index.
Definition: DynScene.h:193
void setStepInterval(int const stepInterval)
Set the step interval for the dynamic scene.
Definition: DynScene.h:235
int getStepInterval() const
Obtain the current step interval for the dynamic scene.
Definition: DynScene.h:228
DynScene(Scene &s, int const stepInterval=1)
Build a dynamic scene using given scene as basis.
Definition: DynScene.h:116
void save(Archive &ar, const unsigned int version) const
Save a serialized DynScene to a stream of bytes.
Definition: DynScene.h:52
DynScene(int const stepInterval=1)
Dynamic scene default constructor.
Definition: DynScene.h:103
shared_ptr< DynObject > getDynObject(size_t const index)
Obtain dynamic object at given index.
Definition: DynScene.h:186
void appendDynObject(shared_ptr< DynObject > dynobj)
Append given dynamic object to the scene.
Definition: DynScene.h:177
void load(Archive &ar, const unsigned int version)
Load a serialized DynScene from a stream of bytes.
Definition: DynScene.h:65
vector< bool > updated
Vector of flags controlling whether a dynamic object has been updated after last step (true) or not.
Definition: DynScene.h:90
vector< shared_ptr< DynObject > > dynObjs
Dynamic objects composing the scene.
Definition: DynScene.h:81
size_t numDynObjects()
Obtain the number of dynamic objects in the scene.
Definition: DynScene.h:213
bool doStep()
Dynamic behavior computation itself.
Definition: DynScene.cpp:25
DynScene(StaticScene &ss, int const stepInterval=1)
Build a dynamic scene using given static scene as basis.
Definition: DynScene.h:124
void serialize(Archive &ar, const unsigned int version)
Serialize a DynScene to a stream of bytes.
Definition: DynScene.h:43
NonVoidStepLoop< bool > stepLoop
The step loop for the dynamic scene.
Definition: DynScene.h:95
bool isDynObjectUpdated(size_t const index) const
Check whether the dynamic object at given index has been updated on last step (true) or not (false)
Definition: DynScene.h:221
Class representing a scene asset.
Definition: Scene.h:28
Static scene basic implementation.
Definition: StaticScene.h:24
virtual int getStepInterval() const
Obtain the step interval.
Definition: StepLoop.h:108
virtual void setStepInterval(int const stepInterval)
Set the step interval.
Definition: StepLoop.h:114