天天看点

osg--几种效果billboards

billboards

适用于小草等的绘制

osg::BillBoard继承自osg::Geode,其下所有osg::Drawable面向观察者。旋转行为通过setMode()设置,分别为

  • POINT_ROT_EYE 几何体z轴旋转到窗口y轴
  • POINT_ROT_WORLD
  • AXIAL_ROT
    • setAxis()

锚点

billboard->addDrawable( child, osg::Vec3(1.0f, 0.0f, 0.0f) );

正向

setNormal()

默认法线是几何体的-y轴

示例

#include <osg/Billboard>
#include <osg/Texture2D>
#include <osgDB/ReadFile>
#include <osgViewer/Viewer>

osg::Geometry* createQuad()
{
	osg::ref_ptr<osg::Texture2D> texture = new osg::Texture2D;
	osg::ref_ptr<osg::Image> image =
		osgDB::readImageFile("Images/osg256.png");
	texture->setImage(image.get());

	osg::ref_ptr<osg::Geometry> quad =
		osg::createTexturedQuadGeometry(
			osg::Vec3(-0.5f, 0.0f, -0.5f),
			osg::Vec3(1.0f, 0.0f, 0.0f),
			osg: