3D Repo Bouncer  1.4
repo_node_camera.h
1 
21 #pragma once
22 #include "repo_node.h"
23 
24 namespace repo {
25  namespace core {
26  namespace model {
27  //------------------------------------------------------------------------------
28  //
29  // Fields specific to camera only
30  //
31  //------------------------------------------------------------------------------
32 #define REPO_NODE_LABEL_ASPECT_RATIO "aspect_ratio"
33 #define REPO_NODE_LABEL_FAR "far"
34 #define REPO_NODE_LABEL_NEAR "near"
35 #define REPO_NODE_LABEL_FOV "fov"
36 #define REPO_NODE_LABEL_LOOK_AT "look_at"
37 #define REPO_NODE_LABEL_POSITION "position"
38 #define REPO_NODE_LABEL_UP "up"
39  //------------------------------------------------------------------------------
40 
41  class REPO_API_EXPORT CameraNode :public RepoNode
42  {
43  public:
44 
48  CameraNode();
49 
54  CameraNode(RepoBSON bson);
55 
59  ~CameraNode();
60 
70  virtual bool positionDependant() { return true; }
71 
72  /*
73  * ------------- Delusional modifiers --------------
74  * These are like "setters" but not. We are actually
75  * creating a new bson object with the changed field
76  */
77 
85  virtual RepoNode cloneAndApplyTransformation(
86  const std::vector<float> &matrix) const;
87 
96  float getAspectRatio() const
97  {
98  return hasField(REPO_NODE_LABEL_ASPECT_RATIO) ?
99  (float)getField(REPO_NODE_LABEL_ASPECT_RATIO).numberDouble() :
100  1.;
101  }
102 
107  float getHorizontalFOV() const
108  {
109  return hasField(REPO_NODE_LABEL_FOV) ?
110  (float)getField(REPO_NODE_LABEL_FOV).numberDouble() :
111  1.;
112  }
113 
119  std::vector<float> getCameraMatrix(const bool &rowMajor = true) const;
120 
125  float getFarClippingPlane() const
126  {
127  return hasField(REPO_NODE_LABEL_FAR) ?
128  (float)getField(REPO_NODE_LABEL_FAR).numberDouble() :
129  1.;
130  }
131 
136  float getFieldOfView() const
137  {
138  return hasField(REPO_NODE_LABEL_FOV) ?
139  (float)getField(REPO_NODE_LABEL_FOV).numberDouble() :
140  1.;
141  }
142 
147  float getNearClippingPlane() const
148  {
149  return hasField(REPO_NODE_LABEL_NEAR) ?
150  (float)getField(REPO_NODE_LABEL_NEAR).numberDouble() :
151  1.;
152  }
153 
158  repo_vector_t getLookAt() const;
159 
164  std::vector<float> getOrientation() const;
165 
170  repo_vector_t getPosition() const;
171 
176  repo_vector_t getUp() const;
177 
185  virtual bool sEqual(const RepoNode &other) const;
186  };
187  } //namespace model
188  } //namespace core
189 } //namespace repo
float getFieldOfView() const
Definition: repo_node_camera.h:136
Definition: repo_connection_pool_mongo.h:32
Definition: repo_node_camera.h:41
float getHorizontalFOV() const
Definition: repo_node_camera.h:107
Definition: repo_node_utils.h:67
float getAspectRatio() const
Definition: repo_node_camera.h:96
Definition: repo_node.h:33
Definition: repo_bson.h:53
float getFarClippingPlane() const
Definition: repo_node_camera.h:125
float getNearClippingPlane() const
Definition: repo_node_camera.h:147
virtual bool positionDependant()
Definition: repo_node_camera.h:70