Polygon Crucher SDK - Documentation
Documentation
Loading...
Searching...
No Matches
3DCamera.h
Go to the documentation of this file.
1//! @file 3DCamera.h
2//! @brief C3DCamera class for handling camera object
3//////////////////////////////////////////////////////////////////////
4
5#if !defined(AFX_3DCAMERA_H__5C85DAE7_BE95_4F8B_B661_B0CF9BE55255__INCLUDED_)
6#define AFX_3DCAMERA_H__5C85DAE7_BE95_4F8B_B661_B0CF9BE55255__INCLUDED_
7
8#ifdef _MSC_VER
9#pragma once
10#endif // _MSC_VER
11
12#include "3DBaseObject.h"
13#include "3DObject.h"
14
15BEGIN_MOOTOOLS_NAMESPACE
16
17//! @enum OBJECT_KINDOF
18//! @brief Camera CustomData internal attributes
19//////////////////////////////////////////////////////////////////////
20typedef enum Camera3DID XEnumType(unsigned int)
21{
22 C3DCAMERA_PROJECTION = MAKE_CUSTOM_ID('c', 'a', 'p', 'j'), //!< int
23 C3DCAMERA_TARGET = MAKE_CUSTOM_ID('c', 'a', 't', 'g'), //!< longuint
24 C3DCAMERA_FOV = MAKE_CUSTOM_ID('c', 'a', 'f', 'o'), //!< double (angle in radian for perspective, distance for orthographic)
25 C3DCAMERA_ASPECT_RATIO = MAKE_CUSTOM_ID('c', 'a', 'a', 'r'), //!< double
26 C3DCAMERA_ZOOM = MAKE_CUSTOM_ID('c', 'a', 'z', 'm'), //!< double
27 C3DCAMERA_NEAR_CLIP = MAKE_CUSTOM_ID('c', 'a', 'n', 'c'), //!< double: distance in cm
28 C3DCAMERA_FAR_CLIP = MAKE_CUSTOM_ID('c', 'a', 'f', 'c'), //!< double
29 C3DCAMERA_FOCUS_DISTANCE = MAKE_CUSTOM_ID('c', 'a', 'f', 'd'), //!< double
30 C3DCAMERA_APERTURE = MAKE_CUSTOM_ID('c', 'a', 'a', 'p'), //!< double (f/<ap>)
32
33// defaults
34#define C3DCAMERA_DEFAULT_PROJECTION (CAMERA_PROJECTION_PERSPECTIVE)
35
36#define C3DCAMERA_DEFAULT_FOV (DEG2RAD(45.f))
37#define C3DCAMERA_DEFAULT_ASPECT_RATIO (1.f)
38#define C3DCAMERA_DEFAULT_ZOOM (1.f)
39
40#define C3DCAMERA_DEFAULT_NEAR_CLIP (-1.0f)
41#define C3DCAMERA_DEFAULT_FAR_CLIP (-1.0f)
42
43#define C3DCAMERA_DEFAULT_FOCUS_DISTANCE (0.f)
44#define C3DCAMERA_DEFAULT_APERTURE (8.f)
45
46// Enums
47typedef enum _CAMERA_PROJECTION_TYPE XEnumType(unsigned int)
48{
49 CAMERA_PROJECTION_PERSPECTIVE = 0,
50 CAMERA_PROJECTION_ORTHOGRAPHIC,
51
52 CAMERA_NB_PROJECTION_TYPES, //Keep it last
54
55//! @class C3DCamera
56//! @brief C3DCamera handles camera object.
57//! @details GetFinalObject returns a camera model in order to display the camera itself.
58//! Camera node contains the transformation matrix of the camera, that can be use to display this object.\n
59//! Camera node matrix is the invert of the LookAt matrix (which can be used to position the scene in the front of camera).
60class DLL_3DFUNCTION C3DCamera : public C3DBaseObject
61{
62 DECLARE_SERIAL_XOBJECT(C3DCamera);
63
64public:
66 virtual ~C3DCamera();
67
68 static bool LookAt(C4x4Matrix& matrix, const C3DPoint& eye, const C3DPoint& target, const C3DVector& up); //!< Compute the lookAt matrix from the given vector. Equivalent to glLookAt. Invert this matrix if you intend to use it as the node matrix
69 static bool PositionMatrix(C4x4Matrix& matrix, const C3DPoint& eye, const C3DPoint& target, const C3DVector& up); //!< Camera node position (invert of LookAt)
70
71 // Getters & setters
72 C3DCAMERA_PROJECTION_TYPE GetProjection() const;
73 void SetProjection(C3DCAMERA_PROJECTION_TYPE v);
74
75 SceneNodeID GetTarget() const;
76 void SetTarget(SceneNodeID v);
77 bool HasTarget() const;
78
79 double GetVFov() const;
80 void SetVFov(double radianAngle);
81 double GetAspectRatio() const;
82 void SetAspectRatio(double v);
83
84 double GetNearClip() const;
85 void SetNearClip(double v);
86 double GetFarClip() const;
87 void SetFarClip(double v);
88 void SetNearFarClip(double vn, double vf);
89
90 double GetFocusDistance() const;
91 void SetFocusDistance(double v);
92 double GetAperture() const;
93 void SetAperture(double v);
94
95 // Ortho methods
96 double GetVOrthoZoom() const;
97 void SetVOrthoZoom(double v);
98
99 bool IsDefined(unsigned int param) const;
100
101 virtual void SetScene(C3DScene *scene); //!< Attach scene and update guid for camera and its displayable
102 virtual bool IsFinalObject() const { return false; }
103 virtual C3DBaseObject *GetFinalObject(bool detach = false, bool computeIfNeeded = true)
104 {
105 if(!displayable && computeIfNeeded)
106 GenerateDisplayable();
107
108 return displayable;
109 }
110
111 virtual unsigned int GetChecksum(unsigned int checksumFlags = CHECKSUM_ALL) const; //!< Return a value that is a simple way to check if the geometry changed between two call to the method
112
113private:
114 C3DObject* displayable;
115 void GenerateDisplayable();
116
117};
118
119END_MOOTOOLS_NAMESPACE
120
121#endif // !defined(AFX_3DCAMERA_H__5C85DAE7_BE95_4F8B_B661_B0CF9BE55255__INCLUDED_)
C3DBaseObject class which is the common base class for all object types.
OBJECT_KINDOF
Definition 3DBaseObject.h:28
@ OBJECT_CAMERA
C3DCamera.
Definition 3DBaseObject.h:38
Camera3DID
Definition 3DCamera.h:21
@ C3DCAMERA_TARGET
longuint
Definition 3DCamera.h:23
@ C3DCAMERA_ZOOM
double
Definition 3DCamera.h:26
@ C3DCAMERA_FAR_CLIP
double
Definition 3DCamera.h:28
@ C3DCAMERA_APERTURE
double (f/<ap>)
Definition 3DCamera.h:30
@ C3DCAMERA_NEAR_CLIP
double: distance in cm
Definition 3DCamera.h:27
@ C3DCAMERA_PROJECTION
int
Definition 3DCamera.h:22
@ C3DCAMERA_FOCUS_DISTANCE
double
Definition 3DCamera.h:29
@ C3DCAMERA_ASPECT_RATIO
double
Definition 3DCamera.h:25
@ C3DCAMERA_FOV
double (angle in radian for perspective, distance for orthographic)
Definition 3DCamera.h:24
The file contains C3DObject class definition which handles N-Gons polygonal object.
@ CHECKSUM_ALL
All is used for computing checksum.
Definition 3DType.h:433
This is the base class for any kind of object.
Definition 3DBaseObject.h:106
C3DCamera handles camera object.
Definition 3DCamera.h:61
static bool LookAt(C4x4Matrix &matrix, const C3DPoint &eye, const C3DPoint &target, const C3DVector &up)
Compute the lookAt matrix from the given vector. Equivalent to glLookAt. Invert this matrix if you in...
virtual unsigned int GetChecksum(unsigned int checksumFlags=CHECKSUM_ALL) const
Return a value that is a simple way to check if the geometry changed between two call to the method.
virtual void SetScene(C3DScene *scene)
Attach scene and update guid for camera and its displayable.
virtual C3DBaseObject * GetFinalObject(bool detach=false, bool computeIfNeeded=true)
Returns the object itself or any kind of object. For example for a patch it can returns a C3DObject o...
Definition 3DCamera.h:103
static bool PositionMatrix(C4x4Matrix &matrix, const C3DPoint &eye, const C3DPoint &target, const C3DVector &up)
Camera node position (invert of LookAt)
C3DObject handles polygonal mesh.
Definition 3DObject.h:24
The class allows to get access to the scene graph, node hierarchy, material.
Definition 3DScene.h:306
The class defines an x, y, z 3D point which can use int, float or double.
Definition 3DPoint.h:27