Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

Model::OpacityComparator Class Reference

#include <model.h>

Inheritance diagram for Model::OpacityComparator:

Inheritance graph
Collaboration diagram for Model::OpacityComparator:

Collaboration graph
List of all members.

Public Member Functions

 OpacityComparator (const Model &)
virtual bool operator() (const Mesh &, const Mesh &) const

Private Member Functions

float getOpacity (const Mesh &mesh) const

Private Attributes

const Modelmodel

Detailed Description

This comparator will roughly sort the model's meshes by opacity so that transparent meshes are rendered last. It's far from perfect, but covers a lot of cases. A better method of opacity sorting would operate at the primitive group level, or even better at the triangle level.

Standard usage for this class is: model->sortMeshes(Model::OpacityComparator(*model));

Definition at line 90 of file model.h.


Constructor & Destructor Documentation

Model::OpacityComparator::OpacityComparator const Model  ) 
 

Definition at line 202 of file model.cpp.

00202                                                              :
00203     model(_model)
00204 {
00205 }


Member Function Documentation

float Model::OpacityComparator::getOpacity const Mesh mesh  )  const [private]
 

Definition at line 212 of file model.cpp.

References Model::getMaterial(), Mesh::PrimitiveGroup::materialIndex, model, and Mesh::Material::opacity.

Referenced by operator()().

00213 {
00214     const Mesh::PrimitiveGroup* group = mesh.getGroup(0);
00215 
00216     if (group != NULL)
00217     {
00218         const Mesh::Material* material = model.getMaterial(group->materialIndex);
00219         if (material != NULL)
00220             return material->opacity;
00221     }
00222 
00223     return 1.0f;
00224 }

bool Model::OpacityComparator::operator() const Mesh ,
const Mesh
const [virtual]
 

Implements Model::MeshComparator.

Definition at line 228 of file model.cpp.

References getOpacity().

00229 {
00230     return getOpacity(a) > getOpacity(b);
00231 }


Member Data Documentation

const Model& Model::OpacityComparator::model [private]
 

Definition at line 100 of file model.h.

Referenced by getOpacity().


The documentation for this class was generated from the following files:
Generated on Sat Jan 14 22:33:28 2006 for Celestia by  doxygen 1.4.1