diff --git a/examples/slideshow3D/ReaderWriterXML.cpp b/examples/slideshow3D/ReaderWriterXML.cpp index 61c385aa0..ff0c95fde 100644 --- a/examples/slideshow3D/ReaderWriterXML.cpp +++ b/examples/slideshow3D/ReaderWriterXML.cpp @@ -228,16 +228,42 @@ void ReaderWriterSS3D::parseModel(SlideShowConstructor& constructor, xmlDocPtr d else std::cout<<"Parser error - coordinate_frame=\""<getBound(); - float model_scale = scale*_slideHeight*0.7f/bs.radius(); + float model_scale = scale*_slideHeight*(1.0f-position.z())*0.7f/bs.radius(); osg::MatrixTransform* transform = new osg::MatrixTransform; transform->setDataVariance(osg::Object::STATIC); @@ -416,11 +416,14 @@ void SlideShowConstructor::addModel(const std::string& filename, CoordinateFrame } else { + osg::Matrix matrix(osg::Matrix::scale(1.0f/scale,1.0f/scale,1.0f/scale)* + osg::Matrix::rotate(osg::DegreesToRadians(rotate[0]),rotate[1],rotate[2],rotate[3])* + osg::Matrix::translate(position)); + + osg::MatrixTransform* transform = new osg::MatrixTransform; transform->setDataVariance(osg::Object::STATIC); - transform->setMatrix(osg::Matrix::translate(-position)* - osg::Matrix::scale(scale,scale,scale)* - osg::Matrix::rotate(osg::DegreesToRadians(rotate[0]),rotate[1],rotate[2],rotate[3])); + transform->setMatrix(osg::Matrix::inverse(matrix)); transform->addChild(model); @@ -586,6 +589,7 @@ void SlideShowConstructor::addModelWithCameraPath(const std::string& filename, C { osg::MatrixTransform* animation_transform = new osg::MatrixTransform; animation_transform->setDataVariance(osg::Object::DYNAMIC); + animation_transform->setReferenceFrame(osg::Transform::RELATIVE_TO_ABSOLUTE); osg::AnimationPathCallback* apc = new osg::AnimationPathCallback(animation); apc->setUseInverseMatrix(true); @@ -593,14 +597,16 @@ void SlideShowConstructor::addModelWithCameraPath(const std::string& filename, C animation_transform->setUpdateCallback(apc); animation_transform->addChild(transform); - osg::MatrixTransform* orientation_transform = new osg::MatrixTransform; - orientation_transform->setDataVariance(osg::Object::STATIC); - orientation_transform->addChild(animation_transform); - - //orientation_transform->setMatrix(osg::Matrix::rotate(osg::DegreesToRadians(-00.0f),0.0f,1.0f,0.0f)); - orientation_transform->setMatrix(osg::Matrix::inverse(osg::Matrix::lookAt(osg::Vec3(0.0,0.0,0.0),osg::Vec3(0.0,1.0,0.0),osg::Vec3(0.0,0.0,1.0)))); + _currentLayer->addChild(animation_transform); - _currentLayer->addChild(orientation_transform); +// osg::MatrixTransform* orientation_transform = new osg::MatrixTransform; +// orientation_transform->setDataVariance(osg::Object::STATIC); +// orientation_transform->addChild(animation_transform); +// +// //orientation_transform->setMatrix(osg::Matrix::rotate(osg::DegreesToRadians(-00.0f),0.0f,1.0f,0.0f)); +// orientation_transform->setMatrix(osg::Matrix::inverse(osg::Matrix::lookAt(osg::Vec3(0.0,0.0,0.0),osg::Vec3(0.0,1.0,0.0),osg::Vec3(0.0,0.0,1.0)))); +// +// _currentLayer->addChild(orientation_transform); } else diff --git a/examples/slideshow3D/SlideShowConstructor.h b/examples/slideshow3D/SlideShowConstructor.h index 3b3db704a..13cb8fd21 100644 --- a/examples/slideshow3D/SlideShowConstructor.h +++ b/examples/slideshow3D/SlideShowConstructor.h @@ -90,6 +90,7 @@ public: protected: osg::Vec3 _slideOrigin; + osg::Vec3 _eyeOrigin; float _slideWidth; float _slideHeight; float _slideDistance;