~baltix/+junk/irrlicht-test

« back to all changes in this revision

Viewing changes to source/Irrlicht/CBoneSceneNode.cpp

  • 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
#include "IrrCompileConfig.h"
 
6
#ifdef _IRR_COMPILE_WITH_SKINNED_MESH_SUPPORT_
 
7
 
 
8
#include "CBoneSceneNode.h"
 
9
 
 
10
namespace irr
 
11
{
 
12
namespace scene
 
13
{
 
14
 
 
15
//! constructor
 
16
CBoneSceneNode::CBoneSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id,
 
17
        u32 boneIndex, const c8* boneName)
 
18
: IBoneSceneNode(parent, mgr, id), BoneIndex(boneIndex),
 
19
        AnimationMode(EBAM_AUTOMATIC), SkinningSpace(EBSS_LOCAL)
 
20
{
 
21
        #ifdef _DEBUG
 
22
        setDebugName("CBoneSceneNode");
 
23
        #endif
 
24
        setName(boneName);
 
25
}
 
26
 
 
27
 
 
28
//! Returns the index of the bone
 
29
u32 CBoneSceneNode::getBoneIndex() const
 
30
{
 
31
        return BoneIndex;
 
32
}
 
33
 
 
34
 
 
35
//! Sets the animation mode of the bone. Returns true if successful.
 
36
bool CBoneSceneNode::setAnimationMode(E_BONE_ANIMATION_MODE mode)
 
37
{
 
38
        AnimationMode = mode;
 
39
        return true;
 
40
}
 
41
 
 
42
 
 
43
//! Gets the current animation mode of the bone
 
44
E_BONE_ANIMATION_MODE CBoneSceneNode::getAnimationMode() const
 
45
{
 
46
        return AnimationMode;
 
47
}
 
48
 
 
49
 
 
50
//! returns the axis aligned bounding box of this node
 
51
const core::aabbox3d<f32>& CBoneSceneNode::getBoundingBox() const
 
52
{
 
53
        return Box;
 
54
}
 
55
 
 
56
 
 
57
/*
 
58
//! Returns the relative transformation of the scene node.
 
59
core::matrix4 CBoneSceneNode::getRelativeTransformation() const
 
60
{
 
61
        return core::matrix4(); // RelativeTransformation;
 
62
}
 
63
*/
 
64
 
 
65
 
 
66
void CBoneSceneNode::OnAnimate(u32 timeMs)
 
67
{
 
68
        if (IsVisible)
 
69
        {
 
70
                // animate this node with all animators
 
71
 
 
72
                ISceneNodeAnimatorList::Iterator ait = Animators.begin();
 
73
                for (; ait != Animators.end(); ++ait)
 
74
                        (*ait)->animateNode(this, timeMs);
 
75
 
 
76
                // update absolute position
 
77
                //updateAbsolutePosition();
 
78
 
 
79
                // perform the post render process on all children
 
80
                ISceneNodeList::Iterator it = Children.begin();
 
81
                for (; it != Children.end(); ++it)
 
82
                        (*it)->OnAnimate(timeMs);
 
83
        }
 
84
}
 
85
 
 
86
 
 
87
void CBoneSceneNode::helper_updateAbsolutePositionOfAllChildren(ISceneNode *Node)
 
88
{
 
89
        Node->updateAbsolutePosition();
 
90
 
 
91
        ISceneNodeList::ConstIterator it = Node->getChildren().begin();
 
92
        for (; it != Node->getChildren().end(); ++it)
 
93
        {
 
94
                helper_updateAbsolutePositionOfAllChildren( (*it) );
 
95
        }
 
96
}
 
97
 
 
98
 
 
99
void CBoneSceneNode::updateAbsolutePositionOfAllChildren()
 
100
{
 
101
        helper_updateAbsolutePositionOfAllChildren( this );
 
102
}
 
103
 
 
104
 
 
105
void CBoneSceneNode::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const
 
106
{
 
107
        IBoneSceneNode::serializeAttributes(out, options);
 
108
        out->addInt("BoneIndex", BoneIndex);
 
109
        out->addEnum("AnimationMode", AnimationMode, BoneAnimationModeNames);
 
110
}
 
111
 
 
112
 
 
113
void CBoneSceneNode::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options)
 
114
{
 
115
        BoneIndex = in->getAttributeAsInt("BoneIndex");
 
116
        AnimationMode = (E_BONE_ANIMATION_MODE)in->getAttributeAsEnumeration("AnimationMode", BoneAnimationModeNames);
 
117
        // for legacy files (before 1.5)
 
118
        const core::stringc boneName = in->getAttributeAsString("BoneName");
 
119
        setName(boneName);
 
120
        IBoneSceneNode::deserializeAttributes(in, options);
 
121
        // TODO: add/replace bone in parent with bone from mesh
 
122
}
 
123
 
 
124
 
 
125
} // namespace scene
 
126
} // namespace irr
 
127
 
 
128
#endif
 
129