#include <drawable.h>
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. |
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.
|
Constructor to convert a sphere into a drawable.
|
|
Constructor to convert a gl_cylinder into a drawable.
|
|
Default constructor.
|
|
Function to add an array of spheres to an array of drawables.
|
|
Function to add an array of gl_cylinders to an array of drawables.
|
|
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.
|
|
Distance from the object to the viewer.
|
|
Determines which type of sphere or cylinder.
|
|
Pointer to a sphere or gl_cylinder.
|