This is used to set the model we want to view in the control object.
| 256 | |
| 257 | // This is used to set the model we want to view in the control object. |
| 258 | void GuiMaterialPreview::setObjectModel(const char* modelName) |
| 259 | { |
| 260 | deleteModel(); |
| 261 | |
| 262 | Resource<TSShape> model = ResourceManager::get().load(modelName); |
| 263 | if (! bool(model)) |
| 264 | { |
| 265 | Con::warnf(avar("GuiMaterialPreview: Failed to load model %s. Please check your model name and load a valid model.", modelName)); |
| 266 | return; |
| 267 | } |
| 268 | |
| 269 | mModel = new TSShapeInstance(model, true); |
| 270 | AssertFatal(mModel, avar("GuiMaterialPreview: Failed to load model %s. Please check your model name and load a valid model.", modelName)); |
| 271 | |
| 272 | // Initialize camera values: |
| 273 | mOrbitPos = mModel->getShape()->center; |
| 274 | mMinOrbitDist = mModel->getShape()->mRadius; |
| 275 | |
| 276 | lastRenderTime = Platform::getVirtualMilliseconds(); |
| 277 | } |
| 278 | |
| 279 | void GuiMaterialPreview::deleteModel() |
| 280 | { |