Camera position as output *SOLVED*

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
thojoh370
Posts: 12
Joined: Sun Nov 04, 2007 7:22 pm
Location: Linköping, Sweden
Contact:

Camera position as output *SOLVED*

Post by thojoh370 »

Hey again,
Sorry for being that quick between each topic ... But I've got to ask you questions in order to continue with my projects. And yes, I always try to find stuff in the tutorials and in the documentation before I ask here.

Now for the problem of mine:
I need to see if the camera's position has exceeded a specific limit, i.e. when you fall off a Quake 3 map in the tutorial example and need to respawn - you 've got to detect that you're actually going down below the map.

So, I want to add something during the main loop that checks if the camera's position on the Y axis exceeds the value of M (which I cannot tell you right now as I've not yet figured out what value M stands for), and if it does, the game moves the camera to the same position as when the game was started for the first time.

You'll probably need the Quake 3 map node's position and the camera's starting position. They are as follows:
QUAKE 3 MAP: q3node->setPosition(core::vector3df(0,-1000,0));
CAMERA STARTING POSITION: camera->setPosition(core::vector3df(0,0,0));

If you need further information about this issue, just ask.
Last edited by thojoh370 on Mon Nov 05, 2007 8:22 pm, edited 1 time in total.
Programmers don't DIE, they just GOSUB and then RETURN.
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

You just need to check if the characters position is below some set limit.

Code: Select all

if (player->getAbsolutePosition().Y < Limit) {
    // fix the problem
}
Ideally Limit would be no lower than the lowest point on the map. You can get the height of the lowest point on the map by using the MinEdge.Y of the world space bounding box for the map itself.

Depending on your game, it might make more sense to make sure that the player is inside the bounding box of the level at all. I mean they could potentially find a way to get onto the ceiling of the map. If that is the case you could just make sure that the player absolute position is inside the world bounding box of your map.

Travis
thojoh370
Posts: 12
Joined: Sun Nov 04, 2007 7:22 pm
Location: Linköping, Sweden
Contact:

No player yet

Post by thojoh370 »

I don't have any player entity yet; it's just a camera this far. But I will make it a player entity as soon as I know how to do that ... But I suppose this will work?:

Code: Select all

if (camera->getAbsolutePosition().Y < Limit) {
    // fix the problem
}  
Programmers don't DIE, they just GOSUB and then RETURN.
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Yeah, player was just a scene nod pointer in my example. It should work fine.
thojoh370
Posts: 12
Joined: Sun Nov 04, 2007 7:22 pm
Location: Linköping, Sweden
Contact:

Worked

Post by thojoh370 »

This worked perfectly! Thank you...!
Programmers don't DIE, they just GOSUB and then RETURN.
Post Reply