本文整理汇总了C++中ogre::Entity::setMaterialName方法的典型用法代码示例。如果您正苦于以下问题:C++ Entity::setMaterialName方法的具体用法?C++ Entity::setMaterialName怎么用?C++ Entity::setMaterialName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::Entity
的用法示例。
在下文中一共展示了Entity::setMaterialName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: kill
void Player::kill(std::string s)
{
Mix_Chunk* chunk;
chunk = Mix_LoadWAV("Music/0/death.wav");
Mix_PlayChannel( -1, chunk, 0 );
health = 0;
Ogre::Entity* mEntity = static_cast<Ogre::Entity*>(rootNode->getAttachedObject(0));
if(s.compare("Cube/deathNormal") == 0)
{
mEntity->setMaterialName(s);
}
else if(s.compare("Cube/deathSpike") == 0)
{
mEntity->setMaterialName(s);
}
else if(poison)
{
mEntity->setMaterialName("Cube/DeathPoison");
}
else if(burn>0)
{
mEntity->setMaterialName("Cube/DeathFire");
}
else if(oxygen<=0)
{
mEntity->setMaterialName("Cube/DeathDrown");
}
}
示例2: setupContent
void StencilShadowTest::setupContent()
{
// turn ambient light off
mSceneMgr->setAmbientLight(ColourValue(0.0, 0.0, 0.0));
// turn on stencil shadows
mSceneMgr->setShadowTechnique(SHADOWTYPE_STENCIL_ADDITIVE);
// add a couple lights
Ogre::Light* light = mSceneMgr->createLight("Light1");
light->setDiffuseColour(0.5f,0.4f,0.35f);
light->setSpecularColour(0, 0, 0);
light->setAttenuation(8000,1,0.0005,0);
light->setPosition(220,100,0);
light->setCastShadows(true);
light->setType(Light::LT_POINT);
light = mSceneMgr->createLight("Light2");
light->setDiffuseColour(0.5f,0.4f,0.35f);
light->setSpecularColour(0, 0, 0);
light->setAttenuation(8000,1,0.0005,0);
light->setPosition(220,100,-200);
light->setCastShadows(true);
light->setType(Light::LT_POINT);
// create a ground plane to receive some shadows
Plane pln = MovablePlane("plane");
pln.normal = Vector3::UNIT_Y;
pln.d = 107;
MeshManager::getSingleton().createPlane("ground_plane",
ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, pln,
1500,1500,50,50,true,1,5,5,Vector3::UNIT_Z);
Ogre::Entity* groundPlane = mSceneMgr->createEntity( "plane", "ground_plane" );
groundPlane->setMaterialName("Examples/Rocky");
groundPlane->setCastShadows(false);
mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(groundPlane);
// and a couple objects to cast the shadows
Ogre::Entity* bar = mSceneMgr->createEntity( "barrel", "Barrel.mesh" );
bar->setCastShadows(true);
Ogre::SceneNode* barNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
barNode->attachObject(bar);
barNode->setScale(7,7,7);
barNode->setPosition(Ogre::Vector3(0,-85,-320));
Ogre::Entity* head = mSceneMgr->createEntity( "ogrehead", "ogrehead.mesh" );
head->setCastShadows(true);
Ogre::SceneNode* headNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
headNode->attachObject(head);
headNode->setPosition(Ogre::Vector3(-100,-80,-320));
Ogre::Entity* torus = mSceneMgr->createEntity( "torus", "knot.mesh" );
torus->setCastShadows(true);
torus->setMaterialName("Examples/RustySteel");
Ogre::SceneNode* torusNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
torusNode->setScale(0.5,0.5,0.5);
torusNode->attachObject(torus);
torusNode->setPosition(Ogre::Vector3(100,-60,-320));
// point the camera down a bit
mCamera->pitch(Ogre::Degree(-20.f));
}
示例3: if
bool HydraxSample1App::keyPressed(const OIS::KeyEvent &arg)
{
/*
if (arg.key == OIS::KC_Q)
{
mCurrentSkyBox++;
if (mCurrentSkyBox == 3)
{
mCurrentSkyBox = 0;
}
}
mSceneMgr->setSkyBox(true,mSkyBoxes[mCurrentSkyBox],1000,true);
mHydrax->setSunPosition(mSunPosition[mCurrentSkyBox]);
mHydrax->setSunColor(mSunColor[mCurrentSkyBox]);
mSceneMgr->getLight("Light0")->setPosition(mSunPosition[mCurrentSkyBox]);
mSceneMgr->getLight("Light0")->setSpecularColour(mSunColor[mCurrentSkyBox].x,mSunColor[mCurrentSkyBox].y,mSunColor[mCurrentSkyBox].z);*/
if (arg.key == OIS::KC_1 || arg.key == OIS::KC_2 || arg.key == OIS::KC_3)
{
CEGUI::Point point = CEGUI::MouseCursor::getSingleton().getPosition();
Ogre::Ray ray = mCameraMan->getCamera()->getCameraToViewportRay(point.d_x/mWindow->getWidth(),point.d_y/mWindow->getHeight());
mRaySceneQuery->setRay(ray);
Ogre::RaySceneQueryResult * mRayQueryResult = &(mRaySceneQuery->execute());
Ogre::RaySceneQueryResult::iterator itr = mRayQueryResult->begin();
while(itr != mRayQueryResult->end())
{
if(itr->worldFragment)
{
Ogre::Entity * ent;
Ogre::SceneNode * node;
if (arg.key == OIS::KC_1)
{
ent = mSceneMgr->createEntity(entityNames[0]);
ent->setMaterialName(materialNames[0]);
node = mSceneMgr->getRootSceneNode()->createChildSceneNode(itr->worldFragment->singleIntersection + Ogre::Vector3(0,200,0));
}
else if (arg.key == OIS::KC_2)
{
ent = mSceneMgr->createEntity(entityNames[1]);
ent->setMaterialName(materialNames[1]);
node = mSceneMgr->getRootSceneNode()->createChildSceneNode(itr->worldFragment->singleIntersection);
}
else if (arg.key == OIS::KC_3)
{
ent = mSceneMgr->createEntity(entityNames[2]);
ent->setMaterialName(materialNames[2]);
node = mSceneMgr->getRootSceneNode()->createChildSceneNode(itr->worldFragment->singleIntersection);
}
node->attachObject(ent);
break;
}
itr++;
}
}
return true;
}
示例4: setupScene
//-----------------------------------------------------------------------------------
void Sample_Compositor::setupScene(void)
{
mSceneMgr->setShadowTechnique(Ogre::SHADOWTYPE_TEXTURE_MODULATIVE);
mSceneMgr->setShadowFarDistance(1000);
Ogre::MovableObject::setDefaultVisibilityFlags(0x00000001);
// Set ambient light
mSceneMgr->setAmbientLight(Ogre::ColourValue(0.3, 0.3, 0.2));
Ogre::Light* l = mSceneMgr->createLight("Light2");
Ogre::Vector3 dir(-1,-1,0);
dir.normalise();
l->setType(Ogre::Light::LT_DIRECTIONAL);
l->setDirection(dir);
l->setDiffuseColour(1, 1, 0.8);
l->setSpecularColour(1, 1, 1);
Ogre::Entity* pEnt;
// House
pEnt = mSceneMgr->createEntity( "1", "tudorhouse.mesh" );
Ogre::SceneNode* n1 = mSceneMgr->getRootSceneNode()->createChildSceneNode(Ogre::Vector3(350, 450, -200));
n1->attachObject( pEnt );
pEnt = mSceneMgr->createEntity( "2", "tudorhouse.mesh" );
Ogre::SceneNode* n2 = mSceneMgr->getRootSceneNode()->createChildSceneNode(Ogre::Vector3(-350, 450, -200));
n2->attachObject( pEnt );
pEnt = mSceneMgr->createEntity( "3", "knot.mesh" );
mSpinny = mSceneMgr->getRootSceneNode()->createChildSceneNode(Ogre::Vector3(0, 0, 300));
mSpinny->attachObject( pEnt );
pEnt->setMaterialName("Examples/MorningCubeMap");
mSceneMgr->setSkyBox(true, "Examples/MorningSkyBox");
Ogre::Plane plane;
plane.normal = Ogre::Vector3::UNIT_Y;
plane.d = 100;
Ogre::MeshManager::getSingleton().createPlane("Myplane",
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, plane,
1500, 1500, 10, 10, true, 1, 5, 5, Ogre::Vector3::UNIT_Z);
Ogre::Entity* pPlaneEnt = mSceneMgr->createEntity( "plane", "Myplane" );
pPlaneEnt->setMaterialName("Examples/Rockwall");
pPlaneEnt->setCastShadows(false);
mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(pPlaneEnt);
mCamera->setPosition(-400, 50, 900);
mCamera->lookAt(0,80,0);
}
示例5:
Banderin::Banderin( Ogre::String nombre , Ogre::SceneManager* sm , float _x , float _y , float _z){
x = _x;
y = _y;
z = _z;
_sceneManager = sm;
nodoBanderin = _sceneManager->createSceneNode("Banderin"+nombre);
Ogre::SceneNode* nodoSuperiorIzq = _sceneManager->createSceneNode(nombre+"superiorIzq");
Ogre::SceneNode* nodoBandera = _sceneManager->createSceneNode(nombre+"bandera");
Ogre::SceneNode* nodoSuperiorDer = _sceneManager->createSceneNode(nombre+"superiorDer");
Ogre::SceneNode* nodoBaseDer = _sceneManager->createSceneNode(nombre+"baseDer");
Ogre::Entity* entBanderin = _sceneManager->createEntity("usb_cilindro.mesh");
Ogre::Entity* entSuperiorIzq = _sceneManager->createEntity("poly10.mesh");
Ogre::Entity* entBandera = _sceneManager->createEntity("usb_planocurvo.mesh");
Ogre::Entity* entSuperiorDer = _sceneManager->createEntity("poly10.mesh");
Ogre::Entity* entBaseDer = _sceneManager->createEntity("usb_cilindro.mesh");
entBanderin->setMaterialName("banderin");
entSuperiorIzq->setMaterialName("superior");
entBandera->setMaterialName("bandera");
entSuperiorDer->setMaterialName("superior");
entBaseDer->setMaterialName("banderin");
nodoSuperiorIzq->attachObject(entSuperiorIzq);
nodoSuperiorIzq->setScale(0.03,0.008,0.06);
nodoSuperiorIzq->translate(2.2,7.2,0.0);
nodoSuperiorIzq->rotate(Ogre::Vector3(0.0,0.0,1.0),Ogre::Radian(Ogre::Degree(180.0)));
nodoBandera->attachObject(entBandera);
nodoBandera->setScale(1.2,3.85,1.0);
nodoBandera->translate(-2.2,7.2,0.0);
nodoBandera->rotate(Ogre::Vector3(0.0,0.0,1.0),Ogre::Radian(Ogre::Degree(90.0)));
nodoSuperiorDer->attachObject(entSuperiorDer);
nodoSuperiorDer->setScale(0.03,0.008,0.06);
nodoSuperiorDer->translate(-152.2,7.2,0.0);
nodoBaseDer->attachObject(entBaseDer);
nodoBaseDer->translate(-150.0,0.0,0.0);
nodoBanderin->attachObject(entBanderin);
nodoBanderin->addChild(nodoSuperiorIzq);
nodoBanderin->addChild(nodoBandera);
nodoBanderin->addChild(nodoSuperiorDer);
nodoBanderin->addChild(nodoBaseDer);
nodoBanderin->setPosition(x,y,z);
nodoBanderin->setScale(60.0,600.0,60.0);
}
示例6: LoadWorld
int CUIMain::LoadWorld(void)
{
Ogre::SceneNode* RootNode = mSceneMgr->getRootSceneNode();
Ogre::Plane plane(Ogre::Vector3::UNIT_Y, -1); //1 unit under the ground
Ogre::MeshManager::getSingleton().createPlane("ground", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, plane,
2000,2000,20,20,true,1,5,5,Ogre::Vector3::UNIT_Z);
Ogre::Entity *GroundEnt = mSceneMgr->createEntity("GroundEntity", "ground");
GroundEnt->setQueryFlags(QUERY_MASK_MOUSE_MOVEMENT);
GroundEnt->setMaterialName("Rockwall");
RootNode->createChildSceneNode()->attachObject(GroundEnt);
CharacterInfo local_player_info;
mWorld.LocalPlayer = new CLocalPlayer(mWorld, RootNode->createChildSceneNode());
AttachMeshes(mWorld.LocalPlayer, local_player_info);
mWorld.LocalPlayer->SetMoveSpeed(100);
mWorld.LocalPlayer->SetState(State_Idle);
//Test:
CreateNewPlayer(0, CharacterInfo());
Ogre::SceneNode *DestMarkerNode = RootNode->createChildSceneNode();
Ogre::Entity *DestMarker = mSceneMgr->createEntity("Ent-DestMarker", "arrow.mesh");
DestMarker->setQueryFlags(0);
DestMarkerNode->attachObject(DestMarker);
DestMarkerNode->setVisible(false);
mWorld.LocalPlayer->SetDestinationMarker(DestMarkerNode, DestMarker);
mMoveDestinationIndicator = RootNode->createChildSceneNode();
Ogre::Entity* MouseIndicatorEntity = mSceneMgr->createEntity("Ent-MouseIndicator", "arrow.mesh");
MouseIndicatorEntity->setQueryFlags(0);
MouseIndicatorEntity->setMaterialName("ArrowTransparent");
mMoveDestinationIndicator->attachObject(MouseIndicatorEntity);
mMoveDestinationIndicator->scale(0.8, 0.8, 0.8);
mEntityHoveringIndicator = RootNode->createChildSceneNode();
mEntitySelectionIndicator = RootNode->createChildSceneNode();
Ogre::Entity* HoverIndicatorEntity = mSceneMgr->createEntity("Ent-HoveringIndicator", "arrows.mesh");
Ogre::Entity* SelectionIndicatorEntity = mSceneMgr->createEntity("Ent-SelectionIndicator", "arrows.mesh");
HoverIndicatorEntity->setQueryFlags(0);
SelectionIndicatorEntity->setQueryFlags(0);
HoverIndicatorEntity->setMaterialName("ArrowTransparent");
mEntitySelectionIndicator->setInheritOrientation(false);
mEntityHoveringIndicator->attachObject(HoverIndicatorEntity);
mEntitySelectionIndicator->attachObject(SelectionIndicatorEntity);
mEntityHoveringIndicator->setVisible(false);
mEntitySelectionIndicator->setVisible(false);
return 1;
}
示例7:
Ogre::SceneNode* AWGraphics::SceneDirector::createPlane(float x, float y, float z)
{
Ogre::Plane plane = Ogre::Plane(Ogre::Vector3::UNIT_Y, 0);
// Initialize a ground entity for later use
Ogre::MeshManager::getSingleton().createPlane(
"ground",
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
plane,
1500, 1500, 20, 20,
true,
1, 5, 5,
Ogre::Vector3::UNIT_Z);
//Ogre::MeshManager::getSingleton().createPlane()
Ogre::Entity* groundEntity = mSceneMgr->createEntity("ground");
groundEntity->setMaterialName("Rockwall");
groundEntity->setCastShadows(false);
Ogre::SceneNode* ogreNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
ogreNode->attachObject(groundEntity);
ogreNode->setPosition(x, y, z);
ogreNode->setOrientation(Ogre::Quaternion::IDENTITY); // hope this is a good reference
return ogreNode;
}
示例8: CreateParticleEntity
Ogre::SceneNode* ParticleFactory::CreateParticleEntity(Ogre::String object_name, Ogre::String material_name,Ogre::SceneNode* parent, Ogre::Vector3 size){
/* Create one instance of the torus (one entity) */
/* The same object can have multiple instances or entities */
/* Create entity */
Ogre::String name = parent->getName() + object_name;
//Ogre::Entity* entity = scene_manager->createEntity(object_name);
Ogre::Entity* entity = scene_manager->createEntity(object_name);
Ogre::MaterialPtr mat = static_cast<Ogre::MaterialPtr>(Ogre::MaterialManager::getSingleton().getByName(material_name));
//mat = mat->clone(object_name.append("_" +material_name.append("_" + Ogre::StringConverter::toString(materialCounter))));
mat = mat->clone(name.append("_" +material_name.append("_" + Ogre::StringConverter::toString(materialCounter))));
//std::cout << "NAME: " << name << std::endl;
//mat = mat->clone(object_name.append(material_name));
/* Apply a material to the entity */
entity->setMaterialName(mat->getName());
//materialArray[numMaterials] = mat->getName();
materialArray.push_back(mat->getName());
/* Create a scene node for the entity */
/* The scene node keeps track of the entity's position */
Ogre::SceneNode* scene_node = parent->createChildSceneNode(mat->getName());
scene_node->attachObject(entity);
//scene_node->translate(0.5,0.5,-1);
incrementCounter();
/* Scale the entity */
scene_node->scale(size);
return scene_node;
}
示例9: setup
bool Application::setup()
{
Ogre::OverlayManager::getSingleton().getByName("InfoPanel")->show();
m_NXOgreScene->getMaterial(0)->setStaticFriction(0.5);
m_NXOgreScene->getMaterial(0)->setDynamicFriction(0.5);
m_NXOgreScene->getMaterial(0)->setRestitution(0.1);
m_NXOgreRenderSystem->createBody(new NxOgre::Box(1, 1, 1),NxOgre::Vec3(0, 20, 0),"cube.1m.mesh");
m_NXOgreRenderSystem->createBody(new NxOgre::Box(1, 1, 1),NxOgre::Vec3(-1, 30, 0),"cube.1m.mesh");
m_NXOgreRenderSystem->createBody(new NxOgre::Box(1, 1, 1),NxOgre::Vec3(0, 25, 0),"cube.1m.mesh");
m_NXOgreRenderSystem->createBody(new NxOgre::Box(1, 1, 1),NxOgre::Vec3(5, 20, 0),"cube.1m.mesh");
m_NXOgreRenderSystem->createBody(new NxOgre::Box(1, 1, 1),NxOgre::Vec3(-5, 20, 0),"cube.1m.mesh");
m_NXOgreScene->createSceneGeometry(new NxOgre::PlaneGeometry(0, NxOgre::Vec3(0, 1, 0)), Matrix44_Identity);
Ogre::Plane *plane = new Ogre::Plane;
plane->normal = Ogre::Vector3::UNIT_Y;
plane->d = 0;
Ogre::MeshManager::getSingleton().createPlane("ground",
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, *plane,
150, 150, 20, 20, true, 1, 5, 5, Ogre::Vector3::UNIT_Z);
Ogre::Entity* pPlaneEnt = m_sceneMgr->createEntity("groundInstance", "ground");
pPlaneEnt->setCastShadows(false);
pPlaneEnt->setMaterialName("Examples/GrassFloor");
m_sceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(pPlaneEnt);
return true;
}
示例10: crearEscenario
void TutorialApplication::crearEscenario(void)
{
Ogre::Light* luzPrincipal = mSceneMgr->createLight();
luzPrincipal->setType(Ogre::Light::LT_DIRECTIONAL);
luzPrincipal->setPosition(Ogre::Vector3(0, 100, 0));
luzPrincipal->setDirection(Ogre::Vector3(0, -1, 0));
luzPrincipal->setDiffuseColour(Ogre::ColourValue(1, 1, 1));
luzPrincipal->setSpecularColour(Ogre::ColourValue(1, 1, 1));
Ogre::Plane plane(Ogre::Vector3::UNIT_Y, 0);
Ogre::MeshManager::getSingleton().createPlane("ground", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
plane, 254, 127, 10, 10, true, 1, 5, 5, Ogre::Vector3::UNIT_Z);
Ogre::Entity* groundEntity = mSceneMgr->createEntity("ground");
mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(groundEntity);
groundEntity->setCastShadows(false);
groundEntity->setMaterialName("Custom/TelaBillar");
PxPhysics* gPhysics = PhysxOgr::PhysxController::getInstance()->getPhysics();
PxRigidStatic* groundPlane = PxCreatePlane(*gPhysics, PxPlane(0, 1, 0, 0), *gPhysics->createMaterial(0.5f, 0.5f, 0.6f));
mPhysx->getScene()->addActor(*groundPlane);
crearBorde(Ogre::Vector3(-132, 0, 0), Ogre::Vector3(0.1, 0.1, 1.27));
crearBorde(Ogre::Vector3(132, 0, 0), Ogre::Vector3(0.1, 0.1, 1.27));
crearBorde(Ogre::Vector3(0, 0, 68.5), Ogre::Vector3(2.54, 0.1, 0.1));
crearBorde(Ogre::Vector3(0, 0, -68.5), Ogre::Vector3(2.54, 0.1, 0.1));
}
示例11: setTableAn
void WheelAnimalSceneObj::setTableAn(int n, int table)
{
Ogre::Entity * ent = getEntity(SceneItemMark(TABLE_0+n));
if(ent)
return ent->setMaterialName(_impl->getTableAn(table));
}
示例12: loadEntity
bool VehicleRenderable::loadEntity(TinyXml::TiXmlElement* ele, Ogre::SceneNode* parent)
{
Ogre::String name = getAttrib(ele, "name");
Ogre::String castShadow = getAttrib(ele, "castShadows");
Ogre::String receiveShadow = getAttrib(ele, "receiveShadows");
Ogre::String meshFile = getAttrib(ele, "meshFile");
Ogre::String materialFile = getAttrib(ele, "materialFile");
try
{
Ogre::Entity* ent = mSceneMgr->createEntity(name, meshFile);
mEntities.push_back(ent);
ent->setCastShadows(Ogre::StringConverter::parseBool(castShadow));
if (!materialFile.empty())
ent->setMaterialName(materialFile);
parent->attachObject(ent);
}
catch (...)
{
Ogre::LogManager::getSingleton().logMessage("VehicleRenderable Error : parsing <" + name + "> error!");
return false;
}
return true;
}
示例13: QWidget
SceneWidget::SceneWidget(QWidget *parent)
: QWidget(parent)
, mWindow(NULL)
, mCamera(NULL)
, mSceneMgr(NULL)
{
setAttribute(Qt::WA_PaintOnScreen);
setAttribute(Qt::WA_NoSystemBackground);
mSceneMgr = Ogre::Root::getSingleton().createSceneManager(Ogre::ST_GENERIC);
// Throw in a random color just to make sure multiple scenes work
Ogre::Real r = Ogre::Math::RangeRandom(0, 1);
Ogre::Real g = Ogre::Math::RangeRandom(0, 1);
Ogre::Real b = Ogre::Math::RangeRandom(0, 1);
mSceneMgr->setAmbientLight(Ogre::ColourValue(r,g,b,1));
Ogre::Light* l = mSceneMgr->createLight();
l->setType (Ogre::Light::LT_DIRECTIONAL);
l->setDirection (Ogre::Vector3(-0.4, -0.7, 0.3));
l->setDiffuseColour (Ogre::ColourValue(0.7,0.7,0.7));
mCamera = mSceneMgr->createCamera("foo");
Ogre::Entity* ent = mSceneMgr->createEntity("cube", Ogre::SceneManager::PT_CUBE);
ent->setMaterialName("BaseWhite");
mSceneMgr->getRootSceneNode()->attachObject(ent);
mCamera->setPosition(300,300,300);
mCamera->lookAt(0,0,0);
mCamera->setNearClipDistance(0.1);
mCamera->setFarClipDistance(3000);
}
示例14: CreateParticleEntity
void OgreApplication::CreateParticleEntity(Ogre::String entity_name, Ogre::String object_name, Ogre::String material_name){
try {
/* Create one instance of the torus (one entity) */
/* The same object can have multiple instances or entities */
/* Retrieve scene manager and root scene node */
Ogre::SceneManager* scene_manager = ogre_root_->getSceneManager("MySceneManager");
Ogre::SceneNode* root_scene_node = scene_manager->getRootSceneNode();
/* Create entity */
Ogre::Entity* entity = scene_manager->createEntity(object_name);
/* Apply a material to the entity */
entity->setMaterialName(material_name);
particle_material_name_ = material_name;
/* Create a scene node for the entity */
/* The scene node keeps track of the entity's position */
Ogre::SceneNode* scene_node = root_scene_node->createChildSceneNode(entity_name);
scene_node->attachObject(entity);
/* Scale the entity */
scene_node->scale(0.5, 0.5, 0.5);
}
catch (Ogre::Exception &e){
throw(OgreAppException(std::string("Ogre::Exception: ") + std::string(e.what())));
}
catch(std::exception &e){
throw(OgreAppException(std::string("std::Exception: ") + std::string(e.what())));
}
}
示例15: createDefaultScene
void BaseManager::createDefaultScene()
{
mNode = mSceneManager->getRootSceneNode()->createChildSceneNode();
try
{
Ogre::Entity* entity = mSceneManager->createEntity("Mikki.mesh", "Mikki.mesh");
mNode->attachObject(entity);
}
catch (Ogre::FileNotFoundException&)
{
WARNING_LOG( "Can't load Mikki.mesh" )
}
try
{
Ogre::MeshManager::getSingleton().createPlane(
"FloorPlane", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
Ogre::Plane(Ogre::Vector3::UNIT_Y, 0), 1000, 1000, 1, 1, true, 1, 1, 1, Ogre::Vector3::UNIT_Z);
Ogre::Entity* entity = getSceneManager()->createEntity("FloorPlane", "FloorPlane");
entity->setMaterialName("Ground");
mNode->attachObject(entity);
}
catch (Ogre::FileNotFoundException&)
{
return;
}
}