OpenSceneGraph 3.6.5
ImpostorSprite
Go to the documentation of this file.
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 *
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version. The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * OpenSceneGraph Public License for more details.
12*/
13
14#ifndef OSG_ImpostorSprite
15#define OSG_ImpostorSprite 1
16
17#include <osg/Vec2>
18#include <osg/Geometry>
19#include <osg/AlphaFunc>
20#include <osg/TexEnv>
21#include <osg/Texture2D>
22#include <osg/Camera>
23
24#include <osgSim/Export>
25
26namespace osgSim {
27
28class Impostor;
29class ImpostorSpriteManager;
30
38{
39 public:
40
42
44 virtual osg::Object* cloneType() const { return new ImpostorSprite(); }
45
49 virtual osg::Object* clone(const osg::CopyOp&) const { return new ImpostorSprite(); }
50 virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const ImpostorSprite*>(obj)!=NULL; }
51 virtual const char* libraryName() const { return "osgSim"; }
52 virtual const char* className() const { return "ImpostorSprite"; }
53
58 void setParent(Impostor* parent) { _parent = parent; }
59
61 Impostor* getParent() { return _parent; }
62
64 const Impostor* getParent() const { return _parent; }
65
68
70 inline const osg::Vec3& getStoredLocalEyePoint() const { return _storedLocalEyePoint; }
71
73 inline void setLastFrameUsed(unsigned int frameNumber) { _lastFrameUsed = frameNumber; }
74
76 inline unsigned int getLastFrameUsed() const { return _lastFrameUsed; }
77
78
79 void dirty();
80
81
85 inline osg::Vec3* getCoords() { return &(_coords->front()); }
86
88 inline const osg::Vec3* getCoords() const { return &(_coords->front()); }
89
90
91
95 inline osg::Vec2* getTexCoords() { return &(_texcoords->front()); }
96
98 inline const osg::Vec2* getTexCoords() const { return &(_texcoords->front()); }
99
113
115 inline const osg::Vec3* getControlCoords() const { return _controlcoords; }
116
117
121 float calcPixelError(const osg::Matrix& MVPW) const;
122
123 void setTexture(osg::Texture2D* tex,int s,int t);
125 const osg::Texture2D* getTexture() const { return _texture; }
126
127 int s() const { return _s; }
128 int t() const { return _t; }
129
131 void setCamera(osg::Camera* camera) { _camera = camera; }
132
134 osg::Camera* getCamera() { return _camera.get(); }
135
137 const osg::Camera* getCamera() const { return _camera.get(); }
138
139 protected:
140
142 ImpostorSprite& operator = (const ImpostorSprite&) { return *this;}
143
145
146 void init();
147
149
151
152 // camera node for doing the pre rendering.
154
155 // support for a double linked list managed by the
156 // ImposotorSpriteManager.
160
161 unsigned int _lastFrameUsed;
162
164
168
170 int _s;
171 int _t;
172
173
174};
175
178{
179 public:
180
182
183 bool empty() const { return _first==0; }
184
186
187 ImpostorSprite* last() { return _last; }
188
190
192
193 ImpostorSprite* createOrReuseImpostorSprite(int s,int t,unsigned int frameNumber);
194
196
197 void reset();
198
199 protected:
200
201
203
206
209
210 typedef std::vector< osg::ref_ptr<osg::StateSet> > StateSetList;
213
214
215};
216
217}
218
219#endif
Vec2f Vec2
Definition Vec2:21
Vec3f Vec3
Definition Vec3:21
Matrixd Matrix
Definition Matrix:27
The osgSim library is a NodeKit that extends the core scene graph to support nodes and drawables that...
Definition BlinkSequence:27
Camera - is a subclass of Transform which represents encapsulates the settings of a Camera.
Definition Camera:45
Copy Op(erator) used to control whether shallow or deep copy is used during copy construction and clo...
Definition CopyOp:41
Definition Geometry:31
Base class/standard interface for objects which require IO support, cloning and reference counting.
Definition Object:61
Smart pointer for handling referenced counted objects.
Definition ref_ptr:32
Base class for providing reference counted objects.
Definition Referenced:44
Stores a set of modes and attributes which represent a set of OpenGL state.
Definition StateSet:46
Encapsulates OpenGL 2D texture functionality.
Definition Texture2D:25
Impostor - is a form of Level Of Detail group node which allows both switching between children depen...
Definition Impostor:65
An ImposterSprite is a textured quad which is rendered in place of 3D geometry.
Definition ImpostorSprite:38
ImpostorSpriteManager * _ism
Definition ImpostorSprite:157
osg::Camera * getCamera()
Get the camera node to use for pre rendering the impostor sprite's texture.
Definition ImpostorSprite:134
const osg::Vec3 * getCoords() const
Get the const coordinates of the corners of the quad.
Definition ImpostorSprite:88
int _t
Definition ImpostorSprite:171
ImpostorSprite * _next
Definition ImpostorSprite:159
osg::Vec3 * getCoords()
Get the coordinates of the corners of the quad.
Definition ImpostorSprite:85
unsigned int _lastFrameUsed
Definition ImpostorSprite:161
Impostor * getParent()
Get the parent, which is an Impostor.
Definition ImpostorSprite:61
const osg::Camera * getCamera() const
Get the const camera node to use for pre rendering the impostor sprite's texture.
Definition ImpostorSprite:137
void setStoredLocalEyePoint(const osg::Vec3 &v)
Set the eye point for when the ImpostorSprite was snapped.
Definition ImpostorSprite:67
virtual bool isSameKindAs(const osg::Object *obj) const
return true if this and obj are of the same kind of object.
Definition ImpostorSprite:50
Impostor * _parent
Definition ImpostorSprite:148
osg::ref_ptr< osg::Camera > _camera
Definition ImpostorSprite:153
osg::Vec3 * getControlCoords()
Get the control coordinates of the corners of the quad.
Definition ImpostorSprite:112
osg::ref_ptr< osg::Vec2Array > _texcoords
Definition ImpostorSprite:166
void setLastFrameUsed(unsigned int frameNumber)
Set the frame number for when the ImpostorSprite was last used in rendering.
Definition ImpostorSprite:73
int _s
Definition ImpostorSprite:170
const osg::Vec3 * getControlCoords() const
Get the const control coordinates of the corners of the quad.
Definition ImpostorSprite:115
ImpostorSprite(const ImpostorSprite &)
const Impostor * getParent() const
Get the const parent, which is an Impostor.
Definition ImpostorSprite:64
osg::Vec2 * getTexCoords()
Get the texture coordinates of the corners of the quad.
Definition ImpostorSprite:95
void setParent(Impostor *parent)
Set the parent, which must be an Impostor.
Definition ImpostorSprite:58
void setTexture(osg::Texture2D *tex, int s, int t)
virtual const char * libraryName() const
return the name of the node's library.
Definition ImpostorSprite:51
const osg::Vec3 & getStoredLocalEyePoint() const
Get the eye point for when the ImpostorSprite was snapped.
Definition ImpostorSprite:70
unsigned int getLastFrameUsed() const
Get the frame number for when the ImpostorSprite was last used in rendering.
Definition ImpostorSprite:76
friend class osgSim::ImpostorSpriteManager
Definition ImpostorSprite:150
virtual osg::Object * cloneType() const
Clone an object of the same type as an ImpostorSprite.
Definition ImpostorSprite:44
ImpostorSprite * _previous
Definition ImpostorSprite:158
const osg::Texture2D * getTexture() const
Definition ImpostorSprite:125
osg::Texture2D * getTexture()
Definition ImpostorSprite:124
osg::ref_ptr< osg::Vec3Array > _coords
Definition ImpostorSprite:165
int t() const
Definition ImpostorSprite:128
osg::Vec3 _storedLocalEyePoint
Definition ImpostorSprite:163
const osg::Vec2 * getTexCoords() const
Get the const texture coordinates of the corners of the quad.
Definition ImpostorSprite:98
void setCamera(osg::Camera *camera)
Set the camera node to use for pre rendering the impostor sprite's texture.
Definition ImpostorSprite:131
virtual const char * className() const
return the name of the node's class type.
Definition ImpostorSprite:52
osg::Vec3 _controlcoords[4]
Definition ImpostorSprite:167
int s() const
Definition ImpostorSprite:127
virtual osg::Object * clone(const osg::CopyOp &) const
Clone on ImpostorSprite just returns a clone of type, since it is not appropriate to share data of an...
Definition ImpostorSprite:49
osg::Texture2D * _texture
Definition ImpostorSprite:169
float calcPixelError(const osg::Matrix &MVPW) const
Calculate the pixel error value for passing in the ModelViewProjectionWindow transform,...
Helper class for managing the reuse of ImpostorSprite resources.
Definition ImpostorSprite:178
ImpostorSprite * first()
Definition ImpostorSprite:185
bool empty() const
Definition ImpostorSprite:183
std::vector< osg::ref_ptr< osg::StateSet > > StateSetList
Definition ImpostorSprite:210
ImpostorSprite * _last
Definition ImpostorSprite:208
osg::StateSet * createOrReuseStateSet()
void push_back(ImpostorSprite *is)
void remove(ImpostorSprite *is)
ImpostorSprite * _first
Definition ImpostorSprite:207
unsigned int _reuseStateSetIndex
Definition ImpostorSprite:212
ImpostorSprite * last()
Definition ImpostorSprite:187
StateSetList _stateSetList
Definition ImpostorSprite:211
osg::ref_ptr< osg::TexEnv > _texenv
Definition ImpostorSprite:204
osg::ref_ptr< osg::AlphaFunc > _alphafunc
Definition ImpostorSprite:205
ImpostorSprite * createOrReuseImpostorSprite(int s, int t, unsigned int frameNumber)
#define NULL
Definition Export:55
#define OSGSIM_EXPORT
Definition Export:38

osg logo
Generated at Wed Jul 23 2025 00:00:00 for the OpenSceneGraph by doxygen 1.14.0.