#include <model.h>
Public Member Functions | |
| uint32 | addMaterial (const Mesh::Material *) |
| uint32 | addMesh (Mesh *) |
| const Mesh::Material * | getMaterial (uint32) const |
| Mesh * | getMesh (uint32) const |
| Model () | |
| void | normalize (const Vec3f ¢erOffset) |
| bool | pick (const Ray3d &r, double &distance) const |
| void | render (RenderContext &) |
| Render the model in the current OpenGL context. | |
| void | sortMeshes (const MeshComparator &) |
| bool | usesTextureType (Mesh::TextureSemantic) const |
| ~Model () | |
Private Attributes | |
| std::vector< const Mesh::Material * > | materials |
| std::vector< Mesh * > | meshes |
| bool | textureUsage [Mesh::TextureSemanticMax] |
Classes | |
| class | MeshComparator |
| class | OpacityComparator |
Definition at line 24 of file model.h.
|
|
Definition at line 41 of file model.cpp. References textureUsage. 00042 {
00043 for (int i = 0; i < Mesh::TextureSemanticMax; i++)
00044 textureUsage[i] = false;
00045 }
|
|
|
Definition at line 48 of file model.cpp. References materials, and meshes. 00049 {
00050 {
00051 for (vector<Mesh*>::iterator iter = meshes.begin();
00052 iter != meshes.end(); iter++)
00053 delete *iter;
00054 }
00055
00056 #if 0
00057 {
00058 for (vector<const Mesh::Material*>::iterator iter = materials.begin();
00059 iter != materials.end(); iter++)
00060 delete *iter;
00061 }
00062 #endif
00063 }
|
|
|
Add a new material to the model's material library; the return value is the number of materials in the model. Definition at line 77 of file model.cpp. References InvalidResource, materials, and textureUsage. Referenced by Convert3DSModel(), BinaryModelLoader::load(), AsciiModelLoader::load(), main(), and mergeModelMeshes(). 00078 {
00079 // Update the texture map usage information for the model. Since
00080 // the material being added isn't necessarily used by a mesh within
00081 // the model, we could potentially end up with false positives--this
00082 // won't cause any rendering troubles, but could hurt performance
00083 // if it forces multipass rendering when it's not required.
00084 for (int i = 0; i < Mesh::TextureSemanticMax; i++)
00085 {
00086 if (m->maps[i] != InvalidResource)
00087 textureUsage[i] = true;
00088 }
00089
00090 materials.push_back(m);
00091 return materials.size();
00092 }
|
|
|
Add a new mesh to the model; the return value is the total number of meshes in the model. Definition at line 106 of file model.cpp. References meshes. Referenced by Convert3DSModel(), BinaryModelLoader::load(), AsciiModelLoader::load(), LoadCelestiaMesh(), main(), and mergeModelMeshes().
|
|
|
Return the material with the specified index, or NULL if the index is out of range. Definition at line 67 of file model.cpp. References materials. Referenced by Model::OpacityComparator::getOpacity(), and main(). 00068 {
00069 if (index < materials.size())
00070 return materials[index];
00071 else
00072 return NULL;
00073 }
|
|
|
Return the mesh with the specified index, or NULL if the index is out of range. Definition at line 96 of file model.cpp. References meshes. Referenced by main(). 00097 {
00098 if (index < meshes.size())
00099 return meshes[index];
00100 else
00101 return NULL;
00102 }
|
|
|
Apply a uniform scale to the model so that it fits into a box with a center at centerOffset and a maximum side length of one. Definition at line 151 of file model.cpp. References AxisAlignedBox::getCenter(), AxisAlignedBox::getExtents(), AxisAlignedBox::include(), meshes, Vector3< T >::x, Vector3< T >::y, and Vector3< T >::z. Referenced by ModelInfo::load(). 00152 {
00153 AxisAlignedBox bbox;
00154
00155 vector<Mesh*>::const_iterator iter;
00156 for (iter = meshes.begin(); iter != meshes.end(); iter++)
00157 bbox.include((*iter)->getBoundingBox());
00158
00159 Point3f center = bbox.getCenter() + centerOffset;
00160 Vec3f extents = bbox.getExtents();
00161 float maxExtent = extents.x;
00162 if (extents.y > maxExtent)
00163 maxExtent = extents.y;
00164 if (extents.z > maxExtent)
00165 maxExtent = extents.z;
00166
00167 for (iter = meshes.begin(); iter != meshes.end(); iter++)
00168 (*iter)->transform(Point3f(0, 0, 0) - center, 2.0f / maxExtent);
00169
00170 #if 0
00171 for (i = vertexLists.begin(); i != vertexLists.end(); i++)
00172 (*i)->transform(Point3f(0, 0, 0) - center, 2.0f / maxExtent);
00173 #endif
00174 }
|
|
||||||||||||
|
Find the closest intersection between the ray and the model. If the ray intersects the model, return true and set distance; otherwise return false and leave distance unmodified. Definition at line 114 of file model.cpp. References distance(), and meshes. Referenced by Body::computeLocations(), and ExactPlanetPickTraversal(). 00115 {
00116 double maxDistance = 1.0e30;
00117 double closest = maxDistance;
00118
00119 for (vector<Mesh*>::const_iterator iter = meshes.begin();
00120 iter != meshes.end(); iter++)
00121 {
00122 double d = maxDistance;
00123 if ((*iter)->pick(r, d) && d < closest)
00124 closest = d;
00125 }
00126
00127 if (closest != maxDistance)
00128 {
00129 distance = closest;
00130 return true;
00131 }
00132 else
00133 {
00134 return false;
00135 }
00136 }
|
|
|
Render the model in the current OpenGL context.
Definition at line 140 of file model.cpp. References materials, meshes, and Mesh::render(). Referenced by Nebula::render(). 00141 {
00142 for (vector<Mesh*>::const_iterator iter = meshes.begin();
00143 iter != meshes.end(); iter++)
00144 {
00145 (*iter)->render(materials, rc);
00146 }
00147 }
|
|
|
Sort the model's meshes in place. Definition at line 235 of file model.cpp. References meshes. Referenced by ModelInfo::load(). 00236 {
00237 sort(meshes.begin(), meshes.end(), MeshComparatorAdapter(comparator));
00238 }
|
|
|
Return true if the specified texture map type is used at all within a mesh. This information is used to decide if multiple rendering passes are required. Definition at line 178 of file model.cpp. References textureUsage. 00179 {
00180 return textureUsage[static_cast<int>(t)];
00181 }
|
|
|
Definition at line 104 of file model.h. Referenced by addMaterial(), getMaterial(), render(), and ~Model(). |
|
|
Definition at line 105 of file model.h. Referenced by addMesh(), getMesh(), normalize(), pick(), render(), sortMeshes(), and ~Model(). |
|
|
Definition at line 107 of file model.h. Referenced by addMaterial(), Model(), and usesTextureType(). |
1.4.1