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
5
#include "IrrCompileConfig.h"
6
#ifdef _IRR_COMPILE_WITH_SKINNED_MESH_SUPPORT_
8
#include "CBoneSceneNode.h"
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)
22
setDebugName("CBoneSceneNode");
28
//! Returns the index of the bone
29
u32 CBoneSceneNode::getBoneIndex() const
35
//! Sets the animation mode of the bone. Returns true if successful.
36
bool CBoneSceneNode::setAnimationMode(E_BONE_ANIMATION_MODE mode)
43
//! Gets the current animation mode of the bone
44
E_BONE_ANIMATION_MODE CBoneSceneNode::getAnimationMode() const
50
//! returns the axis aligned bounding box of this node
51
const core::aabbox3d<f32>& CBoneSceneNode::getBoundingBox() const
58
//! Returns the relative transformation of the scene node.
59
core::matrix4 CBoneSceneNode::getRelativeTransformation() const
61
return core::matrix4(); // RelativeTransformation;
66
void CBoneSceneNode::OnAnimate(u32 timeMs)
70
// animate this node with all animators
72
ISceneNodeAnimatorList::Iterator ait = Animators.begin();
73
for (; ait != Animators.end(); ++ait)
74
(*ait)->animateNode(this, timeMs);
76
// update absolute position
77
//updateAbsolutePosition();
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);
87
void CBoneSceneNode::helper_updateAbsolutePositionOfAllChildren(ISceneNode *Node)
89
Node->updateAbsolutePosition();
91
ISceneNodeList::ConstIterator it = Node->getChildren().begin();
92
for (; it != Node->getChildren().end(); ++it)
94
helper_updateAbsolutePositionOfAllChildren( (*it) );
99
void CBoneSceneNode::updateAbsolutePositionOfAllChildren()
101
helper_updateAbsolutePositionOfAllChildren( this );
105
void CBoneSceneNode::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const
107
IBoneSceneNode::serializeAttributes(out, options);
108
out->addInt("BoneIndex", BoneIndex);
109
out->addEnum("AnimationMode", AnimationMode, BoneAnimationModeNames);
113
void CBoneSceneNode::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options)
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");
120
IBoneSceneNode::deserializeAttributes(in, options);
121
// TODO: add/replace bone in parent with bone from mesh