Refactored ImpostorSprite so that it no longer uses GLBeginEndAdapter
This commit is contained in:
@@ -15,8 +15,7 @@
|
||||
#define OSG_ImpostorSprite 1
|
||||
|
||||
#include <osg/Vec2>
|
||||
#include <osg/BoundingSphere>
|
||||
#include <osg/Drawable>
|
||||
#include <osg/Geometry>
|
||||
#include <osg/AlphaFunc>
|
||||
#include <osg/TexEnv>
|
||||
#include <osg/Texture2D>
|
||||
@@ -35,7 +34,7 @@ class ImpostorSpriteManager;
|
||||
* automatically generated by the osgUtil::CullVisitor so it not
|
||||
* necessary to deal with it directly.
|
||||
*/
|
||||
class OSGSIM_EXPORT ImpostorSprite : public osg::Drawable
|
||||
class OSGSIM_EXPORT ImpostorSprite : public osg::Geometry
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -77,23 +76,26 @@ class OSGSIM_EXPORT ImpostorSprite : public osg::Drawable
|
||||
inline unsigned int getLastFrameUsed() const { return _lastFrameUsed; }
|
||||
|
||||
|
||||
void dirty();
|
||||
|
||||
|
||||
/** Get the coordinates of the corners of the quad.
|
||||
* Stored in the order, [0] - top_left, [1] - bottom_left, [2] - bottom_right, [3] - top_left.
|
||||
*/
|
||||
inline osg::Vec3* getCoords() { return _coords; }
|
||||
inline osg::Vec3* getCoords() { return &(_coords->front()); }
|
||||
|
||||
/** Get the const coordinates of the corners of the quad. */
|
||||
inline const osg::Vec3* getCoords() const { return _coords; }
|
||||
inline const osg::Vec3* getCoords() const { return &(_coords->front()); }
|
||||
|
||||
|
||||
|
||||
/** Get the texture coordinates of the corners of the quad.
|
||||
* Stored in the order, [0] - top_left, [1] - bottom_left, [2] - bottom_right, [3] - top_left.
|
||||
*/
|
||||
inline osg::Vec2* getTexCoords() { return _texcoords; }
|
||||
inline osg::Vec2* getTexCoords() { return &(_texcoords->front()); }
|
||||
|
||||
/** Get the const texture coordinates of the corners of the quad. */
|
||||
inline const osg::Vec2* getTexCoords() const { return _texcoords; }
|
||||
inline const osg::Vec2* getTexCoords() const { return &(_texcoords->front()); }
|
||||
|
||||
/** Get the control coordinates of the corners of the quad.
|
||||
* The control coordinates are the corners of the quad projected
|
||||
@@ -125,32 +127,6 @@ class OSGSIM_EXPORT ImpostorSprite : public osg::Drawable
|
||||
int s() const { return _s; }
|
||||
int t() const { return _t; }
|
||||
|
||||
/** Draw ImpostorSprite directly. */
|
||||
virtual void drawImplementation(osg::RenderInfo& renderInfo) const;
|
||||
|
||||
/** Return true, osg::ImpostorSprite does support accept(Drawable::AttributeFunctor&). */
|
||||
virtual bool supports(const Drawable::AttributeFunctor&) const { return true; }
|
||||
|
||||
/** Accept an Drawable::AttributeFunctor and call its methods to tell it about the internal attributes that this Drawable has. */
|
||||
virtual void accept(Drawable::AttributeFunctor& af);
|
||||
|
||||
/** Return true, osg::ImpostorSprite does support accept(Drawable::ConstAttributeFunctor&). */
|
||||
virtual bool supports(const Drawable::ConstAttributeFunctor&) const { return true; }
|
||||
|
||||
/** Accept a Drawable::ConstAttributeFunctor and call its methods to tell it about the internal attributes that this Drawable has. */
|
||||
virtual void accept(Drawable::ConstAttributeFunctor& af) const;
|
||||
|
||||
/** Return true, osg::ImpostorSprite does support accept(PrimitiveFunctor&). */
|
||||
virtual bool supports(const osg::PrimitiveFunctor&) const { return true; }
|
||||
|
||||
/** Accept a PrimtiveFunctor and call its methods to tell it about the internal primitives that this Drawable has. */
|
||||
virtual void accept(osg::PrimitiveFunctor& pf) const;
|
||||
|
||||
// for debugging purposes.
|
||||
osg::Vec4 _color;
|
||||
|
||||
virtual osg::BoundingBox computeBoundingBox() const;
|
||||
|
||||
/** Set the camera node to use for pre rendering the impostor sprite's texture.*/
|
||||
void setCamera(osg::Camera* camera) { _camera = camera; }
|
||||
|
||||
@@ -167,6 +143,8 @@ class OSGSIM_EXPORT ImpostorSprite : public osg::Drawable
|
||||
|
||||
virtual ~ImpostorSprite();
|
||||
|
||||
void init();
|
||||
|
||||
Impostor* _parent;
|
||||
|
||||
friend class osgSim::ImpostorSpriteManager;
|
||||
@@ -184,8 +162,8 @@ class OSGSIM_EXPORT ImpostorSprite : public osg::Drawable
|
||||
|
||||
osg::Vec3 _storedLocalEyePoint;
|
||||
|
||||
osg::Vec3 _coords[4];
|
||||
osg::Vec2 _texcoords[4];
|
||||
osg::ref_ptr<osg::Vec3Array> _coords;
|
||||
osg::ref_ptr<osg::Vec2Array> _texcoords;
|
||||
osg::Vec3 _controlcoords[4];
|
||||
|
||||
osg::Texture2D* _texture;
|
||||
|
||||
Reference in New Issue
Block a user