Show
Ignore:
Timestamp:
01/27/10 13:24:55 (3 years ago)
Author:
robert
Message:

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.
"

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/src/osgAnimation/RigGeometry.cpp

    r10877 r11009  
    1313 */ 
    1414 
     15#include <osgAnimation/VertexInfluence> 
    1516#include <osgAnimation/RigGeometry> 
    1617#include <osgAnimation/RigTransformSoftware> 
     
    7273} 
    7374 
    74 RigGeometry::RigGeometry(const osg::Geometry& b) : osg::Geometry(b, osg::CopyOp::SHALLOW_COPY) 
    75 { 
    76     _supportsDisplayList = false; 
    77     setUseVertexBufferObjects(true); 
    78     setUpdateCallback(new UpdateVertex); 
    79     setDataVariance(osg::Object::DYNAMIC); 
    80     _needToComputeMatrix = true; 
    81     _matrixFromSkeletonToGeometry = _invMatrixFromSkeletonToGeometry = osg::Matrix::identity(); 
    82  
    83     // disable the computation of boundingbox for the rig mesh 
    84     setComputeBoundingBoxCallback(new RigComputeBoundingBoxCallback); 
    85 } 
    8675 
    8776RigGeometry::RigGeometry(const RigGeometry& b, const osg::CopyOp& copyop) : 
    8877    osg::Geometry(b,copyop), 
     78    _geometry(b._geometry), 
    8979    _vertexInfluenceSet(b._vertexInfluenceSet), 
    9080    _vertexInfluenceMap(b._vertexInfluenceMap), 
     
    115105    for (osgAnimation::VertexInfluenceMap::iterator it = _vertexInfluenceMap->begin();  
    116106         it != _vertexInfluenceMap->end();  
    117          it++) 
     107         ++it) 
    118108        _vertexInfluenceSet.addVertexInfluence(it->second); 
    119109 
     
    131121    } 
    132122    osg::MatrixList mtxList = getParent(0)->getWorldMatrices(_root.get()); 
    133     _matrixFromSkeletonToGeometry = mtxList[0]; 
     123    osg::Matrix notRoot = _root->getMatrix(); 
     124    _matrixFromSkeletonToGeometry = mtxList[0] * osg::Matrix::inverse(notRoot); 
    134125    _invMatrixFromSkeletonToGeometry = osg::Matrix::inverse(_matrixFromSkeletonToGeometry); 
    135126    _needToComputeMatrix = false; 
     
    143134    } 
    144135 
    145     if (getRigTransformImplementation()->needInit()) 
    146         if (!getRigTransformImplementation()->init(*this)) 
    147             return; 
    148     getRigTransformImplementation()->update(*this); 
     136    RigTransform& implementation = *getRigTransformImplementation(); 
     137    (implementation)(*this); 
     138} 
     139 
     140void RigGeometry::copyFrom(osg::Geometry& from) 
     141{ 
     142    bool copyToSelf = (this==&from); 
     143 
     144    osg::Geometry& target = *this; 
     145 
     146    if (!copyToSelf) target.setStateSet(from.getStateSet()); 
     147 
     148    // copy over primitive sets. 
     149    if (!copyToSelf) target.getPrimitiveSetList() = from.getPrimitiveSetList(); 
     150 
     151    if (from.getVertexArray()) 
     152    { 
     153        if (!copyToSelf) target.setVertexArray(from.getVertexArray()); 
     154    } 
     155 
     156    target.setNormalBinding(from.getNormalBinding()); 
     157    if (from.getNormalArray()) 
     158    { 
     159        if (!copyToSelf) target.setNormalArray(from.getNormalArray()); 
     160    } 
     161 
     162    target.setColorBinding(from.getColorBinding()); 
     163    if (from.getColorArray()) 
     164    { 
     165        if (!copyToSelf) target.setColorArray(from.getColorArray()); 
     166    } 
     167 
     168    target.setSecondaryColorBinding(from.getSecondaryColorBinding()); 
     169    if (from.getSecondaryColorArray()) 
     170    { 
     171        if (!copyToSelf) target.setSecondaryColorArray(from.getSecondaryColorArray()); 
     172    } 
     173 
     174    target.setFogCoordBinding(from.getFogCoordBinding()); 
     175    if (from.getFogCoordArray()) 
     176    { 
     177        if (!copyToSelf) target.setFogCoordArray(from.getFogCoordArray()); 
     178    } 
     179 
     180    for(unsigned int ti=0;ti<from.getNumTexCoordArrays();++ti) 
     181    { 
     182        if (from.getTexCoordArray(ti))  
     183        { 
     184            if (!copyToSelf) target.setTexCoordArray(ti,from.getTexCoordArray(ti)); 
     185        } 
     186    } 
     187     
     188    ArrayDataList& arrayList = from.getVertexAttribArrayList(); 
     189    for(unsigned int vi=0;vi< arrayList.size();++vi) 
     190    { 
     191        ArrayData& arrayData = arrayList[vi]; 
     192        if (arrayData.array.valid()) 
     193        { 
     194            if (!copyToSelf) target.setVertexAttribData(vi,arrayData); 
     195        } 
     196    } 
    149197} 
    150198 
     
    156204RigTransform* RigGeometry::getRigTransformImplementation() { return _rigTransformImplementation.get(); } 
    157205void RigGeometry::setRigTransformImplementation(RigTransform* rig) { _rigTransformImplementation = rig; } 
     206 
     207osg::Geometry* RigGeometry::getSourceGeometry() { return _geometry.get(); } 
     208const osg::Geometry* RigGeometry::getSourceGeometry() const { return _geometry.get(); } 
     209void RigGeometry::setSourceGeometry(osg::Geometry* geometry) { _geometry = geometry; }