| 505 | // MOUNTING |
| 506 | |
| 507 | bool GuiShapeEdPreview::mountShape(const char* modelName, const char* nodeName, const char* mountType, S32 slot) |
| 508 | { |
| 509 | if ( !modelName || !modelName[0] ) |
| 510 | return false; |
| 511 | |
| 512 | Resource<TSShape> model = ResourceManager::get().load( modelName ); |
| 513 | if ( !bool( model ) ) |
| 514 | return false; |
| 515 | |
| 516 | TSShapeInstance* tsi = new TSShapeInstance( model, true ); |
| 517 | |
| 518 | if ( slot == -1 ) |
| 519 | { |
| 520 | slot = mMounts.size(); |
| 521 | mMounts.push_back( new MountedShape ); |
| 522 | } |
| 523 | else |
| 524 | { |
| 525 | // Check if we are switching shapes |
| 526 | if ( mMounts[slot]->mShape->getShape() != tsi->getShape() ) |
| 527 | { |
| 528 | delete mMounts[slot]->mShape; |
| 529 | mMounts[slot]->mShape = NULL; |
| 530 | mMounts[slot]->mThread.init(); |
| 531 | } |
| 532 | else |
| 533 | { |
| 534 | // Keep using the existing shape |
| 535 | delete tsi; |
| 536 | tsi = mMounts[slot]->mShape; |
| 537 | } |
| 538 | } |
| 539 | |
| 540 | MountedShape* mount = mMounts[slot]; |
| 541 | mount->mShape = tsi; |
| 542 | |
| 543 | if ( dStrEqual( mountType, "Wheel" ) ) |
| 544 | mount->mType = MountedShape::Wheel; |
| 545 | else if ( dStrEqual( mountType, "Image" ) ) |
| 546 | mount->mType = MountedShape::Image; |
| 547 | else |
| 548 | mount->mType = MountedShape::Object; |
| 549 | |
| 550 | setMountNode( slot, nodeName); |
| 551 | |
| 552 | return true; |
| 553 | } |
| 554 | |
| 555 | void GuiShapeEdPreview::setMountNode(S32 mountSlot, const char* nodeName) |
| 556 | { |