MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / setObjectModel

Method setObjectModel

Engine/source/gui/editor/guiShapeEdPreview.cpp:350–404  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

348}
349
350bool GuiShapeEdPreview::setObjectModel(const char* modelName)
351{
352 SAFE_DELETE( mModel );
353 unmountAll();
354 mThreads.clear();
355 mActiveThread = -1;
356
357 ResourceManager::get().getChangedSignal().remove(this, &GuiShapeEdPreview::_onResourceChanged);
358
359 if (modelName && modelName[0])
360 {
361 Resource<TSShape> model = ResourceManager::get().load( modelName );
362 if (! bool( model ))
363 {
364 Con::warnf( avar("GuiShapeEdPreview: Failed to load model %s. Please check your model name and load a valid model.", modelName ));
365 return false;
366 }
367
368 mModel = new TSShapeInstance( model, true );
369 AssertFatal( mModel, avar("GuiShapeEdPreview: Failed to load model %s. Please check your model name and load a valid model.", modelName ));
370
371 TSShape* shape = mModel->getShape();
372
373 // Initialize camera values:
374 mOrbitPos = shape->center;
375
376 // Set camera move and zoom speed according to model size
377 mMoveSpeed = shape->mRadius / sMoveScaler;
378 mZoomSpeed = shape->mRadius / sZoomScaler;
379
380 // Reset node selection
381 mHoverNode = -1;
382 mSelectedNode = -1;
383 mSelectedObject = -1;
384 mSelectedObjDetail = 0;
385 mProjectedNodes.setSize( shape->nodes.size() );
386
387 // Reset detail stats
388 mCurrentDL = 0;
389
390 // the first time recording
391 mLastRenderTime = Platform::getVirtualMilliseconds();
392
393 mModelName = StringTable->insert(modelName);
394
395 //Now to reflect changes when the model file is changed.
396 ResourceManager::get().getChangedSignal().notify(this, &GuiShapeEdPreview::_onResourceChanged);
397 }
398 else
399 {
400 mModelName = StringTable->EmptyString();
401 }
402
403 return true;
404}
405
406bool GuiShapeEdPreview::setObjectShapeAsset(const char* assetId)
407{

Callers 1

Calls 12

avarFunction · 0.85
EmptyStringMethod · 0.80
getFunction · 0.70
warnfFunction · 0.50
clearMethod · 0.45
removeMethod · 0.45
loadMethod · 0.45
getShapeMethod · 0.45
setSizeMethod · 0.45
sizeMethod · 0.45
insertMethod · 0.45
notifyMethod · 0.45

Tested by

no test coverage detected