~baltix/+junk/irrlicht-test

« back to all changes in this revision

Viewing changes to include/ICameraSceneNode.h

  • Committer: Mantas Kriaučiūnas
  • Date: 2011-07-18 13:06:25 UTC
  • Revision ID: mantas@akl.lt-20110718130625-c5pvifp61e7kj1ol
Included whole irrlicht SVN libraries to work around launchpad recipe issue with quilt, see https://answers.launchpad.net/launchpad/+question/165193

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (C) 2002-2011 Nikolaus Gebhardt
 
2
// This file is part of the "Irrlicht Engine".
 
3
// For conditions of distribution and use, see copyright notice in irrlicht.h
 
4
 
 
5
#ifndef __I_CAMERA_SCENE_NODE_H_INCLUDED__
 
6
#define __I_CAMERA_SCENE_NODE_H_INCLUDED__
 
7
 
 
8
#include "ISceneNode.h"
 
9
#include "IEventReceiver.h"
 
10
 
 
11
namespace irr
 
12
{
 
13
namespace scene
 
14
{
 
15
        struct SViewFrustum;
 
16
 
 
17
        //! Scene Node which is a (controlable) camera.
 
18
        /** The whole scene will be rendered from the cameras point of view.
 
19
        Because the ICameraScenNode is a SceneNode, it can be attached to any
 
20
        other scene node, and will follow its parents movement, rotation and so
 
21
        on.
 
22
        */
 
23
        class ICameraSceneNode : public ISceneNode, public IEventReceiver
 
24
        {
 
25
        public:
 
26
 
 
27
                //! Constructor
 
28
                ICameraSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id,
 
29
                        const core::vector3df& position = core::vector3df(0,0,0),
 
30
                        const core::vector3df& rotation = core::vector3df(0,0,0),
 
31
                        const core::vector3df& scale = core::vector3df(1.0f,1.0f,1.0f))
 
32
                        : ISceneNode(parent, mgr, id, position, rotation, scale), IsOrthogonal(false) {}
 
33
 
 
34
                //! Sets the projection matrix of the camera.
 
35
                /** The core::matrix4 class has some methods to build a
 
36
                projection matrix. e.g:
 
37
                core::matrix4::buildProjectionMatrixPerspectiveFovLH.
 
38
                Note that the matrix will only stay as set by this method until
 
39
                one of the following Methods are called: setNearValue,
 
40
                setFarValue, setAspectRatio, setFOV.
 
41
                \param projection The new projection matrix of the camera.
 
42
                \param isOrthogonal Set this to true if the matrix is an
 
43
                orthogonal one (e.g. from matrix4::buildProjectionMatrixOrtho).
 
44
                */
 
45
                virtual void setProjectionMatrix(const core::matrix4& projection, bool isOrthogonal=false) =0;
 
46
 
 
47
                //! Gets the current projection matrix of the camera.
 
48
                /** \return The current projection matrix of the camera. */
 
49
                virtual const core::matrix4& getProjectionMatrix() const =0;
 
50
 
 
51
                //! Gets the current view matrix of the camera.
 
52
                /** \return The current view matrix of the camera. */
 
53
                virtual const core::matrix4& getViewMatrix() const =0;
 
54
 
 
55
                //! Sets a custom view matrix affector.
 
56
                /** The matrix passed here, will be multiplied with the view
 
57
                matrix when it gets updated. This allows for custom camera
 
58
                setups like, for example, a reflection camera.
 
59
                \param affector The affector matrix. */
 
60
                virtual void setViewMatrixAffector(const core::matrix4& affector) =0;
 
61
 
 
62
                //! Get the custom view matrix affector.
 
63
                /** \return The affector matrix. */
 
64
                virtual const core::matrix4& getViewMatrixAffector() const =0;
 
65
 
 
66
                //! It is possible to send mouse and key events to the camera.
 
67
                /** Most cameras may ignore this input, but camera scene nodes
 
68
                which are created for example with
 
69
                ISceneManager::addCameraSceneNodeMaya or
 
70
                ISceneManager::addCameraSceneNodeFPS, may want to get
 
71
                this input for changing their position, look at target or
 
72
                whatever. */
 
73
                virtual bool OnEvent(const SEvent& event) =0;
 
74
 
 
75
                //! Sets the look at target of the camera
 
76
                /** If the camera's target and rotation are bound ( @see
 
77
                bindTargetAndRotation() ) then calling this will also change
 
78
                the camera's scene node rotation to match the target.
 
79
                \param pos Look at target of the camera, in world co-ordinates. */
 
80
                virtual void setTarget(const core::vector3df& pos) =0;
 
81
 
 
82
                //! Sets the rotation of the node.
 
83
                /** This only modifies the relative rotation of the node.
 
84
                If the camera's target and rotation are bound ( @see
 
85
                bindTargetAndRotation() ) then calling this will also change
 
86
                the camera's target to match the rotation.
 
87
                \param rotation New rotation of the node in degrees. */
 
88
                virtual void setRotation(const core::vector3df& rotation) =0;
 
89
 
 
90
                //! Gets the current look at target of the camera
 
91
                /** \return The current look at target of the camera, in world co-ordinates */
 
92
                virtual const core::vector3df& getTarget() const =0;
 
93
 
 
94
                //! Sets the up vector of the camera.
 
95
                /** \param pos: New upvector of the camera. */
 
96
                virtual void setUpVector(const core::vector3df& pos) =0;
 
97
 
 
98
                //! Gets the up vector of the camera.
 
99
                /** \return The up vector of the camera, in world space. */
 
100
                virtual const core::vector3df& getUpVector() const =0;
 
101
 
 
102
                //! Gets the value of the near plane of the camera.
 
103
                /** \return The value of the near plane of the camera. */
 
104
                virtual f32 getNearValue() const =0;
 
105
 
 
106
                //! Gets the value of the far plane of the camera.
 
107
                /** \return The value of the far plane of the camera. */
 
108
                virtual f32 getFarValue() const =0;
 
109
 
 
110
                //! Gets the aspect ratio of the camera.
 
111
                /** \return The aspect ratio of the camera. */
 
112
                virtual f32 getAspectRatio() const =0;
 
113
 
 
114
                //! Gets the field of view of the camera.
 
115
                /** \return The field of view of the camera in radians. */
 
116
                virtual f32 getFOV() const =0;
 
117
 
 
118
                //! Sets the value of the near clipping plane. (default: 1.0f)
 
119
                /** \param zn: New z near value. */
 
120
                virtual void setNearValue(f32 zn) =0;
 
121
 
 
122
                //! Sets the value of the far clipping plane (default: 2000.0f)
 
123
                /** \param zf: New z far value. */
 
124
                virtual void setFarValue(f32 zf) =0;
 
125
 
 
126
                //! Sets the aspect ratio (default: 4.0f / 3.0f)
 
127
                /** \param aspect: New aspect ratio. */
 
128
                virtual void setAspectRatio(f32 aspect) =0;
 
129
 
 
130
                //! Sets the field of view (Default: PI / 2.5f)
 
131
                /** \param fovy: New field of view in radians. */
 
132
                virtual void setFOV(f32 fovy) =0;
 
133
 
 
134
                //! Get the view frustum.
 
135
                /** Needed sometimes by bspTree or LOD render nodes.
 
136
                \return The current view frustum. */
 
137
                virtual const SViewFrustum* getViewFrustum() const =0;
 
138
 
 
139
                //! Disables or enables the camera to get key or mouse inputs.
 
140
                /** If this is set to true, the camera will respond to key
 
141
                inputs otherwise not. */
 
142
                virtual void setInputReceiverEnabled(bool enabled) =0;
 
143
 
 
144
                //! Checks if the input receiver of the camera is currently enabled.
 
145
                virtual bool isInputReceiverEnabled() const =0;
 
146
 
 
147
                //! Checks if a camera is orthogonal.
 
148
                virtual bool isOrthogonal() const
 
149
                {
 
150
                        _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
 
151
                        return IsOrthogonal;
 
152
                }
 
153
 
 
154
                //! Binds the camera scene node's rotation to its target position and vice vera, or unbinds them.
 
155
                /** When bound, calling setRotation() will update the camera's
 
156
                target position to be along its +Z axis, and likewise calling
 
157
                setTarget() will update its rotation so that its +Z axis will
 
158
                point at the target point. FPS camera use this binding by
 
159
                default; other cameras do not.
 
160
                \param bound True to bind the camera's scene node rotation
 
161
                and targetting, false to unbind them.
 
162
                @see getTargetAndRotationBinding() */
 
163
                virtual void bindTargetAndRotation(bool bound) =0;
 
164
 
 
165
                //! Queries if the camera scene node's rotation and its target position are bound together.
 
166
                /** @see bindTargetAndRotation() */
 
167
                virtual bool getTargetAndRotationBinding(void) const =0;
 
168
 
 
169
                //! Writes attributes of the camera node
 
170
                virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const
 
171
                {
 
172
                        ISceneNode::serializeAttributes(out, options);
 
173
 
 
174
                        if (!out)
 
175
                                return;
 
176
                        out->addBool    ("IsOrthogonal", IsOrthogonal );
 
177
                }
 
178
 
 
179
                //! Reads attributes of the camera node
 
180
                virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0)
 
181
                {
 
182
                        ISceneNode::deserializeAttributes(in, options);
 
183
                        if (!in)
 
184
                                return;
 
185
 
 
186
                        if ( in->findAttribute("IsOrthogonal") )
 
187
                                IsOrthogonal = in->getAttributeAsBool("IsOrthogonal");
 
188
                }
 
189
 
 
190
        protected:
 
191
 
 
192
                void cloneMembers(ICameraSceneNode* toCopyFrom)
 
193
                {
 
194
                        IsOrthogonal = toCopyFrom->IsOrthogonal;
 
195
                }
 
196
 
 
197
                bool IsOrthogonal;
 
198
        };
 
199
 
 
200
} // end namespace scene
 
201
} // end namespace irr
 
202
 
 
203
#endif
 
204