Hi, Robert!
To see what happen, just run osganimationviewer with low FPS with patch and
without it.
*OSG_RUN_MAX_FRAME_RATE={2, 3 or 5} osganimationviewer* *--play-mode once*
some_model_with_rig.osgb
osganimationviewer's source with play-mode option in the attachment.
Without patch, the last rendered picture (with different FPS) can be not
the same.
With patch, rendered picture is always the same no matter of FPS.
KOS
2015-03-13 20:33 GMT+04:00 Robert Osfield robert.osfi...@gmail.com:
Hi Konstantin,
On 13 March 2015 at 13:32, Konstantin lalakos...@gmail.com wrote:
After Animation's update method *return false*,
AnimationManager will remove this animation from the list of playing
animations
and will not call Animation's update method.
No cpu overhead, i think :)
I need to test this out to check what happens right now and with your
patch, and whether there is a CPU overhead.
What is the easiest way to recreate the problem you've seen? Modifying an
OSG example would probably be the most direct way.
Cheers,
Robert.
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
/* -*-c++-*-
* Copyright (C) 2008 Cedric Pinson morni...@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.
*
* Authors:
* Cedric Pinson morni...@plopbyte.net
* jeremy Moles jer...@emperorlinux.com
*/
#include AnimtkViewerKeyHandler
#include AnimtkViewerGUI
#include algorithm
#include iostream
#include osg/io_utils
#include osg/Geometry
#include osg/MatrixTransform
#include osg/Geode
#include osgViewer/Viewer
#include osgViewer/ViewerEventHandlers
#include osgWidget/ViewerEventHandlers
#include osgGA/TrackballManipulator
#include osgGA/StateSetManipulator
#include osgDB/ReadFile
#include osgAnimation/AnimationManagerBase
#include osgAnimation/Bone
const int WIDTH = 1440;
const int HEIGHT = 900;
osg::Geode* createAxis()
{
osg::Geode* geode= new osg::Geode();
osg::Geometry* geometry = new osg::Geometry();
osg::Vec3Array* vertices = new osg::Vec3Array();
osg::Vec4Array* colors = new osg::Vec4Array();
vertices-push_back(osg::Vec3(0.0f, 0.0f, 0.0f));
vertices-push_back(osg::Vec3(1.0f, 0.0f, 0.0f));
vertices-push_back(osg::Vec3(0.0f, 0.0f, 0.0f));
vertices-push_back(osg::Vec3(0.0f, 1.0f, 0.0f));
vertices-push_back(osg::Vec3(0.0f, 0.0f, 0.0f));
vertices-push_back(osg::Vec3(0.0f, 0.0f, 1.0f));
colors-push_back(osg::Vec4(1.0f, 0.0f, 0.0f, 1.0f));
colors-push_back(osg::Vec4(1.0f, 0.0f, 0.0f, 1.0f));
colors-push_back(osg::Vec4(0.0f, 1.0f, 0.0f, 1.0f));
colors-push_back(osg::Vec4(0.0f, 1.0f, 0.0f, 1.0f));
colors-push_back(osg::Vec4(0.0f, 0.0f, 1.0f, 1.0f));
colors-push_back(osg::Vec4(0.0f, 0.0f, 1.0f, 1.0f));
geometry-setVertexArray(vertices);
geometry-setColorArray(colors, osg::Array::BIND_PER_VERTEX);
geometry-addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINES, 0, 6));
geometry-getOrCreateStateSet()-setMode(GL_LIGHTING, false);
geode-addDrawable(geometry);
return geode;
}
struct AnimationManagerFinder : public osg::NodeVisitor
{
osg::ref_ptrosgAnimation::BasicAnimationManager _am;
AnimationManagerFinder() : osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN) {}
void apply(osg::Node node) {
if (_am.valid())
return;
if (node.getUpdateCallback()) {
osgAnimation::AnimationManagerBase* b = dynamic_castosgAnimation::AnimationManagerBase*(node.getUpdateCallback());
if (b) {
_am = new osgAnimation::BasicAnimationManager(*b);
return;
}
}
traverse(node);
}
};
struct AddHelperBone : public osg::NodeVisitor
{
AddHelperBone() : osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN) {}
void apply(osg::Transform node) {
osgAnimation::Bone* bone = dynamic_castosgAnimation::Bone*(node);
if (bone)
bone-addChild(createAxis());
traverse(node);
}
};
int main(int argc, char** argv)
{
osg::ArgumentParser arguments(argc, argv);
arguments.getApplicationUsage()-setApplicationName(arguments.getApplicationName());
arguments.getApplicationUsage()-setDescription(arguments.getApplicationName()+ is an example for viewing osgAnimation animations.);