|
楼主 |
发表于 2014-4-1 21:51:19
|
显示全部楼层
是的。但是添加了操作器后屏幕一片空白,方块也没有显示出来。会不会是osg::ShapeDrawable的问题呢?
我把我的代码贴出来了,方便的话可不可以帮我看一下问题出在哪儿?
#include <osgViewer/Viewer>
#include<osg/Node>
#include<osg/Geode>
#include<osg/Group>
#include<osg/ShapeDrawable>
#include<osgDB/ReadFile>
#include<osgDB/WriteFile>
#include <osgGA/TrackballManipulator>
#include<osgUtil/Optimizer>
const float pi = atan(1.0f)*4;
int main()
{
osg::ref_ptr<osgViewer::Viewer> viewer= new osgViewer::Viewer();
osg::ref_ptr<osg::Group> root= new osg::Group();
osg::ShapeDrawable* box;
root->addChild(createCube(box));
viewer->setSceneData(root.get());
viewer->realize();
viewer->setCameraManipulator(new osgGA::TrackballManipulator);
//position the camera
osg::Matrixd myCameraMatrix;
osg::Matrixd cameraRotation;
osg::Matrixd cameraTrans;
cameraRotation.makeRotate(
osg:egreesToRadians(-20.0), osg::Vec3(0,1,0), // roll
osg::DegreesToRadians(-15.0), osg::Vec3(1,0,0) , // pitch
osg::DegreesToRadians( 10.0), osg::Vec3(0,0,1) ); // heading
cameraTrans.makeTranslate( 10,-50,15 );
myCameraMatrix = cameraRotation * cameraTrans;
viewer->getCameraManipulator()->setByMatrix(myCameraMatrix);
viewer->run();
return 0;
} |
|