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

Teddy::Models Namespace Reference


Compounds

class  Teddy::Models::Box
 Box shaped Model. More...

class  Teddy::Models::Capsule
 Capsule shaped Model. More...

class  Teddy::Models::Cone
 Cone shaped Model. More...

class  Teddy::Models::Cube
class  Teddy::Models::Cuboctahedron
class  Teddy::Models::Cylinder
 Cylinder shaped Model. More...

class  Teddy::Models::Dodecahedron
class  Teddy::Models::Element
 A simple renderable part of Geometry. More...

class  Teddy::Models::Face
 Ordered collection of vertices to define a polygon. More...

class  Teddy::Models::Geometry
 Geometry maintains modelling data for part of Model. No materials. More...

class  Teddy::Models::Grid
 Tis is Grid primitive model. More...

class  Teddy::Models::Icosahedron
class  Teddy::Models::Line
 Line Element. More...

class  Teddy::Models::LineGeometry
 A set of lines, suitable for grid for example. More...

class  Teddy::Models::Model
class  Teddy::Models::Octahedron
class  Teddy::Models::PointGeometry
 Collection of Vertex Elements drawn as GL_POINTS. More...

class  Teddy::Models::Quads
class  Teddy::Models::QuadStrip
 Q uadStrip Element builds up a quad strip from its vertices. More...

class  Teddy::Models::Rhombicosidodecahedron
class  Teddy::Models::Rhomicuboctahedron
class  Teddy::Models::Ring
 Ring shaped Model. More...

class  Teddy::Models::Sphere
 Sphere shaped Model. More...

class  Teddy::Models::Tetrahedron
class  Teddy::Models::Torus
 Torus (donought) shape. More...

class  Teddy::Models::TriangleFan
 TriangleFan Element builds up a triangle fan from its vertices. More...

class  Teddy::Models::Triangles
class  Teddy::Models::TriangleStrip
class  Teddy::Models::TruncatedCube
class  Teddy::Models::TruncatedCuboctahedron
class  Teddy::Models::TruncatedDodecahedron
class  Teddy::Models::TruncatedIcosahedron
class  Teddy::Models::TruncatedIcosidodecahedron
class  Teddy::Models::TruncatedOctahedron
class  Teddy::Models::TruncatedTetrahedron
class  Teddy::Models::Vertex
 Defines one point of polygon or line or other element. More...


Functions

void xyz_to_h (const float x, const float y, const float z, float &h)
 This subroutine is used by texture coordinate calculations. More...

void xyz_to_hp (float x, float y, float z, float &h, float &p)
 This subroutine is used by texture coordinate calculations. More...

float fract (float f)
 This subroutine is used by texture coordinate calculations. More...


Variables

const double sq2 = sqrt( 2.0 )
const double sq3 = sqrt( 3.0 )
const double sq5 = sqrt( 5.0 )


Detailed Description

\section section_models_intro Introduction to Models

Models namespace contains classes to maintain model modeling and rendering data.

Model represents a renderable object. Each model defines shape, material, location and orientation.

The shape of a Model is defined by a Geometry object. Geometry object contains elements such as vertices, lines, polygons, trinagle strips etc. Each Vertex may spesify space coordinate, texture coordinate, color value and normal coordinates.

The material of a Model is defined by a Material object. Material object spesifies lighting properties like ambient, diffuse and specular color components, together with possible Texture spesification.

Location and orientation of a Model should be accessed through Model::getPosition(), Model::setPosition(), Model::getAttitude() and Model::setAttitude() -methods.

Models can be hierarchial. Model can have children models. This can be used in to ways. First, one can build complex objects from several different simpler parts by making each part a separate Model, and adding these parts as children to a single Model. Second, the same Model can be used in several objects by adding the 'shape' Model as a child to several other 'instance' Models. The instance models can spesify independent position and orientation, but they use the same shape Model for drawing.

If a Model does not spesify materiel, and it is drawn as child of some other Model, it will use the material from its parent Model. This way the same shape can be drawn in different naterials on different Models.

\section section_hierarchial_models More about hierarchial models

Each Model has material, geometry and set of children. If the material is set, that material is used to draw the geometry.

If you want to have object with multiple materials, you must divide the object into multiple parts. For each part you make a separate Model. The shape data is placed into geometry of the model as usual, but now each submodel can also have their own material. Finally you need one parent Model into which you place the sub models as children.

I really should do an example showing power of this. I might even try doing it tonight

A moderately complex draft for this example is below.. it is a car :)

To make up a simple car model I want to have single box representing a body and four cylinders representing tires. The body is red and tires are black.

create reusable shapes

Box *body = new Box(...); Cylinder *tire = new Cylinder(...);

create one instance of car Model *car = new Model(...); Model *front_left_tire = new Model(...); Model *front_right_tire = new Model(...); Model *rear_left_tire = new Model(...); Model *rear_right_tire = new Model(...); front_left_tire .add( tire ); // use the shape from tire, do not redefine front_right_tire.add( tire ); // use the shape from tire, do not redefine rear_left_tire .add( tire ); // use the shape from tire, do not redefine rear_right_tire .add( tire ); // use the shape from tire, do not redefine car.add( body ); car.add( front_left_tire ); car.add( front_right_tire ); car.add( rear_left_tire ); car.add( rear_right_tire );

Now you have option to set materials either for body and tire, or car, front_left_tire, front_right_tire, rear_left_tire and rear_right_tire.

If you do spesify material for tire, then all tires will use that material.

If you do not spesify material for body (set it to NULL), then when the car is drawn its body will be drawn using the material set for the car. This way you can have several cars using the same body but different material.

While this is not about materials, I'll mention it here because it is related to the hierarchial Models and use of child Models. If you transform tire, say, turn it left a bit. This would affect all tires - nasty, you probably dont want that. But if you had

Model *front_tire = new Model(...); front_tire.add( tire );

and

front_left_tire .add( front_tire ); // change initial example front_right_tire.add( front_tire ); // change initial example

then turning the front_tire would turn both front tires at the same time, and this could be actually be useful somewhere (while this example still is not realistic)..


Function Documentation

float fract float    f [static]
 

This subroutine is used by texture coordinate calculations.

Definition at line 90 of file GeometryTextureCoordinates.cpp.

Referenced by Teddy::Models::Geometry::makeCylindricalTextureCoordinates, and Teddy::Models::Geometry::makeSphericalTextureCoordinates.

void xyz_to_h const float    x,
const float    y,
const float    z,
float &    h
[static]
 

This subroutine is used by texture coordinate calculations.

Definition at line 42 of file GeometryTextureCoordinates.cpp.

Referenced by Teddy::Models::Geometry::makeCylindricalTextureCoordinates.

void xyz_to_hp float    x,
float    y,
float    z,
float &    h,
float &    p
[static]
 

This subroutine is used by texture coordinate calculations.

Definition at line 58 of file GeometryTextureCoordinates.cpp.

Referenced by Teddy::Models::Geometry::makeSphericalTextureCoordinates.


Variable Documentation

const double Teddy::Models::sq2 = sqrt( 2.0 ) [static]
 

Definition at line 34 of file Solids.cpp.

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

const double Teddy::Models::sq3 = sqrt( 3.0 ) [static]
 

Definition at line 35 of file Solids.cpp.

Referenced by Teddy::Models::Cube::Cube, Teddy::Models::Dodecahedron::Dodecahedron, Teddy::Models::Tetrahedron::Tetrahedron, and Teddy::Models::TruncatedCuboctahedron::TruncatedCuboctahedron.

const double Teddy::Models::sq5 = sqrt( 5.0 ) [static]
 

Definition at line 36 of file Solids.cpp.

Referenced by Teddy::Models::Dodecahedron::Dodecahedron, Teddy::Models::Icosahedron::Icosahedron, and Teddy::Models::TruncatedOctahedron::TruncatedOctahedron.