Splitscreen

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Ayanami
Posts: 24
Joined: Wed Jan 14, 2004 1:30 pm

Splitscreen

Post by Ayanami »

moin,

example 2.Quake3Map .. without splitscreen have on start of this map 234fps .. with splitscreen 150fps .. gives a better way?


ok, my problem .. i want use a "radar-camera" which static camera to look at from above
Imagepicture1
.. user move an radar too .. user turn left or right and radar too. but it not correctly work :(

the radar follow the player but not display only form top (->picture1) and
have clipping errors ..
Image


declare 2 cameras:
scene::ICameraSceneNode* camera[2] = {0,0};

define cameras:
//User-controlled
camera[1] = smgr->addCameraSceneNodeFPS();
//radar
camera[0] = smgr->addCameraSceneNode(
camera[1],
vector3df(0,50,0),
vector3df(0,0,0));

display 2 cameras:
driver->beginScene(true, true, video::SColor(0,100,100,100));

//Activate camera1
smgr->setActiveCamera(camera[0]);
//Set viewpoint to the second quarter (right top)
driver->setViewPort(rect<s32>(30,30,150,150));
//Draw scene
smgr->drawAll();

driver->setViewPort(rect<s32>(0,0,ResX,ResY));
//Activate camera2
smgr->setActiveCamera(camera[1]);
//Draw scene
smgr->drawAll();

driver->endScene();



additional: can i make a round radar camera? momentary it's a rectangle...
rt
Posts: 150
Joined: Sun Nov 30, 2003 6:54 am
Location: canada
Contact:

Re: Splitscreen

Post by rt »

Ayanami wrote:additional: can i make a round radar camera? momentary it's a rectangle...
i posted a wonderful solution to this, but the irrlicht forums ate my posting and then went down! :shock: what a waste..

basically i said that instead of using a camera to make a radar you should just use 2d images like this

Code: Select all

//blt the circle background image of the radar
device->getVideoDriver()->draw2DImage(radar_background,radar_pos,radar_frame_size,NULL,irr::video::SColor(255,255,255,255),true);

// get a forward vector from the player model (or camera.. whatever)
vector3df forward( sin( player->getRotation().Y*PI/180.0f ), 0, cos( player->getRotation().Y*PI/180.0f ) ); 
forward.normalize(); // make it a unit vector
float scale = 0.1f; // convert from world to radar scale

//loop through all objects in the game world
curr = list.begin(); EOL = list.end();
while (curr != EOL) {
  node = (*curr)->node; //get a pointer to the node (however you store it)
  vector3df distance = (node->getPosition - player->getPosition); //this might be backwards
  if (distance.magnitude() > 200) {
     //object is too far away to be seen on the radar
     curr++;
     continue;
  }
  int x_dist = distance.dot(forward); // get the distance between the objects in the 'forward' direction
  int y_dist = sqrt(distance.magnitude() - x_dist*x_dist);
  posistion2d obj_pos(radar_pos.X - x_dist*scale,radar_pos.Y - y_dist*scale);
  //blt obj
  device->getVideoDriver()->draw2DImage(radar_obj,obj_pos,obj_frame_size,NULL,irr::video::SColor(255,255,255,255),true);
  curr++
}
the x and y variables might need to be reversed as this is off the top of my head, but the idea is that the radar will show from an overhead view the relative position of objects near the player. the radar will spin so that 'up' on the radar is 'forward' in the game world
keless
Posts: 805
Joined: Mon Dec 15, 2003 10:37 pm
Location: Los Angeles, California, USA

Post by keless »

if you dont do something similar to RT's way, you're likely going to have problems with any level that has a ceiling.

if you take Natural Selection for instance, when you get in the commander's chair you see the level and people from top down-- this is possible because they actually keep TWO copies of the level-- one normal one, and one without ceilings. (actually, if they're smart its one level where all the 'ceiling' brushes are labeled with a special brush so they are not drawn from this view-- but you get the point)

also, the frame rate drop when using multiple viewports is to be expected: because its rendering the scene MULTIPLE TIMEs.. as many times as you have viewports. It even says so in the tutorial.
a screen cap is worth 0x100000 DWORDS
rt
Posts: 150
Joined: Sun Nov 30, 2003 6:54 am
Location: canada
Contact:

Post by rt »

keless wrote:if you dont do something similar to RT's way, you're likely going to have problems with any level that has a ceiling.
you could use the difference in y values as an alpha fade so that nodes which are above or below the player will be faded out on the radar based on their distance away. or just clamp the radar to only show object which are within a specified delta y.
Post Reply