固定的正交像機_用於觀察採樣貼圖_爲屏幕空間環境光遮蔽作準備

記錄這種像機怎麼設置 像機將會盯着承載採樣貼圖的面片不動code

osg::Camera* texCamera = new osg::Camera;
	texCamera->setGraphicsContext(gc);
	texCamera->setClearMask(GL_COLOR_BUFFER_BIT);
	texCamera->setClearColor(osg::Vec4(0.0, 0.0, 0.0, 0.0));
	texCamera->setReferenceFrame(osg::Camera::ABSOLUTE_RF);
	texCamera->setViewport(0, 0, 800, 600);
	texCamera->setDrawBuffer(GL_BACK);
	texCamera->setReadBuffer(GL_BACK);
	texCamera->addChild(geodeQuad);
	texCamera->setAllowEventFocus(false);
	texCamera->setCullingMode(osg::CullSettings::NO_CULLING);
	texCamera->setProjectionResizePolicy(osg::Camera::FIXED);
	viewer1->setCamera(texCamera);

面片的代碼:get

#include <osg/Texture2D>
osg::Geode* createTextureQuad(osg::Texture2D *texture)
{
	osg::Vec3Array *vertices = new osg::Vec3Array;
	vertices->push_back(osg::Vec3(-1.0, -1.0, 0.0));
	vertices->push_back(osg::Vec3(1.0, -1.0, 0.0));
	vertices->push_back(osg::Vec3(1.0, 1.0, 0.0));
	vertices->push_back(osg::Vec3(-1.0, 1.0, 0.0));

	osg::Vec2Array *texcoord = new osg::Vec2Array;
	texcoord->push_back(osg::Vec2(0.0, 0.0));
	texcoord->push_back(osg::Vec2(1.0, 0.0));
	texcoord->push_back(osg::Vec2(1.0, 1.0));
	texcoord->push_back(osg::Vec2(0.0, 1.0));

	osg::Geometry *geom = new osg::Geometry;
	geom->setVertexArray(vertices);
	geom->setTexCoordArray(0, texcoord);
	geom->addPrimitiveSet(new osg::DrawArrays(GL_QUADS, 0, 4));

	osg::Geode *geode = new osg::Geode;
	geode->addDrawable(geom);
	geode->getOrCreateStateSet()->setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON);

	return geode;
}

這兩段是從osgfpdepth.cpp中抄來的, 這個OSG例子的目的是使用顯卡的多重採樣抗鋸齒的功能.it

相關文章
相關標籤/搜索