From Cedric Pinson, "Here a list of changes:
Bone now inherit from MatrixTransform. It simplify a lot the update of Bone matrix. It helps to have the bone system more generic. eg it's now possible to have animation data with precomputed bind matrix. The other benefit, is now the collada plugin will be able to use osgAnimation to display skinned mesh. Michael Plating did a great work to improve this aspect, he is working on the collada plugin and should be able to submit a new version soon. The RigGeometry has been refactored so now it works when you save and reload RigGeometry because the source is not touched anymore. The benefit with this update is that it should be now possible to use a MorphGeometry as source for a RigGeometry. The bad news is that the format has changed, so i have rebuild osg-data related to osgAnimation data, updated the blender exporter to export to the new format. The fbx plugin could be touched about this commit, i dont compile it so i can't give more information about it. The bvh plugin has been updated by Wang rui so this one is fixed with the new code of osgAnimation. The examples has been updated to work with the new code too... The example osg-data/example.osg should be remove, it's an old example that does not work. For people using blender the blender exporter up to date is here: http://hg.plopbyte.net/osgexport2/ it will be merge to http://hg.plopbyte.net/osgexport/ as soon as the modification will be push in the trunk. "
This commit is contained in:
@@ -5,5 +5,3 @@ FILE(GLOB TARGET_H *.h)
|
||||
SET(TARGET_ADDED_LIBRARIES osgAnimation )
|
||||
#### end var setup ###
|
||||
SETUP_PLUGIN(osganimation)
|
||||
|
||||
|
||||
|
||||
51
src/osgWrappers/deprecated-dotosg/osgAnimation/Matrix.cpp
Normal file
51
src/osgWrappers/deprecated-dotosg/osgAnimation/Matrix.cpp
Normal file
@@ -0,0 +1,51 @@
|
||||
#include "Matrix.h"
|
||||
|
||||
|
||||
bool readMatrix(osg::Matrix& matrix, osgDB::Input& fr, const char* keyword)
|
||||
{
|
||||
bool iteratorAdvanced = false;
|
||||
|
||||
if (fr[0].matchWord(keyword) && fr[1].isOpenBracket())
|
||||
{
|
||||
int entry = fr[0].getNoNestedBrackets();
|
||||
|
||||
fr += 2;
|
||||
|
||||
int row=0;
|
||||
int col=0;
|
||||
double v;
|
||||
while (!fr.eof() && fr[0].getNoNestedBrackets()>entry)
|
||||
{
|
||||
if (fr[0].getFloat(v))
|
||||
{
|
||||
matrix(row,col)=v;
|
||||
++col;
|
||||
if (col>=4)
|
||||
{
|
||||
col = 0;
|
||||
++row;
|
||||
}
|
||||
++fr;
|
||||
}
|
||||
else fr.advanceOverCurrentFieldOrBlock();
|
||||
}
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
|
||||
return iteratorAdvanced;
|
||||
}
|
||||
|
||||
|
||||
bool writeMatrix(const osg::Matrix& matrix, osgDB::Output& fw, const char* keyword)
|
||||
{
|
||||
fw.indent() << keyword <<" {" << std::endl;
|
||||
fw.moveIn();
|
||||
fw.indent() << matrix(0,0) << " " << matrix(0,1) << " " << matrix(0,2) << " " << matrix(0,3) << std::endl;
|
||||
fw.indent() << matrix(1,0) << " " << matrix(1,1) << " " << matrix(1,2) << " " << matrix(1,3) << std::endl;
|
||||
fw.indent() << matrix(2,0) << " " << matrix(2,1) << " " << matrix(2,2) << " " << matrix(2,3) << std::endl;
|
||||
fw.indent() << matrix(3,0) << " " << matrix(3,1) << " " << matrix(3,2) << " " << matrix(3,3) << std::endl;
|
||||
fw.moveOut();
|
||||
fw.indent() << "}"<< std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
13
src/osgWrappers/deprecated-dotosg/osgAnimation/Matrix.h
Normal file
13
src/osgWrappers/deprecated-dotosg/osgAnimation/Matrix.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef DOTOSG_MATRIX
|
||||
#define DOTOSG_MATRIX
|
||||
|
||||
#include <osg/Matrix>
|
||||
|
||||
#include <osgDB/Input>
|
||||
#include <osgDB/Output>
|
||||
|
||||
extern bool readMatrix(osg::Matrix& matrix, osgDB::Input& fr, const char* keyword="Matrix");
|
||||
|
||||
extern bool writeMatrix(const osg::Matrix& matrix, osgDB::Output& fw, const char* keyword="Matrix");
|
||||
|
||||
#endif
|
||||
@@ -10,24 +10,30 @@
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* OpenSceneGraph Public License for more details.
|
||||
*/
|
||||
*/
|
||||
|
||||
|
||||
#include <osgDB/Registry>
|
||||
#include <osgDB/FileNameUtils>
|
||||
#include <osgDB/FileUtils>
|
||||
#include <osgDB/ReaderWriter>
|
||||
|
||||
#include <osg/io_utils>
|
||||
#include <osgAnimation/AnimationManagerBase>
|
||||
#include <osgAnimation/BasicAnimationManager>
|
||||
#include <osgAnimation/TimelineAnimationManager>
|
||||
#include <osgAnimation/VertexInfluence>
|
||||
#include <osgAnimation/Animation>
|
||||
#include <osgAnimation/Bone>
|
||||
#include <osgAnimation/UpdateBone>
|
||||
#include <osgAnimation/UpdateMatrixTransform>
|
||||
#include <osgAnimation/Skeleton>
|
||||
#include <osgAnimation/RigGeometry>
|
||||
#include <osgAnimation/MorphGeometry>
|
||||
#include <osgAnimation/UpdateCallback>
|
||||
#include <osgAnimation/StackedTransform>
|
||||
#include <osgAnimation/StackedTranslateElement>
|
||||
#include <osgAnimation/StackedRotateAxisElement>
|
||||
#include <osgAnimation/StackedMatrixElement>
|
||||
#include <osgAnimation/StackedScaleElement>
|
||||
#include "Matrix.h"
|
||||
|
||||
#include <osgDB/Registry>
|
||||
#include <osgDB/Input>
|
||||
@@ -42,7 +48,7 @@ bool Bone_readLocalData(Object& obj, Input& fr)
|
||||
|
||||
osg::Quat att;
|
||||
bool iteratorAdvanced = false;
|
||||
if (fr.matchSequence("bindQuaternion %f %f %f %f"))
|
||||
if (fr.matchSequence("bindQuaternion %f %f %f %f"))
|
||||
{
|
||||
fr[1].getFloat(att[0]);
|
||||
fr[2].getFloat(att[1]);
|
||||
@@ -51,10 +57,11 @@ bool Bone_readLocalData(Object& obj, Input& fr)
|
||||
|
||||
fr += 5;
|
||||
iteratorAdvanced = true;
|
||||
osg::notify(osg::WARN) << "Old osgAnimation file format update your data file" << std::endl;
|
||||
}
|
||||
|
||||
osg::Vec3d pos(0,0,0);
|
||||
if (fr.matchSequence("bindPosition %f %f %f"))
|
||||
if (fr.matchSequence("bindPosition %f %f %f"))
|
||||
{
|
||||
fr[1].getFloat(pos[0]);
|
||||
fr[2].getFloat(pos[1]);
|
||||
@@ -62,10 +69,11 @@ bool Bone_readLocalData(Object& obj, Input& fr)
|
||||
|
||||
fr += 4;
|
||||
iteratorAdvanced = true;
|
||||
osg::notify(osg::WARN) << "Old osgAnimation file format update your data file" << std::endl;
|
||||
}
|
||||
|
||||
osg::Vec3d scale(1,1,1);
|
||||
if (fr.matchSequence("bindScale %f %f %f"))
|
||||
if (fr.matchSequence("bindScale %f %f %f"))
|
||||
{
|
||||
fr[1].getFloat(scale[0]);
|
||||
fr[2].getFloat(scale[1]);
|
||||
@@ -73,31 +81,45 @@ bool Bone_readLocalData(Object& obj, Input& fr)
|
||||
|
||||
fr += 4;
|
||||
iteratorAdvanced = true;
|
||||
osg::notify(osg::WARN) << "Old osgAnimation file format update your data file" << std::endl;
|
||||
}
|
||||
|
||||
bone.setBindMatrixInBoneSpace( osg::Matrix(att) * osg::Matrix::translate(pos));
|
||||
if (fr.matchSequence("InvBindMatrixInSkeletonSpace {"))
|
||||
{
|
||||
Matrix matrix;
|
||||
if (readMatrix(matrix,fr, "InvBindMatrixInSkeletonSpace"))
|
||||
{
|
||||
bone.setInvBindMatrixInSkeletonSpace(matrix);
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
}
|
||||
if (fr.matchSequence("MatrixInSkeletonSpace {"))
|
||||
{
|
||||
Matrix matrix;
|
||||
if (readMatrix(matrix,fr, "MatrixInSkeletonSpace"))
|
||||
{
|
||||
bone.setMatrixInSkeletonSpace(matrix);
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
}
|
||||
return iteratorAdvanced;
|
||||
}
|
||||
|
||||
bool Bone_writeLocalData(const Object& obj, Output& fw)
|
||||
bool Bone_writeLocalData(const Object& obj, Output& fw)
|
||||
{
|
||||
const osgAnimation::Bone& bone = dynamic_cast<const osgAnimation::Bone&>(obj);
|
||||
osg::Vec3 t;
|
||||
osg::Quat r;
|
||||
osg::Vec3 s;
|
||||
osg::Quat rs;
|
||||
bone.getBindMatrixInBoneSpace().decompose(t,r,s,rs);
|
||||
fw.indent() << "bindQuaternion " << r << std::endl;
|
||||
fw.indent() << "bindPosition " << t << std::endl;
|
||||
fw.indent() << "bindScale " << s << std::endl;
|
||||
return true;
|
||||
bool res1 = writeMatrix(bone.getInvBindMatrixInSkeletonSpace(), fw, "InvBindMatrixInSkeletonSpace");
|
||||
// write this field for debug only
|
||||
// because it's recompute at each update
|
||||
bool res2 = writeMatrix(bone.getMatrixInSkeletonSpace(), fw, "MatrixInSkeletonSpace");
|
||||
return (res1 || res2);
|
||||
}
|
||||
|
||||
RegisterDotOsgWrapperProxy g_atkBoneProxy
|
||||
RegisterDotOsgWrapperProxy g_BoneProxy
|
||||
(
|
||||
new osgAnimation::Bone,
|
||||
"osgAnimation::Bone",
|
||||
"Object Node Transform osgAnimation::Bone Group",
|
||||
"Object Node MatrixTransform osgAnimation::Bone Group",
|
||||
&Bone_readLocalData,
|
||||
&Bone_writeLocalData
|
||||
);
|
||||
@@ -112,11 +134,11 @@ bool Skeleton_writeLocalData(const Object& obj, Output& fr)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
RegisterDotOsgWrapperProxy g_atkRootSkeletonProxy
|
||||
RegisterDotOsgWrapperProxy g_SkeletonProxy
|
||||
(
|
||||
new osgAnimation::Skeleton,
|
||||
"osgAnimation::Skeleton",
|
||||
"Object Node Transform osgAnimation::Bone osgAnimation::Skeleton Group",
|
||||
"Object Node MatrixTransform osgAnimation::Skeleton Group",
|
||||
&Skeleton_readLocalData,
|
||||
&Skeleton_writeLocalData,
|
||||
DotOsgWrapper::READ_AND_WRITE
|
||||
@@ -723,7 +745,7 @@ bool AnimationManagerBase_writeLocalData(const osgAnimation::AnimationManagerBas
|
||||
const osgAnimation::AnimationList& animList = manager.getAnimationList();
|
||||
|
||||
fw.indent() << "num_animations " << animList.size() << std::endl;
|
||||
for (osgAnimation::AnimationList::const_iterator it = animList.begin(); it != animList.end(); it++)
|
||||
for (osgAnimation::AnimationList::const_iterator it = animList.begin(); it != animList.end(); ++it)
|
||||
{
|
||||
if (!fw.writeObject(**it))
|
||||
osg::notify(osg::WARN)<<"Warning: can't write an animation object"<< std::endl;
|
||||
@@ -816,6 +838,13 @@ bool RigGeometry_readLocalData(Object& obj, Input& fr)
|
||||
if (!vmap->empty())
|
||||
geom.setInfluenceMap(vmap.get());
|
||||
|
||||
if (fr.matchSequence("Geometry {"))
|
||||
{
|
||||
osg::Geometry* source = dynamic_cast<osg::Geometry*>(fr.readObject());
|
||||
geom.setSourceGeometry(source);
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
|
||||
return iteratorAdvanced;
|
||||
}
|
||||
|
||||
@@ -827,7 +856,7 @@ bool RigGeometry_writeLocalData(const Object& obj, Output& fw)
|
||||
return true;
|
||||
fw.indent() << "num_influences " << vm->size() << std::endl;
|
||||
fw.moveIn();
|
||||
for (osgAnimation::VertexInfluenceMap::const_iterator it = vm->begin(); it != vm->end(); it++)
|
||||
for (osgAnimation::VertexInfluenceMap::const_iterator it = vm->begin(); it != vm->end(); ++it)
|
||||
{
|
||||
std::string name = it->first;
|
||||
if (name.empty())
|
||||
@@ -843,6 +872,8 @@ bool RigGeometry_writeLocalData(const Object& obj, Output& fw)
|
||||
fw.indent() << "}" << std::endl;
|
||||
}
|
||||
fw.moveOut();
|
||||
|
||||
fw.writeObject(*geom.getSourceGeometry());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -850,7 +881,7 @@ RegisterDotOsgWrapperProxy g_atkRigGeometryProxy
|
||||
(
|
||||
new osgAnimation::RigGeometry,
|
||||
"osgAnimation::RigGeometry",
|
||||
"Object Drawable osgAnimation::RigGeometry Geometry",
|
||||
"Object osgAnimation::RigGeometry Drawable Geometry",
|
||||
&RigGeometry_readLocalData,
|
||||
&RigGeometry_writeLocalData,
|
||||
DotOsgWrapper::READ_AND_WRITE
|
||||
@@ -975,7 +1006,10 @@ RegisterDotOsgWrapperProxy g_osgAnimationMorphGeometryProxy
|
||||
);
|
||||
|
||||
|
||||
bool UpdateBone_readLocalData(Object& obj, Input& fr)
|
||||
|
||||
|
||||
|
||||
bool UpdateBone_readLocalData(Object& obj, Input& fr)
|
||||
{
|
||||
bool iteratorAdvanced = false;
|
||||
return iteratorAdvanced;
|
||||
@@ -986,11 +1020,11 @@ bool UpdateBone_writeLocalData(const Object& obj, Output& fw)
|
||||
return true;
|
||||
}
|
||||
|
||||
RegisterDotOsgWrapperProxy g_atkUpdateBoneProxy
|
||||
RegisterDotOsgWrapperProxy g_UpdateBoneProxy
|
||||
(
|
||||
new osgAnimation::Bone::UpdateBone,
|
||||
new osgAnimation::UpdateBone,
|
||||
"osgAnimation::UpdateBone",
|
||||
"Object NodeCallback osgAnimation::UpdateBone",
|
||||
"Object NodeCallback osgAnimation::UpdateMatrixTransform osgAnimation::UpdateBone",
|
||||
&UpdateBone_readLocalData,
|
||||
&UpdateBone_writeLocalData,
|
||||
DotOsgWrapper::READ_AND_WRITE
|
||||
@@ -1009,7 +1043,7 @@ bool UpdateSkeleton_writeLocalData(const Object& obj, Output& fw)
|
||||
return true;
|
||||
}
|
||||
|
||||
RegisterDotOsgWrapperProxy g_atkUpdateSkeletonProxy
|
||||
RegisterDotOsgWrapperProxy g_UpdateSkeletonProxy
|
||||
(
|
||||
new osgAnimation::Skeleton::UpdateSkeleton,
|
||||
"osgAnimation::UpdateSkeleton",
|
||||
@@ -1020,51 +1054,6 @@ RegisterDotOsgWrapperProxy g_atkUpdateSkeletonProxy
|
||||
);
|
||||
|
||||
|
||||
|
||||
bool UpdateTransform_readLocalData(Object& obj, Input& fr)
|
||||
{
|
||||
bool iteratorAdvanced = false;
|
||||
return iteratorAdvanced;
|
||||
}
|
||||
|
||||
bool UpdateTransform_writeLocalData(const Object& obj, Output& fw)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
RegisterDotOsgWrapperProxy g_atkUpdateTransformProxy
|
||||
(
|
||||
new osgAnimation::UpdateTransform,
|
||||
"osgAnimation::UpdateTransform",
|
||||
"Object NodeCallback osgAnimation::UpdateTransform",
|
||||
&UpdateTransform_readLocalData,
|
||||
&UpdateTransform_writeLocalData,
|
||||
DotOsgWrapper::READ_AND_WRITE
|
||||
);
|
||||
|
||||
|
||||
|
||||
bool UpdateMaterial_readLocalData(Object& obj, Input& fr)
|
||||
{
|
||||
bool iteratorAdvanced = false;
|
||||
return iteratorAdvanced;
|
||||
}
|
||||
|
||||
bool UpdateMaterial_writeLocalData(const Object& obj, Output& fw)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
RegisterDotOsgWrapperProxy g_UpdateMaterialProxy
|
||||
(
|
||||
new osgAnimation::UpdateMaterial,
|
||||
"osgAnimation::UpdateMaterial",
|
||||
"Object StateAttribute::Callback osgAnimation::UpdateMaterial",
|
||||
&UpdateMaterial_readLocalData,
|
||||
&UpdateMaterial_writeLocalData,
|
||||
DotOsgWrapper::READ_AND_WRITE
|
||||
);
|
||||
|
||||
bool UpdateMorph_readLocalData(Object& obj, Input& fr)
|
||||
{
|
||||
bool iteratorAdvanced = false;
|
||||
@@ -1076,7 +1065,7 @@ bool UpdateMorph_writeLocalData(const Object& obj, Output& fw)
|
||||
return true;
|
||||
}
|
||||
|
||||
RegisterDotOsgWrapperProxy g_atkUpdateMorphProxy
|
||||
RegisterDotOsgWrapperProxy g_UpdateMorphProxy
|
||||
(
|
||||
new osgAnimation::UpdateMorph,
|
||||
"osgAnimation::UpdateMorph",
|
||||
|
||||
@@ -0,0 +1,228 @@
|
||||
/* -*-c++-*-
|
||||
* Copyright (C) 2009 Cedric Pinson <cedric.pinson@plopbyte.net>
|
||||
*
|
||||
* This library is open source and may be redistributed and/or modified under
|
||||
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
||||
* (at your option) any later version. The full license is in LICENSE file
|
||||
* included with this distribution, and on the openscenegraph.org website.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* OpenSceneGraph Public License for more details.
|
||||
*/
|
||||
|
||||
#include <osgAnimation/StackedTranslateElement>
|
||||
#include <osgAnimation/StackedMatrixElement>
|
||||
#include <osgAnimation/StackedScaleElement>
|
||||
#include <osgAnimation/StackedRotateAxisElement>
|
||||
#include <osgAnimation/StackedQuaternionElement>
|
||||
#include <osgDB/Input>
|
||||
#include <osgDB/Output>
|
||||
#include <osgDB/Registry>
|
||||
#include <osgDB/ReaderWriter>
|
||||
#include <osg/io_utils>
|
||||
|
||||
#include "Matrix.h"
|
||||
|
||||
using namespace osgDB;
|
||||
using namespace osg;
|
||||
|
||||
bool readStackedTranslateElement(Object& obj, Input& fr)
|
||||
{
|
||||
osgAnimation::StackedTranslateElement& element = dynamic_cast<osgAnimation::StackedTranslateElement&>(obj);
|
||||
bool iteratorAdvanced = false;
|
||||
if (fr.matchSequence("translate %f %f %f"))
|
||||
{
|
||||
++fr;
|
||||
osg::Vec3 translate;
|
||||
fr[0].getFloat(translate.x());
|
||||
fr[1].getFloat(translate.y());
|
||||
fr[2].getFloat(translate.z());
|
||||
element.setTranslate(translate);
|
||||
fr += 3;
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
return iteratorAdvanced;
|
||||
}
|
||||
|
||||
bool writeStackedTranslateElement(const Object& obj, Output& fw)
|
||||
{
|
||||
const osgAnimation::StackedTranslateElement& element = dynamic_cast<const osgAnimation::StackedTranslateElement&>(obj);
|
||||
fw.indent() << "translate " << element.getTranslate() << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
RegisterDotOsgWrapperProxy g_StackedTranslateElementProxy
|
||||
(
|
||||
new osgAnimation::StackedTranslateElement,
|
||||
"osgAnimation::StackedTranslateElement",
|
||||
"Object osgAnimation::StackedTranslateElement",
|
||||
&readStackedTranslateElement,
|
||||
&writeStackedTranslateElement,
|
||||
DotOsgWrapper::READ_AND_WRITE
|
||||
);
|
||||
|
||||
|
||||
bool readStackedScaleElement(Object& obj, Input& fr)
|
||||
{
|
||||
osgAnimation::StackedScaleElement& element = dynamic_cast<osgAnimation::StackedScaleElement&>(obj);
|
||||
bool iteratorAdvanced = false;
|
||||
if (fr.matchSequence("scale %f %f %f"))
|
||||
{
|
||||
++fr;
|
||||
osg::Vec3 scale;
|
||||
fr[0].getFloat(scale.x());
|
||||
fr[1].getFloat(scale.y());
|
||||
fr[2].getFloat(scale.z());
|
||||
element.setScale(scale);
|
||||
fr += 3;
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
return iteratorAdvanced;
|
||||
}
|
||||
|
||||
bool writeStackedScaleElement(const Object& obj, Output& fw)
|
||||
{
|
||||
const osgAnimation::StackedScaleElement& element = dynamic_cast<const osgAnimation::StackedScaleElement&>(obj);
|
||||
fw.indent() << "scale " << element.getScale() << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
RegisterDotOsgWrapperProxy g_StackedScaleElementProxy
|
||||
(
|
||||
new osgAnimation::StackedScaleElement,
|
||||
"osgAnimation::StackedScaleElement",
|
||||
"Object osgAnimation::StackedScaleElement",
|
||||
&readStackedScaleElement,
|
||||
&writeStackedScaleElement,
|
||||
DotOsgWrapper::READ_AND_WRITE
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bool readStackedMatrixElement(Object& obj, Input& fr)
|
||||
{
|
||||
osgAnimation::StackedMatrixElement& element = dynamic_cast<osgAnimation::StackedMatrixElement&>(obj);
|
||||
bool iteratorAdvanced = false;
|
||||
if (fr[0].matchWord("Matrix"))
|
||||
{
|
||||
osg::Matrix matrix;
|
||||
matrix.makeIdentity();
|
||||
iteratorAdvanced = readMatrix(matrix, fr);
|
||||
element.setMatrix(matrix);
|
||||
}
|
||||
|
||||
return iteratorAdvanced;
|
||||
}
|
||||
|
||||
bool writeStackedMatrixElement(const Object& obj, Output& fw)
|
||||
{
|
||||
const osgAnimation::StackedMatrixElement& element = dynamic_cast<const osgAnimation::StackedMatrixElement&>(obj);
|
||||
writeMatrix(element.getMatrix(), fw);
|
||||
return true;
|
||||
}
|
||||
|
||||
RegisterDotOsgWrapperProxy g_StackedMatrixElementProxy
|
||||
(
|
||||
new osgAnimation::StackedMatrixElement,
|
||||
"osgAnimation::StackedMatrixElement",
|
||||
"Object osgAnimation::StackedMatrixElement",
|
||||
&readStackedMatrixElement,
|
||||
&writeStackedMatrixElement,
|
||||
DotOsgWrapper::READ_AND_WRITE
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
bool writeStackedRotateAxisElement(const Object& obj, Output& fw)
|
||||
{
|
||||
const osgAnimation::StackedRotateAxisElement& element = dynamic_cast<const osgAnimation::StackedRotateAxisElement&>(obj);
|
||||
fw.indent() << "axis " << element.getAxis() << std::endl;
|
||||
fw.indent() << "angle " << element.getAngle() << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool readStackedRotateAxisElement(Object& obj, Input& fr)
|
||||
{
|
||||
osgAnimation::StackedRotateAxisElement& element = dynamic_cast<osgAnimation::StackedRotateAxisElement&>(obj);
|
||||
bool iteratorAdvanced = false;
|
||||
if (fr.matchSequence("axis %f %f %f"))
|
||||
{
|
||||
++fr;
|
||||
osg::Vec3 axis;
|
||||
fr[0].getFloat(axis.x());
|
||||
fr[1].getFloat(axis.y());
|
||||
fr[2].getFloat(axis.z());
|
||||
element.setAxis(axis);
|
||||
fr += 3;
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
|
||||
if (fr.matchSequence("angle %f"))
|
||||
{
|
||||
++fr;
|
||||
double angle = 0;
|
||||
fr[0].getFloat(angle);
|
||||
++fr;
|
||||
element.setAngle(angle);
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
return iteratorAdvanced;
|
||||
}
|
||||
|
||||
RegisterDotOsgWrapperProxy g_StackedRotateAxisElementProxy
|
||||
(
|
||||
new osgAnimation::StackedRotateAxisElement,
|
||||
"osgAnimation::StackedRotateAxisElement",
|
||||
"Object osgAnimation::StackedRotateAxisElement",
|
||||
&readStackedRotateAxisElement,
|
||||
&writeStackedRotateAxisElement,
|
||||
DotOsgWrapper::READ_AND_WRITE
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bool readStackedQuaternionElement(Object& obj, Input& fr)
|
||||
{
|
||||
osgAnimation::StackedQuaternionElement& element = dynamic_cast<osgAnimation::StackedQuaternionElement&>(obj);
|
||||
bool iteratorAdvanced = false;
|
||||
if (fr.matchSequence("quaternion %f %f %f %f"))
|
||||
{
|
||||
++fr;
|
||||
osg::Quat quaternion;
|
||||
fr[0].getFloat(quaternion[0]);
|
||||
fr[1].getFloat(quaternion[1]);
|
||||
fr[2].getFloat(quaternion[2]);
|
||||
fr[3].getFloat(quaternion[3]);
|
||||
element.setQuaternion(quaternion);
|
||||
fr += 4;
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
return iteratorAdvanced;
|
||||
}
|
||||
|
||||
bool writeStackedQuaternionElement(const Object& obj, Output& fw)
|
||||
{
|
||||
const osgAnimation::StackedQuaternionElement& element = dynamic_cast<const osgAnimation::StackedQuaternionElement&>(obj);
|
||||
fw.indent() << "quaternion " << element.getQuaternion() << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
RegisterDotOsgWrapperProxy g_StackedQuaternionElementProxy
|
||||
(
|
||||
new osgAnimation::StackedQuaternionElement,
|
||||
"osgAnimation::StackedQuaternionElement",
|
||||
"Object osgAnimation::StackedQuaternionElement",
|
||||
&readStackedQuaternionElement,
|
||||
&writeStackedQuaternionElement,
|
||||
DotOsgWrapper::READ_AND_WRITE
|
||||
);
|
||||
@@ -0,0 +1,47 @@
|
||||
/* -*-c++-*-
|
||||
* Copyright (C) 2009 Cedric Pinson <cedric.pinson@plopbyte.net>
|
||||
*
|
||||
* This library is open source and may be redistributed and/or modified under
|
||||
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
||||
* (at your option) any later version. The full license is in LICENSE file
|
||||
* included with this distribution, and on the openscenegraph.org website.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* OpenSceneGraph Public License for more details.
|
||||
*/
|
||||
|
||||
|
||||
#include <osgDB/Input>
|
||||
#include <osgDB/Output>
|
||||
#include <osgDB/Registry>
|
||||
#include <osgDB/ReaderWriter>
|
||||
#include <osg/io_utils>
|
||||
#include <osgAnimation/UpdateMaterial>
|
||||
|
||||
|
||||
using namespace osg;
|
||||
using namespace osgDB;
|
||||
|
||||
|
||||
bool UpdateMaterial_readLocalData(Object& obj, Input& fr)
|
||||
{
|
||||
bool iteratorAdvanced = false;
|
||||
return iteratorAdvanced;
|
||||
}
|
||||
|
||||
bool UpdateMaterial_writeLocalData(const Object& obj, Output& fw)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
RegisterDotOsgWrapperProxy g_UpdateMaterialProxy
|
||||
(
|
||||
new osgAnimation::UpdateMaterial,
|
||||
"osgAnimation::UpdateMaterial",
|
||||
"Object StateAttribute::Callback osgAnimation::UpdateMaterial",
|
||||
&UpdateMaterial_readLocalData,
|
||||
&UpdateMaterial_writeLocalData,
|
||||
DotOsgWrapper::READ_AND_WRITE
|
||||
);
|
||||
@@ -0,0 +1,70 @@
|
||||
/* -*-c++-*-
|
||||
* Copyright (C) 2009 Cedric Pinson <cedric.pinson@plopbyte.net>
|
||||
*
|
||||
* This library is open source and may be redistributed and/or modified under
|
||||
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
||||
* (at your option) any later version. The full license is in LICENSE file
|
||||
* included with this distribution, and on the openscenegraph.org website.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* OpenSceneGraph Public License for more details.
|
||||
*/
|
||||
|
||||
|
||||
#include <osgDB/Input>
|
||||
#include <osgDB/Output>
|
||||
#include <osgDB/Registry>
|
||||
#include <osgDB/ReaderWriter>
|
||||
#include <osg/io_utils>
|
||||
#include <osgAnimation/StackedTransformElement>
|
||||
#include <osgAnimation/UpdateMatrixTransform>
|
||||
|
||||
|
||||
using namespace osg;
|
||||
using namespace osgDB;
|
||||
|
||||
bool UpdateMatrixTransform_readLocalData(Object& obj, Input& fr)
|
||||
{
|
||||
bool iteratorAdvanced = false;
|
||||
|
||||
osgAnimation::UpdateMatrixTransform& updateCallback = dynamic_cast<osgAnimation::UpdateMatrixTransform&>(obj);
|
||||
osgAnimation::StackedTransform& stackedTransform = updateCallback.getStackedTransforms();
|
||||
|
||||
int entry = fr[0].getNoNestedBrackets();
|
||||
while (!fr.eof() && fr[0].getNoNestedBrackets() == entry && fr.matchSequence("%w {"))
|
||||
{
|
||||
osgAnimation::StackedTransformElement* element = dynamic_cast<osgAnimation::StackedTransformElement*>(fr.readObject());
|
||||
if (element)
|
||||
stackedTransform.push_back(element);
|
||||
}
|
||||
return iteratorAdvanced;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool UpdateMatrixTransform_writeLocalData(const Object& obj, Output& fw)
|
||||
{
|
||||
const osgAnimation::UpdateMatrixTransform* uc = dynamic_cast<const osgAnimation::UpdateMatrixTransform*>(&obj);
|
||||
const osgAnimation::StackedTransform& transforms = uc->getStackedTransforms();
|
||||
for (osgAnimation::StackedTransform::const_iterator it = transforms.begin(); it != transforms.end(); ++it)
|
||||
{
|
||||
osgAnimation::StackedTransformElement* element = *it;
|
||||
if (element)
|
||||
fw.writeObject(*element);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
RegisterDotOsgWrapperProxy g_UpdateMatrixTransformProxy
|
||||
(
|
||||
new osgAnimation::UpdateMatrixTransform,
|
||||
"osgAnimation::UpdateMatrixTransform",
|
||||
"Object NodeCallback osgAnimation::UpdateMatrixTransform",
|
||||
&UpdateMatrixTransform_readLocalData,
|
||||
&UpdateMatrixTransform_writeLocalData,
|
||||
DotOsgWrapper::READ_AND_WRITE
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user