本文整理汇总了C++中ogre::SceneManager::createLight方法的典型用法代码示例。如果您正苦于以下问题:C++ SceneManager::createLight方法的具体用法?C++ SceneManager::createLight怎么用?C++ SceneManager::createLight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::SceneManager
的用法示例。
在下文中一共展示了SceneManager::createLight方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
void TerrainOgreComponent::init()
{
OgreComponent::init();
Ogre::SceneManager* sMgr = StateManager::getInstance()->inGameState->getSceneMgr();
// Copy-pasted from the tutorials, need to tweak
sMgr->setAmbientLight(Ogre::ColourValue(0.0, 0.0, 0.0));
sMgr->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_ADDITIVE);
/*
Ogre::Entity* entNinja = sMgr->createEntity("Ninja", "chassis.mesh");
entNinja->setCastShadows(true);
Ogre::SceneNode* ninjaNode = sMgr->getRootSceneNode()->createChildSceneNode();
// ninjaNode->setScale(20, 20, 20);
ninjaNode->setPosition(0, 2, 2);
ninjaNode->attachObject(entNinja);
*/
Ogre::Plane plane(Ogre::Vector3::UNIT_Y, 0);
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::Entity* entGround = sMgr->createEntity("GroundEntity", "ground");
sMgr->getRootSceneNode()->createChildSceneNode()->attachObject(entGround);
entGround->setMaterialName("Ground/Grid");
entGround->setCastShadows(false);
/*
Ogre::Light* pointLight = sMgr->createLight("pointLight");
pointLight->setType(Ogre::Light::LT_POINT);
pointLight->setPosition(Ogre::Vector3(0, 50, 0));
pointLight->setDiffuseColour(1.0, 1.0, 1.0);
pointLight->setSpecularColour(1.0, 1.0, 1.0);
*/
Ogre::Light* directionalLight = sMgr->createLight("directionalLight");
directionalLight->setType(Ogre::Light::LT_DIRECTIONAL);
directionalLight->setDiffuseColour(Ogre::ColourValue(.1, .1, .1));
directionalLight->setSpecularColour(Ogre::ColourValue(.1, .1, .1));
directionalLight->setDirection(Ogre::Vector3( 0, -1, .3));
Ogre::Light* spotLight = sMgr->createLight("spotLight");
spotLight->setType(Ogre::Light::LT_SPOTLIGHT);
spotLight->setDiffuseColour(1.0, 1.0, 1.0);
spotLight->setSpecularColour(1.0, 1.0, 1.0);
spotLight->setDirection(-1, -1, 0);
spotLight->setPosition(Ogre::Vector3(30, 30, 0));
spotLight->setSpotlightRange(Ogre::Degree(10), Ogre::Degree(50));
//sMgr->setSkyDome(true, "Sky/Stars", 5, 8);
/* Consider: weirnc: Add fog in the future? Can't get the 2nd line to work
Ogre::ColourValue fadeColour(0.9, 0.9, 0.9);
Application::getInstance()->getWindow()->getViewport(0)->setBackgroundColour(fadeColour);
sMgr->setFog(Ogre::FOG_EXP, fadeColour, 0.0, 50, 500);
*/
}
示例2: _createLight
VBOOL VPointLightElement::_createLight()
{
assert(VNULL == mLight);
VBOOL result = VFALSE;
if (mBaseNode != VNULL)
{
Ogre::SceneManager *sceneMgr = VENGINE.getGfxSystem()->getSceneManager();
mLight = sceneMgr->createLight(mBaseNode->getName());
// ³õʼ»¯¹âÔ´
mLight->setDiffuseColour(mDiffuse);
mLight->setSpecularColour(mSpecular);
mLight->setAttenuation(mRange, mAttenuationConstant, mAttenuationLinear, mAttenuationQuadric);
mLight->setCastShadows(VFALSE);
mLight->setVisible(mVisible);
mBaseNode->attachObject(mLight);
mBaseNode->setPosition(mRelPos);
mBaseNode->setOrientation(mRelOrientation);
result = VTRUE;
}
return result;
}
示例3: loadMesh
//-------------------------------------------------------------------------------------------
void MagickWidget::loadMesh(Ogre::MeshPtr pMesh)
{
QString directory(OgitorsRoot::getSingletonPtr()->GetProjectOptions()->ProjectDir.c_str());
if(directory.isEmpty())
directory = "./";
QDir(directory).mkpath("entitycache");
Ogre::TexturePtr texture = Ogre::TextureManager::getSingleton().createManual( "MeshMagickTex",
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D,
512, 512, 0, Ogre::PF_R8G8B8A8 , Ogre::TU_RENDERTARGET );
Ogre::RenderTexture *rttTex = texture->getBuffer()->getRenderTarget();
Ogre::SceneManager *mSceneMgr = Ogre::Root::getSingletonPtr()->createSceneManager("OctreeSceneManager", "MeshMagickTexMgr");
Ogre::Light *dirl = mSceneMgr->createLight("DisplayLight");
dirl->setDirection(-1,-1,-1);
dirl->setDiffuseColour(1,1,1);
dirl->setType(Ogre::Light::LT_DIRECTIONAL);
Ogre::Camera* RTTCam = mSceneMgr->createCamera("MeshMagickCam");
RTTCam->setNearClipDistance(0.01F);
RTTCam->setFarClipDistance(0);
RTTCam->setAspectRatio(1);
RTTCam->setFOVy(Ogre::Degree(90));
RTTCam->setPosition(0,0,1);
RTTCam->lookAt(0,0,0);
Ogre::Viewport *v = rttTex->addViewport( RTTCam );
v->setClearEveryFrame( true );
v->setBackgroundColour(Ogre::ColourValue(0,0,0));
Ogre::Entity *mEntity;
mEntity = mSceneMgr->createEntity("scbDisplay", pMesh->getName());
mSceneMgr->getRootSceneNode()->attachObject(mEntity);
Ogre::Vector3 vSize = mEntity->getBoundingBox().getHalfSize();
Ogre::Vector3 vCenter = mEntity->getBoundingBox().getCenter();
vSize += Ogre::Vector3(vSize.z, vSize.z, vSize.z);
float maxsize = std::max(std::max(vSize.x,vSize.y),vSize.z);
vSize = Ogre::Vector3(0, 0, maxsize * 1.15f) + vCenter;
RTTCam->setPosition(vSize.x,vSize.y,vSize.z);
RTTCam->lookAt(vCenter.x,vCenter.y,vCenter.z);
rttTex->update();
Ogre::String imagefile = OgitorsUtils::QualifyPath(directory.toStdString() + "/entitycache/meshmagick.png");
rttTex->writeContentsToFile(imagefile);
mEntity->detachFromParent();
mSceneMgr->destroyEntity(mEntity);
rttTex->removeAllViewports();
Ogre::Root::getSingletonPtr()->destroySceneManager(mSceneMgr);
mDisplayWidget->setImage(QString(imagefile.c_str()));
}
示例4: SetupScene
void DepthVideoApp::SetupScene(void)
{
Ogre::SceneManager* sceneManager = MagicCore::RenderSystem::Get()->GetSceneManager();
sceneManager->setAmbientLight(Ogre::ColourValue(0.3, 0.3, 0.3));
Ogre::Light* light = sceneManager->createLight("DepthVideoApp_SimpleLight");
light->setPosition(0, 0, 20);
light->setDiffuseColour(0.8, 0.8, 0.8);
light->setSpecularColour(0.5, 0.5, 0.5);
InitViewTool();
}
示例5: SetupScene
void PointShopApp::SetupScene(void)
{
InfoLog << "PointShopApp::SetupScene" << std::endl;
Ogre::SceneManager* pSceneMgr = MagicCore::RenderSystem::GetSingleton()->GetSceneManager();
pSceneMgr->setAmbientLight(Ogre::ColourValue(0.1, 0.1, 0.1));
Ogre::Light* sl = pSceneMgr->createLight("SimpleLight");
sl->setPosition(0, 0, 20);
sl->setDiffuseColour(0.8, 0.8, 0.8);
sl->setSpecularColour(0.5, 0.5, 0.5);
}
示例6:
Ogre::SceneManager *OgreInitializer::createSceneManager(Ogre::SceneType type)
{
Ogre::SceneManager * mgr = mRoot->createSceneManager(type);
mgr->setSkyBox(true,"Examples/CloudyNoonSkyBox");
mgr->setAmbientLight(Ogre::ColourValue::White);
mgr->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_ADDITIVE);
Ogre::Light * l = mgr->createLight();
l->setType(Ogre::Light::LT_DIRECTIONAL);
l->setDirection(0.03, -1.0, 0.01);
return mgr;
}
示例7: CreateSunlight
void EC_OgreEnvironment::CreateSunlight()
{
if (renderer_.expired())
return;
RendererPtr renderer = renderer_.lock();
Ogre::SceneManager* sceneManager = renderer->GetSceneManager();
sunlight_ = sceneManager->createLight(renderer->GetUniqueObjectName());
sunlight_->setType(Ogre::Light::LT_DIRECTIONAL);
///\todo Read parameters from config file?
sunlight_->setDiffuseColour(0.93f, 1, 0.13f);
sunlight_->setDirection(-1, -1, -1);
sunlight_->setCastShadows(true);
SetAmbientLightColor(Color(0.5, 0.5, 0.5, 1));
}
示例8: mSceneManager
MapCameraLightning::MapCameraLightning(Ogre::SceneManager& sceneManager)
: mSceneManager(sceneManager)
{
mLight = sceneManager.createLight("MapFixedSunLight");
mLight->setType(Ogre::Light::LT_DIRECTIONAL);
mLight->setPosition(Ogre::Vector3(-500,300,-350));
Ogre::Vector3 dir = -mLight->getPosition();
dir.normalise();
mLight->setDirection(dir);
mLight->setDiffuseColour(Ogre::ColourValue(0.8, 0.8, 0.6)); //yellow
//mSun->setSpecularColour(1, 1, 0.7); //yellow
mLight->setCastShadows(false);
mLight->setAttenuation(1000000, 1, 0, 0);
mLight->setVisible(false);
}
示例9: createScene
void createScene(){
_sceneManager->setAmbientLight(Ogre::ColourValue(1.0f,1.0f,1.0f));
Ogre::SceneNode* nodeEsfera02;
Ogre::Light* light02;
Ogre::SceneNode* nM01 = _sceneManager->createSceneNode("nm01");
Ogre::Entity* entMesh01 = _sceneManager->createEntity("Entnm01", "proyectoOgreI.mesh");
_sceneManager->getRootSceneNode()->addChild(nM01);
nM01->attachObject(entMesh01);
entMesh01->setMaterialName("mat02");
Ogre::SceneNode* nM02 = _sceneManager->createSceneNode("nm02");
Ogre::Entity* entMesh02 = _sceneManager->createEntity("Entnm02", "ejes01.mesh");
_sceneManager->getRootSceneNode()->addChild(nM02);
nM02->attachObject(entMesh02);
nM02->scale(10.0f,10.0f,10.0f);
Ogre::SceneNode* nM03 = _sceneManager->createSceneNode("nm03");
Ogre::Entity* entMesh03 = _sceneManager->createEntity("Entnm03", "ogrehead.mesh");
_sceneManager->getRootSceneNode()->addChild(nM03);
nM03->attachObject(entMesh03);
nM03->scale(5.0f,5.0f,5.0f);
entMesh03->setMaterialName("mat01");
Ogre::Entity* entEsfera02 = _sceneManager->createEntity("EntEsfera02","sphere.mesh");
//Ogre::SceneNode* nodeEsfera02 = mSceneMgr->createSceneNode("NodeEsfera02");
nodeEsfera02 = _sceneManager->createSceneNode("NodeEsfera02");
_sceneManager->getRootSceneNode()->addChild(nodeEsfera02);
nodeEsfera02->attachObject(entEsfera02);
//NODO LUZ
float lightScale = 0.9f;
Ogre::SceneNode* nodeLuz02 = _sceneManager->createSceneNode("NodeLuz02");
light02 = _sceneManager->createLight("LuzPoint01");
light02->setType(Ogre::Light::LT_POINT);
light02->setDiffuseColour(lightScale*Ogre::ColourValue(2.0f,2.0f,2.0f));
nodeLuz02->attachObject(light02);
nodeEsfera02->addChild(nodeLuz02);
nodeEsfera02->setScale(0.05f,0.05f,0.05f);
nodeEsfera02->setPosition(-500.0f,500.0f,500.0f);
}
示例10: ShowTanks
//---------------------------------------------------------------------------------------------
void TShowTankWoT_test::ShowTanks(int cnt)
{
Ogre::SceneManager* pSM = TModuleLogic::Get()->GetC()->pGraphicEngine->GetGE()->GetSceneManager();
pSM->setAmbientLight(Ogre::ColourValue(1, 1, 1));
// light
Ogre::String nameLight = "mainLight";
Ogre::Light* pLight = NULL;
if( pSM->hasLight(nameLight) )
pLight = pSM->getLight(nameLight);
else
pLight = pSM->createLight(nameLight);
pLight->setType(Ogre::Light::LT_SPOTLIGHT);
pLight->setCastShadows(false);
pLight->setVisible(true);
Ogre::Vector3 posLight(0,0,0);
pLight->setPosition(posLight);
Ogre::Vector3 dirLight(1,0,0);
dirLight.normalise();
pLight->setDirection(dirLight);
//pLight->setSpotlightRange(Ogre::Degree(20.0f), Ogre::Degree(25.0f), 0.95f);
pLight->setDiffuseColour(1.0f, 1.0f, 1.0f);
pLight->setDiffuseColour(1.0f, 1.0f, 1.0f);
pLight->setSpecularColour(1.0f, 1.0f, 1.0f);
//pLight->setAttenuation(1000.0f, 1.0f, 0.0005f, 0.0f);
// light
Ogre::Vector3 pos;
pos.y = 0;
pos.z = 0;
for( int i = 0 ; i < cnt ; i++ )
{
pos.x = i*50;
ShowTank(i, pos);
}
Ogre::Camera* pCamera = TModuleLogic::Get()->GetC()->pGraphicEngine->GetGE()->GetCamera();
pCamera->setPosition(160,160,160);
pCamera->lookAt(0,0,0);
}
示例11: createProjectile
entityx::Entity Factory::createProjectile(entityx::ptr<EntityManager> where, Ogre::Vector3 pos, Ogre::Quaternion ori, Ogre::Real velocity, std::string materialName)
{
Ogre::Entity *projMesh;
Ogre::SceneManager *sceneMgr = RenderManager::getPtr()->getSceneManager();
projMesh = sceneMgr->createEntity("ProjectileMesh.mesh");
projMesh->setMaterialName(materialName);
Entity proj = where->create();
Ogre::SceneNode *projNode = sceneMgr->getRootSceneNode()->createChildSceneNode();
projNode->attachObject(projMesh);
Ogre::Light *light = sceneMgr->createLight();
if(materialName == "RedLaser")
light->setDiffuseColour(Ogre::ColourValue(.8, .2, .2));
else
light->setDiffuseColour(Ogre::ColourValue(.2, .2, .8));
light->setType(Ogre::Light::LT_POINT);
projNode->attachObject(light);
projNode->setPosition(pos);
projNode->setOrientation(ori);
//projNode->translate(0, 0, -2, Ogre::SceneNode::TS_LOCAL);
proj.assign<Position>(projNode->getPosition());
proj.assign<Orientation>(ori);
proj.assign<Velocity>(0, 0, velocity);
proj.component<Velocity>()->direction.z = -1;
proj.assign<Renderable>(projNode);
proj.assign<AngularVelocity>(0, 0, 10);
proj.assign<Name>("proiettile");
proj.assign<LightComponent>(light);
return proj;
}
示例12: onGameEntityAdded
//int GameDirectionalLight::onGameEntityAdded(Ogre::SceneManager * pSceneManager)
int GameDirectionalLight::onGameEntityAdded(OGraphics::GraphicsSystem * pGraphicsSystem)
{
Ogre::SceneManager * pSceneManager = pGraphicsSystem->getSceneManager();
DirectionalLightUpdateBlock * pInitialBlock = &(mpUpdateBlockGroup->mUpdateBlocks[0]);
Ogre::Light * pLight = pSceneManager->createLight();
if (mpParentEntity)
{
mSceneNode = mpParentEntity->mSceneNode->createChildSceneNode(mSceneType);
}
else
{
mSceneNode = pGraphicsSystem->getSceneNodeWorld()->createChildSceneNode(mSceneType);
}
// pLight needs to be attached before setDirection can be called
mSceneNode->attachObject(pLight);
mSceneNode->setPosition(pInitialBlock->mTransform.vPos);
mSceneNode->setOrientation(pInitialBlock->mTransform.qRot);
pLight->setRenderQueueGroup(pInitialBlock->renderGroupQueue);
pLight->setVisibilityFlags(pInitialBlock->visibilityFlags);
pLight->setPowerScale(pInitialBlock->powerScale);
pLight->setType(mpLightDefinition->lightType);
pLight->setDirection(pInitialBlock->direction);
pLight->setCastShadows(pInitialBlock->castShadows);
pLight->setSpecularColour(pInitialBlock->specular);
pLight->setDiffuseColour(pInitialBlock->diffuse);
mpLightDefinition->mMovableObject = pLight;
pSceneManager->setAmbientLight(
pInitialBlock->ambientLight.upperHemisphere,
pInitialBlock->ambientLight.lowerHemisphere,
pInitialBlock->ambientLight.hemisphereDir,
pInitialBlock->ambientLight.envMapScale);
return 0;
}
示例13: SetupScene
void Homepage::SetupScene()
{
Ogre::SceneManager* sceneManager = MagicCore::RenderSystem::Get()->GetSceneManager();
sceneManager->setAmbientLight(Ogre::ColourValue(0.3, 0.3, 0.3));
Ogre::Light* light = sceneManager->createLight("Homepage_SimpleLight");
light->setPosition(-5, 5, 20);
light->setDiffuseColour(0.8, 0.8, 0.8);
light->setSpecularColour(0.5, 0.5, 0.5);
if (mpViewTool == NULL)
{
mpViewTool = new MagicCore::ViewTool;
}
GPP::TriMesh* triMesh = ModelManager::Get()->GetMesh();
if (triMesh)
{
mpUI->SetModelInfo(triMesh->GetVertexCount(), triMesh->GetTriangleCount());
}
GPP::PointCloud* pointCloud = ModelManager::Get()->GetPointCloud();
if (pointCloud)
{
mpUI->SetModelInfo(pointCloud->GetPointCount(), 0);
}
}
示例14: test
void test()
{
Ogre::Root* pOgre = new Ogre::Root("", "");
pOgre->loadPlugin(RENDER_SYSTEM);
pOgre->setRenderSystem(pOgre->getAvailableRenderers().front());
pOgre->initialise(false);
Ogre::NameValuePairList lArgs;
//lArgs["externalWindowHandle"] = bk::format("%d", (bk::uint)l_window.get_handle()).astr;
Ogre::RenderWindow* pWindow = pOgre->createRenderWindow("Heart|Dockyard", 1024, 768, false, &lArgs);
Ogre::SceneManager* pSceneManager = pOgre->createSceneManager(Ogre::ST_GENERIC,"SceneManager");
pSceneManager->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_ADDITIVE);
pSceneManager->setShadowCameraSetup(Ogre::ShadowCameraSetupPtr(new Ogre::FocusedShadowCameraSetup()));
pSceneManager->setAmbientLight(Ogre::ColourValue(0.1f, 0.1f, 0.1f));
Ogre::Camera* pCamera = pSceneManager->createCamera("Camera");
pCamera->setFixedYawAxis(true, Ogre::Vector3::UNIT_Z);
pCamera->setPosition(Ogre::Vector3(0.0f, 50.0f, 20.0f));
pCamera->lookAt(Ogre::Vector3(0.0f, 0.0f, 0.0f));
pCamera->setNearClipDistance(0.1f);
pCamera->setFarClipDistance(100.0f);
Ogre::Viewport* pViewport = pWindow->addViewport(pCamera);
pViewport->setBackgroundColour(Ogre::ColourValue(0.0f, 0.0f, 0.0f));
pCamera->setAspectRatio(Ogre::Real(pViewport->getActualWidth()) / Ogre::Real(pViewport->getActualHeight()));
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("../data/dockyard.zip", "Zip", "Dockyard", true);
Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
Ogre::MeshManager::getSingleton().createPlane("GroundPlane", "Dockyard", Ogre::Plane(0.0f, 0.0f, 1.0f, 0.0f), 100.0f, 100.0f, 100, 100, true, 1, 3.0f, 3.0f);
Ogre::Entity* pGroundEntity = pSceneManager->createEntity("GroundPlane");
pGroundEntity->setMaterialName("Examples/Rockwall");
pGroundEntity->setCastShadows(false);
pGroundEntity->getSubEntity(0)->getMaterial()->setShadingMode(Ogre::SO_PHONG);
Ogre::SceneNode* pGroundNode = pSceneManager->getRootSceneNode()->createChildSceneNode();
pGroundNode->attachObject(pGroundEntity);
Ogre::Entity* pCubeEntity = pSceneManager->createEntity("Cube", Ogre::SceneManager::PT_CUBE);
pCubeEntity->setMaterialName("Examples/10PointBlock");
pCubeEntity->setCastShadows(true);
Ogre::SceneNode* pCubeNode = pSceneManager->getRootSceneNode()->createChildSceneNode();
pCubeNode->attachObject(pCubeEntity);
pCubeNode->setPosition(0.0f, 0.0f, 5.f);
pCubeNode->setScale(0.1f, 0.1f, 0.1f);
Ogre::ColourValue lColour1(1.0f, 1.0f, 1.0f);
Ogre::ColourValue lColour2(1.0f, 1.0f, 1.0f);
Ogre::ColourValue lColour3(1.0f, 1.0f, 1.0f);
Ogre::Light* pLight1 = pSceneManager->createLight();
pLight1->setType(Ogre::Light::LT_SPOTLIGHT);
pLight1->setPosition(30.0f, 30.0f, 30.0f);
pLight1->setDirection(-1.0f, -1.0f, -1.0f);
pLight1->setSpotlightRange(Ogre::Degree(30), Ogre::Degree(50));
pLight1->setDiffuseColour(lColour1 * 0.5f);
Ogre::Light* pLight2 = pSceneManager->createLight();
pLight2->setType(Ogre::Light::LT_SPOTLIGHT);
pLight2->setPosition(-30.0f, 30.0f, 30.0f);
pLight2->setDirection(1.0f, -1.0f, -1.0f);
pLight2->setSpotlightRange(Ogre::Degree(30), Ogre::Degree(50));
pLight2->setDiffuseColour(lColour2 * 0.5f);
Ogre::Light* pLight3 = pSceneManager->createLight();
pLight3->setType(Ogre::Light::LT_SPOTLIGHT);
pLight3->setPosition(30.0f, -30.0f, 30.0f);
pLight3->setDirection(-1.0f, 1.0f, -1.0f);
pLight3->setSpotlightRange(Ogre::Degree(30), Ogre::Degree(50));
pLight3->setDiffuseColour(lColour3 * 0.5f);
Ogre::Overlay* pMenuOverlay = Ogre::OverlayManager::getSingleton().create("Menu");
Ogre::OverlayElement* pMenu = Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", "Menu");
pMenu->setMetricsMode(Ogre::GMM_PIXELS);
pMenu->setWidth(200);
pMenu->setHeight(200);
pMenu->setTop(30);
pMenu->setLeft(30);
pMenu->setMaterialName("Examples/BumpyMetal");
if (pMenu->isContainer()) pMenuOverlay->add2D(static_cast<Ogre::OverlayContainer*>(pMenu));
pMenuOverlay->show();
pOgre->startRendering();
}
示例15: setup
void btoBiome::setup() {
btBiome::setup();
// Essential objects
BulletOgreEngine* btoEngine = world->getBulletOgreEngine();
Ogre::SceneManager* sceneManager = btoEngine->getOgreEngine()->getOgreSceneManager();
// ---------
// -- Sky --
// ---------
if(data.contains("skyMaterial")) {
QString skyMaterial = data["skyMaterial"].toString();
if(skyMaterial.contains("box", Qt::CaseInsensitive))
sceneManager->setSkyBox(true, skyMaterial.toStdString(), 1000);
else
sceneManager->setSkyDome(true, skyMaterial.toStdString(), 10, 8, 1000);
}
// -------------
// -- Shadows --
// -------------
sceneManager->setShadowTechnique(Ogre::SHADOWTYPE_NONE);
sceneManager->setAmbientLight(Ogre::ColourValue(0.3, 0.3, 0.3, 0.3));
// ------------
// -- Lights --
// ------------
int nbPointLights = 0; // for id
int nbDirectionalLights = 0; // for id
int nbSpotLights = 0; // for id
foreach(QVariant lightData, lightsData) {
QVariantMap lightMap = lightData.toMap();
// TODO diffuse and specular !!! dr, dg, db, sr, sg, sb
btScalar r = lightMap["r"].toFloat();
btScalar g = lightMap["g"].toFloat();
btScalar b = lightMap["b"].toFloat();
QString type = lightMap["type"].toString();
if(type.compare("ambient") == 0) {
sceneManager->setAmbientLight(Ogre::ColourValue(r, g, b));
}
else if(type.compare("point") == 0) {
nbPointLights++;
btScalar x = lightMap["posX"].toFloat();
btScalar y = lightMap["posY"].toFloat();
btScalar z = lightMap["posZ"].toFloat();
Ogre::Light* pointLight = sceneManager->createLight();
pointLight->setType(Ogre::Light::LT_POINT);
pointLight->setPosition(Ogre::Vector3(x, y, z));
pointLight->setDiffuseColour(r, g, b);
pointLight->setSpecularColour(r, g, b);
}
else if(type.compare("directional") == 0) {
nbDirectionalLights++;
btScalar dirX = lightMap["dirX"].toFloat();
btScalar dirY = lightMap["dirY"].toFloat();
btScalar dirZ = lightMap["dirZ"].toFloat();
Ogre::Light* directionalLight = sceneManager->createLight();
directionalLight->setType(Ogre::Light::LT_DIRECTIONAL);
directionalLight->setDiffuseColour(Ogre::ColourValue(r, g, b));
directionalLight->setSpecularColour(Ogre::ColourValue(r, g, b));
directionalLight->setDirection(Ogre::Vector3( dirX, dirY, dirZ));
}
else if(type.compare("spot") == 0) {
nbSpotLights++;
btScalar dirX = lightMap["dirX"].toFloat();
btScalar dirY = lightMap["dirY"].toFloat();
btScalar dirZ = lightMap["dirZ"].toFloat();
btScalar posX = lightMap["posX"].toFloat();
btScalar posY = lightMap["posY"].toFloat();
btScalar posZ = lightMap["posZ"].toFloat();
btScalar innerAngle = lightMap["innerAngle"].toFloat();
btScalar outerAngle = lightMap["outerAngle"].toFloat();
//btScalar falloff = lightMap["falloff"].toFloat();
Ogre::Light* spotLight = sceneManager->createLight();
spotLight->setType(Ogre::Light::LT_SPOTLIGHT);
spotLight->setDiffuseColour(r,g,b);
spotLight->setSpecularColour(r,g,b);
spotLight->setDirection(dirX, dirY, dirZ);
spotLight->setPosition(posX, posY, posZ);
spotLight->setSpotlightRange(Ogre::Radian(innerAngle), Ogre::Radian(outerAngle));
}
//.........这里部分代码省略.........