]> git.lizzy.rs Git - irrlicht.git/blob - source/Irrlicht/CCameraSceneNode.h
Revert "Fix: Listbox was sometimes sending EGET_LISTBOX_SELECTED_AGAIN instead of...
[irrlicht.git] / source / Irrlicht / CCameraSceneNode.h
1 // Copyright (C) 2002-2012 Nikolaus Gebhardt\r
2 // This file is part of the "Irrlicht Engine".\r
3 // For conditions of distribution and use, see copyright notice in irrlicht.h\r
4 \r
5 #ifndef __C_CAMERA_SCENE_NODE_H_INCLUDED__\r
6 #define __C_CAMERA_SCENE_NODE_H_INCLUDED__\r
7 \r
8 #include "ICameraSceneNode.h"\r
9 #include "SViewFrustum.h"\r
10 \r
11 namespace irr\r
12 {\r
13 namespace scene\r
14 {\r
15 \r
16         class CCameraSceneNode : public ICameraSceneNode\r
17         {\r
18         public:\r
19 \r
20                 //! constructor\r
21                 CCameraSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id,\r
22                         const core::vector3df& position = core::vector3df(0,0,0),\r
23                         const core::vector3df& lookat = core::vector3df(0,0,100));\r
24 \r
25                 //! Sets the projection matrix of the camera.\r
26                 /** The core::matrix4 class has some methods\r
27                 to build a projection matrix. e.g: core::matrix4::buildProjectionMatrixPerspectiveFovLH.\r
28                 Note that the matrix will only stay as set by this method until one of\r
29                 the following Methods are called: setNearValue, setFarValue, setAspectRatio, setFOV.\r
30                 \param projection The new projection matrix of the camera.\r
31                 \param isOrthogonal Set this to true if the matrix is an orthogonal one (e.g.\r
32                 from matrix4::buildProjectionMatrixOrthoLH(). */\r
33                 void setProjectionMatrix(const core::matrix4& projection, bool isOrthogonal = false) override;\r
34 \r
35                 //! Gets the current projection matrix of the camera\r
36                 //! \return Returns the current projection matrix of the camera.\r
37                 const core::matrix4& getProjectionMatrix() const override;\r
38 \r
39                 //! Gets the current view matrix of the camera\r
40                 //! \return Returns the current view matrix of the camera.\r
41                 const core::matrix4& getViewMatrix() const override;\r
42 \r
43                 //! Sets a custom view matrix affector.\r
44                 /** \param affector: The affector matrix. */\r
45                 void setViewMatrixAffector(const core::matrix4& affector) override;\r
46 \r
47                 //! Gets the custom view matrix affector.\r
48                 const core::matrix4& getViewMatrixAffector() const override;\r
49 \r
50                 //! It is possible to send mouse and key events to the camera. Most cameras\r
51                 //! may ignore this input, but camera scene nodes which are created for\r
52                 //! example with scene::ISceneManager::addMayaCameraSceneNode or\r
53                 //! scene::ISceneManager::addMeshViewerCameraSceneNode, may want to get this input\r
54                 //! for changing their position, look at target or whatever.\r
55                 bool OnEvent(const SEvent& event) override;\r
56 \r
57                 //! Sets the look at target of the camera\r
58                 /** If the camera's target and rotation are bound ( @see bindTargetAndRotation() )\r
59                 then calling this will also change the camera's scene node rotation to match the target.\r
60                 \param pos: Look at target of the camera. */\r
61                 void setTarget(const core::vector3df& pos) override;\r
62 \r
63                 //! Sets the rotation of the node.\r
64                 /** This only modifies the relative rotation of the node.\r
65                 If the camera's target and rotation are bound ( @see bindTargetAndRotation() )\r
66                 then calling this will also change the camera's target to match the rotation.\r
67                 \param rotation New rotation of the node in degrees. */\r
68                 void setRotation(const core::vector3df& rotation) override;\r
69 \r
70                 //! Gets the current look at target of the camera\r
71                 /** \return The current look at target of the camera */\r
72                 const core::vector3df& getTarget() const override;\r
73 \r
74                 //! Sets the up vector of the camera.\r
75                 //! \param pos: New upvector of the camera.\r
76                 void setUpVector(const core::vector3df& pos) override;\r
77 \r
78                 //! Gets the up vector of the camera.\r
79                 //! \return Returns the up vector of the camera.\r
80                 const core::vector3df& getUpVector() const override;\r
81 \r
82                 //! Gets distance from the camera to the near plane.\r
83                 //! \return Value of the near plane of the camera.\r
84                 f32 getNearValue() const override;\r
85 \r
86                 //! Gets the distance from the camera to the far plane.\r
87                 //! \return Value of the far plane of the camera.\r
88                 f32 getFarValue() const override;\r
89 \r
90                 //! Get the aspect ratio of the camera.\r
91                 //! \return The aspect ratio of the camera.\r
92                 f32 getAspectRatio() const override;\r
93 \r
94                 //! Gets the field of view of the camera.\r
95                 //! \return Field of view of the camera\r
96                 f32 getFOV() const override;\r
97 \r
98                 //! Sets the value of the near clipping plane. (default: 1.0f)\r
99                 void setNearValue(f32 zn) override;\r
100 \r
101                 //! Sets the value of the far clipping plane (default: 2000.0f)\r
102                 void setFarValue(f32 zf) override;\r
103 \r
104                 //! Sets the aspect ratio (default: 4.0f / 3.0f)\r
105                 void setAspectRatio(f32 aspect) override;\r
106 \r
107                 //! Sets the field of view (Default: PI / 3.5f)\r
108                 void setFOV(f32 fovy) override;\r
109 \r
110                 //! PreRender event\r
111                 void OnRegisterSceneNode() override;\r
112 \r
113                 //! Render\r
114                 void render() override;\r
115 \r
116                 //! Update\r
117                 void updateMatrices() override;\r
118 \r
119                 //! Returns the axis aligned bounding box of this node\r
120                 const core::aabbox3d<f32>& getBoundingBox() const override;\r
121 \r
122                 //! Returns the view area.\r
123                 const SViewFrustum* getViewFrustum() const override;\r
124 \r
125                 //! Disables or enables the camera to get key or mouse inputs.\r
126                 //! If this is set to true, the camera will respond to key inputs\r
127                 //! otherwise not.\r
128                 void setInputReceiverEnabled(bool enabled) override;\r
129 \r
130                 //! Returns if the input receiver of the camera is currently enabled.\r
131                 bool isInputReceiverEnabled() const override;\r
132 \r
133                 //! Returns type of the scene node\r
134                 ESCENE_NODE_TYPE getType() const override { return ESNT_CAMERA; }\r
135 \r
136                 //! Binds the camera scene node's rotation to its target position and vice versa, or unbinds them.\r
137                 void bindTargetAndRotation(bool bound) override;\r
138 \r
139                 //! Queries if the camera scene node's rotation and its target position are bound together.\r
140                 bool getTargetAndRotationBinding(void) const override;\r
141 \r
142                 //! Creates a clone of this scene node and its children.\r
143                 ISceneNode* clone(ISceneNode* newParent=0, ISceneManager* newManager=0) override;\r
144 \r
145         protected:\r
146 \r
147                 void recalculateProjectionMatrix();\r
148                 void recalculateViewArea();\r
149 \r
150                 core::aabbox3d<f32> BoundingBox;\r
151 \r
152                 core::vector3df Target;\r
153                 core::vector3df UpVector;\r
154 \r
155                 f32 Fovy;       // Field of view, in radians.\r
156                 f32 Aspect;     // Aspect ratio.\r
157                 f32 ZNear;      // value of the near view-plane.\r
158                 f32 ZFar;       // Z-value of the far view-plane.\r
159 \r
160                 SViewFrustum ViewArea;\r
161                 core::matrix4 Affector;\r
162 \r
163                 bool InputReceiverEnabled;\r
164                 bool TargetAndRotationAreBound;\r
165 \r
166                 bool HasD3DStyleProjectionMatrix;       // true: projection from 0 to w; false: -w to w\r
167         };\r
168 \r
169 } // end namespace\r
170 } // end namespace\r
171 \r
172 #endif\r
173 \r