We noticed a "Bug" in osgAnimation of the stable osg release 2.8.2, and
only on Linux ( Ubuntu 9.04 ), which does not occur on Windows with
Visual Studio 2005.
When writing out an osgAnimation programm to a osg file, the process
stops before writing keyframe data:
Node {
nodeMask 0xffffffff
cullingActive TRUE
UpdateCallbacks {
osgAnimation::BasicAnimationManager {
num_animations 1
osgAnimation::Animation {
name "myTestanimation"
num_channels 1
Channel {
name "position"
target "whatever"
Keyframes "Vec3" 2 {
In Debug Mode we figured out, that the problem comes from
src/osgplugins/osganimation/ReaderWriter.cpp Line 273, 274, pointer kk
points to adresse 0x0 after dynamic_cast
osgAnimation::Vec3KeyframeContainer* kk =
dynamic_cast<osgAnimation::Vec3KeyframeContainer*>(kf);
fw.indent() << "key " << (*kk)[k].getTime() << " " <<
(*kk)[k].getValue() << std::endl;
Source Code Attached
Cheers, searching for the Pivot of my Soul, PP !!!
/* -*-c++-*-
* Copyright (C) 2008 Cedric Pinson <[email protected]>
*
* 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 <iostream>
#include <osg/Geometry>
#include <osg/Shape>
#include <osg/ShapeDrawable>
#include <osgViewer/Viewer>
#include <osgDB/FileUtils>
#include <osgDB/WriteFile>
#include <osgDB/ReadFile>
#include <osgGA/TrackballManipulator>
#include <osg/MatrixTransform>
#include <osg/Material>
#include <osgAnimation/Sampler>
#include <osgAnimation/BasicAnimationManager>
#include <osgAnimation/Animation>
int main( int , char** )
{
//create node
osg::Node* testNode = new osg::Node(); //you can also use osg::Group or osg::MatrixTransform here
//create animationmanager (= updatecallback)
osgAnimation::BasicAnimationManager* testanimationManager = new osgAnimation::BasicAnimationManager();
//create animation for this updatecallback
osgAnimation::Animation* testAnimation = new osgAnimation::Animation();
testAnimation->setName("myTestanimation");
//create channel for this animation
osgAnimation::Vec3LinearChannel* testchannel = new osgAnimation::Vec3LinearChannel; //we are not using Vec3CubicBezier because this cannot be written to file. maybe it is not specified in writer.
testchannel->setTargetName("whatever");
testchannel->setName("position"); //the name must be a certain keyword like "position" otherwise it does not work
//get keys and fill them with some data --- WARNING: IF you add no keys, programm will crash when calling "testAnimation->addChannel(testchannel);"
osgAnimation::Vec3KeyframeContainer* keys = testchannel->getOrCreateSampler()->getOrCreateKeyframeContainer();
keys->push_back(osgAnimation::Vec3Keyframe(0, osg::Vec3(0,0,0))); //first frame
keys->push_back(osgAnimation::Vec3Keyframe(2, osg::Vec3(1,1,0))); //second frame
// now add channel to animation
testAnimation->addChannel(testchannel);
//add animation to updatecallback
testanimationManager->registerAnimation(testAnimation);
//add updatecallback (=animationmanager) to node
testNode->addUpdateCallback(testanimationManager);
//in the end write all data to a file
osgDB::writeNodeFile(*testNode, "testNode.osg");
}
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org