40 #ifndef _graphicsmeshmanager_cpp
41 #define _graphicsmeshmanager_cpp
44 #include "Graphics/meshmanager.h"
45 #include "Graphics/mesh.h"
51 template<> Graphics::MeshManager* Singleton<Graphics::MeshManager>::SingletonPtr = NULL;
75 MeshIterator lit = this->LoadedMeshes.find(MeshName);
76 if(lit != this->LoadedMeshes.end())
78 MeshIterator git = this->GeneratedMeshes.find(MeshName);
79 if(git != this->GeneratedMeshes.end())
95 MeshIterator it = this->LoadedMeshes.find(MeshName);
96 if( it != this->LoadedMeshes.end() )
98 Mesh* Loaded =
new Mesh(Ogre::MeshManager::getSingleton().load(MeshName,Group));
99 this->LoadedMeshes[MeshName] = Loaded;
105 MeshIterator it = this->LoadedMeshes.find(MeshName);
106 if( it == this->LoadedMeshes.end() )
108 Ogre::MeshManager::getSingleton().unload(MeshName);
110 this->LoadedMeshes.erase(it);
115 return this->LoadedMeshes.size();
120 for( MeshIterator it = this->LoadedMeshes.begin() ; it != this->LoadedMeshes.end() ; it++ )
124 this->LoadedMeshes.clear();
125 Ogre::MeshManager::getSingleton().unloadAll();
133 return this->GeneratedMeshes.size();
138 MeshIterator it = this->GeneratedMeshes.find(MeshName);
139 if(it == this->GeneratedMeshes.end())
141 Ogre::MeshManager::getSingletonPtr()->remove((*it).second->GetName());
143 this->GeneratedMeshes.erase(it);
149 for( MeshIterator it = this->GeneratedMeshes.begin() ; it != this->GeneratedMeshes.end() ; it++ )
151 Ogre::MeshManager::getSingletonPtr()->remove((*it).second->GetName());
154 this->GeneratedMeshes.clear();
163 Ogre::MaterialPtr TheMaterial = Ogre::MaterialManager::getSingleton().getByName(MaterialName);
164 String GroupName = TheMaterial->getGroup();
166 Ogre::ManualObject* box =
new Ogre::ManualObject(
"TempMan");
167 box->begin(MaterialName);
169 box->position(-Half.
X,-Half.
Y,Half.
Z); box->normal(0,0,1); box->textureCoord(0,1);
170 box->position(Half.
X,-Half.
Y,Half.
Z); box->normal(0,0,1); box->textureCoord(1,1);
171 box->position(Half.
X,Half.
Y,Half.
Z); box->normal(0,0,1); box->textureCoord(1,0);
172 box->position(-Half.
X,Half.
Y,Half.
Z); box->normal(0,0,1); box->textureCoord(0,0);
174 box->position(Half.
X,-Half.
Y,-Half.
Z); box->normal(0,0,-1); box->textureCoord(0,1);
175 box->position(-Half.
X,-Half.
Y,-Half.
Z); box->normal(0,0,-1); box->textureCoord(1,1);
176 box->position(-Half.
X,Half.
Y,-Half.
Z); box->normal(0,0,-1); box->textureCoord(1,0);
177 box->position(Half.
X,Half.
Y,-Half.
Z); box->normal(0,0,-1); box->textureCoord(0,0);
179 box->position(-Half.
X,-Half.
Y,-Half.
Z); box->normal(-1,0,0); box->textureCoord(0,1);
180 box->position(-Half.
X,-Half.
Y,Half.
Z); box->normal(-1,0,0); box->textureCoord(1,1);
181 box->position(-Half.
X,Half.
Y,Half.
Z); box->normal(-1,0,0); box->textureCoord(1,0);
182 box->position(-Half.
X,Half.
Y,-Half.
Z); box->normal(-1,0,0); box->textureCoord(0,0);
184 box->position(Half.
X,-Half.
Y,Half.
Z); box->normal(1,0,0); box->textureCoord(0,1);
185 box->position(Half.
X,-Half.
Y,-Half.
Z); box->normal(1,0,0); box->textureCoord(1,1);
186 box->position(Half.
X,Half.
Y,-Half.
Z); box->normal(1,0,0); box->textureCoord(1,0);
187 box->position(Half.
X,Half.
Y,Half.
Z); box->normal(1,0,0); box->textureCoord(0,0);
189 box->position(-Half.
X,Half.
Y,Half.
Z); box->normal(0,1,0); box->textureCoord(0,1);
190 box->position(Half.
X,Half.
Y,Half.
Z); box->normal(0,1,0); box->textureCoord(1,1);
191 box->position(Half.
X,Half.
Y,-Half.
Z); box->normal(0,1,0); box->textureCoord(1,0);
192 box->position(-Half.
X,Half.
Y,-Half.
Z); box->normal(0,1,0); box->textureCoord(0,0);
194 box->position(-Half.
X,-Half.
Y,-Half.
Z); box->normal(0,-1,0); box->textureCoord(0,1);
195 box->position(Half.
X,-Half.
Y,-Half.
Z); box->normal(0,-1,0); box->textureCoord(1,1);
196 box->position(Half.
X,-Half.
Y,Half.
Z); box->normal(0,-1,0); box->textureCoord(1,0);
197 box->position(-Half.
X,-Half.
Y,Half.
Z); box->normal(0,-1,0); box->textureCoord(0,0);
199 box->triangle(0,1,2); box->triangle(0,2,3);
200 box->triangle(4,5,6); box->triangle(4,6,7);
201 box->triangle(8,9,10); box->triangle(8,10,11);
202 box->triangle(12,13,14); box->triangle(12,14,15);
203 box->triangle(16,17,18); box->triangle(16,18,19);
204 box->triangle(20,21,22); box->triangle(20,22,23);
207 Ogre::MeshPtr boxmesh = box->convertToMesh(MeshName, GroupName);
208 boxmesh->_setBounds(Ogre::AxisAlignedBox(-Half.
X,-Half.
Y,-Half.
Z,Half.
X,Half.
Y,Half.
Z));
209 Real FirstCheck = Half.
X > Half.
Y ? Half.
X : Half.
Y;
210 Real Largest = FirstCheck > Half.
Z ? FirstCheck : Half.
Z;
211 boxmesh->_setBoundingSphereRadius(1.4 * Largest);
213 this->GeneratedMeshes[MeshName] = NewMesh;
220 String MatName(MeshName+
"Mat");
228 Ogre::Quaternion RotationModifier;
230 RotationModifier = Ogre::Quaternion(Ogre::Radian(0.5),Ogre::Vector3::UNIT_Z);
232 RotationModifier = Ogre::Quaternion(1,0,0,0);
234 RotationModifier = Ogre::Quaternion(Ogre::Radian(0.5),Ogre::Vector3::UNIT_X);
237 Ogre::MaterialPtr TheMaterial = Ogre::MaterialManager::getSingleton().getByName(MaterialName);
238 String GroupName = TheMaterial->getGroup();
240 Real deltaAngle = (Ogre::Math::TWO_PI / CircleRes);
241 Real deltaHeight = (Half.
Y * 2)/(
Real)Segments;
242 Real radius = Half.
X;
245 Ogre::ManualObject* cylinder =
new Ogre::ManualObject(
"TempMan");
246 cylinder->begin(MaterialName);
248 for(
Whole i = 0 ; i <= Segments ; i++ )
250 for(
Whole j = 0 ; j < CircleRes ; j++ )
252 Real x0 = radius * cosf(j*deltaAngle);
253 Real z0 = radius * sinf(j*deltaAngle);
254 cylinder->position( RotationModifier * Ogre::Vector3(x0, (i*deltaHeight) - Half.
Y, z0) );
255 cylinder->normal( RotationModifier * Ogre::Vector3(x0,0,z0).normalisedCopy() );
256 cylinder->textureCoord(j/(
Real)CircleRes, i/(
Real)Segments);
262 if(offset + CircleRes == CircleRes * 2)
263 cylinder->index(CircleRes);
265 cylinder->index(offset + CircleRes + 1);
267 cylinder->index(offset);
268 cylinder->index(offset + CircleRes);
270 if(offset + CircleRes == CircleRes * 2)
273 cylinder->index(offset + CircleRes + 1);
275 cylinder->index(offset + 1);
276 cylinder->index(offset);
283 Whole centerIndex = offset;
284 cylinder->position( RotationModifier * Ogre::Vector3(0,-Half.
Y,0) );
285 cylinder->normal( RotationModifier * Ogre::Vector3::NEGATIVE_UNIT_Y );
286 cylinder->textureCoord(0,1);
288 for(
Whole j = 0 ; j <= CircleRes ; j++ )
290 Real x0 = radius * cosf(j*deltaAngle);
291 Real z0 = radius * sinf(j*deltaAngle);
293 cylinder->position( RotationModifier * Ogre::Vector3(x0,-Half.
Y, z0) );
294 cylinder->normal( RotationModifier * Ogre::Vector3::NEGATIVE_UNIT_Y );
295 cylinder->textureCoord(j/(
Real)CircleRes,0.0);
298 cylinder->index(centerIndex);
299 cylinder->index(offset);
300 cylinder->index(offset+1);
306 centerIndex = offset;
307 cylinder->position( RotationModifier * Ogre::Vector3(0,Half.
Y,0) );
308 cylinder->normal( RotationModifier * Ogre::Vector3::UNIT_Y );
309 cylinder->textureCoord(0,0);
311 for(
Whole j = 0 ; j <= CircleRes ; j++ )
313 Real x0 = radius * cosf(j*deltaAngle);
314 Real z0 = radius * sinf(j*deltaAngle);
316 cylinder->position( RotationModifier * Ogre::Vector3(x0, Half.
Y, z0) );
317 cylinder->normal( RotationModifier * Ogre::Vector3::UNIT_Y );
318 cylinder->textureCoord(j/(
Real)CircleRes,1);
321 cylinder->index(centerIndex);
322 cylinder->index(offset+1);
323 cylinder->index(offset);
329 Ogre::MeshPtr cylindermesh = cylinder->convertToMesh(MeshName, GroupName);
330 cylindermesh->_setBounds(Ogre::AxisAlignedBox(-Half.
X,-Half.
Y,-Half.
Z,Half.
X,Half.
Y,Half.
Z));
331 Real FirstCheck = Half.
X > Half.
Y ? Half.
X : Half.
Y;
332 Real Largest = FirstCheck > Half.
Z ? FirstCheck : Half.
Z;
333 cylindermesh->_setBoundingSphereRadius(1.4 * Largest);
334 Mesh* NewMesh =
new Mesh(cylindermesh);
335 this->GeneratedMeshes[MeshName] = NewMesh;
343 String MatName(MeshName+
"Mat");
345 return this->
CreateCylinderMesh(MeshName,MatName,HalfExtents,AxisOrientation,CircleRes,Segments);
350 Ogre::MaterialPtr TheMaterial = Ogre::MaterialManager::getSingleton().getByName(MaterialName);
351 String GroupName = TheMaterial->getGroup();
353 Real RingAngle = (Ogre::Math::PI / Rings);
354 Real SegAngle = (2 * Ogre::Math::PI / Segments);
357 Ogre::ManualObject* sphere =
new Ogre::ManualObject(
"TempMan");
358 sphere->begin(MaterialName);
360 for(
Whole ring = 0 ; ring <= Rings ; ring++ ) {
361 Real r0 = Radius * sinf (ring * RingAngle);
362 Real y0 = Radius * cosf (ring * RingAngle);
365 for(
Whole seg = 0 ; seg <= Segments ; seg++ ) {
366 Real x0 = r0 * sinf(seg * SegAngle);
367 Real z0 = r0 * cosf(seg * SegAngle);
370 sphere->position( x0, y0, z0);
371 sphere->normal(Ogre::Vector3(x0, y0, z0).normalisedCopy());
372 sphere->textureCoord((
Real) seg / (
Real) Segments, (
Real) ring / (
Real) Rings);
376 sphere->index(VertIndex + Segments + 1);
377 sphere->index(VertIndex);
378 sphere->index(VertIndex + Segments);
379 sphere->index(VertIndex + Segments + 1);
380 sphere->index(VertIndex + 1);
381 sphere->index(VertIndex);
388 Ogre::MeshPtr spheremesh = sphere->convertToMesh(MeshName, GroupName);
389 spheremesh->_setBounds(Ogre::AxisAlignedBox(-Radius,-Radius,-Radius,Radius,Radius,Radius));
390 spheremesh->_setBoundingSphereRadius(Radius);
391 Mesh* NewMesh =
new Mesh(spheremesh);
392 this->GeneratedMeshes[MeshName] = NewMesh;
399 String MatName(MeshName+
"Mat");
417 TextureCoord=TextureCoord_;
425 Vector3 Full = HalfExtents * 2;
428 Real FirstSizeCheck = HalfExtents.
X < HalfExtents.
Y ? HalfExtents.
X : HalfExtents.
Y;
429 Real Smallest = FirstSizeCheck < HalfExtents.
Z ? FirstSizeCheck : HalfExtents.
Z;
430 if(Smallest * 2 <= FirstSizeCheck) Length = Smallest * 0.5;
431 else Length = Smallest * 0.25;
432 Ogre::MaterialPtr TheMaterial = Ogre::MaterialManager::getSingleton().getByName(MaterialName);
433 String GroupName = TheMaterial->getGroup();
435 Ogre::ManualObject* boxcorner =
new Ogre::ManualObject(
"TempMan");
436 boxcorner->begin(MaterialName);
439 std::vector<IdealPoint> IdealShape;
443 IdealShape.push_back( IdealPoint(
Vector3(-Half.
X + BoxThickness,Half.
Y - Length,Half.
Z),
Vector3(0,0,1),
Vector2(BoxThickness / Full.
X,0.5) ));
444 IdealShape.push_back( IdealPoint(
Vector3(-Half.
X + BoxThickness,Half.
Y - BoxThickness,Half.
Z),
Vector3(0,0,1),
Vector2(BoxThickness / Full.
X,BoxThickness / Full.
Y) ));
445 IdealShape.push_back( IdealPoint(
Vector3(-Half.
X + Length,Half.
Y - BoxThickness,Half.
Z),
Vector3(0,0,1),
Vector2(0.5,BoxThickness / Full.
Y) ));
450 IdealShape.push_back( IdealPoint(
Vector3(-Half.
X + Length,Half.
Y,Half.
Z - BoxThickness),
Vector3(0,1,0),
Vector2(0.5,1 - (BoxThickness / Full.
Y)) ));
451 IdealShape.push_back( IdealPoint(
Vector3(-Half.
X + BoxThickness,Half.
Y,Half.
Z - BoxThickness),
Vector3(0,1,0),
Vector2(BoxThickness / Full.
X,1 - (BoxThickness / Full.
Y)) ));
452 IdealShape.push_back( IdealPoint(
Vector3(-Half.
X + BoxThickness,Half.
Y,Half.
Z - Length),
Vector3(0,1,0),
Vector2(BoxThickness / Full.
X,0.5) ));
457 IdealShape.push_back( IdealPoint(
Vector3(-Half.
X,Half.
Y - BoxThickness,Half.
Z - Length),
Vector3(-1,0,0),
Vector2(0.5,BoxThickness / Full.
Y) ));
458 IdealShape.push_back( IdealPoint(
Vector3(-Half.
X,Half.
Y - BoxThickness,Half.
Z - BoxThickness),
Vector3(-1,0,0),
Vector2(1 - (BoxThickness / Full.
X),BoxThickness / Full.
Y) ));
459 IdealShape.push_back( IdealPoint(
Vector3(-Half.
X,Half.
Y - Length,Half.
Z - BoxThickness),
Vector3(-1,0,0),
Vector2(1 - (BoxThickness / Full.
X),0.5) ));
462 IdealShape.push_back( IdealPoint(
Vector3(-Half.
X + Length,Half.
Y,Half.
Z - BoxThickness),
Vector3(0,0,-1),
Vector2(0.5,0) ));
463 IdealShape.push_back( IdealPoint(
Vector3(-Half.
X + Length,Half.
Y - BoxThickness,Half.
Z - BoxThickness),
Vector3(0,0,-1),
Vector2(0.5,BoxThickness / Full.
Y) ));
464 IdealShape.push_back( IdealPoint(
Vector3(-Half.
X + BoxThickness,Half.
Y - BoxThickness,Half.
Z - BoxThickness),
Vector3(0,0,-1),
Vector2(1 - (BoxThickness / Full.
X),BoxThickness / Full.
Y) ));
465 IdealShape.push_back( IdealPoint(
Vector3(-Half.
X + BoxThickness,Half.
Y,Half.
Z - BoxThickness),
Vector3(0,0,-1),
Vector2(1 - (BoxThickness / Full.
X),0) ));
466 IdealShape.push_back( IdealPoint(
Vector3(-Half.
X + BoxThickness,Half.
Y,Half.
Z - Length),
Vector3(0,0,-1),
Vector2(1 - (BoxThickness / Full.
X),0) ));
467 IdealShape.push_back( IdealPoint(
Vector3(-Half.
X + BoxThickness,Half.
Y - BoxThickness,Half.
Z - Length),
Vector3(0,0,-1),
Vector2(1 - (BoxThickness / Full.
X),BoxThickness / Full.
Y) ));
468 IdealShape.push_back( IdealPoint(
Vector3(-Half.
X,Half.
Y - BoxThickness,Half.
Z - Length),
Vector3(0,0,-1),
Vector2(1,BoxThickness / Full.
Y) ));
470 IdealShape.push_back( IdealPoint(
Vector3(-Half.
X + BoxThickness,Half.
Y - BoxThickness,Half.
Z - BoxThickness),
Vector3(0,0,-1),
Vector2(1 - (BoxThickness / Full.
X),BoxThickness / Full.
Y) ));
471 IdealShape.push_back( IdealPoint(
Vector3(-Half.
X + BoxThickness,Half.
Y - Length,Half.
Z - BoxThickness),
Vector3(0,0,-1),
Vector2(1 - (BoxThickness / Full.
X),0.5) ));
472 IdealShape.push_back( IdealPoint(
Vector3(-Half.
X,Half.
Y - Length,Half.
Z - BoxThickness),
Vector3(0,0,-1),
Vector2(1,0.5) ));
473 IdealShape.push_back( IdealPoint(
Vector3(-Half.
X,Half.
Y - BoxThickness,Half.
Z - BoxThickness),
Vector3(0,0,-1),
Vector2(1,BoxThickness / Full.
Y) ));
475 IdealShape.push_back( IdealPoint(
Vector3(-Half.
X + BoxThickness,Half.
Y - BoxThickness,Half.
Z),
Vector3(0,-1,0),
Vector2(BoxThickness / Full.
X,0) ));
476 IdealShape.push_back( IdealPoint(
Vector3(-Half.
X + BoxThickness,Half.
Y - BoxThickness,Half.
Z - BoxThickness),
Vector3(0,-1,0),
Vector2(BoxThickness / Full.
X,BoxThickness / Full.
Y) ));
477 IdealShape.push_back( IdealPoint(
Vector3(-Half.
X + Length,Half.
Y - BoxThickness,Half.
Z - BoxThickness),
Vector3(0,-1,0),
Vector2(0.5,BoxThickness / Full.
Y) ));
478 IdealShape.push_back( IdealPoint(
Vector3(-Half.
X + Length,Half.
Y - BoxThickness,Half.
Z),
Vector3(0,-1,0),
Vector2(0.5,0) ));
480 IdealShape.push_back( IdealPoint(
Vector3(-Half.
X,Half.
Y - Length,Half.
Z - BoxThickness),
Vector3(0,-1,0),
Vector2(0,BoxThickness / Full.
Y) ));
481 IdealShape.push_back( IdealPoint(
Vector3(-Half.
X + BoxThickness,Half.
Y - Length,Half.
Z - BoxThickness),
Vector3(0,-1,0),
Vector2(BoxThickness / Full.
X,BoxThickness / Full.
Y) ));
482 IdealShape.push_back( IdealPoint(
Vector3(-Half.
X + BoxThickness,Half.
Y - Length,Half.
Z),
Vector3(0,-1,0),
Vector2(BoxThickness / Full.
X,0) ));
483 IdealShape.push_back( IdealPoint(
Vector3(-Half.
X,Half.
Y - BoxThickness,Half.
Z - BoxThickness),
Vector3(0,-1,0),
Vector2(0,BoxThickness / Full.
Y) ));
484 IdealShape.push_back( IdealPoint(
Vector3(-Half.
X,Half.
Y - BoxThickness,Half.
Z - Length),
Vector3(0,-1,0),
Vector2(0,0.5) ));
485 IdealShape.push_back( IdealPoint(
Vector3(-Half.
X + BoxThickness,Half.
Y - BoxThickness,Half.
Z - Length),
Vector3(0,-1,0),
Vector2(BoxThickness / Full.
X,0.5) ));
486 IdealShape.push_back( IdealPoint(
Vector3(-Half.
X + BoxThickness,Half.
Y - BoxThickness,Half.
Z - BoxThickness),
Vector3(0,-1,0),
Vector2(BoxThickness / Full.
X,BoxThickness / Full.
Y) ));
488 IdealShape.push_back( IdealPoint(
Vector3(-Half.
X + BoxThickness,Half.
Y,Half.
Z - BoxThickness),
Vector3(1,0,0),
Vector2(BoxThickness / Full.
X,0) ));
489 IdealShape.push_back( IdealPoint(
Vector3(-Half.
X + BoxThickness,Half.
Y - BoxThickness,Half.
Z - BoxThickness),
Vector3(1,0,0),
Vector2(BoxThickness / Full.
X,BoxThickness / Full.
Y) ));
490 IdealShape.push_back( IdealPoint(
Vector3(-Half.
X + BoxThickness,Half.
Y - BoxThickness,Half.
Z - Length),
Vector3(1,0,0),
Vector2(0.5,BoxThickness / Full.
Y) ));
491 IdealShape.push_back( IdealPoint(
Vector3(-Half.
X + BoxThickness,Half.
Y,Half.
Z - Length),
Vector3(1,0,0),
Vector2(0.5,0) ));
493 IdealShape.push_back( IdealPoint(
Vector3(-Half.
X + Length,Half.
Y - BoxThickness,Half.
Z),
Vector3(1,0,0),
Vector2(0,BoxThickness / Full.
Y) ));
494 IdealShape.push_back( IdealPoint(
Vector3(-Half.
X + Length,Half.
Y - BoxThickness,Half.
Z - BoxThickness),
Vector3(1,0,0),
Vector2(BoxThickness / Full.
X,BoxThickness / Full.
Y) ));
495 IdealShape.push_back( IdealPoint(
Vector3(-Half.
X + Length,Half.
Y,Half.
Z - BoxThickness),
Vector3(1,0,0),
Vector2(BoxThickness / Full.
X,0) ));
496 IdealShape.push_back( IdealPoint(
Vector3(-Half.
X + BoxThickness,Half.
Y - BoxThickness,Half.
Z),
Vector3(1,0,0),
Vector2(0,BoxThickness / Full.
Y) ));
497 IdealShape.push_back( IdealPoint(
Vector3(-Half.
X + BoxThickness,Half.
Y - Length,Half.
Z),
Vector3(1,0,0),
Vector2(0,0.5) ));
498 IdealShape.push_back( IdealPoint(
Vector3(-Half.
X + BoxThickness,Half.
Y - Length,Half.
Z - BoxThickness),
Vector3(1,0,0),
Vector2(BoxThickness / Full.
X,0.5) ));
499 IdealShape.push_back( IdealPoint(
Vector3(-Half.
X + BoxThickness,Half.
Y - BoxThickness,Half.
Z - BoxThickness),
Vector3(1,0,0),
Vector2(BoxThickness / Full.
X,BoxThickness / Full.
Y) ));
502 std::vector<Vector3> Flips;
503 Flips.push_back(
Vector3(1,1,1));
504 Flips.push_back(
Vector3(1,1,-1));
505 Flips.push_back(
Vector3(1,-1,1));
506 Flips.push_back(
Vector3(-1,1,1));
507 Flips.push_back(
Vector3(1,-1,-1));
508 Flips.push_back(
Vector3(-1,1,-1));
509 Flips.push_back(
Vector3(-1,-1,1));
510 Flips.push_back(
Vector3(-1,-1,-1));
513 for( std::vector<Vector3>::iterator CurrentFlip=Flips.begin() ; CurrentFlip!=Flips.end() ; ++CurrentFlip )
515 for(std::vector<IdealPoint>::iterator CurrentVertex=IdealShape.begin(); CurrentVertex!=IdealShape.end(); ++CurrentVertex)
517 boxcorner->position( (CurrentVertex->Vertex * *CurrentFlip).GetOgreVector3() );
518 boxcorner->normal( (CurrentVertex->Normal * *CurrentFlip).GetOgreVector3() );
519 boxcorner->textureCoord( CurrentVertex->TextureCoord.GetOgreVector2() );
524 for(
Whole FlipCount = 0 ; FlipCount<Flips.size() ; ++FlipCount )
526 Whole ShapeIndex = FlipCount*IdealShape.size();
529 if(1==Flips.at(FlipCount).Z)
532 boxcorner->triangle(0+ShapeIndex,1+ShapeIndex,2+ShapeIndex);
533 boxcorner->triangle(0+ShapeIndex,2+ShapeIndex,3+ShapeIndex);
534 boxcorner->triangle(0+ShapeIndex,3+ShapeIndex,4+ShapeIndex);
535 boxcorner->triangle(0+ShapeIndex,4+ShapeIndex,5+ShapeIndex);
537 boxcorner->triangle(18+ShapeIndex,19+ShapeIndex,20+ShapeIndex);
538 boxcorner->triangle(18+ShapeIndex,20+ShapeIndex,21+ShapeIndex);
539 boxcorner->triangle(22+ShapeIndex,23+ShapeIndex,24+ShapeIndex);
540 boxcorner->triangle(22+ShapeIndex,24+ShapeIndex,25+ShapeIndex);
541 boxcorner->triangle(26+ShapeIndex,27+ShapeIndex,28+ShapeIndex);
542 boxcorner->triangle(26+ShapeIndex,28+ShapeIndex,29+ShapeIndex);
545 boxcorner->triangle(0+ShapeIndex,1+ShapeIndex,2+ShapeIndex);
546 boxcorner->triangle(0+ShapeIndex,3+ShapeIndex,4+ShapeIndex);
547 boxcorner->triangle(0+ShapeIndex,2+ShapeIndex,3+ShapeIndex);
548 boxcorner->triangle(0+ShapeIndex,4+ShapeIndex,5+ShapeIndex);
550 boxcorner->triangle(26+ShapeIndex,28+ShapeIndex,29+ShapeIndex);
551 boxcorner->triangle(26+ShapeIndex,27+ShapeIndex,28+ShapeIndex);
552 boxcorner->triangle(22+ShapeIndex,24+ShapeIndex,25+ShapeIndex);
553 boxcorner->triangle(22+ShapeIndex,23+ShapeIndex,24+ShapeIndex);
554 boxcorner->triangle(18+ShapeIndex,20+ShapeIndex,21+ShapeIndex);
555 boxcorner->triangle(18+ShapeIndex,19+ShapeIndex,20+ShapeIndex);
558 if(1==Flips.at(FlipCount).Y)
561 boxcorner->triangle(6+ShapeIndex,7+ShapeIndex,8+ShapeIndex);
562 boxcorner->triangle(6+ShapeIndex,8+ShapeIndex,9+ShapeIndex);
563 boxcorner->triangle(6+ShapeIndex,9+ShapeIndex,10+ShapeIndex);
564 boxcorner->triangle(6+ShapeIndex,10+ShapeIndex,11+ShapeIndex);
566 boxcorner->triangle(30+ShapeIndex,31+ShapeIndex,32+ShapeIndex);
567 boxcorner->triangle(30+ShapeIndex,32+ShapeIndex,33+ShapeIndex);
568 boxcorner->triangle(34+ShapeIndex,35+ShapeIndex,36+ShapeIndex);
569 boxcorner->triangle(34+ShapeIndex,36+ShapeIndex,37+ShapeIndex);
570 boxcorner->triangle(38+ShapeIndex,39+ShapeIndex,40+ShapeIndex);
571 boxcorner->triangle(38+ShapeIndex,40+ShapeIndex,41+ShapeIndex);
574 boxcorner->triangle(6+ShapeIndex,10+ShapeIndex,11+ShapeIndex);
575 boxcorner->triangle(6+ShapeIndex,9+ShapeIndex,10+ShapeIndex);
576 boxcorner->triangle(6+ShapeIndex,8+ShapeIndex,9+ShapeIndex);
577 boxcorner->triangle(6+ShapeIndex,7+ShapeIndex,8+ShapeIndex);
579 boxcorner->triangle(38+ShapeIndex,40+ShapeIndex,41+ShapeIndex);
580 boxcorner->triangle(38+ShapeIndex,39+ShapeIndex,40+ShapeIndex);
581 boxcorner->triangle(34+ShapeIndex,36+ShapeIndex,37+ShapeIndex);
582 boxcorner->triangle(34+ShapeIndex,35+ShapeIndex,36+ShapeIndex);
583 boxcorner->triangle(30+ShapeIndex,32+ShapeIndex,33+ShapeIndex);
584 boxcorner->triangle(30+ShapeIndex,31+ShapeIndex,32+ShapeIndex);
587 if(1==Flips.at(FlipCount).X)
590 boxcorner->triangle(12+ShapeIndex,13+ShapeIndex,14+ShapeIndex);
591 boxcorner->triangle(12+ShapeIndex,14+ShapeIndex,15+ShapeIndex);
592 boxcorner->triangle(12+ShapeIndex,15+ShapeIndex,16+ShapeIndex);
593 boxcorner->triangle(12+ShapeIndex,16+ShapeIndex,17+ShapeIndex);
595 boxcorner->triangle(42+ShapeIndex,43+ShapeIndex,44+ShapeIndex);
596 boxcorner->triangle(42+ShapeIndex,44+ShapeIndex,45+ShapeIndex);
597 boxcorner->triangle(46+ShapeIndex,47+ShapeIndex,48+ShapeIndex);
598 boxcorner->triangle(46+ShapeIndex,48+ShapeIndex,49+ShapeIndex);
599 boxcorner->triangle(50+ShapeIndex,51+ShapeIndex,52+ShapeIndex);
600 boxcorner->triangle(50+ShapeIndex,52+ShapeIndex,53+ShapeIndex);
603 boxcorner->triangle(12+ShapeIndex,16+ShapeIndex,17+ShapeIndex);
604 boxcorner->triangle(12+ShapeIndex,15+ShapeIndex,16+ShapeIndex);
605 boxcorner->triangle(12+ShapeIndex,14+ShapeIndex,15+ShapeIndex);
606 boxcorner->triangle(12+ShapeIndex,13+ShapeIndex,14+ShapeIndex);
608 boxcorner->triangle(50+ShapeIndex,52+ShapeIndex,53+ShapeIndex);
609 boxcorner->triangle(50+ShapeIndex,51+ShapeIndex,52+ShapeIndex);
610 boxcorner->triangle(46+ShapeIndex,48+ShapeIndex,49+ShapeIndex);
611 boxcorner->triangle(46+ShapeIndex,47+ShapeIndex,48+ShapeIndex);
612 boxcorner->triangle(42+ShapeIndex,44+ShapeIndex,45+ShapeIndex);
613 boxcorner->triangle(42+ShapeIndex,43+ShapeIndex,44+ShapeIndex);
618 Ogre::MeshPtr boxcornermesh = boxcorner->convertToMesh(MeshName, GroupName);
619 boxcornermesh->_setBounds(Ogre::AxisAlignedBox(-Half.
X,-Half.
Y,-Half.
Z,Half.
X,Half.
Y,Half.
Z));
620 Real FirstCheck = Half.
X > Half.
Y ? Half.
X : Half.
Y;
621 Real Largest = FirstCheck > Half.
Z ? FirstCheck : Half.
Z;
622 boxcornermesh->_setBoundingSphereRadius(1.4 * Largest);
623 Mesh* NewMesh =
new Mesh(boxcornermesh);
624 this->GeneratedMeshes[MeshName] = NewMesh;
631 String MatName(MeshName+
"Mat");
646 Ogre::ResourceManager::ResourceCreateOrRetrieveResult Result = Ogre::MaterialManager::getSingletonPtr()->createOrRetrieve(MatName, Group.empty() ? Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME : Group);
647 Ogre::MaterialPtr NewMaterial =
static_cast<Ogre::MaterialPtr
>(Result.first);
648 NewMaterial->setReceiveShadows(
false);
649 Ogre::Pass* pass = NewMaterial->getTechnique(0)->getPass(0);
650 pass->setCullingMode(Ogre::CULL_NONE);
651 pass->setDepthCheckEnabled(
true);
652 pass->setDepthWriteEnabled(
false);
653 pass->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
656 NewMaterial->prepare();
674 {
return ManagerBase::MT_MeshManager; }
677 {
return "DefaultMeshManager"; }
692 return "DefaultMeshManager";
715 delete ToBeDestroyed;