先来看看ShapeDrawable,这个类继承Drawable,是用来绘制简单的几何体。
在Drawable中定义了ref_ptr<Shape> _shape;几何体的类型基类,
class Sphere;
class Box;
class Cone;
class Cylinder;
class Capsule;
class InfinitePlane;
class TriangleMesh;
class ConvexHull;
class HeightField;
class CompositeShape;
都是继承Shape,这些是osg中自带的几何体。
我们从Drawable的drawImplementation开始研究它是怎么实现的,之前我们说过Drawable的绘制是从古drawImplementation这个函数,ShapeDrawable同样是这个函数,进去看看:
void ShapeDrawable::drawImplementation(RenderInfo& renderInfo) const
{
osg::State& state = *renderInfo.getState();
GLBeginEndAdapter& gl = state.getGLBeginEndAdapter();
if (_shape.valid())
{
gl.Color4fv(_color.ptr());
DrawShapeVisitor dsv(state,_tessellationHints.get());
在Drawable中定义了ref_ptr<Shape> _shape;几何体的类型基类,
class Sphere;
class Box;
class Cone;
class Cylinder;
class Capsule;
class InfinitePlane;
class TriangleMesh;
class ConvexHull;
class HeightField;
class CompositeShape;
都是继承Shape,这些是osg中自带的几何体。
我们从Drawable的drawImplementation开始研究它是怎么实现的,之前我们说过Drawable的绘制是从古drawImplementation这个函数,ShapeDrawable同样是这个函数,进去看看:
void ShapeDrawable::drawImplementation(RenderInfo& renderInfo) const
{
osg::State& state = *renderInfo.getState();
GLBeginEndAdapter& gl = state.getGLBeginEndAdapter();
if (_shape.valid())
{
gl.Color4fv(_color.ptr());
DrawShapeVisitor dsv(state,_tessellationHints.get());