|
楼主 |
发表于 2009-10-12 22:28:30
|
显示全部楼层
- #include <stdafx.h>
- #include <osgDB/ReadFile>
- #include <osgViewer/Viewer>
- #include <osg/Node>
- #include <osg/MatrixTransform>
- #include <osgGA/MatrixManipulator>
- void main()
- {
- osgViewer::Viewer viewer;
- osg::ref_ptr<osg::Group> root = new osg::Group;
- osg::ref_ptr<osg::Node> tank = new osg::Node;
- osg::ref_ptr<osg::Node> terrain = new osg::Node;
- osg::ref_ptr<osg::MatrixTransform> trans = new osg::MatrixTransform;
-
- osg::Matrix mr;
- //mr.translate(osg::Vec3(0.f,0.f,10.f));
- trans->setMatrix(mr);
- //mr.scale(osg::Vec3(5.f,5.f,5.f));
- mr.rotate(osg::DegreesToRadians(90.f),osg::Vec3(1.f,0.f,0.f));
- terrain = osgDB::readNodeFile("lz.osg");
- spaceship= osgDB::readNodeFile("spaceship.osg");
- trans->addChild(spaceship);
- root->addChild(trans);
- //root->addChild(terrain);
- viewer.setSceneData(root.get());
-
- viewer.getCamera()->setViewMatrixAsLookAt(osg::Vec3(0.f,0.f,10.f),osg::Vec3(0.f,0.f,-10.f),osg::Vec3(0.f,10.f,0.f));
- viewer.realize();
- viewer.run();
- }
复制代码 |
|