~baltix/+junk/irrlicht-test

« back to all changes in this revision

Viewing changes to include/IAnimatedMeshSceneNode.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_ANIMATED_MESH_SCENE_NODE_H_INCLUDED__
 
6
#define __I_ANIMATED_MESH_SCENE_NODE_H_INCLUDED__
 
7
 
 
8
#include "ISceneNode.h"
 
9
#include "IBoneSceneNode.h"
 
10
#include "IAnimatedMeshMD2.h"
 
11
#include "IAnimatedMeshMD3.h"
 
12
 
 
13
namespace irr
 
14
{
 
15
namespace scene
 
16
{
 
17
        class IShadowVolumeSceneNode;
 
18
 
 
19
        enum E_JOINT_UPDATE_ON_RENDER
 
20
        {
 
21
                //! do nothing
 
22
                EJUOR_NONE = 0,
 
23
 
 
24
                //! get joints positions from the mesh (for attached nodes, etc)
 
25
                EJUOR_READ,
 
26
 
 
27
                //! control joint positions in the mesh (eg. ragdolls, or set the animation from animateJoints() )
 
28
                EJUOR_CONTROL
 
29
        };
 
30
 
 
31
 
 
32
        class IAnimatedMeshSceneNode;
 
33
 
 
34
        //! Callback interface for catching events of ended animations.
 
35
        /** Implement this interface and use
 
36
        IAnimatedMeshSceneNode::setAnimationEndCallback to be able to
 
37
        be notified if an animation playback has ended.
 
38
        **/
 
39
        class IAnimationEndCallBack : public virtual IReferenceCounted
 
40
        {
 
41
        public:
 
42
 
 
43
                //! Will be called when the animation playback has ended.
 
44
                /** See IAnimatedMeshSceneNode::setAnimationEndCallback for
 
45
                more informations.
 
46
                \param node: Node of which the animation has ended. */
 
47
                virtual void OnAnimationEnd(IAnimatedMeshSceneNode* node) = 0;
 
48
        };
 
49
 
 
50
        //! Scene node capable of displaying an animated mesh and its shadow.
 
51
        /** The shadow is optional: If a shadow should be displayed too, just
 
52
        invoke the IAnimatedMeshSceneNode::createShadowVolumeSceneNode().*/
 
53
        class IAnimatedMeshSceneNode : public ISceneNode
 
54
        {
 
55
        public:
 
56
 
 
57
                //! Constructor
 
58
                IAnimatedMeshSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id,
 
59
                        const core::vector3df& position = core::vector3df(0,0,0),
 
60
                        const core::vector3df& rotation = core::vector3df(0,0,0),
 
61
                        const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f))
 
62
                        : ISceneNode(parent, mgr, id, position, rotation, scale) {}
 
63
 
 
64
                //! Destructor
 
65
                virtual ~IAnimatedMeshSceneNode() {}
 
66
 
 
67
                //! Sets the current frame number.
 
68
                /** From now on the animation is played from this frame.
 
69
                \param frame: Number of the frame to let the animation be started from.
 
70
                The frame number must be a valid frame number of the IMesh used by this
 
71
                scene node. Set IAnimatedMesh::getMesh() for details. */
 
72
                virtual void setCurrentFrame(f32 frame) = 0;
 
73
 
 
74
                //! Sets the frame numbers between the animation is looped.
 
75
                /** The default is 0 - MaximalFrameCount of the mesh.
 
76
                \param begin: Start frame number of the loop.
 
77
                \param end: End frame number of the loop.
 
78
                \return True if successful, false if not. */
 
79
                virtual bool setFrameLoop(s32 begin, s32 end) = 0;
 
80
 
 
81
                //! Sets the speed with which the animation is played.
 
82
                /** \param framesPerSecond: Frames per second played. */
 
83
                virtual void setAnimationSpeed(f32 framesPerSecond) = 0;
 
84
 
 
85
                //! Gets the speed with which the animation is played.
 
86
                /** \return Frames per second played. */
 
87
                virtual f32 getAnimationSpeed() const =0;
 
88
 
 
89
                //! Creates shadow volume scene node as child of this node.
 
90
                /** The shadow can be rendered using the ZPass or the zfail
 
91
                method. ZPass is a little bit faster because the shadow volume
 
92
                creation is easier, but with this method there occur ugly
 
93
                looking artifacs when the camera is inside the shadow volume.
 
94
                These error do not occur with the ZFail method.
 
95
                \param shadowMesh: Optional custom mesh for shadow volume.
 
96
                \param id: Id of the shadow scene node. This id can be used to
 
97
                identify the node later.
 
98
                \param zfailmethod: If set to true, the shadow will use the
 
99
                zfail method, if not, zpass is used.
 
100
                \param infinity: Value used by the shadow volume algorithm to
 
101
                scale the shadow volume.
 
102
                \return Pointer to the created shadow scene node. This pointer
 
103
                should not be dropped. See IReferenceCounted::drop() for more
 
104
                information. */
 
105
                virtual IShadowVolumeSceneNode* addShadowVolumeSceneNode(const IMesh* shadowMesh=0,
 
106
                        s32 id=-1, bool zfailmethod=true, f32 infinity=10000.0f) = 0;
 
107
 
 
108
 
 
109
                //! Get a pointer to a joint in the mesh (if the mesh is a bone based mesh).
 
110
                /** With this method it is possible to attach scene nodes to
 
111
                joints for example possible to attach a weapon to the left hand
 
112
                of an animated model. This example shows how:
 
113
                \code
 
114
                ISceneNode* hand =
 
115
                        yourAnimatedMeshSceneNode->getJointNode("LeftHand");
 
116
                hand->addChild(weaponSceneNode);
 
117
                \endcode
 
118
                Please note that the joint returned by this method may not exist
 
119
                before this call and the joints in the node were created by it.
 
120
                \param jointName: Name of the joint.
 
121
                \return Pointer to the scene node which represents the joint
 
122
                with the specified name. Returns 0 if the contained mesh is not
 
123
                an skinned mesh or the name of the joint could not be found. */
 
124
                virtual IBoneSceneNode* getJointNode(const c8* jointName)=0;
 
125
 
 
126
                //! same as getJointNode(const c8* jointName), but based on id
 
127
                virtual IBoneSceneNode* getJointNode(u32 jointID) = 0;
 
128
 
 
129
                //! Gets joint count.
 
130
                /** \return Amount of joints in the mesh. */
 
131
                virtual u32 getJointCount() const = 0;
 
132
 
 
133
                //! Starts a default MD2 animation.
 
134
                /** With this method it is easily possible to start a Run,
 
135
                Attack, Die or whatever animation, if the mesh contained in
 
136
                this scene node is an md2 mesh. Otherwise, nothing happens.
 
137
                \param anim: An MD2 animation type, which should be played, for
 
138
                example EMAT_STAND for the standing animation.
 
139
                \return True if successful, and false if not, for example if
 
140
                the mesh in the scene node is not a md2 mesh. */
 
141
                virtual bool setMD2Animation(EMD2_ANIMATION_TYPE anim) = 0;
 
142
 
 
143
                //! Starts a special MD2 animation.
 
144
                /** With this method it is easily possible to start a Run,
 
145
                Attack, Die or whatever animation, if the mesh contained in
 
146
                this scene node is an md2 mesh. Otherwise, nothing happens.
 
147
                This method uses a character string to identify the animation.
 
148
                If the animation is a standard md2 animation, you might want to
 
149
                start this animation with the EMD2_ANIMATION_TYPE enumeration
 
150
                instead.
 
151
                \param animationName: Name of the animation which should be
 
152
                played.
 
153
                \return Returns true if successful, and false if not, for
 
154
                example if the mesh in the scene node is not an md2 mesh, or no
 
155
                animation with this name could be found. */
 
156
                virtual bool setMD2Animation(const c8* animationName) = 0;
 
157
 
 
158
                //! Returns the currently displayed frame number.
 
159
                virtual f32 getFrameNr() const = 0;
 
160
                //! Returns the current start frame number.
 
161
                virtual s32 getStartFrame() const = 0;
 
162
                //! Returns the current end frame number.
 
163
                virtual s32 getEndFrame() const = 0;
 
164
 
 
165
                //! Sets looping mode which is on by default.
 
166
                /** If set to false, animations will not be played looped. */
 
167
                virtual void setLoopMode(bool playAnimationLooped) = 0;
 
168
 
 
169
                //! Sets a callback interface which will be called if an animation playback has ended.
 
170
                /** Set this to 0 to disable the callback again.
 
171
                Please note that this will only be called when in non looped
 
172
                mode, see IAnimatedMeshSceneNode::setLoopMode(). */
 
173
                virtual void setAnimationEndCallback(IAnimationEndCallBack* callback=0) = 0;
 
174
 
 
175
                //! Sets if the scene node should not copy the materials of the mesh but use them in a read only style.
 
176
                /** In this way it is possible to change the materials a mesh
 
177
                causing all mesh scene nodes referencing this mesh to change
 
178
                too. */
 
179
                virtual void setReadOnlyMaterials(bool readonly) = 0;
 
180
 
 
181
                //! Returns if the scene node should not copy the materials of the mesh but use them in a read only style
 
182
                virtual bool isReadOnlyMaterials() const = 0;
 
183
 
 
184
                //! Sets a new mesh
 
185
                virtual void setMesh(IAnimatedMesh* mesh) = 0;
 
186
 
 
187
                //! Returns the current mesh
 
188
                virtual IAnimatedMesh* getMesh(void) = 0;
 
189
 
 
190
                //! Get the absolute transformation for a special MD3 Tag if the mesh is a md3 mesh, or the absolutetransformation if it's a normal scenenode
 
191
                virtual const SMD3QuaternionTag* getMD3TagTransformation( const core::stringc & tagname) = 0;
 
192
 
 
193
                //! Set how the joints should be updated on render
 
194
                virtual void setJointMode(E_JOINT_UPDATE_ON_RENDER mode)=0;
 
195
 
 
196
                //! Sets the transition time in seconds
 
197
                /** Note: This needs to enable joints, and setJointmode set to
 
198
                EJUOR_CONTROL. You must call animateJoints(), or the mesh will
 
199
                not animate. */
 
200
                virtual void setTransitionTime(f32 Time) =0;
 
201
 
 
202
                //! animates the joints in the mesh based on the current frame.
 
203
                /** Also takes in to account transitions. */
 
204
                virtual void animateJoints(bool CalculateAbsolutePositions=true) = 0;
 
205
 
 
206
                //! render mesh ignoring its transformation.
 
207
                /** Culling is unaffected. */
 
208
                virtual void setRenderFromIdentity( bool On )=0;
 
209
 
 
210
                //! Creates a clone of this scene node and its children.
 
211
                /** \param newParent An optional new parent.
 
212
                \param newManager An optional new scene manager.
 
213
                \return The newly created clone of this node. */
 
214
                virtual ISceneNode* clone(ISceneNode* newParent=0, ISceneManager* newManager=0) = 0;
 
215
 
 
216
        };
 
217
 
 
218
} // end namespace scene
 
219
} // end namespace irr
 
220
 
 
221
#endif
 
222