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

sphere< T, S > Class Template Reference

A template class to model spheres displayed using OpenGL. More...

#include <sphere.h>

Inheritance diagram for sphere< T, S >:

gl_sphere< T, S > List of all members.

Public Member Functions

 sphere (double x, double y, double z, double size, int color)
 Constructor which specifies sphere location, size and color.

 sphere ()
 Default constructor.


Public Attributes

x
 x coordinate

y
 y coordinate

z
 z coordinate

size
 diameter

unsigned char color
 An index which specifies a drawing list with a color.


Detailed Description

template<class T, class S>
class sphere< T, S >

A template class to model spheres displayed using OpenGL.

This file defines a sphere class and a gl_sphere class. The sphere class is the base class and is designed to use as few bytes as possible. It has been instantiated using short int coordinates and byte color and size values. In this form a sphere is stored in 8 bytes. A second instantiation uses float coordinates and size values. This form requires 17 bytes per sphere which is typically rounded up to 20 bytes.

The gl_sphere class is derived from the sphere class to allow depth sorting. Drawing transparent objects properly in OpenGL requires first drawing opaque objects and then drawing transparent or translucent objects in decreasing order of distance from the viewpoint. To make the sorting faster, it is best to store the distances in the object with the sphere values.

For simplicity and versatility animp considers each object to be translucent and sorts all the objects. This requires more time, but not very much more.

The distance values are only used in comparison to each other, so this class actually uses distances squared to avoid wasting time calling sqrt.

The distance value is a double so the gl_sphere objects are 16 bytes each compared to 8 for the sphere objects (or 28 versus 20 for the float variety).

Author:
Ray Seyfarth


Constructor & Destructor Documentation

template<class T, class S>
sphere< T, S >::sphere< T, S > double  x,
double  y,
double  z,
double  size,
int  color
 

Constructor which specifies sphere location, size and color.

Parameters:
x X coordinate for sphere center
y Y coordinate for sphere center
z Z coordinate for sphere center
size Radius of the sphere
color Color index for the sphere

template<class T, class S>
sphere< T, S >::sphere< T, S >  ) 
 

Default constructor.

This constructor is used when arrays of spheres are created.


Member Data Documentation

template<class T, class S>
T sphere< T, S >::x
 

x coordinate

template<class T, class S>
T sphere< T, S >::y
 

y coordinate

template<class T, class S>
T sphere< T, S >::z
 

z coordinate

template<class T, class S>
S sphere< T, S >::size
 

diameter

template<class T, class S>
unsigned char sphere< T, S >::color
 

An index which specifies a drawing list with a color.

An integer which selects a drawing list for the sphere. Each drawing list specifies a color.


The documentation for this class was generated from the following files:
Generated on Thu Nov 27 08:17:11 2003 for Animp - Animated Particles by doxygen 1.3.2