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

drawable Class Reference

A class to keep track of drawable objects which are displayed using OpenGL. More...

#include <drawable.h>

List of all members.

Public Member Functions

template<class T, class S>  drawable (sphere< T, S > *s)
 Constructor to convert a sphere into a drawable.

template<class T, class S>  drawable (gl_cylinder< T, S > *c)
 Constructor to convert a gl_cylinder into a drawable.

 drawable ()
 Default constructor.


Static Public Member Functions

template<class T, class S> void add (ap_array< drawable > *objects, ap_array< sphere< T, S > > *spheres, int is_short=0)
 Function to add an array of spheres to an array of drawables.

template<class T, class S> void add (ap_array< drawable > *objects, ap_array< gl_cylinder< T, S > > *cylinders, int is_short=0)
 Function to add an array of gl_cylinders to an array of drawables.

void sort (ap_array< drawable > *objects)
 Function to sort an array of drawables.


Public Attributes

double distance
 Distance from the object to the viewer.

int type
 Determines which type of sphere or cylinder.

void * object
 Pointer to a sphere or gl_cylinder.


Detailed Description

A class to keep track of drawable objects which are displayed using OpenGL.

This file defines a drawable class to keep track of the x, y, z, color, distances and sizes of spheres and cylinders.

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

For space conservation reasons, this is not a parent class for the gl_sphere and gl_cylinder classes.

Author:
Ray Seyfarth


Constructor & Destructor Documentation

template<class T, class S>
drawable::drawable sphere< T, S > *  s  )  [inline]
 

Constructor to convert a sphere into a drawable.

template<class T, class S>
drawable::drawable gl_cylinder< T, S > *  c  )  [inline]
 

Constructor to convert a gl_cylinder into a drawable.

drawable::drawable  )  [inline]
 

Default constructor.


Member Function Documentation

template<class T, class S>
void drawable::add ap_array< drawable > *  objects,
ap_array< sphere< T, S > > *  spheres,
int  is_short = 0
[static]
 

Function to add an array of spheres to an array of drawables.

Parameters:
objects Pointer to an array of drawables to receive the spheres
spheres Pointer to an array of spheres to add to objects
is_short Whether the spheres are short or float variety

Todo:
The drawable add functions should determine the type of objects being added rather than the caller giving the type.

template<class T, class S>
void drawable::add ap_array< drawable > *  objects,
ap_array< gl_cylinder< T, S > > *  cylinders,
int  is_short = 0
[static]
 

Function to add an array of gl_cylinders to an array of drawables.

Parameters:
objects Pointer to an array of drawables to receive the data
cylinders Pointer to an array of gl_cylinders to add
is_short Whether the gl_cylinders are short or float variety

void drawable::sort ap_array< drawable > *  objects  )  [static]
 

Function to sort an array of drawables.

This function is used by gl_box::draw to sort the drawable objects based on depth. This is important for better rendering of translucent objects.

The sort function is a version of Shell Sort using a nice sequence of gap values based on 2 intermingled sequences. Shell Sort was chosen to assist with rotation. While rotating the sort will not move array elements far. With Shell Sort this will be O(n). For the size arrays being sorted, Shell Sort is very close to optimal for random data.

Parameters:
onjects Array of drawables to sort


Member Data Documentation

double drawable::distance
 

Distance from the object to the viewer.

int drawable::type
 

Determines which type of sphere or cylinder.

void* drawable::object
 

Pointer to a sphere or gl_cylinder.


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