Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

Teddy::Models::Model Class Reference

#include <Model.h>

Inheritance diagram for Teddy::Models::Model:

Inheritance graph
[legend]
Collaboration diagram for Teddy::Models::Model:

Collaboration graph
[legend]
List of all members.

Public Methods

 Model (std::string name, Model *shape=NULL)
 Create new Model. More...

Teddy::Maths::Matrix getLocalToWorldMatrix () const
Teddy::Maths::Matrix getWorldToLocalMatrix () const
Teddy::Maths::Matrix getViewMatrix () const
Teddy::Maths::Matrix getModelMatrix (Model *camera) const
Teddy::Maths::Matrix getScaledModelMatrix (Model *camera) const
void doMaterial (Teddy::PhysicalComponents::Projection *p, Model *parent=NULL)
 Apply Model material. More...

virtual void draw (Teddy::PhysicalComponents::Projection *p, Model *parent=NULL)
 Drawing the instance. More...

list< Model * > & getChildren ()
void add (Model *child)
 Add child Model. More...

void remove (Model *child)
 Remove child Model. More...

Geometry * getGeometry () const
void setGeometry (Geometry *g)
virtual Teddy::Materials::Material * getMaterial () const
 Return the effective material used for this Model. More...

void setMaterial (Teddy::Materials::Material *m, bool recursive=false)
 Set Model Material. More...

void applyMaterial (const Teddy::PhysicalComponents::Projection &p, Teddy::Materials::Material *material)
void setClipRadius (const double clip_radius)
void setupClipRadius ()
double getClipRadius () const
void add (Element *e)
 Insert Element to Model. More...

void addTri (Vertex *a, Vertex *b, Vertex *c)
void addQuad (Vertex *a, Vertex *b, Vertex *c, Vertex *d)
void addPenta (Vertex *a, Vertex *b, Vertex *c, Vertex *d, Vertex *e)
void addHexa (Vertex *a, Vertex *b, Vertex *c, Vertex *d, Vertex *e, Vertex *f)
void addOcta (Vertex *a, Vertex *b, Vertex *c, Vertex *d, Vertex *e, Vertex *f, Vertex *g, Vertex *h)
void transformVertices (const Teddy::Maths::Matrix &m)
void transformVertices (const Teddy::Maths::Matrix &m, const Teddy::Maths::Matrix &normal_matrix, const bool reverse)
void clearTraversal ()
void truncate ()
Teddy::Maths::Quaternion & getAttitude ()
void copyAttitude (const Model &other)
 Copy orientation (attitude) from other Model. More...

Teddy::Maths::TVector< double > vectorTo (const Model &other) const
 Return vector to other Model. More...

double distanceTo (const Model &other) const
 Return distance to another Model. More...

double distanceTo (const Teddy::Maths::TVector< double > &pos) const
void setPosition (const double x, const double y, const double z)
void setPosition (const Teddy::Maths::TVector< double > &v)
Teddy::Maths::TVector< double > getPosition () const
 Get position relative to parent. More...

void transform (const Teddy::Maths::Matrix &m)
void translate (const Teddy::Maths::TVector< double > &v)
void roll (const double radians)
 Concatenate roll. More...

void pitch (const double radians)
 Concatenate pitch. More...

void heading (const double radians)
 Concatenate heading. More...

void foward (const double l)
 Move Model foward. More...


Static Public Attributes

const unsigned long OPT_VISIBLE = (1ul<<1ul)
const unsigned long OPT_RECURS_MATERIAL = (1ul<<2ul)

Protected Attributes

Teddy::Maths::Quaternion attitude
 Attitude (orientation). More...

Teddy::Maths::TVector< double > position
 Position (location). More...

double clip_radius
 For view volume clipping. More...

list< Model * > children
 Hierarchial. More...

Geometry * geometry
 Geometry. More...

Teddy::Materials::Material * material
 Material property for this Model. More...


Static Protected Attributes

Teddy::Materials::Material * default_material

Detailed Description

This is the base class for all three-dimensional objects which can be part of scene.

Definition at line 61 of file Model.h.


Constructor & Destructor Documentation

Teddy::Models::Model::Model (  std::string    name,
Model *    shape = NULL
) 
 

Create new Model.

Parameters:
name  Name for the new Model
mesh  Model defining shape for the new Model

Definition at line 52 of file Model.cpp.

References add, and setClipRadius.

Referenced by Teddy::Imports::LWLayer::faceList, Teddy::Imports::LWLayer::polygonTags_ID4_d, Teddy::Imports::LWLayer::processLayer, setupClipRadius, and Teddy::Imports::LWLayer::surfaceList.


Member Function Documentation

void Teddy::Models::Model::add (  Element *    e ) 
 

Insert Element to Model.

Parameters:
e  Element which is added to this Model

Definition at line 79 of file Model.cpp.

References geometry.

void Teddy::Models::Model::add (  Model *    child ) 
 

Add child Model.

Definition at line 70 of file Model.cpp.

References children.

Referenced by addHexa, addOcta, addPenta, addQuad, addTri, Teddy::Models::Box::Box, Teddy::Models::Capsule::Capsule, Teddy::Models::Cone::Cone, Teddy::Models::Grid::Grid, Teddy::Imports::LWModel::layer_U2_U2_S0, Teddy::Imports::LWModel::layer_U2_U2_VEC12_S0_U2, Teddy::Imports::LWModel::LWModel, Model, Teddy::Imports::LWLayer::polygonTags_ID4_d, Teddy::Models::Ring::Ring, Teddy::Models::Sphere::Sphere, Teddy::Imports::LWLayer::surfaceList, and Teddy::Models::Torus::Torus.

void Teddy::Models::Model::addHexa (  Vertex *    a,
Vertex *    b,
Vertex *    c,
Vertex *    d,
Vertex *    e,
Vertex *    f
) 
 

Definition at line 256 of file Model.cpp.

References add.

Referenced by Teddy::Models::TruncatedOctahedron::TruncatedOctahedron.

void Teddy::Models::Model::addOcta (  Vertex *    a,
Vertex *    b,
Vertex *    c,
Vertex *    d,
Vertex *    e,
Vertex *    f,
Vertex *    g,
Vertex *    h
) 
 

Definition at line 269 of file Model.cpp.

References add.

Referenced by Teddy::Models::TruncatedCube::TruncatedCube.

void Teddy::Models::Model::addPenta (  Vertex *    a,
Vertex *    b,
Vertex *    c,
Vertex *    d,
Vertex *    e
) 
 

Definition at line 244 of file Model.cpp.

References add.

Referenced by Teddy::Models::Dodecahedron::Dodecahedron.

void Teddy::Models::Model::addQuad (  Vertex *    a,
Vertex *    b,
Vertex *    c,
Vertex *    d
) 
 

Definition at line 233 of file Model.cpp.

References add.

Referenced by Teddy::Models::Cube::Cube, Teddy::Models::Cuboctahedron::Cuboctahedron, Teddy::Models::TruncatedCuboctahedron::TruncatedCuboctahedron, and Teddy::Models::TruncatedOctahedron::TruncatedOctahedron.

void Teddy::Models::Model::addTri (  Vertex *    a,
Vertex *    b,
Vertex *    c
) 
 

Definition at line 223 of file Model.cpp.

References add.

Referenced by Teddy::Models::Cuboctahedron::Cuboctahedron, Teddy::Models::Icosahedron::Icosahedron, Teddy::Models::Octahedron::Octahedron, Teddy::Models::Tetrahedron::Tetrahedron, Teddy::Models::TruncatedCube::TruncatedCube, and Teddy::Models::TruncatedCuboctahedron::TruncatedCuboctahedron.

void Teddy::Models::Model::applyMaterial (  const Teddy::PhysicalComponents::Projection &    p,
Teddy::Materials::Material *    material
) 
 

void Teddy::Models::Model::clearTraversal (    ) 
 

Definition at line 149 of file Model.cpp.

References children, and geometry.

void Teddy::Models::Model::copyAttitude (  const Model &    other ) 
 

Copy orientation (attitude) from other Model.

Parameters:
other  The source Model of the orientation

Definition at line 106 of file ModelTransform.cpp.

References attitude.

double Teddy::Models::Model::distanceTo (  const Teddy::Maths::TVector< double > &    pos )  const
 

double Teddy::Models::Model::distanceTo (  const Model &    other )  const
 

Return distance to another Model.

Parameters:
obj  The other Model to which the distance is calculated
Note:
Distance between object centers is calculated. The actual distance is usually a little less. You might want to substract clip radius of both Models in some cases from the given distance.

Definition at line 78 of file ModelTransform.cpp.

References Teddy::Maths::TVector< double >::distance, and position.

void Teddy::Models::Model::doMaterial (  Teddy::PhysicalComponents::Projection *    p,
Model *    parent = NULL
) 
 

Apply Model material.

Definition at line 43 of file ModelDraw.cpp.

References material.

Referenced by draw.

void Teddy::Models::Model::draw (  Teddy::PhysicalComponents::Projection *    p,
Model *    parent = NULL
)  [virtual]
 

Drawing the instance.

Definition at line 57 of file ModelDraw.cpp.

References children, doMaterial, geometry, getLocalToWorldMatrix, Teddy::MixIn::Options::isEnabled, material, and OPT_VISIBLE.

void Teddy::Models::Model::foward (  const double    len ) 
 

Move Model foward.

Parameters:
len  Amount of translation
Model is translated along its view axis (Z) by len units.

Definition at line 156 of file ModelTransform.cpp.

References attitude, Teddy::Maths::Quaternion::getViewAxis, and translate.

Quaternion & Teddy::Models::Model::getAttitude (    ) 
 

Definition at line 42 of file ModelTransform.cpp.

References attitude.

Referenced by Teddy::Materials::Light::applyLight.

list< Model * > & Teddy::Models::Model::getChildren (    ) 
 

Definition at line 218 of file Model.cpp.

References children.

double Teddy::Models::Model::getClipRadius (    )  const
 

Definition at line 203 of file Model.cpp.

References clip_radius.

Referenced by Teddy::Imports::LWModel::layer_U2_U2_S0, and Teddy::Imports::LWModel::layer_U2_U2_VEC12_S0_U2.

Geometry * Teddy::Models::Model::getGeometry (    )  const
 

Definition at line 213 of file Model.cpp.

References geometry.

Matrix Teddy::Models::Model::getLocalToWorldMatrix (    )  const
 

Simple transformation matrix from local coordinates to world coordinates. No tricks.

localToWolrd() is usually used for model matrices.

Definition at line 56 of file ModelMatrices.cpp.

References attitude, and position.

Referenced by draw.

Material * Teddy::Models::Model::getMaterial (    )  const [virtual]
 

Return the effective material used for this Model.

Note:
Each Model may set material, but it does not have to set it.
If Model has not set material, material of the Model is used when drawing. In such case this method returns the material of the Model.

Definition at line 100 of file Model.cpp.

References material.

Matrix Teddy::Models::Model::getModelMatrix (  Model *    camera )  const
 

Return model matrix, which works by applying camera positioning into objects' model matrices

Definition at line 84 of file ModelMatrices.cpp.

References attitude, and position.

Referenced by getScaledModelMatrix.

TVector< double > Teddy::Models::Model::getPosition (    )  const
 

Get position relative to parent.

Definition at line 54 of file ModelTransform.cpp.

References position.

Referenced by Teddy::Materials::Light::applyLight.

Matrix Teddy::Models::Model::getScaledModelMatrix (  Model *    camera )  const
 

Author:
Sean O'Neil
Return scaled model matrix. Makes all objects fit to depth range, but objects might overlap in z buffer because of this

Definition at line 97 of file ModelMatrices.cpp.

References getModelMatrix, Teddy::Maths::TVector< double >::magnitude, position, and Vector.

Matrix Teddy::Models::Model::getViewMatrix (    )  const
 

Camera matrix which only contains rotations; translations are expexted to be applied into objects' model matrices instead.

Definition at line 70 of file ModelMatrices.cpp.

References attitude.

Matrix Teddy::Models::Model::getWorldToLocalMatrix (    )  const
 

Simple transformation matrix from world coordinates to local coordinates. No tricks.

worldToLocal() is usually used for camera matrices.

Definition at line 39 of file ModelMatrices.cpp.

References attitude, position, and Teddy::Maths::TVector< double >::v.

Referenced by Teddy::Scenes::Camera::doCamera.

void Teddy::Models::Model::heading (  const double    radians ) 
 

Concatenate heading.

Parameters:
radians  Rotation angle in radians
Model is rotated around heading axis (Y) by angle degrees.

Definition at line 144 of file ModelTransform.cpp.

References attitude, Teddy::Maths::Quaternion::getUpAxis, and Teddy::Maths::Quaternion::rotate.

Referenced by Teddy::Behaviour::ModelAnimator::tick.

void Teddy::Models::Model::pitch (  const double    radians ) 
 

Concatenate pitch.

Parameters:
radians  Rotation angle in radians
Model is rotated around pitch axis (X) by angle degrees.

Definition at line 133 of file ModelTransform.cpp.

References attitude, Teddy::Maths::Quaternion::getRightAxis, and Teddy::Maths::Quaternion::rotate.

Referenced by Teddy::Behaviour::ModelAnimator::tick.

void Teddy::Models::Model::remove (  Model *    child ) 
 

Remove child Model.

Definition at line 88 of file Model.cpp.

References children.

void Teddy::Models::Model::roll (  const double    radians ) 
 

Concatenate roll.

Parameters:
radians  Rotation angle in radians
Model is rotated around roll axis (Z) by angle degrees.

Definition at line 122 of file ModelTransform.cpp.

References attitude, Teddy::Maths::Quaternion::getViewAxis, and Teddy::Maths::Quaternion::rotate.

Referenced by Teddy::Behaviour::ModelAnimator::tick.

void Teddy::Models::Model::setClipRadius (  const double    clip_radius ) 
 

Definition at line 198 of file Model.cpp.

References clip_radius.

Referenced by Teddy::Models::Grid::Grid, Teddy::Imports::LWModel::layer_U2_U2_S0, Teddy::Imports::LWModel::layer_U2_U2_VEC12_S0_U2, Model, Teddy::Models::Ring::Ring, and setupClipRadius.

void Teddy::Models::Model::setGeometry (  Geometry *    g ) 
 

Definition at line 208 of file Model.cpp.

References geometry.

Referenced by Teddy::Models::Grid::Grid.

void Teddy::Models::Model::setMaterial (  Teddy::Materials::Material *    m,
bool    recursive = false
) 
 

Set Model Material.

Parameters:
m  Material for this Model

Definition at line 109 of file Model.cpp.

References children, and material.

Referenced by Teddy::Imports::LWModel::LWModel.

void Teddy::Models::Model::setPosition (  const Teddy::Maths::TVector< double > &    v ) 
 

void Teddy::Models::Model::setPosition (  const double    x,
const double    y,
const double    z
) 
 

Definition at line 46 of file ModelTransform.cpp.

References position, and Teddy::Maths::TVector< double >::v.

void Teddy::Models::Model::setupClipRadius (    ) 
 

Definition at line 182 of file Model.cpp.

References children, geometry, Model, and setClipRadius.

Referenced by Teddy::Models::Box::Box, Teddy::Models::Capsule::Capsule, Teddy::Models::Cone::Cone, Teddy::Models::Cube::Cube, Teddy::Models::Cuboctahedron::Cuboctahedron, Teddy::Models::Dodecahedron::Dodecahedron, Teddy::Models::Icosahedron::Icosahedron, Teddy::Imports::LWModel::LWModel, Teddy::Models::Octahedron::Octahedron, Teddy::Models::Sphere::Sphere, Teddy::Models::Tetrahedron::Tetrahedron, Teddy::Models::Torus::Torus, Teddy::Models::TruncatedCube::TruncatedCube, Teddy::Models::TruncatedCuboctahedron::TruncatedCuboctahedron, and Teddy::Models::TruncatedOctahedron::TruncatedOctahedron.

void Teddy::Models::Model::transform (  const Teddy::Maths::Matrix &    m ) 
 

void Teddy::Models::Model::transformVertices (  const Teddy::Maths::Matrix &    m,
const Teddy::Maths::Matrix &    normal_matrix,
const bool    reverse
) 
 

void Teddy::Models::Model::transformVertices (  const Teddy::Maths::Matrix &    m ) 
 

void Teddy::Models::Model::translate (  const Teddy::Maths::TVector< double > &    v ) 
 

Referenced by foward, and Teddy::Behaviour::ModelAnimator::tick.

void Teddy::Models::Model::truncate (    ) 
 

TVector< double > Teddy::Models::Model::vectorTo (  const Model &    other )  const
 

Return vector to other Model.

Parameters:
obj  The other Model to which the delta vector is returned

Definition at line 97 of file ModelTransform.cpp.

References position.


Member Data Documentation

Teddy::Maths::Quaternion Teddy::Models::Model::attitude [protected]
 

Attitude (orientation).

Definition at line 124 of file Model.h.

Referenced by copyAttitude, foward, getAttitude, getLocalToWorldMatrix, getModelMatrix, getViewMatrix, getWorldToLocalMatrix, heading, pitch, and roll.

list<Model*> Teddy::Models::Model::children [protected]
 

Hierarchial.

Definition at line 127 of file Model.h.

Referenced by add, clearTraversal, draw, getChildren, Teddy::Imports::LWLayer::processLayer, remove, setMaterial, and setupClipRadius.

double Teddy::Models::Model::clip_radius [protected]
 

For view volume clipping.

Definition at line 126 of file Model.h.

Referenced by getClipRadius, and setClipRadius.

Teddy::Materials::Material* Teddy::Models::Model::default_material [static, protected]
 

Definition at line 132 of file Model.h.

Geometry* Teddy::Models::Model::geometry [protected]
 

Geometry.

Definition at line 128 of file Model.h.

Referenced by add, clearTraversal, draw, getGeometry, setGeometry, and setupClipRadius.

Teddy::Materials::Material* Teddy::Models::Model::material [protected]
 

Material property for this Model.

Definition at line 129 of file Model.h.

Referenced by doMaterial, draw, getMaterial, and setMaterial.

const unsigned long Teddy::Models::Model::OPT_RECURS_MATERIAL = (1ul<<2ul) [static]
 

Definition at line 44 of file Model.cpp.

const unsigned long Teddy::Models::Model::OPT_VISIBLE = (1ul<<1ul) [static]
 

Definition at line 43 of file Model.cpp.

Referenced by draw.

Teddy::Maths::TVector<double> Teddy::Models::Model::position [protected]
 

Position (location).

Definition at line 125 of file Model.h.

Referenced by distanceTo, getLocalToWorldMatrix, getModelMatrix, getPosition, getScaledModelMatrix, getWorldToLocalMatrix, setPosition, and vectorTo.


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