Ogre Procedural
0.3.0 unstable
Procedural Geometry & Textures for Ogre3D

#include <ProceduralShape.h>
Public Member Functions  
Shape ()  
Default constructor. More...  
Shape &  addPoint (const Ogre::Vector2 &pt) 
Adds a point to the shape. More...  
Shape &  addPoint (Ogre::Real x, Ogre::Real y) 
Adds a point to the shape. More...  
Shape &  insertPoint (size_t index, Ogre::Real x, Ogre::Real y) 
Inserts a point to the shape. More...  
Shape &  insertPoint (size_t index, const Ogre::Vector2 &pt) 
Inserts a point to the shape. More...  
Shape &  addPointRel (const Ogre::Vector2 &pt) 
Adds a point to the shape, relative to the last point added. More...  
Shape &  addPointRel (Ogre::Real x, Ogre::Real y) 
Adds a point to the shape, relative to the last point added. More...  
Shape &  appendShape (const Shape &other) 
Appends another shape at the end of this one. More...  
Shape &  appendShapeRel (const Shape &other) 
Appends another shape at the end of this one, relative to the last point of this shape. More...  
Shape  extractSubShape (unsigned int first, unsigned int last) 
Extracts a part of the shape as a new shape. More...  
Shape &  reverse () 
Reverses direction of the shape The outside is preserved. More...  
Shape &  reset () 
Clears the content of the shape. More...  
Path  convertToPath () const 
Converts the shape to a path, with Y=0. More...  
Track  convertToTrack (Track::AddressingMode addressingMode=Track::AM_RELATIVE_LINEIC) const 
Outputs a track, with Key=X and Value=Y. More...  
std::vector< Ogre::Vector2 >  getPoints () const 
Gets a copy of raw vector data of this shape. More...  
std::vector< Ogre::Vector2 > &  getPointsReference () 
Gets raw vector data of this shape as a nonconst reference. More...  
const std::vector< Ogre::Vector2 > &  getPointsReference () const 
Gets raw vector data of this shape as a nonconst reference. More...  
const Ogre::Vector2 &  getPoint (int i) const 
Boundssafe method to get a point : it will allow you to go beyond the bounds. More...  
unsigned int  getBoundedIndex (int i) const 
const std::vector< Ogre::Vector2 >::size_type  getPointCount () const 
Gets number of points in current point list. More...  
Shape &  close () 
Makes the shape a closed shape, ie it will automatically connect the last point to the first point. More...  
Shape &  setOutSide (Side side) 
Sets which side (left or right) is on the outside of the shape. More...  
Side  getOutSide () const 
Gets which side is out. More...  
Shape &  switchSide () 
Switches the inside and the outside. More...  
size_t  getSegCount () const 
Gets the number of segments in that shape. More...  
bool  isClosed () const 
Gets whether the shape is closed or not. More...  
Ogre::Vector2  getDirectionAfter (unsigned int i) const 
Returns local direction after the current point. More...  
Ogre::Vector2  getDirectionBefore (unsigned int i) const 
Returns local direction after the current point. More...  
Ogre::Vector2  getAvgDirection (unsigned int i) const 
Gets the average between before direction and after direction. More...  
Ogre::Vector2  getNormalAfter (unsigned int i) const 
Gets the shape normal just after that point. More...  
Ogre::Vector2  getNormalBefore (unsigned int i) const 
Gets the shape normal just before that point. More...  
Ogre::Vector2  getAvgNormal (unsigned int i) const 
Gets the "normal" of that point ie an average between before and after normals. More...  
Ogre::MeshPtr  realizeMesh (const std::string &name="") const 
Outputs a mesh representing the shape. More...  
void  _appendToManualObject (Ogre::ManualObject *manual) const 
Appends the shape vertices to a manual object being edited. More...  
bool  isPointInside (const Ogre::Vector2 &point) const 
Tells whether a point is inside a shape or not. More...  
MultiShape  booleanIntersect (const Shape &other) const 
Computes the intersection between this shape and another one. More...  
MultiShape  booleanUnion (const Shape &other) const 
Computes the union between this shape and another one. More...  
MultiShape  booleanDifference (const Shape &other) const 
Computes the difference between this shape and another one. More...  
Side  findRealOutSide () const 
On a closed shape, find if the outside is located on the right or on the left. More...  
bool  isOutsideRealOutside () const 
Determines whether the outside as defined by user equals "real" outside. More...  
Shape  mergeKeysWithTrack (const Track &track) const 
Creates a shape with the keys of this shape and extra keys coming from a track. More...  
Shape &  translate (const Ogre::Vector2 &translation) 
Applies the given translation to all the points already defined. More...  
Shape &  translate (Ogre::Real translationX, Ogre::Real translationY) 
Applies the given translation to all the points already defined. More...  
Shape &  rotate (Ogre::Radian angle) 
Applies the given rotation to all the points already defined. More...  
Shape &  scale (Ogre::Real amount) 
Applies the given scale to all the points already defined. More...  
Shape &  scale (Ogre::Real scaleX, Ogre::Real scaleY) 
Applies the given scale to all the points already defined. More...  
Shape &  scale (const Ogre::Vector2 &amount) 
Applies the given scale to all the points already defined. More...  
Shape &  reflect (const Ogre::Vector2 &normal) 
Reflect all points in this shape against a zeroorigined line with a given normal. More...  
Shape &  mirror (bool flip=false) 
Create a symetric copy at the origin point. More...  
Shape &  mirror (Ogre::Real x, Ogre::Real y, bool flip=false) 
Create a symetric copy at a given point. More...  
Shape &  mirrorAroundPoint (Ogre::Vector2 point, bool flip=false) 
Create a symetric copy at a given point. More...  
Shape &  mirrorAroundAxis (const Ogre::Vector2 &axis, bool flip=false) 
Create a symetric copy at a given axis. More...  
Ogre::Real  getTotalLength () const 
Returns the total lineic length of that shape. More...  
Ogre::Vector2  getPosition (unsigned int i, Ogre::Real coord) const 
Gets a position on the shape with index of the point and a percentage of position on the segment. More...  
Ogre::Vector2  getPosition (Ogre::Real coord) const 
Gets a position on the shape from lineic coordinate. More...  
Ogre::Real  findBoundingRadius () const 
Computes the radius of a bounding circle centered on the origin. More...  
MultiShape  thicken (Ogre::Real amount) 
Applies a "thickness" to a shape, ie a bit like the extruder, but in 2D. More...  
Describes a succession of interconnected 2D points. It can be closed or not, and there's always an outside and an inside
Procedural::Shape::Shape  (  ) 
Default constructor.
void Procedural::Shape::_appendToManualObject  (  Ogre::ManualObject *  manual  )  const 
Appends the shape vertices to a manual object being edited.
Shape& Procedural::Shape::addPoint  (  const Ogre::Vector2 &  pt  ) 
Adds a point to the shape.
Referenced by extractSubShape(), Procedural::RectangleShape::realizeShape(), Procedural::CircleShape::realizeShape(), Procedural::EllipseShape::realizeShape(), and Procedural::TriangleShape::realizeShape().
Shape& Procedural::Shape::addPoint  (  Ogre::Real  x, 
Ogre::Real  y  
) 
Adds a point to the shape.
Shape& Procedural::Shape::addPointRel  (  const Ogre::Vector2 &  pt  ) 
Adds a point to the shape, relative to the last point added.
Shape& Procedural::Shape::addPointRel  (  Ogre::Real  x, 
Ogre::Real  y  
) 
Adds a point to the shape, relative to the last point added.
Appends another shape at the end of this one.
Appends another shape at the end of this one, relative to the last point of this shape.
MultiShape Procedural::Shape::booleanDifference  (  const Shape &  other  )  const 
Computes the difference between this shape and another one.
Both shapes must be closed.
other  The shape against which the diffenrence is computed 
Ogre::InvalidStateException  Current shapes must be closed and has to contain at least 2 points! 
Ogre::InvalidParametersException  Other shapes must be closed and has to contain at least 2 points! 
MultiShape Procedural::Shape::booleanIntersect  (  const Shape &  other  )  const 
Computes the intersection between this shape and another one.
Both shapes must be closed.
other  The shape against which the intersection is computed 
Ogre::InvalidStateException  Current shapes must be closed and has to contain at least 2 points! 
Ogre::InvalidParametersException  Other shapes must be closed and has to contain at least 2 points! 
MultiShape Procedural::Shape::booleanUnion  (  const Shape &  other  )  const 
Computes the union between this shape and another one.
Both shapes must be closed.
other  The shape against which the union is computed 
Ogre::InvalidStateException  Current shapes must be closed and has to contain at least 2 points! 
Ogre::InvalidParametersException  Other shapes must be closed and has to contain at least 2 points! 
Shape& Procedural::Shape::close  (  ) 
Makes the shape a closed shape, ie it will automatically connect the last point to the first point.
Referenced by extractSubShape(), Procedural::RectangleShape::realizeShape(), Procedural::CircleShape::realizeShape(), Procedural::EllipseShape::realizeShape(), and Procedural::TriangleShape::realizeShape().
Path Procedural::Shape::convertToPath  (  )  const 
Converts the shape to a path, with Y=0.
Track Procedural::Shape::convertToTrack  (  Track::AddressingMode  addressingMode = Track::AM_RELATIVE_LINEIC  )  const 
Outputs a track, with Key=X and Value=Y.
Shape Procedural::Shape::extractSubShape  (  unsigned int  first, 
unsigned int  last  
) 
Extracts a part of the shape as a new shape.
first  first index to be in the new shape 
last  last index to be in the new shape 
References addPoint(), close(), and setOutSide().
Ogre::Real Procedural::Shape::findBoundingRadius  (  )  const 
Computes the radius of a bounding circle centered on the origin.
References Ogre::Math::Sqrt().
Side Procedural::Shape::findRealOutSide  (  )  const 
On a closed shape, find if the outside is located on the right or on the left.
If the outside can easily be guessed in your context, you'd rather use setOutside(), which doesn't need any computation.
Ogre::Vector2 Procedural::Shape::getAvgDirection  (  unsigned int  i  )  const 
Gets the average between before direction and after direction.
References Vector< 2, Real >::normalisedCopy().
Ogre::Vector2 Procedural::Shape::getAvgNormal  (  unsigned int  i  )  const 
Gets the "normal" of that point ie an average between before and after normals.
References Procedural::SIDE_RIGHT.
unsigned int Procedural::Shape::getBoundedIndex  (  int  i  )  const 
References Procedural::Utils::cap(), and Procedural::Utils::modulo().
Ogre::Vector2 Procedural::Shape::getDirectionAfter  (  unsigned int  i  )  const 
Returns local direction after the current point.
References Vector< 2, Real >::normalisedCopy().
Ogre::Vector2 Procedural::Shape::getDirectionBefore  (  unsigned int  i  )  const 
Returns local direction after the current point.
References Vector< 2, Real >::normalisedCopy().
Ogre::Vector2 Procedural::Shape::getNormalAfter  (  unsigned int  i  )  const 
Gets the shape normal just after that point.
References Procedural::SIDE_RIGHT.
Ogre::Vector2 Procedural::Shape::getNormalBefore  (  unsigned int  i  )  const 
Gets the shape normal just before that point.
References Procedural::SIDE_RIGHT.
Side Procedural::Shape::getOutSide  (  )  const 
Gets which side is out.
const Ogre::Vector2& Procedural::Shape::getPoint  (  int  i  )  const 
Boundssafe method to get a point : it will allow you to go beyond the bounds.
const std::vector<Ogre::Vector2>::size_type Procedural::Shape::getPointCount  (  )  const 
Gets number of points in current point list.
std::vector<Ogre::Vector2> Procedural::Shape::getPoints  (  )  const 
Gets a copy of raw vector data of this shape.
std::vector<Ogre::Vector2>& Procedural::Shape::getPointsReference  (  ) 
Gets raw vector data of this shape as a nonconst reference.
const std::vector<Ogre::Vector2>& Procedural::Shape::getPointsReference  (  )  const 
Gets raw vector data of this shape as a nonconst reference.
Ogre::Vector2 Procedural::Shape::getPosition  (  Ogre::Real  coord  )  const 
Gets a position on the shape from lineic coordinate.
coord  lineic coordinate 
Ogre::InvalidStateException  The shape must at least contain 2 points 
References Ogre::Exception::ERR_INVALID_STATE, getPosition(), and OGRE_EXCEPT.
Ogre::Vector2 Procedural::Shape::getPosition  (  unsigned int  i, 
Ogre::Real  coord  
)  const 
Gets a position on the shape with index of the point and a percentage of position on the segment.
i  index of the segment 
coord  a number between 0 and 1 meaning the percentage of position on the segment 
Ogre::InvalidParametersException  i is out of bounds 
Ogre::InvalidParametersException  coord must be comprised between 0 and 1 
References Ogre::Exception::ERR_INVALIDPARAMS, and OGRE_EXCEPT.
size_t Procedural::Shape::getSegCount  (  )  const 
Gets the number of segments in that shape.
Ogre::Real Procedural::Shape::getTotalLength  (  )  const 
Returns the total lineic length of that shape.
Shape& Procedural::Shape::insertPoint  (  size_t  index, 
const Ogre::Vector2 &  pt  
) 
Inserts a point to the shape.
index  the index before the inserted point 
pt  new point's position 
Shape& Procedural::Shape::insertPoint  (  size_t  index, 
Ogre::Real  x,  
Ogre::Real  y  
) 
Inserts a point to the shape.
index  the index before the inserted point 
x  new point's x coordinate 
y  new point's y coordinate 
bool Procedural::Shape::isClosed  (  )  const 
Gets whether the shape is closed or not.
bool Procedural::Shape::isOutsideRealOutside  (  )  const 
Determines whether the outside as defined by user equals "real" outside.
bool Procedural::Shape::isPointInside  (  const Ogre::Vector2 &  point  )  const 
Tells whether a point is inside a shape or not.
point  The point to check 
Creates a shape with the keys of this shape and extra keys coming from a track.
track  the track to merge keys with 
Shape& Procedural::Shape::mirror  (  bool  flip = false  ) 
Create a symetric copy at the origin point.
flip  true if function should start mirroring with the last point in list (default false ) 
Shape& Procedural::Shape::mirror  (  Ogre::Real  x, 
Ogre::Real  y,  
bool  flip = false 

) 
Create a symetric copy at a given point.
x  x coordinate of point where to mirror 
y  y coordinate of point where to mirror 
flip  true if function should start mirroring with the last point in list (default false ) 
Shape& Procedural::Shape::mirrorAroundAxis  (  const Ogre::Vector2 &  axis, 
bool  flip = false 

) 
Create a symetric copy at a given axis.
axis  Axis where to mirror 
flip  true if function should start mirroring with the first point in list (default false ) 
References Vector< 2, Real >::normalisedCopy(), and Vector< 2, Real >::reflect().
Shape& Procedural::Shape::mirrorAroundPoint  (  Ogre::Vector2  point, 
bool  flip = false 

) 
Create a symetric copy at a given point.
point  Point where to mirror 
flip  true if function should start mirroring with the last point in list (default false ) 
Ogre::MeshPtr Procedural::Shape::realizeMesh  (  const std::string &  name = ""  )  const 
Outputs a mesh representing the shape.
Mostly for debugging purposes
Shape& Procedural::Shape::reflect  (  const Ogre::Vector2 &  normal  ) 
Shape& Procedural::Shape::reset  (  ) 
Clears the content of the shape.
Shape& Procedural::Shape::reverse  (  ) 
Reverses direction of the shape The outside is preserved.
Shape& Procedural::Shape::rotate  (  Ogre::Radian  angle  ) 
Applies the given rotation to all the points already defined.
Has strictly no effect on the points defined after that
angle  angle of rotation 
References Ogre::Math::Cos(), Ogre::Math::Sin(), and Ogre::Radian::valueRadians().
Shape& Procedural::Shape::scale  (  const Ogre::Vector2 &  amount  ) 
Applies the given scale to all the points already defined.
Has strictly no effect on the points defined after that
amount  of scale 
Shape& Procedural::Shape::scale  (  Ogre::Real  amount  ) 
Applies the given scale to all the points already defined.
Has strictly no effect on the points defined after that
amount  amount of scale 
Shape& Procedural::Shape::scale  (  Ogre::Real  scaleX, 
Ogre::Real  scaleY  
) 
Applies the given scale to all the points already defined.
Has strictly no effect on the points defined after that
scaleX  amount of scale in the X direction 
scaleY  amount of scale in the Y direction 
Sets which side (left or right) is on the outside of the shape.
It is used for such things as normal generation Default is right, which corresponds to placing points anticlockwise.
Referenced by extractSubShape().
Shape& Procedural::Shape::switchSide  (  ) 
Switches the inside and the outside.
References Procedural::SIDE_LEFT, and Procedural::SIDE_RIGHT.
MultiShape Procedural::Shape::thicken  (  Ogre::Real  amount  ) 
Applies a "thickness" to a shape, ie a bit like the extruder, but in 2D.
Shape& Procedural::Shape::translate  (  const Ogre::Vector2 &  translation  ) 
Applies the given translation to all the points already defined.
Has strictly no effect on the points defined after that
translation  the translation vector 
Referenced by Procedural::TriangleShape::realizeShape().
Shape& Procedural::Shape::translate  (  Ogre::Real  translationX, 
Ogre::Real  translationY  
) 
Applies the given translation to all the points already defined.
Has strictly no effect on the points defined after that
translationX  X component of the translation vector 
translationY  Y component of the translation vector 
References translate().