AGXDynamics  2.35.0.3
PointSpriteDrawable.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2022. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 #ifndef AGXOSG_POINTSPRITEDRAWABLE_H
18 #define AGXOSG_POINTSPRITEDRAWABLE_H
19 
20 #include <agxOSG/export.h>
21 
22 #include <agx/PushDisableWarnings.h> // Disabling warnings. Include agx/PopDisableWarnings.h below!
23 #include <osg/Drawable>
24 #include <osg/Version>
25 #include <agx/PopDisableWarnings.h> // End of disabled warnings.
26 
27 #include <agx/Task.h>
28 #include <agxData/Buffer.h>
29 #include <agxData/Value.h>
30 #include <agxData/Array.h>
31 // #include <agx/Bound.h>
32 #include <agx/Vec3.h>
33 #include <agx/Vec4.h>
34 
35 namespace agxOSG
36 {
37  class AGXOSG_EXPORT PointSpriteDrawable : public osg::Drawable
38  {
39  public:
41  agxData::Buffer *colors, agxData::Buffer *enableRendering,
42  agxData::Value *bound, agx::Component *context);
43 
44  // void set( agxData::Array<agx::Vec3> positions, agxData::Array<agx::Real> radii, agx::Bound3 bound );
45 
46  void setColor(const agx::Vec4& color);
47  void setEnable(bool flag);
48 
49 
51 # if OSG_VERSION_GREATER_OR_EQUAL(3,4,0)
52  virtual osg::BoundingSphere computeBound() const;
53  virtual osg::BoundingBox computeBoundingBox() const;
54 #else
55  virtual osg::BoundingBox computeBound() const;
56 #endif
57 
59  virtual void drawImplementation(osg::RenderInfo& renderInfo) const;
60 
61  public:
62  virtual osg::Object* cloneType() const { return new PointSpriteDrawable (m_positions, m_rotations, m_radii, m_colors, m_enableRendering, m_bound, m_renderTask->getContext()->as<agx::Component>()); }
63  virtual osg::Object* clone(const osg::CopyOp&) const { return new PointSpriteDrawable (*this); }
64  virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const PointSpriteDrawable *>(obj)!=nullptr; }
65  virtual const char* libraryName() const { return "agxOSG"; }
66  virtual const char* className() const { return "PointSpriteDrawable"; }
67 
68  protected:
69  virtual ~PointSpriteDrawable();
70 
71  private:
72  agx::TaskRef m_renderTask;
73  agxData::BufferRef m_positions;
74  agxData::BufferRef m_rotations;
75  agxData::BufferRef m_radii;
76  agxData::BufferRef m_colors;
77  agxData::BufferRef m_enableRendering;
78  agxData::ValueRef m_bound;
79  bool m_enabled;
80 
81  // agxData::Array< agx::Vec3 > m_positions;
82  // agxData::Array< agx::Real > m_radii;
83  // agx::Bound3 m_bound;
84  };
85 
86  typedef osg::ref_ptr<PointSpriteDrawable> PointSpriteDrawableRef;
87 }
88 
89 
90 #endif /* AGXOSG_POINTSPRITEDRAWABLE_H */
agxData::Value
Abstract representation of a value.
Definition: Value.h:42
agxOSG::PointSpriteDrawable::isSameKindAs
virtual bool isSameKindAs(const osg::Object *obj) const
Definition: PointSpriteDrawable.h:64
Task.h
agxOSG::PointSpriteDrawable::clone
virtual osg::Object * clone(const osg::CopyOp &) const
Definition: PointSpriteDrawable.h:63
agxOSG::PointSpriteDrawableRef
osg::ref_ptr< PointSpriteDrawable > PointSpriteDrawableRef
Definition: PointSpriteDrawable.h:86
agx::Vec4T
A class holding 4 dimensional vectors and providing basic arithmetic.
Definition: Vec4Template.h:34
Array.h
Vec4.h
agxOSG::PointSpriteDrawable::cloneType
virtual osg::Object * cloneType() const
Definition: PointSpriteDrawable.h:62
Vec3.h
agx::ref_ptr< Task >
agxOSG
The agxOSG namespace provides functionality for visualizing AGX simulations with OpenSceneGraph.
PushDisableWarnings.h
agxData::Buffer
Abstract representation of a data buffer.
Definition: Buffer.h:55
Buffer.h
agxOSG::PointSpriteDrawable
Definition: PointSpriteDrawable.h:37
agx::Component
A component is an object containing other objects, enabling hierarchical structuring.
Definition: Component.h:38
agxOSG::PointSpriteDrawable::libraryName
virtual const char * libraryName() const
Definition: PointSpriteDrawable.h:65
export.h
agxOSG::PointSpriteDrawable::className
virtual const char * className() const
Definition: PointSpriteDrawable.h:66
Value.h
AGXOSG_EXPORT
#define AGXOSG_EXPORT
PopDisableWarnings.h