|
楼主 |
发表于 2014-10-26 12:52:07
|
显示全部楼层
嘿嘿,老师现在是画上了,但是黑点太小了。。。。我salce 32 32 32怎么还不行呢?
- #include <osgViewer/Viewer>
- #include <osgDB/ReadFile>
- #include <osg/geode>
- #include <osg/LineWidth>
- #include <osg/MatrixTransform>
- #include <osg/Point>
- #include <osgViewer/Viewer>
- #include <osgDB/ReadFile>
- #include <osg/Node>
- #include <osg/Geode>
- #include <osg/Geometry>
- #include <osg/ShapeDrawable>
- #include <osg/MatrixTransform>
- #include <osgViewer/Viewer>
- #include <osgDB/ReadFile>
- #include <osgGA/TrackballManipulator>
- /*#include <osgOcean/OceanScene>
- #include <osgOcean/FFTOceanSurface> */
- #include <osgViewer/ViewerEventHandlers>
- #include <osg/TextureCubeMap>
- #include <osg/MatrixTransform>
- #pragma comment(lib,"OpenThreadsd.lib")
- #pragma comment(lib,"osgd.lib")
- #pragma comment(lib,"osgDBd.lib")
- #pragma comment(lib,"osgAPExd.lib")
- #pragma comment(lib,"osgGAd.lib")
- #pragma comment(lib,"osgUtild.lib")
- #pragma comment(lib,"osgTextd.lib")
- #pragma comment(lib,"osgSimd.lib")
- #pragma comment(lib,"osgViewerd.lib")
- int _tmain(int argc, _TCHAR* argv[])
- {
- osg::ref_ptr<osgViewer::Viewer> viewer = new osgViewer::Viewer;
- osg::ref_ptr<osg::Group> g_Root = new osg::Group;
- osg::ref_ptr<osg::Geode> pNode = new osg::Geode;
- osg::ref_ptr<osg::Vec3Array> VertexV3a = new osg::Vec3Array;
- osg::Geometry* PolygonGeometry = new osg::Geometry;
- osg::StateSet* PolygonStateset = new osg::StateSet;
- PolygonGeometry->setStateSet(PolygonStateset);
- if(!pNode)
- return 0;
- VertexV3a->push_back(osg::Vec3(-1.02168, -2.15188, 0.885735));
- // pass the created vertex array to the points geometry object.
- PolygonGeometry->setVertexArray(VertexV3a);
- osg::Vec4Array* colors = new osg::Vec4Array;
- // add a white color, colors take the form r,g,b,a with 0.0 off, 1.0 full on.
- colors->push_back(osg::Vec4(1.0f,1.0f,0.0f,1.0f));
- // pass the color array to points geometry, note the binding to tell the geometry
- // that only use one color for the whole object.
- PolygonGeometry->setColorArray(colors);
- PolygonGeometry->setColorBinding(osg::Geometry::BIND_OVERALL);
- osg::ref_ptr <osg::Point> ptSize = new osg::Point;
- ptSize->setSize( 12.0) ;
- PolygonStateset->setAttributeAndModes(ptSize.get(),osg::StateAttribute::ON);
- // set the normal in the same way color.
- osg::Vec3Array* normals = new osg::Vec3Array;
- normals->push_back(osg::Vec3(0.0f,-1.0f,0.0f));
- PolygonGeometry->setNormalArray(normals);
- PolygonGeometry->setNormalBinding(osg::Geometry::BIND_OVERALL);
- PolygonGeometry->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::POINTS,0,VertexV3a->size()));
- osgGA::TrackballManipulator *tb = new osgGA::TrackballManipulator;
- tb->setHomePosition(osg::Vec3d(0.0,0.0,0.0),osg::Vec3d(-1.02168, -2.15188, 0.885735),osg::Z_AXIS);
- viewer->setCameraManipulator(tb);
- pNode->addDrawable(PolygonGeometry);
- osg::MatrixTransform* mt = new osg::MatrixTransform;
- mt->setMatrix(osg::Matrixd::scale(33,33,33));
- mt->addChild(pNode);
- g_Root->addChild(mt);
- viewer->getCamera()->setCullingMode(viewer->getCamera()->getCullingMode()&~osg::CullSettings::SMALL_FEATURE_CULLING);
- viewer->setSceneData(g_Root);
- viewer->run();
- return 0;
- }
复制代码 |
|