MCPcopy Create free account
hub / github.com/OGRECave/ogre / setupModels

Function setupModels

Samples/Simple/include/SkeletalAnimation.h:230–300  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

228 }
229
230 void setupModels()
231 {
232 tweakSneakAnim();
233
234 SceneNode* sn = NULL;
235 Entity* ent = NULL;
236 AnimationState* as = NULL;
237
238 // make sure we can get the buffers for bbox calculations
239 MeshManager::getSingleton().load("jaiqua.mesh",
240 ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
241 HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY,
242 HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY, true, true);
243
244 auto& controllerMgr = ControllerManager::getSingleton();
245
246 for (int i = 0; i < NUM_MODELS; i++)
247 {
248 // create scene nodes for the models at regular angular intervals
249 sn = mSceneMgr->getRootSceneNode()->createChildSceneNode();
250 sn->yaw(Radian(Math::TWO_PI * (float)i / (float)NUM_MODELS));
251 sn->translate(0, 0, -20, Node::TS_LOCAL);
252 mModelNodes.push_back(sn);
253
254 // create and attach a jaiqua entity
255 ent = mSceneMgr->createEntity("Jaiqua" + StringConverter::toString(i + 1), "jaiqua.mesh");
256 ent->setMaterialName("jaiqua");
257 sn->attachObject(ent);
258
259 // enable the entity's sneaking animation at a random speed and loop it manually since translation is involved
260 as = ent->getAnimationState("Sneak");
261 as->setEnabled(true);
262 as->setLoop(false);
263
264 controllerMgr.createController(controllerMgr.getFrameTimeSource(),
265 AnimationStateControllerValue::create(as, true),
266 ScaleControllerFunction::create(Math::RangeRandom(0.5, 1.5)));
267 mAnimStates.push_back(as);
268 }
269
270 // create name and value for skinning mode
271 StringVector names;
272 names.push_back("Help");
273 names.push_back("Skinning");
274 names.push_back(mBoneBoundingBoxesItemName);
275
276 // create a params panel to display the help and skinning mode
277 mStatusPanel = mTrayMgr->createParamsPanel(TL_TOPLEFT, "HelpMessage", 200, names);
278 mStatusPanel->setParamValue("Help", "H / F1");
279 String value = "Software";
280 enableBoneBoundingBoxMode( false ); // update status panel entry
281
282 // make sure we query the correct scheme
283 MaterialManager::getSingleton().setActiveScheme(mViewport->getMaterialScheme());
284
285 // change the value if hardware skinning is enabled
286 MaterialPtr entityMaterial = ent->getSubEntity(0)->getMaterial();
287 if(entityMaterial)

Callers 1

Calls 15

tweakSneakAnimFunction · 0.85
RangeRandomFunction · 0.85
getRootSceneNodeMethod · 0.80
createEntityMethod · 0.80
attachObjectMethod · 0.80
createControllerMethod · 0.80
createParamsPanelMethod · 0.80
setParamValueMethod · 0.80
setActiveSchemeMethod · 0.80
getMaterialMethod · 0.80
getSubEntityMethod · 0.80

Tested by

no test coverage detected