The small3d framework
SceneObject.hpp
Go to the documentation of this file.
1 
10 #pragma once
11 
12 #include <vector>
13 #include <sstream>
14 #include <iomanip>
15 #include <stdexcept>
16 #include <memory>
17 
18 #include "Model.hpp"
19 #include "Logger.hpp"
20 #include "Image.hpp"
21 #include "BoundingBoxSet.hpp"
22 #include <glm/glm.hpp>
23 
24 namespace small3d
25 {
36  {
37  private:
38 
39  bool animating;
40  int frameDelay;
41  int currentFrame;
42  int framesWaited;
43  int numFrames;
44  std::string name;
45 
46  public:
51  std::vector<Model> models;
52 
85  SceneObject(const std::string name, const std::string modelPath,
86  const int numFrames = 1,
87  const std::string boundingBoxSetPath = "", const int startFrameIndex = 1);
88 
92  ~SceneObject() = default;
93 
98  Model& getModel() ;
99 
105  bool isAnimated() const;
106 
111  const std::string getName() const;
112 
116  glm::vec3 offset;
117 
121  glm::vec3 rotation;
122 
126  void startAnimating();
127 
131  void stopAnimating();
132 
136  void resetAnimation();
137 
143  void setFrameDelay(const int delay);
144 
148  void animate();
149 
155 
162  bool collidesWith(const glm::vec3 point) const;
163 
171  bool collidesWith(SceneObject otherObject) const;
172 
173  };
174 
175 }
A 3D model, loaded from a Wavefront file.
Definition: Model.hpp:25
std::vector< Model > models
The models making up the object's animation. Do not manipulate directly.
Definition: SceneObject.hpp:51
void resetAnimation()
Reset the animation sequence (go to the first frame)
Definition: SceneObject.cpp:62
Header of the Image class.
void animate()
Process animation (progress current frame if necessary)
Definition: SceneObject.cpp:70
SceneObject(const std::string name, const std::string modelPath, const int numFrames=1, const std::string boundingBoxSetPath="", const int startFrameIndex=1)
Constructor.
Definition: SceneObject.cpp:13
BoundingBoxSet boundingBoxSet
The bounding boxes for the object, used for collision detection.
Definition: SceneObject.hpp:154
void stopAnimating()
Stop animating the object.
Definition: SceneObject.cpp:58
~SceneObject()=default
Destructor.
Model & getModel()
Get the object's model.
Definition: SceneObject.cpp:46
glm::vec3 offset
Definition: SceneObject.hpp:116
void startAnimating()
Start animating the object.
Definition: SceneObject.cpp:54
bool isAnimated() const
Is this an animated or a static object (is it associated with more than one frames/models)?
Definition: SceneObject.cpp:115
void setFrameDelay(const int delay)
Set the animation speed.
Definition: SceneObject.cpp:66
An object that appears on the 3D scene. It is made up of one or more models (the latter for animation...
Definition: SceneObject.hpp:35
Header of the BoundingBoxSet class.
Header of the Model class.
Header of the Logger class.
glm::vec3 rotation
Definition: SceneObject.hpp:121
const std::string getName() const
Get the name of the object.
Definition: SceneObject.cpp:50
Set of bounding boxes for a SceneObject, loaded from a Wavefront file, allowing for collision detecti...
Definition: BoundingBoxSet.hpp:26
bool collidesWith(const glm::vec3 point) const
Check if the object collides with a given point.
Definition: SceneObject.cpp:83