Geometry class that defined strokes entered by a user. The creation and usage of this class must be followed after certain steps. Here's an example of how to create a new stroke when user is drawing right away:
More...
#include <Stroke.h>
|
| Stroke () |
|
| Stroke (const Stroke ©, const osg::CopyOp ©op=osg::CopyOp::SHALLOW_COPY) |
|
| META_Node (entity, Stroke) void setIsCurved(bool curved) |
|
bool | getIsCurved () const |
|
virtual bool | copyFrom (const entity::ShaderedEntity2D *copy) |
|
virtual bool | redefineToShape (osg::MatrixTransform *t=0) |
|
osg::Node * | getMeshRepresentation () const |
|
float | getLength () const |
|
bool | isLengthy () const |
|
cher::ENTITY_TYPE | getEntityType () const |
|
virtual ProgramStroke * | getProgram () const |
|
virtual void | appendPoint (const float u, const float v) |
|
| ShaderedEntity2D (unsigned int drawing, osg::Geometry::AttributeBinding binding, const std::string &name, const osg::Vec4f &color) |
|
| ShaderedEntity2D (const entity::ShaderedEntity2D ©, const osg::CopyOp ©op) |
|
virtual void | initializeProgram (ProgramEntity2D *p, unsigned int mode=GL_LINE_STRIP) |
|
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 |
|
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) |
|
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) |
|
| Entity2D (const Entity2D ©, const osg::CopyOp ©op=osg::CopyOp::SHALLOW_COPY) |
|
|
osg::ref_ptr< osg::DrawArrays > | m_lines |
|
osg::observer_ptr< ProgramEntity2D > | m_program |
|
bool | m_isShadered |
|
osg::Vec4f | m_colorNormal |
|
osg::Vec4f | m_colorSelected |
|
Geometry class that defined strokes entered by a user. The creation and usage of this class must be followed after certain steps. Here's an example of how to create a new stroke when user is drawing right away:
original->addPoint(u,v);
\\ after user is finished drawing, re-define the look (shaderize as well)
The below example provides details on how to copy/clone a stroke that is already present on the scene graph:
§ Stroke() [1/2]
entity::Stroke::Stroke |
( |
| ) |
|
Constructor that creates an empty stroke.
§ Stroke() [2/2]
entity::Stroke::Stroke |
( |
const Stroke & |
copy, |
|
|
const osg::CopyOp & |
copyop = osg::CopyOp::SHALLOW_COPY |
|
) |
| |
Copy constructor, only used for serialization; not to be used otherwise.
§ appendPoint()
void entity::Stroke::appendPoint |
( |
const float |
u, |
|
|
const float |
v |
|
) |
| |
|
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
-
u | is local U coordinate, |
v | is local V coordinate. |
§ copyFrom()
A method to be used to copy the input geometry data. It is assumed *this is empty.
- Parameters
-
copy | is the source geometry to copy from. |
Reimplemented from entity::ShaderedEntity2D.
§ denormalize()
void entity::Stroke::denormalize |
( |
osg::Vec3Array * |
path, |
|
|
const osg::Vec3f & |
center, |
|
|
double |
scale |
|
) |
| |
|
protected |
A method to denormalize the curve coordinates. Should be used after the curve fitting algorithm.
- See also
- normalize().
§ getCurvePoints()
osg::Vec3Array * entity::Stroke::getCurvePoints |
( |
const osg::Vec3Array * |
bezierPts | ) |
const |
|
protected |
- Returns
- Sampled points from provided set of bezier control points.
§ getEntityType()
cher::ENTITY_TYPE entity::Stroke::getEntityType |
( |
| ) |
const |
|
virtual |
§ getLength()
float entity::Stroke::getLength |
( |
| ) |
const |
- Returns
- length of the stroke, which is measured as a largest dimention of the bounding box around the stroke.
§ getMeshRepresentation()
osg::Node * entity::Stroke::getMeshRepresentation |
( |
| ) |
const |
A method that generates mesh representation of the stroke using Parallel Transport Algorithm.
- Returns
- pointer on the cretated mesh structure. The structure is not attached to the scene graph.
§ isLengthy()
bool entity::Stroke::isLengthy |
( |
| ) |
const |
- Returns
- true if the stroke is longer than allowed threshold, false otherwise.
§ normalize()
double entity::Stroke::normalize |
( |
osg::Vec3Array * |
path, |
|
|
const osg::Vec3f & |
center |
|
) |
| |
|
protected |
A method to make sure the curve is not too small, neither too large for a fitter tolerance level. Nomalization should be applied before the fitting algorithm, and then the result coordinates must get denrmalized back to their true size. The nornalization algorithm is as follows:
- Find center of the points.
- For each curve coordinate, substract a center coordinate from it.
- The scale factor equals to all the squared point deviations devided by total number of the points.
- Scale each coordinate by scale factor.
- Parameters
-
path | is the point array to normalize, |
center | is local 2d center (e.g., bounding box center). |
- Returns
- scaling factor.
§ redefineToShader()
bool entity::Stroke::redefineToShader |
( |
osg::MatrixTransform * |
t | ) |
|
|
protectedvirtual |
A method to tune the look of the stroke with smoother connections and thicker linewidth. So that to avoid broken and thin look of the default OpenGL functionality when using GL_LINE_STRIP_ADJACENCY and such.
Implements entity::ShaderedEntity2D.
§ redefineToShape()
bool entity::Stroke::redefineToShape |
( |
osg::MatrixTransform * |
t = 0 | ) |
|
|
virtual |
A method that fits the stroke's points to a set of curve using Schneider's algorithm.
- Parameters
-
t | is the Canvas matrix transform. If none is provided, the transform of the current canvas is taken. |
tolerance | is the threshold fitting. |
- Returns
- true upon success.
Implements entity::ShaderedEntity2D.
The documentation for this class was generated from the following files:
- src/libSGEntities/Stroke.h
- src/libSGEntities/Stroke.cpp