cherish
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
entity::ShaderedEntity2D Class Referenceabstract

Abstract class for all the shaderized entities, i.e., strokes, polygons and line segments. More...

#include <ShaderedEntity2D.h>

Inheritance diagram for entity::ShaderedEntity2D:
entity::Entity2D entity::LineSegment entity::Polygon entity::Stroke

Public Member Functions

 ShaderedEntity2D (unsigned int drawing, osg::Geometry::AttributeBinding binding, const std::string &name, const osg::Vec4f &color)
 
 ShaderedEntity2D (const entity::ShaderedEntity2D &copy, const osg::CopyOp &copyop)
 
virtual void initializeProgram (ProgramEntity2D *p, unsigned int mode=GL_LINE_STRIP)
 
virtual bool copyFrom (const entity::ShaderedEntity2D *copy)
 
virtual void appendPoint (const float u, const float v, osg::Vec4f color)
 
virtual osg::Vec2f getPoint (unsigned int i) const
 
virtual osg::Vec3f getPoint3 (unsigned int i) const
 
virtual bool redefineToShape (osg::MatrixTransform *t=0)=0
 
int getNumPoints () const
 
virtual void moveDelta (double du, double dv)
 
virtual void scale (double scaleX, double scaleY, osg::Vec3f center)
 
virtual void scale (double scale, osg::Vec3f center)
 
virtual void rotate (double theta, osg::Vec3f center)
 
virtual cher::ENTITY_TYPE getEntityType () const =0
 
void setLines (osg::DrawArrays *lines)
 
const osg::DrawArrays * getLines () const
 
void setColor (const osg::Vec4f &color)
 
const osg::Vec4f & getColor () const
 
void setSelected (float alpha)
 
void setUnselected (float alpha)
 
void setIsShadered (bool shadered)
 
bool getIsShadered () const
 
virtual void setProgram (ProgramEntity2D *p)
 
virtual ProgramEntity2DgetProgram () const
 
- Public Member Functions inherited from entity::Entity2D
 Entity2D (const Entity2D &copy, const osg::CopyOp &copyop=osg::CopyOp::SHALLOW_COPY)
 

Protected Member Functions

virtual bool redefineToShader (osg::MatrixTransform *t)=0
 

Protected Attributes

osg::ref_ptr< osg::DrawArrays > m_lines
 
osg::observer_ptr< ProgramEntity2Dm_program
 
bool m_isShadered
 
osg::Vec4f m_colorNormal
 
osg::Vec4f m_colorSelected
 

Detailed Description

Abstract class for all the shaderized entities, i.e., strokes, polygons and line segments.

Constructor & Destructor Documentation

§ ShaderedEntity2D() [1/2]

entity::ShaderedEntity2D::ShaderedEntity2D ( unsigned int  drawing,
osg::Geometry::AttributeBinding  binding,
const std::string &  name,
const osg::Vec4f &  color 
)

Constructor that creates an empty shadered entity

§ ShaderedEntity2D() [2/2]

entity::ShaderedEntity2D::ShaderedEntity2D ( const entity::ShaderedEntity2D copy,
const osg::CopyOp &  copyop 
)

Copy constructor to be used only for serializatiob purposes.

Member Function Documentation

§ appendPoint()

void entity::ShaderedEntity2D::appendPoint ( const float  u,
const float  v,
osg::Vec4f  color 
)
virtual

A method to add a point to the end of the entity. It is normally used when constructing an emtity in-motion while sketching.

Parameters
uis local U coordinate,
vis local V coordinate.

§ copyFrom()

bool entity::ShaderedEntity2D::copyFrom ( const entity::ShaderedEntity2D copy)
virtual

A method to be used to copy the input geometry data. It is assumed *this is empty.

Parameters
copyis the source geometry to copy from.

Reimplemented in entity::Stroke.

§ getNumPoints()

int entity::ShaderedEntity2D::getNumPoints ( ) const
Returns
number of vertices.

§ getPoint()

osg::Vec2f entity::ShaderedEntity2D::getPoint ( unsigned int  i) const
virtual
Parameters
iis the point index.
Returns
point coordinates at the specified index.

§ getPoint3()

osg::Vec3f entity::ShaderedEntity2D::getPoint3 ( unsigned int  i) const
virtual
See also
getPoint() but it returns 3d format, e.g. {u,v,0}.

§ initializeProgram()

void entity::ShaderedEntity2D::initializeProgram ( ProgramEntity2D p,
unsigned int  mode = GL_LINE_STRIP 
)
virtual

A method tok be called after it is initialized. It initializes the program that entity is going to use for shadering.

§ moveDelta()

void entity::ShaderedEntity2D::moveDelta ( double  du,
double  dv 
)
virtual

A method to perform translation of the stroke in delta movement.

Parameters
duis delta movement in X local axis direction,
dvis delta movement in Y local axis direction.

Implements entity::Entity2D.

§ redefineToShader()

virtual bool entity::ShaderedEntity2D::redefineToShader ( osg::MatrixTransform *  t)
protectedpure virtual

A method to tune the look of the entity with shader effects.

Implemented in entity::Stroke, entity::Polygon, and entity::LineSegment.

§ redefineToShape()

virtual bool entity::ShaderedEntity2D::redefineToShape ( osg::MatrixTransform *  t = 0)
pure virtual

A method that changed geometry type, e.g. from polyline to polygon. Is used after the user is finished with sketching and now the entity's look can be re-defined as it will appear on the scene permanately.

Parameters
tis the Canvas matrix transform. If none is provided, the transform of the current canvas is taken.
Returns
true upon success.

Implemented in entity::Stroke, and entity::Polygon.

§ rotate()

void entity::ShaderedEntity2D::rotate ( double  theta,
osg::Vec3f  center 
)
virtual

A method to rotate the stroke around a fixed point.

Parameters
thetais angle in radians,
centeris the local 2D center around which to rotate.

Implements entity::Entity2D.

§ scale() [1/2]

void entity::ShaderedEntity2D::scale ( double  scaleX,
double  scaleY,
osg::Vec3f  center 
)
virtual

A method to scale the stroke around a fixed point.

Parameters
scaleXis scaling factor along U local axis,
scaleYis scaling factor along V local axis,
centeris the local 2D center around which to scale.

Implements entity::Entity2D.

§ scale() [2/2]

void entity::ShaderedEntity2D::scale ( double  scale,
osg::Vec3f  center 
)
virtual

A method to uniformely scale the stroke around a fixed point.

Parameters
scaleis scaling factor,
centeris the local 2D center around which to scale.

Implements entity::Entity2D.

§ setSelected()

void entity::ShaderedEntity2D::setSelected ( float  alpha)
virtual
Parameters
alphais transparency channel.

Implements entity::Entity2D.

§ setUnselected()

void entity::ShaderedEntity2D::setUnselected ( float  alpha)
virtual
Parameters
alphais transparency channel.

Implements entity::Entity2D.


The documentation for this class was generated from the following files: