RenderTools::Curve< T > Class Template Reference

#include <Curve.h>

Inheritance diagram for RenderTools::Curve< T >:

RenderTools::AbstractCurve RenderTools::Rendernode RenderTools::UpdateInterface RenderTools::BindingInterface RenderTools::RenderInterface RenderTools::RelationalNode RenderTools::TransformNode RenderTools::AbstractPropertyContainer RenderTools::ContainerProperty RenderTools::AbstractProperty RenderTools::InitializeInterface

List of all members.

Public Member Functions

 Curve (void)
virtual ~Curve (void)
virtual void createProperties (void)
virtual const string getTypeName (bool ofComponent=false) const
virtual void onUpdate (void)
virtual void clear (void)
 must be implemented
void addKnot (const T &knot, int index=-1, bool rebuild=true)
 must be implemented
void removeKnot (unsigned int index, bool rebuild=true)
T & getKnot (unsigned int index)
const T & getKnot (unsigned int index) const
unsigned int getNumKnots (void) const
vector< T > & getKnots (void)
const vector< T > & getKnots (void) const
T & getPoint (unsigned int index)
const T & getPoint (unsigned int index) const
unsigned int getNumPoints (void) const
vector< T > & getPoints (void)
const vector< T > & getPoints (void) const
T & getTangent (unsigned int index)
const T & getTangent (unsigned int index) const
unsigned int getNumTangents (void) const
vector< T > & getTangents (void)
const vector< T > & getTangents (void) const

Static Public Member Functions

static PropertyPtr create (const XMLNodePtr &xml=XMLNodePtr())

Protected Attributes

vector< T > m_knots
vector< T > m_points
vector< T > m_tangents


Detailed Description

template<class T = Vec3>
class RenderTools::Curve< T >

Warning:
template class must be either: Vec2, Vec3 or Vec4

Definition at line 14 of file Curve.h.


Constructor & Destructor Documentation

template<class T >
RenderTools::Curve< T >::Curve ( void   )  [inline]

Definition at line 52 of file Curve.h.

template<class T >
RenderTools::Curve< T >::~Curve ( void   )  [inline, virtual]

Definition at line 57 of file Curve.h.


Member Function Documentation

template<class T >
void RenderTools::Curve< T >::addKnot ( const T &  knot,
int  index = -1,
bool  rebuild = true 
) [inline]

must be implemented

Definition at line 79 of file Curve.h.

template<class T >
void RenderTools::Curve< T >::clear ( void   )  [inline, virtual]

must be implemented

Implements RenderTools::AbstractCurve.

Definition at line 108 of file Curve.h.

template<class T = Vec3>
static PropertyPtr RenderTools::Curve< T >::create ( const XMLNodePtr xml = XMLNodePtr()  )  [static]

Reimplemented from RenderTools::AbstractCurve.

template<class T >
void RenderTools::Curve< T >::createProperties ( void   )  [inline, virtual]

Reimplemented from RenderTools::AbstractCurve.

Definition at line 62 of file Curve.h.

template<class T >
const T & RenderTools::Curve< T >::getKnot ( unsigned int  index  )  const [inline]

bogus vector return

Definition at line 115 of file Curve.h.

template<class T >
T & RenderTools::Curve< T >::getKnot ( unsigned int  index  )  [inline]

bogus vector return

Definition at line 128 of file Curve.h.

template<class T >
const vector< T > & RenderTools::Curve< T >::getKnots ( void   )  const [inline]

Definition at line 146 of file Curve.h.

template<class T = Vec3>
vector< T >& RenderTools::Curve< T >::getKnots ( void   ) 

template<class T >
unsigned int RenderTools::Curve< T >::getNumKnots ( void   )  const [inline]

Definition at line 141 of file Curve.h.

template<class T >
unsigned int RenderTools::Curve< T >::getNumPoints ( void   )  const [inline]

Definition at line 151 of file Curve.h.

template<class T >
unsigned int RenderTools::Curve< T >::getNumTangents ( void   )  const [inline]

Definition at line 187 of file Curve.h.

template<class T >
const T & RenderTools::Curve< T >::getPoint ( unsigned int  index  )  const [inline]

bogus vector return

Definition at line 161 of file Curve.h.

template<class T >
T & RenderTools::Curve< T >::getPoint ( unsigned int  index  )  [inline]

bogus vector return

Definition at line 174 of file Curve.h.

template<class T >
const vector< T > & RenderTools::Curve< T >::getPoints ( void   )  const [inline]

Definition at line 156 of file Curve.h.

template<class T = Vec3>
vector< T >& RenderTools::Curve< T >::getPoints ( void   ) 

template<class T >
const T & RenderTools::Curve< T >::getTangent ( unsigned int  index  )  const [inline]

bogus vector return

Definition at line 197 of file Curve.h.

template<class T >
T & RenderTools::Curve< T >::getTangent ( unsigned int  index  )  [inline]

bogus vector return

Definition at line 210 of file Curve.h.

template<class T >
const vector< T > & RenderTools::Curve< T >::getTangents ( void   )  const [inline]

Definition at line 192 of file Curve.h.

template<class T = Vec3>
vector< T >& RenderTools::Curve< T >::getTangents ( void   ) 

template<class T >
const string RenderTools::Curve< T >::getTypeName ( bool  ofComponent = false  )  const [inline, virtual]

Reimplemented from RenderTools::AbstractCurve.

Definition at line 68 of file Curve.h.

template<class T >
void RenderTools::Curve< T >::onUpdate ( void   )  [inline, virtual]

a closed curve needs three or more knotpoints

points & tangents is what we calculate here

don't need to do anything

except add the beginning to the end if closed

subdivide the curve given by m_knots

start a new iteration with an empty curve

keep the last point

keep the new curve

store the smoothed curve

calculate the tangents for each point

interpolate and store in m_points

find the four vertices 'surrounding' [i] and [i+1]

we look at segment i, i+1

if we're on the last point

if closed, bridge the gap

if open, don't start a new segment

check if we're on the first segment

wrap around to the last point

extend the first segment 'backwards'

take the previous point

this is the actual segment we want to process

check if we're on the last segment

if closed, wrap to the beginning

else extend the last segment by itself

take the next knot-point

process v1->v2

make sure we don't include the endpoint

if we're not processing the last segment (open or closed)

See also:
http://local.wasp.uwa.edu.au/~pbourke/miscellaneous/interpolation/
average & interpolate the tangents

TODO: make sure we don't get degenerate tangents

Implements RenderTools::UpdateInterface.

Definition at line 223 of file Curve.h.

template<class T >
void RenderTools::Curve< T >::removeKnot ( unsigned int  index,
bool  rebuild = true 
) [inline]

Definition at line 95 of file Curve.h.


Member Data Documentation

template<class T = Vec3>
vector<T> RenderTools::Curve< T >::m_knots [protected]

Definition at line 45 of file Curve.h.

template<class T = Vec3>
vector<T> RenderTools::Curve< T >::m_points [protected]

Definition at line 46 of file Curve.h.

template<class T = Vec3>
vector<T> RenderTools::Curve< T >::m_tangents [protected]

Definition at line 47 of file Curve.h.


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

Generated on Wed Jan 26 00:15:36 2011 for RenderTools by  doxygen 1.5.8