From Cedric Pinson, "updated osgAnimation with the trunk here the update:

examples/osganimationviewer/AnimtkViewer.cpp:
- add option to display bone (--drawbone)
- dont crash if the file does not contains a AnimationManagerBase, display the content only

examples/osganimationviewer/AnimtkViewerGUI.cpp:
- adjust the path of image for the gui

include/osgAnimation/Interpolator:
- add warn message instead of old assert

include/osgAnimation/Bone:
src/osgAnimation/Skeleton.cpp:
- change a method name to fit better with what it does. setMatrixInSkeletonSpace instead of setBoneInSkeletonSpace

include/osgAnimation/Skinning:
src/osgAnimation/RigGeometry.cpp:
- add patch from Fabien Lavignotte to compute normal correctly

include/osgAnimation/Sampler:
- adjust behviour without assert, return 0 instead of crashing
"
This commit is contained in:
Robert Osfield
2009-01-21 19:02:54 +00:00
parent d542961ca3
commit 55e89e4466
8 changed files with 105 additions and 22 deletions

View File

@@ -213,7 +213,7 @@ namespace osgAnimation
const osg::Matrix& getBindMatrixInBoneSpace() const { return _bindInBoneSpace; }
const osg::Matrix& getMatrixInSkeletonSpace() const { return _boneInSkeletonSpace; }
const osg::Matrix& getInvBindMatrixInSkeletonSpace() const { return _invBindInSkeletonSpace;}
void setBoneInSkeletonSpace(const osg::Matrix& matrix) { _boneInSkeletonSpace = matrix; }
void setMatrixInSkeletonSpace(const osg::Matrix& matrix) { _boneInSkeletonSpace = matrix; }
void setBindMatrixInBoneSpace(const osg::Matrix& matrix)
{
_bindInBoneSpace = matrix;

View File

@@ -15,6 +15,7 @@
#ifndef OSGANIMATION_INTERPOLATOR_H
#define OSGANIMATION_INTERPOLATOR_H
#include <osg/Notify>
#include <osgAnimation/Interpolator>
#include <osgAnimation/Keyframe>
@@ -38,8 +39,12 @@ namespace osgAnimation
{
// todo use a cache
int key_size = keys.size();
if (!key_size) {
osg::notify(osg::WARN) << "TemplateInterpolatorBase::getKeyIndexFromTime the container is empty, impossible to get key index from time" << std::endl;;
return -1;
}
const TemplateKeyframe<KeyframeType>* keysVector = &keys.front();
for (int i = 0; i < key_size-1; i++)
for (int i = 0; i < key_size-1; i++)
{
float time0 = keysVector[i].getTime();
float time1 = keysVector[i+1].getTime();
@@ -50,9 +55,7 @@ namespace osgAnimation
return i;
}
}
std::cout << time << " first key " << keysVector[0].getTime() << " last key " << keysVector[key_size-1].getTime() << std::endl;
*((int *)0) = 0;
osg::notify(osg::WARN) << time << " first key " << keysVector[0].getTime() << " last key " << keysVector[key_size-1].getTime() << std::endl;
return -1;
}
};

View File

@@ -64,11 +64,15 @@ namespace osgAnimation
float getStartTime() const
{
if (!_keyframes)
return 0.0f;
return _keyframes->front().getTime();
}
float getEndTime() const
{
if (!_keyframes)
return 0.0f;
return _keyframes->back().getTime();
}

View File

@@ -91,9 +91,9 @@ namespace osgAnimation
ptrresult[13] += ptr[13] * weight;
ptrresult[14] += ptr[14] * weight;
}
void computeMatrixForVertexSet()
void computeMatrixForVertexSet()
{
if (_bones.empty())
if (_bones.empty())
{
osg::notify(osg::WARN) << "TransformVertexFunctor::UniqBoneSetVertexSet no bones found" << std::endl;
_result = MatrixType::identity();
@@ -181,6 +181,7 @@ namespace osgAnimation
template <class V> void compute(const MatrixType& transform, const MatrixType& invTransform, const V* src, V* dst)
{
// the result of matrix mult should be cached to be used for vertexes transform and normal transform and maybe other computation
int size = _boneSetVertexSet.size();
for (int i = 0; i < size; i++)
{
@@ -198,6 +199,26 @@ namespace osgAnimation
}
}
template <class V> void computeNormal(const MatrixType& transform, const MatrixType& invTransform, const V* src, V* dst)
{
int size = _boneSetVertexSet.size();
for (int i = 0; i < size; i++)
{
UniqBoneSetVertexSet& uniq = _boneSetVertexSet[i];
uniq.computeMatrixForVertexSet();
MatrixType matrix = transform * uniq.getMatrix() * invTransform;
const VertexList& vertexes = uniq.getVertexes();
int vertexSize = vertexes.size();
for (int j = 0; j < vertexSize; j++)
{
int idx = vertexes[j];
dst[idx] = MatrixType::transform3x3(src[idx],matrix);
}
}
}
protected:
std::vector<UniqBoneSetVertexSet> _boneSetVertexSet;