本文整理汇总了C++中ogre::SceneManager类的典型用法代码示例。如果您正苦于以下问题:C++ SceneManager类的具体用法?C++ SceneManager怎么用?C++ SceneManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SceneManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createDummyScene
void AbstractGameCore::createDummyScene()
{
m_pRenderWindow->removeAllViewports();
Ogre::SceneManager* sm = m_pOgreRoot->createSceneManager(Ogre::ST_GENERIC, "DummyScene");
Ogre::Camera* cam = sm->createCamera("DummyCamera");
m_pRenderWindow->addViewport(cam);
}
示例2: rayTest
bool gkMouseSensor::rayTest(void)
{
// cannot test no movable data,
if (m_type == MOUSE_MOUSE_OVER && (m_object->getType() == GK_OBJECT || m_object->getType() == GK_SKELETON))
return false;
GK_ASSERT(m_object);
gkCamera* cam = m_object->getOwner()->getMainCamera();
Ogre::Camera* oc = cam->getCamera();
gkMouse* mse = gkWindowSystem::getSingleton().getMouse();
gkScalar ncx = mse->position.x / mse->winsize.x;
gkScalar ncy = mse->position.y / mse->winsize.y;
Ogre::Ray dest;
oc->getCameraToViewportRay(ncx, ncy, &dest);
if (m_rayQuery == 0)
{
Ogre::SceneManager* mgr = m_object->getOwner()->getManager();
m_rayQuery = mgr->createRayQuery(dest);
}
else m_rayQuery->setRay(dest);
// do the test
Ogre::RaySceneQueryResult& res = m_rayQuery->execute();
bool result = false;
for (Ogre::RaySceneQueryResult::iterator it = res.begin(); it != res.end(); ++it)
{
Ogre::RaySceneQueryResultEntry ent = (*it);
if (ent.movable == oc)
continue;
if (ent.movable)
{
if (m_type == MOUSE_MOUSE_OVER)
{
if (ent.movable == m_object->getMovable())
{
result = true;
break;
}
}
else
{
result = true;
break;
}
}
}
return result;
}
示例3: RemoveMesh
void EC_Mesh::RemoveMesh()
{
OgreWorldPtr world = world_.lock();
if (entity_)
{
emit MeshAboutToBeDestroyed();
RemoveAllAttachments();
DetachEntity();
Ogre::SceneManager* sceneMgr = world->OgreSceneManager();
sceneMgr->destroyEntity(entity_);
entity_ = 0;
}
if (!cloned_mesh_name_.empty())
{
try
{
Ogre::MeshManager::getSingleton().remove(cloned_mesh_name_);
}
catch(Ogre::Exception& e)
{
LogWarning("EC_Mesh::RemoveMesh: Could not remove cloned mesh:" + std::string(e.what()));
}
cloned_mesh_name_ = std::string();
}
}
示例4: enter
void MainGameState::enter()
{
// Create the scene
m_pScene = new Scene("main");
Visual::World* pVisualWorld = new Visual::World("", m_pScene->getComponentsList());
Ogre::SceneManager* pSceneManager = pVisualWorld->createSceneManager(Ogre::ST_GENERIC);
pSceneManager->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_ADDITIVE);
pSceneManager->setShadowFarDistance(20.0f);
pVisualWorld->setAmbientLight(Color(0.5f, 0.5f, 0.5f));
m_pCameraEntity = m_pScene->create("Camera");
Visual::Camera* pCamera = new Visual::Camera("Camera", m_pCameraEntity->getComponentsList());
pCamera->createViewport(Engine::getSingletonPtr()->getMainWindow());
pCamera->setAutoAspectRatio(true);
pCamera->setNearClipDistance(1.0f);
m_pCameraEntity->getTransforms()->setPosition(0.0f, 0.0f, 300.0f);
m_pEntity = m_pScene->create("Head");
Visual::Object* pObject = new Visual::Object("Mesh", m_pEntity->getComponentsList());
pObject->loadMesh("ogrehead.mesh");
Entity* pLightEntity = m_pScene->create("Light");
pLightEntity->getTransforms()->setPosition(200.0f, 100.0f, 200.0f);
Visual::PointLight* pLight = new Visual::PointLight("Light", pLightEntity->getComponentsList());
pLight->setDiffuseColor(Color(0.8f, 0.8f, 0.8f));
m_pScene->show();
}
示例5: GetName
NxNode::~NxNode()
{
LogMsg("Erasing NxNode : " + GetName() );
LogMsg("Erasing NxActors ... " );
NxActorListIterator NxActorsIter = GetNxActorIterator();
while( NxActorsIter.hasMoreElements() ){
delete NxActorsIter.getNext();
}
mNxActors.clear();
LogMsg("Erasing NxActors : DONE" );
LogMsg("Erasing NxSounds ... " );
NxSoundMapIterator SoundIter = GetNxSoundIterator();
while( SoundIter.hasMoreElements() ){
delete SoundIter.getNext();
}
LogMsg("Erasing NxSounds : DONE" );
LogMsg("Erasing NxEntities... " );
NxEntityListIterator EntityIter = GetNxEntityIterator();
while( EntityIter.hasMoreElements() ){
delete EntityIter.getNext();
}
LogMsg("Erasing NxEntities : DONE" );
Ogre::SceneManager * mManager = mSceneNode->getCreator(); // detach child first ?
mManager->destroySceneNode( mSceneNode );
LogMsg("Erasing NxNode : Done" );
LogMsg("-----------------------");
}
示例6: AddConstructionCapability
void LagomPlayerBase::AddConstructionCapability(LagomActorFactory* f)
{
if(!f)
return;
if(_actorFactories.find(f) != _actorFactories.end())
return;
Ogre::SceneManager* manager = _state.GetSceneManager();
Ogre::SceneNode* node = manager->createSceneNode();
Ogre::Entity* constructionObject = manager->createEntity(f->Mesh.c_str());
Ogre::MaterialPtr materialPtr = Ogre::MaterialManager::getSingleton().getByName(getIntFactory().ConstructingMaterial);
materialPtr->setSelfIllumination(1.0f,1.0f,1.0f);
constructionObject->setCastShadows(false);
constructionObject->setRenderQueueGroup(RENDER_QUEUE_SKIES_LATE);
constructionObject->setMaterialName(getIntFactory().ConstructingMaterial);
node->attachObject(constructionObject);
node->setScale( f->MeshScale );
_actorFactories.insert(FactoryMap::value_type(f,node));
if( _selectedActorFactory ==_actorFactories.end())
_selectedActorFactory=_actorFactories.begin();
}
示例7: drawRaycast
// Dibujado de raycast para depurar
void CShootRaycast::drawRaycast(const Ray& raycast) {
Graphics::CScene *scene = Graphics::CServer::getSingletonPtr()->getActiveScene();
Ogre::SceneManager *mSceneMgr = scene->getSceneMgr();
std::stringstream aux;
aux << "laser" << _nameWeapon << _temporal;
++_temporal;
std::string laser = aux.str();
Ogre::ManualObject* myManualObject = mSceneMgr->createManualObject(laser);
Ogre::SceneNode* myManualObjectNode = mSceneMgr->getRootSceneNode()->createChildSceneNode(laser+"_node");
myManualObject->begin("laser", Ogre::RenderOperation::OT_LINE_STRIP);
Vector3 v = raycast.getOrigin();
myManualObject->position(v.x,v.y,v.z);
for(int i=0; i < _distance;++i){
Vector3 v = raycast.getPoint(i);
myManualObject->position(v.x,v.y,v.z);
// etc
}
myManualObject->end();
myManualObjectNode->attachObject(myManualObject);
}// drawRaycast
示例8: paintPlaceShipMode
/*
*Paint the board and the ships needed to place the ships
*
*/
void MyFrameListener::paintPlaceShipMode() {
Board* boardPS = new Board("MyFleetBoard", FLEET_BOARD);
Ogre::Vector3* fleetBoardPosition = new Ogre::Vector3(-3, 1.0f, 0);
Ogre::SceneManager* currentSM = Ogre::Root::getSingleton().
getSceneManager("mainSM");
boardPS->paintBoard(currentSM,
currentSM->getRootSceneNode(),
fleetBoardPosition);
for ( int i = 0; i < 6; i++ ) {
int size = 4;
if (i < 2) {
size = 1;
} else if (i < 4) {
size = 2;
} else if (i < 5) {
size = 3;
}
Ogre::Vector3* shipPos = new Ogre::Vector3(shipPositions[i][0]
, shipPositions[i][1],
shipPositions[i][2]);
ShipOgreWrapper* ship = new ShipOgreWrapper(i, shipPos, size);
ship->paintShip(currentSM,
currentSM->getRootSceneNode(),
NULL);
boardPS->addShip(ship);
}
this->playerBoard = boardPS;
}
示例9: DestroyOcean
void EC_MeshmoonWater::DestroyOcean()
{
#ifdef MESHMOON_TRITON
if (!state_.IsCreated())
return;
try
{
Ogre::SceneManager *ogreSceneManager = OgreSceneManager();
if (ogreSceneManager)
{
if (renderQueueListener_)
ogreSceneManager->removeRenderQueueListener(renderQueueListener_);
}
else
LogWarning(LC + "Failed to uninitialize Triton library cleanly from Ogre, rendering scene not available!");
if (renderSystemListener_)
Ogre::Root::getSingleton().getRenderSystem()->removeListener(renderSystemListener_);
}
catch(const Ogre::Exception &ex)
{
LogError(LC + QString::fromStdString(ex.getDescription()));
}
SAFE_DELETE(renderQueueListener_);
SAFE_DELETE(renderSystemListener_);
SAFE_DELETE(renderTargetListener_);
SAFE_DELETE(state_.environment);
SAFE_DELETE(state_.ocean);
SAFE_DELETE(state_.resourceLoader);
state_.Reset();
#endif
}
示例10: operator
bool operator()()
{
Ogre::SceneManager* sm = GraphicsManager::get().sceneManager();
Ogre::SceneNode* sceneNode =
positionComponent->sceneNode()->createChildSceneNode(
Ogre::StringConverter::toString(
component->localId()),
offset,
offsetRotation);
Ogre::ParticleSystem* ps = sm->createParticleSystem(
Ogre::StringConverter::toString(component->localId()),
fileName);
sceneNode->attachObject(ps);
component->m_sceneNode = sceneNode;
component->m_particleSystem = ps;
ThreadPool::get().schedule(boost::bind(
&ComponentContainer::componentAttachedCallback,
component->parent(), component));
return true;
}
示例11: operator
bool operator()()
{
Ogre::SceneManager* sm = GraphicsManager::get().sceneManager();
Ogre::Entity* entity = sm->createEntity(
Ogre::StringConverter::toString(component->localId()),
fileName);
Ogre::StaticGeometry* sg = sm->createStaticGeometry(
Ogre::StringConverter::toString(component->localId()));
sg->addEntity(
entity,
positionComponent->sceneNode()->getPosition() + offset,
positionComponent->sceneNode()->getOrientation() *
offsetRotation);
sg->build();
component->m_entity = entity;
component->m_staticGeometry = sg;
ThreadPool::get().schedule(boost::bind(
&ComponentContainer::componentAttachedCallback,
component->parent(), component));
return true;
}
示例12: createOgreVehicle
OgreVehicle* OgreVehicle::createOgreVehicle(Ogre::SceneNode* parNode, std::string name, Ogre::Vector3 pos)
{
if (parNode)
{
OgreVehicle* vehicle = new OgreVehicle();
vehicle->mName = name;
vehicle->mParNode = parNode;
Ogre::SceneManager* sceneMgr = vehicle->mParNode->getCreator();
Ogre::String nodeName = "User_" + name;
vehicle->mNode = vehicle->mParNode->createChildSceneNode(nodeName);
Ogre::SceneNode* pNodeBody = vehicle->mNode->createChildSceneNode("Body" + nodeName);
Ogre::SceneNode* pNodeCam = vehicle->mNode->createChildSceneNode("Cam" + nodeName);
Ogre::Entity* eBody = sceneMgr->createEntity("eBody"+nodeName, OGRE_VEHICLE_FILE);
pNodeBody->attachObject(eBody);
pNodeBody->setScale(0.0002*SCALE_TERRAIN, 0.0002*SCALE_TERRAIN, 0.0002*SCALE_TERRAIN);
vehicle->mNode->setPosition(pos);
vehicle->mWheels[0] = OgreWheel::createOgreWheel(pNodeBody, Ogre::Vector3(1.02f, -0.3622f, 1.26));
vehicle->mWheels[1] = OgreWheel::createOgreWheel(pNodeBody, Ogre::Vector3(1.12f, -0.3622f,-1.54));
vehicle->mWheels[2] = OgreWheel::createOgreWheel(pNodeBody, Ogre::Vector3(-1.02f, -0.3622f, 1.26));
vehicle->mWheels[3] = OgreWheel::createOgreWheel(pNodeBody, Ogre::Vector3(-1.12f, -0.3622f,-1.54));
return vehicle;
}
return NULL;
}
示例13: updateFromCamera
void DeferredLight::updateFromCamera(Ogre::Camera* camera)
{
const Ogre::MaterialPtr& mat = getMaterial();
if (!mat->isLoaded())
{
mat->load();
}
Ogre::Technique* tech = mat->getBestTechnique();
Ogre::Vector3 farCorner = camera->getViewMatrix(true) * camera->getWorldSpaceCorners()[4];
for (unsigned short i=0; i<tech->getNumPasses(); i++)
{
Ogre::Pass* pass = tech->getPass(i);
Ogre::GpuProgramParametersSharedPtr params = pass->getVertexProgramParameters();
if (params->_findNamedConstantDefinition("farCorner"))
params->setNamedConstant("farCorner", farCorner);
params = pass->getFragmentProgramParameters();
if (params->_findNamedConstantDefinition("farCorner"))
params->setNamedConstant("farCorner", farCorner);
// If inside light geometry, render back faces with CMPF_GREATER, otherwise normally
if (mParentLight->getType() == Ogre::Light::LT_DIRECTIONAL)
{
pass->setCullingMode(Ogre::CULL_CLOCKWISE);
pass->setDepthCheckEnabled(false);
}
else
{
pass->setDepthCheckEnabled(true);
if (isCameraInsideLight(camera))
{
pass->setCullingMode(Ogre::CULL_ANTICLOCKWISE);
pass->setDepthFunction(Ogre::CMPF_GREATER_EQUAL);
}
else
{
pass->setCullingMode(Ogre::CULL_CLOCKWISE);
pass->setDepthFunction(Ogre::CMPF_LESS_EQUAL);
}
}
Ogre::Camera shadowCam("ShadowCameraSetupCam", 0);
shadowCam._notifyViewport(camera->getViewport());
Ogre::SceneManager* sm = mParentLight->_getManager();
sm->getShadowCameraSetup()->getShadowCamera(sm,
camera, camera->getViewport(), mParentLight, &shadowCam, 0);
//Get the shadow camera position
if (params->_findNamedConstantDefinition("shadowCamPos"))
{
params->setNamedConstant("shadowCamPos", shadowCam.getPosition());
}
if (params->_findNamedConstantDefinition("shadowFarClip"))
{
params->setNamedConstant("shadowFarClip", shadowCam.getFarClipDistance());
}
}
}
示例14: parseLevel
void Level::parseLevel (XmlFile *file, XMLElement *element)
{
Ogre::SceneManager *mSceneMgr = RadXML::getSingletonPtr ()->getSceneManager ();
name = element->getAttributeValue ("name");
setJavascriptToEvent ("onload", element->getAttributeValue ("onload"));
std::string strSkyBox = element->getAttributeValue ("skybox");
std::string strAmbientColor = element->getAttributeValue ("ambientcolor");
std::string strShadowColor = element->getAttributeValue ("shadowcolor");
if (name == "")
{
int iRandName = rand ();
setName (RadXmlCommon::s13IntToString (iRandName));
}
if (strSkyBox != "")
mSceneMgr->setSkyBox (true, strSkyBox);
if (strAmbientColor != "")
{
Ogre::ColourValue cvColor = RadXML::parseColourValue (strAmbientColor);
mSceneMgr->setAmbientLight (cvColor);
}
if (strShadowColor != "")
{
Ogre::ColourValue cvColor = RadXML::parseColourValue (strAmbientColor);
mSceneMgr->setShadowColour (cvColor);
}
parseXMLMovables (file, element);
}
示例15:
GameplayScreen::~GameplayScreen()
{
//Destroy our game objects
delete mWhacker;
for(unsigned int i=0; i<mDragons.size(); i++)
{
delete mDragons[i];
}
//Destroy all entities created
Ogre::SceneManager* mSceneManager = Ogre::Root::getSingletonPtr()->getSceneManager("ApplicationSceneManager");
mSceneManager->destroyEntity("Stage");
//Remove the stage mesh
mStageNode->removeAndDestroyAllChildren();
mStageNode->getParentSceneNode()->removeAndDestroyChild(mStageNode->getName());
//Destroy our score overlay
//To do this, we must traverse all elements contained within
//the overlay and remove them one at a time.
Ogre::OverlayManager* overlayMgr = Ogre::OverlayManager::getSingletonPtr();
Ogre::Overlay::Overlay2DElementsIterator iter = mOverlay->get2DElementsIterator();
for(;iter.hasMoreElements();)
{
Ogre::OverlayContainer * childContainer = iter.getNext();
Ogre::OverlayContainer::ChildIterator contIter = childContainer->getChildIterator();
for(;contIter.hasMoreElements();)
{
Ogre::OverlayElement* curElement = contIter.getNext();
overlayMgr->destroyOverlayElement(curElement->getName());
}
overlayMgr->destroyOverlayElement(childContainer->getName());
}
overlayMgr->destroy(mOverlay->getName());
}