本文整理汇总了C++中ISceneManager::setActiveCamera方法的典型用法代码示例。如果您正苦于以下问题:C++ ISceneManager::setActiveCamera方法的具体用法?C++ ISceneManager::setActiveCamera怎么用?C++ ISceneManager::setActiveCamera使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISceneManager
的用法示例。
在下文中一共展示了ISceneManager::setActiveCamera方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnEvent
bool Hud::OnEvent(const SEvent& event)
{
if (!_showMinimap)
return false;
ISceneManager* scene;
IVideoDriver* video;
switch (Game::ToGameEvent(event)) {
case EGE_ADDITIONAL_RENDER_STARTING:
scene = _game->getDevice()->getSceneManager();
video = _game->getDevice()->getVideoDriver();
_previousCamera = scene->getActiveCamera();
scene->setActiveCamera(_minimapCamera);
video->setRenderTarget(_minimapTexture);
show(false);
break;
case EGE_ADDITIONAL_RENDER_FINISHED:
scene = _game->getDevice()->getSceneManager();
video = _game->getDevice()->getVideoDriver();
scene->setActiveCamera(_previousCamera);
video->setRenderTarget(NULL);
show(true);
break;
}
return false;
}
示例2: setActive
/// Add self into scene manager's render queue
void CameraComponent::setActive(bool active)
{
if (this->active == active) return;
this->active = active;
ISceneManager* smgr = getNode()->getSceneManager();
smgr->setActiveCamera(getNode());
}
示例3: getIView
CGameCamera::CGameCamera()
{
m_targetObject = NULL;
m_objectType = CGameObject::CameraObject;
#ifdef GSEDITOR
m_cameraMesh = NULL;
#endif
ISceneManager *smgr = getIView()->getSceneMgr();
// save old camera
ICameraSceneNode *oldCam = smgr->getActiveCamera();
// create new camera
m_camera = smgr->addCameraSceneNode();
m_camera->setFOV( core::degToRad(60.0f) );
m_camera->setFarValue( 8000.0f );
m_camera->grab();
core::vector3df pos(0,0,0);
setPosition( pos );
core::vector3df target(1,0,0);
setTarget( target );
#ifdef GSEDITOR
CColladaMeshComponent *comp = new CColladaMeshComponent( this );
comp->loadFromFile( getIView()->getPath("data/editor/camera.dae") );
addComponent( comp );
setLighting( false );
m_cameraMesh = m_node;
m_cameraMesh->setVisible( true );
ITriangleSelector *selector = smgr->createTriangleSelectorFromBoundingBox( m_cameraMesh );
m_cameraMesh->setTriangleSelector(selector);
selector->drop();
#endif
// set camera node
m_node = m_camera;
// restore camera
smgr->setActiveCamera( oldCam );
m_animator = NULL;
#ifndef GSGAMEPLAY
setEditorCamera();
#else
setFreeCamera();
#endif
}
示例4: Update
STATE StateTemp::Update()
{
SmartPointer<PacketAddr> pAddr;
m_pNetworkControl->ReceivePacket();
ISceneManager * smgr = Irrdevice::GetInstance()->GetSceneManager();
if((pAddr= m_pNetworkControl->GetPacket()) != NULL)
{
ServerPacketParsing(pAddr.getPoint());
}
if(IsKeyDown(irr::KEY_KEY_T))
{
smgr->setActiveCamera(m_pCamera);
}
if(IsKeyDown(irr::KEY_KEY_H))
{
m_pMe->SetActiveCamera();
}
if(IsKeyDown(irr::KEY_KEY_N))
{
m_pYou->SetActiveCamera();
}
// if(IsKeyDown(irr::KEY_KEY_T))
// {
// Packet p(BASE_ACK,m_MyId);
// p<<1;
// m_pNetworkControl->SendClientToPacket(p);
// }
// if(IsKeyDown(irr::KEY_KEY_F))
// {
// Packet p(BASE_ACK,m_MyId);
// p<<2;
// m_pNetworkControl->SendClientToPacket(p);
// }
// if(IsKeyDown(irr::KEY_KEY_G))
// {
// Packet p(BASE_ACK,m_MyId);
// p<<3;
// m_pNetworkControl->SendClientToPacket(p);
// }
// if(IsKeyDown(irr::KEY_KEY_H))
// {
// Packet p(BASE_ACK,m_MyId);
// p<<4;
// m_pNetworkControl->SendClientToPacket(p);
// }
return STATE_NONE;
}
示例5: main
//.........这里部分代码省略.........
/*
Create a variable for counting the fps and hide the mouse:
*/
//Hide mouse
device->getCursorControl()->setVisible(false);
//We want to count the fps
int lastFPS = -1;
/*
There wasn't much new stuff - till now!
Only by defining four cameras, the game won't be splitscreen.
To do this you need several steps:
- Set the viewport to the whole screen
- Begin a new scene (Clear screen)
- The following 3 steps are repeated for every viewport in the splitscreen
- Set the viewport to the area you wish
- Activate the camera which should be "linked" with the viewport
- Render all objects
- If you have a GUI:
- Set the viewport the whole screen
- Display the GUI
- End scene
Sounds a little complicated, but you'll see it isn't:
*/
while(device->run())
{
//Set the viewpoint to the whole screen and begin scene
driver->setViewPort(rect<s32>(0,0,ResX,ResY));
driver->beginScene(true,true,SColor(255,100,100,100));
//If SplitScreen is used
if (SplitScreen)
{
//Activate camera1
smgr->setActiveCamera(camera[0]);
//Set viewpoint to the first quarter (left top)
driver->setViewPort(rect<s32>(0,0,ResX/2,ResY/2));
//Draw scene
smgr->drawAll();
//Activate camera2
smgr->setActiveCamera(camera[1]);
//Set viewpoint to the second quarter (right top)
driver->setViewPort(rect<s32>(ResX/2,0,ResX,ResY/2));
//Draw scene
smgr->drawAll();
//Activate camera3
smgr->setActiveCamera(camera[2]);
//Set viewpoint to the third quarter (left bottom)
driver->setViewPort(rect<s32>(0,ResY/2,ResX/2,ResY));
//Draw scene
smgr->drawAll();
//Set viewport the last quarter (right bottom)
driver->setViewPort(rect<s32>(ResX/2,ResY/2,ResX,ResY));
}
//Activate camera4
smgr->setActiveCamera(camera[3]);
//Draw scene
smgr->drawAll();
driver->endScene();
/*
As you can probably see, the image is rendered for every
viewport seperately. That means, that you'll loose much performance.
Ok, if you're aksing "How do I have to set the viewport
to get this or that screen?", don't panic. It's really
easy: In the rect-function you define 4 coordinates:
- X-coordinate of the corner left top
- Y-coordinate of the corner left top
- X-coordinate of the corner right bottom
- Y-coordinate of the corner right bottom
That means, if you want to split the screen into 2 viewports
you would give the following coordinates:
- 1st viewport: 0,0,ResX/2,ResY
- 2nd viewport: ResX/2,0,ResX,ResY
If you didn't fully understand, just play arround with the example
to check out what happens.
Now we just view the current fps and shut down the engine,
when the user wants to:
*/
//Get and show fps
if (driver->getFPS() != lastFPS)
{
lastFPS = driver->getFPS();
core::stringw tmp = L"Irrlicht SplitScreen-Example (FPS: ";
tmp += lastFPS;
tmp += ")";
device->setWindowCaption(tmp.c_str());
}
}
//Delete device
device->drop();
return 0;
}
示例6: run
bool Editor::run(IrrlichtDevice* irr_device,Configuration* conf){
// Do Irrlicht Stuff
_device = irr_device;
IVideoDriver* driver = GetDevice()->getVideoDriver();
ISceneManager* smgr = GetDevice()->getSceneManager();
IGUIEnvironment* guienv = GetDevice()->getGUIEnvironment();
GetDevice()->setEventReceiver(this);
if (!conf->getSettingAsBool("fullscreen"))
GetDevice()->setResizable(true);
// Project and state
Project* proj = new Project();
_state = new EditorState(GetDevice(),proj,conf);
// Menu State
MenuState* ms = new MenuState(GetState());
GetState()->SetMenu(ms);
// Add editor modes
GetState()->AddMode(new NBEditor(GetState()));
// Set up project
proj->AddNode(new Node(GetDevice(),GetState()));
proj->SelectNode(0);
// Load user interface
LoadScene();
GetState()->Menu()->init();
GetState()->Mode()->load();
printf("Complete!\n");
int LastX = driver->getScreenSize().Width;
if (!GetState()->Settings()->getSettingAsBool("hide_sidebar"))
LastX -= 256;
int LastY = driver->getScreenSize().Height;
int lastFPS = -1;
while (GetDevice()->run()){
if (GetState()->NeedsClose()){
GetDevice()->closeDevice();
return true;
}
driver->beginScene(true, true, irr::video::SColor(255,150,150,150));
int ResX = driver->getScreenSize().Width;
if (!GetState()->Settings()->getSettingAsBool("hide_sidebar"))
ResX -= 256;
int ResY = driver->getScreenSize().Height;
if (currentWindow == -1)
{
// Draw Camera 0
if (camera[0]){
smgr->setActiveCamera(camera[0]);
rect<s32> offset = rect<s32>(0,0,ResX/2,ResY/2);
driver->setViewPort(offset);
smgr->drawAll();
if (GetState()->Mode())
GetState()->Mode()->viewportTick(EVIEW_PERS, driver, offset);
}
// Draw Camera 1
if (camera[1]){
smgr->setActiveCamera(camera[1]);
rect<s32> offset = rect<s32>(ResX/2,0,ResX,ResY/2);
driver->setViewPort(offset);
smgr->drawAll();
if (GetState()->Mode())
GetState()->Mode()->viewportTick(EVIEW_XZ, driver, offset);
}
// Draw Camera 2
if (camera[2]){
smgr->setActiveCamera(camera[2]);
rect<s32> offset = rect<s32>(0,ResY/2,ResX/2,ResY);
driver->setViewPort(offset);
smgr->drawAll();
if (GetState()->Mode())
GetState()->Mode()->viewportTick(EVIEW_XY, driver, offset);
}
// Draw Camera 3
if (camera[3]){
smgr->setActiveCamera(camera[3]);
rect<s32> offset = rect<s32>(ResX/2,ResY/2,ResX,ResY);
driver->setViewPort(offset);
smgr->drawAll();
if (GetState()->Mode())
GetState()->Mode()->viewportTick(EVIEW_ZY, driver, offset);
}
// Draw GUI
driver->setViewPort(rect<s32>(0,0,driver->getScreenSize().Width,driver->getScreenSize().Height));
//.........这里部分代码省略.........
示例7: main
//.........这里部分代码省略.........
//-- robots ------------------------------------------------------------//
//create robots
Fly2D::Brain* brains[nRobots];
//all to a default type
//for ( int i=0; i<nRobots; i++ )
//{
//brains[i] = new Fly2D::BrainForward;
////brains[i] = new Fly2D::BrainCircle();
//}
brains[0] = new Fly2D::BrainForward;
brains[1] = new Fly2D::BrainForward;
//decide human control
vector<Fly2D::BrainHuman*> hBrains;
for (
vector<int>::iterator i = humanBrainIds.begin();
i != humanBrainIds.end();
++i
)
{
if ( *i > nRobots )
{
cerr << "no such robot: " << *i << endl;
exit(EXIT_FAILURE);
}
delete brains[*i];
Fly2D::BrainHuman* hBrain = new Fly2D::BrainHuman;
brains[*i] = hBrain;
hBrains.push_back(hBrain);
}
Fly2D::ReceiverHuman hReceiver = Fly2D::ReceiverHuman( hBrains );
device->setEventReceiver( &hReceiver );
Robot* robots[nRobots];
robots[0] = new Fly2D::Robot( *device, *meta, *brains[0], vector3df(0,0,-0.5f), vector3df(0,0, 0.5f), 0.01 );
robots[1] = new Fly2D::Robot( *device, *meta, *brains[1], vector3df(0,0,0.5f), vector3df(0,0, -0.5f), 0.01 );
meta->drop(); // As soon as we're done with the selector, drop it.
//-- run ------------------------------------------------------------//
//TEST
vector3df oldpos, oldtarget;
//END TEST
int nFrames = 0;
ITimer* timer = device->getTimer();
int t0 = timer->getTime();
int w = driver->getScreenSize().Width;
int h = driver->getScreenSize().Height;
int dh = h/nRobots;
int observeRobot = 0;
while(device->run())
{
//if (device->isWindowActive()) //only work if window has focus.
//draw
driver->setViewPort(rect<s32>(0,0,w,h));
driver->beginScene(true,true,0);
for(int i=0; i<nRobots; i++)
{
driver->setViewPort(rect<s32>(0,dh*i,w,dh*(i+1)));
//only part of window gets drawn into
smgr->setActiveCamera(robots[i]->camera);
smgr->drawAll();
//draws on window scene of active camera
robots[i]->update();
}
driver->endScene();
//TEST
//if
//(
//robots[observeRobot].getPosition() != oldpos
//|| robots[observeRobot].getTarget() != oldtarget
//)
//oldpos = robots[observeRobot].getPosition();
//oldtarget = robots[observeRobot].getTarget();
cout << robots[observeRobot]->str();
//FPS info
//cout << "frame no:" << endl << nFrames << endl;;
//cout << "average fps:" << endl << 1000*nFrames/(float)(timer->getTime()-t0) << endl;
//nFrames++;
cout << "fps:" << endl << driver->getFPS() << endl;
//END TEST
}
device->drop();
return 0;
}
示例8: viewportTick
void Editor::viewportTick(Viewport viewport, rect<s32> rect,
bool mousehit, bool middlehit)
{
// Init
IVideoDriver *driver = device->getVideoDriver();
ISceneManager *smgr = device->getSceneManager();
IGUIEnvironment *guienv = device->getGUIEnvironment();
ViewportType type = state->getViewportType(viewport);
// Draw camera
smgr->setActiveCamera(camera[(int)viewport]);
driver->setViewPort(rect);
if (type == VIEWT_BOTTOM)
plane->setVisible(false);
smgr->drawAll();
if (type == VIEWT_BOTTOM)
plane->setVisible(true);
// Callbacks
if (state->Mode())
state->Mode()->viewportTick(viewport, driver, rect);
if (viewport_drag == viewport) {
vector2di delta = state->mouse_position;
delta -= viewport_drag_last;
viewport_drag_last = state->mouse_position;
viewport_offset[(int)viewport].X -= (f32)delta.X * 0.01f;
viewport_offset[(int)viewport].Y += (f32)delta.Y * 0.01f;
if (viewport_offset[(int)viewport].X > 0.5)
viewport_offset[(int)viewport].X = 0.5;
if (viewport_offset[(int)viewport].X < -0.5)
viewport_offset[(int)viewport].X = -0.5;
if (viewport_offset[(int)viewport].Y > 0.5)
viewport_offset[(int)viewport].Y = 0.5;
if (viewport_offset[(int)viewport].Y < -0.5)
viewport_offset[(int)viewport].Y = -0.5;
applyCameraOffsets(viewport);
}
if (middlehit && rect.isPointInside(state->mouse_position)
&& type != VIEWT_PERS) {
viewport_drag = viewport;
viewport_drag_last = state->mouse_position;
}
// Draw text
driver->setViewPort(rects32(0, 0, driver->getScreenSize().Width,
driver->getScreenSize().Height));
{
static const wchar_t* labels[7] = {L"Perspective", L"Front", L"Left",
L"Top", L"Back", L"Right", L"Bottom"};
// Handle clicking
position2d<s32> labelpos(rect.LowerRightCorner.X - 86,
rect.UpperLeftCorner.Y + ((rect.UpperLeftCorner.Y < 50)?30:10));
rects32 backgroundrect(rect.LowerRightCorner.X - 96,
rect.UpperLeftCorner.Y + ((rect.UpperLeftCorner.Y < 50)?25:5),
rect.LowerRightCorner.X - 5,
rect.UpperLeftCorner.Y + ((rect.UpperLeftCorner.Y < 50)?185:165));
bool context_is_open = (viewport_contextmenu == viewport);
if (mousehit && !state->menu->dialog) {
if ((rects32(labelpos.X, labelpos.Y, labelpos.X + 90,
labelpos.Y + 25)).isPointInside(state->mouse_position)) {
viewport_contextmenu = viewport;
} else if (context_is_open) {
context_is_open = false;
viewport_contextmenu = VIEW_NONE;
if (backgroundrect.isPointInside(state->mouse_position)) {
int y = 0;
for (int i = 0; i < 7; i++) {
if (i != (int)type) {
int ty = rect.UpperLeftCorner.Y +
((rect.UpperLeftCorner.Y < 50)?56:36)
+ y * 20;
rects32 trect(rect.LowerRightCorner.X - 96,
ty,
rect.LowerRightCorner.X - 5, ty + 20);
y++;
if (trect.isPointInside(state->mouse_position)) {
viewport_offset[(int)viewport] = vector3df(0, 0, 0);
state->settings->set(viewportToSetting(viewport),
viewportTypeToSetting((ViewportType)i));
recreateCameras();
break;
}
}
}
}
}
}
// Context menu
if (context_is_open) {
// Context menu background
driver->draw2DRectangle(SColor(100, 32, 32, 32), backgroundrect);
s32 y2 = rect.UpperLeftCorner.Y + ((rect.UpperLeftCorner.Y < 50)?52:32);
driver->draw2DLine(position2d<s32>(rect.LowerRightCorner.X - 96, y2),
position2d<s32>(rect.LowerRightCorner.X - 5, y2),
SColor(100, 255, 255, 255));
// Draw options
//.........这里部分代码省略.........
示例9: 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;
}
示例10: run
bool Editor::run(IrrlichtDevice* irr_device,Configuration* conf)
{
// Do Irrlicht Stuff
device = irr_device;
IVideoDriver *driver = device->getVideoDriver();
ISceneManager *smgr = device->getSceneManager();
IGUIEnvironment *guienv = device->getGUIEnvironment();
device->setEventReceiver(this);
device->setWindowCaption(L"Node Box Editor");
if (!conf->getBool("fullscreen")) {
device->setResizable(true);
}
// Project and state
Project *proj = new Project();
state = new EditorState(device, proj, conf);
// Menu State
state->menu = new MenuState(state);
// Add editor modes
state->AddMode(new NBEditor(state));
state->AddMode(new NodeEditor(state));
// Set up project
proj->AddNode(state, true, false);
// Load user interface
LoadScene();
state->SelectMode(0);
int LastX = driver->getScreenSize().Width;
if (!state->settings->getBool("hide_sidebar")) {
LastX -= 256;
}
int LastY = driver->getScreenSize().Height;
#ifdef _DEBUG
int lastFPS = -1;
#endif
bool dosleep = state->settings->getBool("use_sleep");
u32 last = std::clock();
double dtime = 0;
while (device->run()) {
if (state->NeedsClose()) {
device->closeDevice();
return true;
}
driver->beginScene(true, true, irr::video::SColor(255, 150, 150, 150));
int ResX = driver->getScreenSize().Width;
if (!state->settings->getBool("hide_sidebar"))
ResX -= 256;
int ResY = driver->getScreenSize().Height;
if (currentWindow == -1) {
// Draw Camera 0
if (camera[0]) {
smgr->setActiveCamera(camera[0]);
rect<s32> offset = rect<s32>(0, 0, ResX/2, ResY/2);
driver->setViewPort(offset);
smgr->drawAll();
if (state->Mode())
state->Mode()->viewportTick(VIEW_PERS, driver, offset);
}
// Draw Camera 1
if (camera[1]) {
smgr->setActiveCamera(camera[1]);
rect<s32> offset = rect<s32>(ResX/2, 0, ResX, ResY/2);
driver->setViewPort(offset);
smgr->drawAll();
if (state->Mode())
state->Mode()->viewportTick(VIEW_XZ, driver, offset);
}
// Draw Camera 2
if (camera[2]) {
smgr->setActiveCamera(camera[2]);
rect<s32> offset = rect<s32>(0, ResY/2, ResX/2, ResY);
driver->setViewPort(offset);
smgr->drawAll();
if (state->Mode())
state->Mode()->viewportTick(VIEW_XY, driver, offset);
}
// Draw Camera 3
if (camera[3]) {
smgr->setActiveCamera(camera[3]);
rect<s32> offset = rect<s32>(ResX/2, ResY/2, ResX, ResY);
driver->setViewPort(offset);
smgr->drawAll();
//.........这里部分代码省略.........