本文整理汇总了C++中ISceneManager::addSkyBoxSceneNode方法的典型用法代码示例。如果您正苦于以下问题:C++ ISceneManager::addSkyBoxSceneNode方法的具体用法?C++ ISceneManager::addSkyBoxSceneNode怎么用?C++ ISceneManager::addSkyBoxSceneNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISceneManager
的用法示例。
在下文中一共展示了ISceneManager::addSkyBoxSceneNode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char** argv) {
CustomEventReceiver receiver;
IrrlichtDevice *device = createDevice( video::EDT_OPENGL, dimension2d<u32>(800, 600), 16, false, false, false, &receiver);
if (!device) {
return EXIT_FAILURE;
}
device->setWindowCaption(L"Solar System Simulator");
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* sceneManager = device->getSceneManager();
scene::ISceneCollisionManager* collisionManager= sceneManager->getSceneCollisionManager();
IGUIEnvironment* guiEnv = device->getGUIEnvironment();
guiEnv->addStaticText(L"Click on a planet to attach the camera to it", rect<s32>(10,10,260,22), false);
sf::SoundBuffer buffer;
if (buffer.loadFromFile(currentPath() + "/sounds/burning.aif")) {
sf::Listener::setPosition(0, 0,0);
sf::Sound sound;
sound.setBuffer(buffer);
sound.setPosition(0, 0, 0);
sound.setLoop(true);
sound.play();
}
const char* spaceTexturePath = ( currentPath() + "/textures/space.jpg" ).c_str();
video::ITexture* space = driver->getTexture(spaceTexturePath);
scene::ISceneNode* skybox = sceneManager->addSkyBoxSceneNode(space, space, space, space, space, space);
sceneManager->addLightSceneNode(0, vector3df(0, 0, -50), video::SColorf(1.0f, 1.0f, 1.0f), 50.0f, 1001);
PlanetFactory planetFactory(sceneManager, driver);
Planet sun = planetFactory.create(PlanetId::Sun);
Planet earth = planetFactory.create(PlanetId::Earth);
Planet pluto = planetFactory.create(PlanetId::Pluto);
Planet jupiter = planetFactory.create(PlanetId::Jupiter);
Planet uranus = planetFactory.create(PlanetId::Uranus);
Planet neptune = planetFactory.create(PlanetId::Neptune);
vector<Planet> planets = { sun, planetFactory.create(PlanetId::Mercury) };
planets.push_back(planetFactory.create(PlanetId::Venus));
planets.push_back(earth);
planets.push_back(planetFactory.create(PlanetId::Mars));
planets.push_back(jupiter);
planets.push_back(planetFactory.create(PlanetId::Saturn));
planets.push_back(uranus);
planets.push_back(neptune);
planets.push_back(pluto);
ICameraSceneNode* camera = sceneManager->addCameraSceneNode(0, vector3df(0,0,40), vector3df(0,0,0));
rect<s32> mainCameraViewPortRect(0, 0, 800, 600);
ICameraSceneNode* topViewCamera = sceneManager->addCameraSceneNode(0, vector3df(0,50,0), vector3df(0,0,0));
sceneManager->setAmbientLight(video::SColorf(255.0,255.0,255.0));
ISceneNode* selectedNode = sun.node;
while(device->run()) {
if(receiver.GetMouseState().LeftButtonDown) {
position2di mousepos = receiver.GetMouseState().Position;
line3df ray = sceneManager->getSceneCollisionManager()->getRayFromScreenCoordinates( mousepos, camera);
vector3df intersection;
triangle3df tri;
for(Planet& planet : planets) {
ITriangleSelector* wselector = sceneManager->createTriangleSelectorFromBoundingBox(planet.node);
if (collisionManager->getCollisionPoint(ray, wselector, intersection, tri, planet.node)) {
selectedNode = planet.node;
}
wselector->drop();
}
}
camera->setTarget(selectedNode->getAbsolutePosition());
skybox->setVisible(true);
driver->setViewPort(mainCameraViewPortRect);
driver->beginScene(true, true, SColor(255,100,101,140));
sceneManager->setActiveCamera(camera);
sceneManager->drawAll();
guiEnv->drawAll();
driver->setViewPort(rect<s32>(0, 380, 200, 600));
driver->draw2DRectangle(SColor(100,0,0,190), mainCameraViewPortRect);
skybox->setVisible(false);
sceneManager->setActiveCamera(topViewCamera);
sceneManager->drawAll();
driver->endScene();
}
device->drop();
return EXIT_SUCCESS;
}