CIsosurface Class Reference
Collaboration diagram for CIsosurface:
[legend]List of all members.
Detailed Description
Use this class to visualize iso surfaces. Support has been added to calculate energy values for metaballs. The calculation of the generated triangles is done using the marching cubes algoritm. This algoritms is patented, so be carefull using it in a commercial product!
void render() {
load_camera();
static CIsosurface iso;
iso.setSize(10, 10, 10);
CIsosurfaceMetaball ball;
ball.p[0] = sin(time);
ball.p[1] = 0.0;
ball.p[2] = cos(time);
ball.a = 1.0;
iso.calculate(&ball, 1);
iso.calculateNormals();
CIsosurfaceVertex v[300];
glVertexPointer(GL_FLOAT, 3, v, sizeof(CIsosurfaceVertex));
glEnableClientState(GL_NORMAL_ARRAY);
glNormalPointer(GL_FLOAT, v, sizeof(CIsosurfaceVertex));
glEnableClientState(GL_VERTEX_ARRAY);
glBegin(GL_TRIANGLES); {
iso.output(100, v, render_triangle);
} glEnd();
}
void render_triangle(int triangles, CIsosurfaceVertex* v) {
glDrawArrays(0, triangles*3);
}
Definition at line 111 of file CIsosurface.h.
|
Public Member Functions |
void | setSize (int sx, int sy, int sz) |
void | calculate (CIsosurfaceMetaball *ball, int balls) |
void | calculateNormals () |
void | output (void(*triangle)(CIsosurfaceVertex *v)) |
void | output (int triangles, CIsosurfaceVertex *v, void(*triangle)(int num, CIsosurfaceVertex *v)) |
void | output (CMesh &mesh) |
Public Attributes |
CIsosurfaceValue *** | v |
| Energy values.
|
CIsosurfaceCube *** | cube |
| Cube for marching cubes algo.
|
int | sx |
int | sy |
int | sz |
| Size of the grid.
|
float | treshold |
| Isosurface border. If energy(x, y, z) >= treshold, (x, y, z) is solid.
|
Member Function Documentation
void CIsosurface::setSize |
( |
int |
sx, |
|
|
int |
sy, |
|
|
int |
sz |
|
) |
|
|
|
Sets the size of the grid. Passing (0, 0, 0) will free memory. - Parameters:
-
| sx | Resolution in x direction. |
| sy | Resolution in y direction. |
| sz | Resolution in z direction. |
|
|
Calculates energy values for a given number of mataballs. Note that you don't have to use this function to generate energy values. You can use all kinds of custom functions to do this. - Parameters:
-
| ball | Pointer to first ball in array. |
| balls | The size of the ball array. |
|
void CIsosurface::calculateNormals |
( |
|
) |
|
|
|
Call this just before output() to have valid normal values if you need them. |
|
Spawns triangles. The callback function will be called for every triangle with three metavert_t structures. - Parameters:
-
| triangle | Callback function that will be called for every generated triangle. |
|
|
Spawns multiple triangles at once. Triangles is the maximum number of triangles to spawn at once. v must be an array of triangles*3 metavert_t structures. The callback function will be called with the number of triangles to render and a pointer to v. Triangles are stored 123.123.123. - Parameters:
-
| triangles | The maximum number of triangles to output at once. |
| v | An array of vertices large enough to store triangles*3 vertices. |
| triangle | Callback function that will be called for multiple generated triangles. |
|
void CIsosurface::output |
( |
CMesh & |
mesh |
) |
|
|
|
Spawn triangles to a mesh. This method isn't recommended for real-time use. - Parameters:
-
|
The documentation for this class was generated from the following file:
Generated on Tue Feb 8 21:59:38 2005 for MarSTDv2004 by
1.4.1