hi, I am using 3.4.0 with VisualStudio 2013, Win 8.1/x64, which all built fine (examples all work as expected).
So, I wrote a very simple program, which unfortunately renders the cube offset from the horizontal axis, instead of being centered. The bounding sphere center = 0,0,0. If I instead add: view1.setUpViewInWindow(0, 0, image_width, image_height); then it renders as expected at the center of the window with the default node trackball camera manipulator. Would anyone have a clue why am I observing this behavior and how to correct the problem? #include "stdafx.h" #include <stdio.h> #include <stdlib.h> #include <iostream> #include <osg/Node> #include <osg/Group> #include <osg/Geode> #include <osg/Geometry> #include <osgDB/ReadFile> #include <osgGA/TrackballManipulator> #include <osg/ShapeDrawable> #include <osg/MatrixTransform> #include <osg/StateAttribute> #include <osg/PositionAttitudeTransform> #include <osgGA/NodeTrackerManipulator> #include <osg/LineWidth> #include <osg/Transform> #include <osgText/Text> #include <osgUtil/PolytopeIntersector> #include <osgViewer/Viewer> #include <osg/Viewport> #include <osg/NodeCallback> #include <osg/Notify> #include <ctype.h> int _tmain(int argc, _TCHAR* argv[]) { float dimx = 2.0, dimy = 2.0, dimz = 2.0; osg::ref_ptr<osg::Box> cube_primitive(new osg::Box(osg::Vec3f(0, 0, 0), dimx, dimy, dimz)); osg::ref_ptr<osg::ShapeDrawable> shape(new osg::ShapeDrawable(cube_primitive.get())); shape->setColor(osg::Vec4(8.0, 0.2, 0.0, 1.0)); osg::ref_ptr<osg::Geode> shapegeode = new osg::Geode; shapegeode->addDrawable(shape.get()); osg::Group * SceneNode = new osg::Group; SceneNode->addChild(shapegeode); osg::BoundingSphere bsphere = SceneNode->getBound(); osg::Vec3d center = bsphere.center(); printf(" *****bsphere: %f,%f,%f\n", center.x(), center.y(), center.z()); osgViewer::Viewer view1; view1.setSceneData(SceneNode); view1.realize(); view1.run(); return 0; }
_______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org