void setFilename(const char* name) { filename = name; if (filename == "\"<stdin>\"") { filename = getBaseFilename(); } else if (filename[0] == '"') { filename = filename.substr(1, filename.length() - 2); } }
bool SimInterior::loadShape(const char* fileName) { // setFilename returns false if the filename is invalid, OR if the filename // is the same as the one already set. In either case, we exit wo/ doing // any work... // if (setFilename(fileName) == false) { return false; } // NOTE: This function is VERY poor on error checking, there are only a few // asserts in ITRInstance(). Maybe restructure to be a bit more robust? // ResourceManager *rm = SimResource::get(manager); Resource<ITRShape> itrShape; bool missionLit; // check if we need to try and find the missionlit ver if( rm->findFile( fileName ) ) { missionLit = missionLitName(); itrShape = rm->load( fileName); } else { if( !missionLitName() ) return( false ); String base = String(fileName); getBaseFilename( base ); if( rm->findFile( base.c_str() ) ) itrShape = rm->load(base.c_str()); missionLit = false; } if( !bool( itrShape ) ) return( false ); // If we make it to here, then all is cool, nuke the old resources... // unloadResources(); ITRInstance* pInstance = new ITRInstance(rm, itrShape, 0); if( missionLit ) pInstance->setMissionLit(); renderImage.instance = pInstance; // Set the geometry for the database and collision image. Note that this // is the highest level of state 0 for the interior. May have to change // the collision image geometry pointer on detail level change, probably // will only change the database pointer on state switches... // updateBoundingBox(); SimContainer* root = NULL; root = findObject(manager,SimRootContainerId,root); root->addObject(this); getInstance()->getAutoStartIDs(animatingLights); SimSet* pITRTimerSet = dynamic_cast<SimSet*>(manager->findObject(SimITRTimerSetId)); if (pITRTimerSet == NULL) manager->addObject(new SimTimerSet(1.0f/15.0f, SimITRTimerSetId)); bool timerSuccess = addToSet(SimITRTimerSetId); AssertFatal(timerSuccess == true, "Could not add to SimITRTimerSet"); return true; }