3 #include <boost/archive/text_iarchive.hpp>
4 #include <boost/archive/text_oarchive.hpp>
5 #include <boost/serialization/base_object.hpp>
6 #include <boost/serialization/split_member.hpp>
13 #include <DetailedVoxel.h>
18 #include <KDTreeNodeRoot.h>
19 #include <KDGroveFactory.h>
21 #include <KDGroveRaycaster.h>
23 #include <RaySceneIntersection.h>
33 friend class boost::serialization::access;
41 template <
class Archive>
44 unsigned int const version
47 ar.template register_type<Vertex>();
48 ar.template register_type<AABB>();
49 ar.template register_type<Triangle>();
50 ar.template register_type<Voxel>();
51 ar.template register_type<DetailedVoxel>();
54 boost::serialization::void_cast_register<Scene, Asset>();
55 ar &boost::serialization::base_object<Asset>(*
this);
70 template <
class Archive>
73 unsigned int const fileVersion
76 ar.template register_type<Vertex>();
77 ar.template register_type<AABB>();
78 ar.template register_type<Triangle>();
79 ar.template register_type<Voxel>();
80 ar.template register_type<DetailedVoxel>();
83 boost::serialization::void_cast_register<Scene, Asset>();
84 ar &boost::serialization::base_object<Asset>(*
this);
95 BOOST_SERIALIZATION_SPLIT_MEMBER();
105 std::shared_ptr<KDGroveFactory>
kdgf;
141 std::vector<std::shared_ptr<ScenePart>>
parts;
183 std::shared_ptr<AABB>
getAABB();
203 glm::dvec3
const &rayOrigin,
204 glm::dvec3
const &rayDir,
205 bool const groundOnly
216 vector<double>
const &tMinMax,
217 glm::dvec3
const &rayOrigin,
218 glm::dvec3
const &rayDir,
219 bool const groundOnly
234 glm::dvec3 &rayOrigin,
236 bool const groundOnly
362 int const searchDepth,
363 glm::dvec3
const minzv,
364 vector<Vertex *> &vertices,
365 vector<double>
const &o,
366 vector<double>
const &v
385 virtual inline std::shared_ptr<KDGroveRaycaster>
const &getRaycaster()
400 std::shared_ptr<KDGroveFactory>
const kdgf
423 virtual inline std::shared_ptr<AABB>
getBBox()
const {
return bbox;}
443 {this->bbox_crs =
bbox;}
451 for(std::shared_ptr<ScenePart> part :
parts){
452 if(part->getType()==ScenePart::ObjectType::DYN_MOVING_OBJECT)
Base class for all assets.
Definition: Asset.h:10
Definition: KDGroveFactory.h:18
Abstract class defining the common behavior for all primitives.
Definition: Primitive.h:24
Class representing a scene asset.
Definition: Scene.h:28
std::shared_ptr< AABB > bbox
Axis aligned bounding box defining scene boundaries.
Definition: Scene.h:114
virtual std::shared_ptr< AABB > getBBox() const
Obtain the scene's bounding box.
Definition: Scene.h:423
virtual std::shared_ptr< KDGrove > getKDGrove() const
Obtain the KDGrove used by the scene.
Definition: Scene.h:408
virtual void setKDGroveFactory(std::shared_ptr< KDGroveFactory > const kdgf)
Set the KDGrove factory to be used by the scene.
Definition: Scene.h:399
static Scene * readObject(std::string path)
Read serialized scene from given file.
Definition: Scene.cpp:392
glm::dvec3 getShift()
Obtain the minimum boundaries of the original axis aligned bounding box containing the scene,...
Definition: Scene.cpp:210
std::shared_ptr< RaySceneIntersection > getIntersection(glm::dvec3 const &rayOrigin, glm::dvec3 const &rayDir, bool const groundOnly) const
Obtain the intersection between the ray and the scene, if any.
Definition: Scene.cpp:168
std::shared_ptr< KDGroveFactory > kdgf
The KDGrove factory used to build the scene KDGrove.
Definition: Scene.h:105
void doForceOnGround()
For each scene part which is flagged as forceOnGround, it will be vertically translated to closest gr...
Definition: Scene.cpp:222
std::vector< std::shared_ptr< ScenePart > > parts
Parts composing the scene with no repeats.
Definition: Scene.h:141
glm::dvec3 getGroundPointAt(glm::dvec3 point)
Obtain the ground point at specified XY coordinates.
Definition: Scene.cpp:144
void buildKDGrove(bool const safe=false)
Build the KDGrove for the scene, overwriting previous one if any.
Definition: Scene.cpp:359
std::map< double, Primitive * > getIntersections(glm::dvec3 &rayOrigin, glm::dvec3 &rayDir, bool const groundOnly)
Obtain all intersections between the ray and the scene, if any.
Definition: Scene.cpp:193
void save(Archive &ar, unsigned int const version) const
Handle scene save operation.
Definition: Scene.h:42
glm::dvec3 const & getShiftRef() const
Like Scene::getShift but returning a const reference instead of a copy.
Definition: Scene.h:252
std::shared_ptr< AABB > bbox_crs
Original axis aligned bounding box defining scene boundaries before centering it.
Definition: Scene.h:119
glm::dvec3 findForceOnGroundQ(int const searchDepth, glm::dvec3 const minzv, vector< Vertex * > &vertices, vector< double > const &o, vector< double > const &v)
Assist doForceOnGround function to find an adequate for step 4.
Definition: Scene.cpp:328
std::vector< Primitive * > primitives
Vector of primitives composing the scene.
Definition: Scene.h:132
virtual void writeObject(std::string path)
Serialize the scene and write it to given output file.
Definition: Scene.cpp:385
std::shared_ptr< KDGrove > kdgrove
KDGrove containing a KDTree for each scene part to speed-up ray-primitive intersection check computat...
Definition: Scene.h:110
void registerParts()
Register all scene parts composing the scene in the parts vector with no repetitions.
Definition: Scene.cpp:129
virtual std::shared_ptr< KDGroveFactory > getKDGroveFactory() const
Obtain the KDGrove factory used by the scene.
Definition: Scene.h:392
virtual void setKDGrove(std::shared_ptr< KDGrove > const kdgrove)
Set the KDGrove to be used by the scene.
Definition: Scene.h:415
std::shared_ptr< AABB > getAABB()
Obtain the axis aligned bounding box defining scene boundaries.
Definition: Scene.cpp:142
std::shared_ptr< KDGroveRaycaster > raycaster
The raycaster based on KDGrove.
Definition: Scene.h:126
void load(Archive &ar, unsigned int const fileVersion)
Handle scene load operation.
Definition: Scene.h:71
virtual void setBBox(std::shared_ptr< AABB > const bbox)
Set the scene's bounding box.
Definition: Scene.h:429
Scene()
Scene default constructor.
Definition: Scene.h:148
void buildKDGroveWithLog(bool const safe=false)
Call buildKDGrove exporting building information through logging system.
Definition: Scene.cpp:372
bool finalizeLoading(bool const safe=false)
Handle scene loading finish process.
Definition: Scene.cpp:69
virtual bool doSimStep()
Support simulation step handling from scene side.
Definition: Scene.h:484
std::vector< Vertex * > getAllVertices()
Obtain all vertices (without repetitions) composing the scene.
Definition: Scene.cpp:212
virtual void setBBoxCRS(std::shared_ptr< AABB > const bbox)
Set the scene's coordinate reference system bounding box.
Definition: Scene.h:442
virtual bool hasMovingObjects() const
Checke whether the scene contains at least one moving object (true) or not (false)
Definition: Scene.h:450
virtual std::shared_ptr< AABB > getBBoxCRS() const
Obtain the scene's coordinate reference system bounding box.
Definition: Scene.h:436
Class providing building methods for simple k-dimensional trees.
Definition: SimpleKDTreeFactory.h:18