資源簡介
main.cpp
代碼片段和文件信息
#include?“../Common/Common.h“
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#ifdef?_DEBUG
#pragma?comment(lib?“../Debug/Commond.lib“)
#else
#pragma?comment(lib?“../Release/Common.lib“)
#endif
osg::ref_ptr?CreateBox()
{
????osg::ref_ptr?geode?=?new?osg::Geode;
????osg::ref_ptr?hints?=?new?osg::TessellationHints;
????osg::ref_ptr?shape?=?new?osg::ShapeDrawable(new?osg::Box(osg::Vec3(0.0?0.0?0.0)?1.0?10.0?10.0)?hints.get());
????osg::ref_ptr?material?=?new?osg::Material;
????osg::ref_ptr?texture2D?=?new?osg::Texture2D;
????osg::ref_ptr?image;
????//設置顏色
????shape->setColor(osg::Vec4(0.5?0.5?0.5?0.1));
????//設置精度
????hints->setDetailRatio(0.5);
????//設置材質
????material->setAmbient(osg::Material::FRONT_AND_BACK?osg::Vec4f(1.0?1.0?1.0?0.5));
????material->setDiffuse(osg::Material::FRONT_AND_BACK?osg::Vec4f(1.0?1.0?1.0?0.5));
????material->setSpecular(osg::Material::FRONT_AND_BACK?osg::Vec4f(1.0?1.0?1.0?0.5));
????material->setShininess(osg::Material::FRONT_AND_BACK?6.0);
????//設置紋理
????image?=?osgDB::readImageFile(“Images/whitemetal_diffuse.jpg“);
????if(image.valid())
????{
???????texture2D->setImage(image.get());
????}
????//set?state
????geode->getOrCreateStateSet()->setAttributeAndModes(material.get()?osg::StateAttribute::ON);
????geode->getOrCreateStateSet()->setMode(GL_BLEND?osg::StateAttribute::ON);
????geode->getOrCreateStateSet()->setMode(GL_DEPTH_TEST?osg::StateAttribute::ON);
????geode->getOrCreateStateSet()->setTextureAttributeAndModes(0?texture2D.get()?osg::StateAttribute::ON);
????geode->addDrawable(shape.get());
????return?
- 上一篇:MFC讀寫CSV文件
- 下一篇:C++ Builder利用PDFLib生成PDF文檔
評論
共有 條評論