class Ast3DFract: public Ast

This class represent a asteroid with a 3D random fractal shape

Inheritance:


Public Fields

[more]Mesh M
The mesh representing the asteroid shape

Public Methods

[more] Ast3DFract(char *filename="tetra.raw")
Default constructor
[more]void Draw()
Draw the asteroid shape
[more]void Split(int seed, float strenght=1)
This function split each triangle of the mesh into four smaller triangles
[more]Point3f MidPoint( Point3f &p0, Point3f &p1, Point3f const &BC, int seed, float strengh)
This function calculates a point on an edge that is slightly perturbed form its original midpoint position

Inherited from Ast:

Public Fields

ofloat size

Inherited from GameObj:

Public Fields

oPoint3f p
oPoint3f axis
ofloat angle
oPoint3f v
ofloat av
obool active

Public Methods

ovoid Update(int t)
oPoint3f VDir()

Documentation

This class represent a asteroid with a 3D random fractal shape. The fractal shape is stored in a mesh and it is generated, starting from a loaded base mesh (i.e. ast.raw or tetra.raw) and by recursively subdividing each face into four smaller faces.
oMesh M
The mesh representing the asteroid shape.

o Ast3DFract(char *filename="tetra.raw")
Default constructor. It load a mesh from a file (default is tetra.raw, a simple tetrahedron), resize it into a unitary box and Split each face three times (e.g. the resulting mesh has 64x faces). At the end it calculates smooth per-vertex normal

ovoid Draw()
Draw the asteroid shape. Simply draw the stored mesh.

ovoid Split(int seed, float strenght=1)
This function split each triangle of the mesh into four smaller triangles. When splitting a triangle we geneate three new vertices (one for each edge) whose coordinates are calculated by MidPoint depending on the coordinates of the two vertices of the triangle edge where the new midpoint lies. The two params are passed directly to the MidPoint function and influence how the new point is calculated.

oPoint3f MidPoint( Point3f &p0, Point3f &p1, Point3f const &BC, int seed, float strengh)
This function calculates a point on an edge that is slightly perturbed form its original midpoint position. It is important that the pertubation is not really random but it depends on the coords of the two edge vertexes. In this way we generate twice the same midpoint when splitting the same edge on two adjacent triangles.
Parameters:
p0_p1 - the two points of the edge. We use an hash function to get a random seed for each vertex.
BC - the BariCenter of the Asteroids; the perturbation is along the line from bc to the middlepoint
seed - a random seed to avoid to calculate always the same asteroid when starting from the same triangles...
stenght - the {strenght} of the perturbation when strenght == 0 the shape tends to a sphere, good values are in the [.2,2] range.


This class has no child classes.

Alphabetic index HTML hierarchy of classes or Java



This page was generated with the help of DOC++.