Jump to content
  • Advertisement
Sign in to follow this  
Anddos

making camera go up stairs fps type camera

This topic is 2857 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am finding it hard to figure out how to make the camera walk up stairs , how is done exactly , i have a feeling its done with picking but could be messy or getting the hieight y value of the steps vertex and setting the camera position to that...can anyone shed some light on this, as its got me baffelled... the stairs is a seperate mesh from the corridor btw..

Share this post


Link to post
Share on other sites
Advertisement
Depends on what routines you have available in your engine. You can certainly do picking - shoot a ray "down" from your camera position to get an elevation. If your application has a collision engine included, you can use a bounding sphere for the camera and let collisions between that sphere and the "terrain" determine the camera location.

Share this post


Link to post
Share on other sites
but lets says i place a pick ray like you suggest , if i am heading towards the stairs , its going to pick the triangle thats facing the camera and not the actual steps, plus what if the player is looking upwards and still wants to move up the steps , what happens then as the pick is going to pick the steps further up etc..

see the blue triangle is the picked triangle, if i was to get that the height of that it would make no sense :/
http://img19.imageshack.us/img19/8323/picksteps.jpg

Share this post


Link to post
Share on other sites
Its only going to pick whats in front if you shoot the ray from the camera forward in the look direct, you want to pick whats below the player then shoot the ray down.
Physics systems like bullet or nvidias physx have character controllers that auto step up a given height, making things like this a lot easier, thats what I would suggest using, unless you are trying to do it yourself that is.

Share this post


Link to post
Share on other sites
Quote:
Original post by NumberXaero
Its only going to pick whats in front if you shoot the ray from the camera forward in the look direct, you want to pick whats below the player then shoot the ray down.
Physics systems like bullet or nvidias physx have character controllers that auto step up a given height, making things like this a lot easier, thats what I would suggest using, unless you are trying to do it yourself that is.


if try placing a ray at the camera positon with a direction of 0,1,0 , then its going to pick the underside of the steps right?

Share this post


Link to post
Share on other sites
Just to try and clear up some confusion...

What was suggested is that you shoot a ray from your camera's position downward and find the ground.

This isn't done through picking (the process where you find whats under the mouse on the screen), this is done through what's called a ray cast.

Basically you test a ray for collisions against your world geometry.

It doesn't have anything to do with what is or is not on screen or under the mouse.

It has more to do with what is under the player's feet and how far it is to the ground from the player's current position.

Also if wondering, often times even though the stairs look like steps, the collision object for them in games is often a ramp. That makes the camera go smoothly up it and simplifies some other things (esp navigation mesh pathfinding type things).

If you go the route of actually having stairs in the collision geometry, you will probably want to smooth the camera movement to make it not look jerky as you go up and down steps. One way to do this is to interpolate to the camera's target position over time instead of teleporting it there each frame.

HTH!

Share this post


Link to post
Share on other sites
if i do this i get nothing
D3DXVECTOR3 RayPos(gCamera->mPosW.x,gCamera->mPosW.y,gCamera->mPosW.z + 1.0f);
D3DXVECTOR3 RayDir(0.0f,1.0f,0.0f);


D3DXMatrixInverse(&i,NULL,&(bl2->BuildingWorld * gCamera->view()));
D3DXVec3TransformCoord(&TransPos,&RayPos,&i);
D3DXVec3TransformNormal(&TransLook,&RayDir,&i);
D3DXVec3Normalize(&TransLook,&TransLook);
D3DXIntersect(bl2->Mesh,&TransPos,&TransLook,&Hit,&FaceIndex,NULL,NULL,&Dist,NULL,NULL);
if(Hit)
{
//MessageBox(NULL,"Hit","",0);
sprintf(buffer,"%s %d %f","Hit",FaceIndex,Dist);
SetWindowText(FindWindow("D3DWndClassName",NULL),buffer);
//pm->RenderPickedTri(bl2->Mesh,bl2->BuildingWorld,FaceIndex);
}

Share this post


Link to post
Share on other sites
well isnt it better to pick the steps from underneath?
then the Dist float would tell me how much i need to add to camera.y etc

Share this post


Link to post
Share on other sites
It's because TransPos is the starting position and TransLook is how far out you test (as in it's next position to test too). I am referring to the layout you used in this function...
D3DXIntersect(bl2->Mesh,&TransPos,&TransLook,&Hit,&FaceIndex,NULL,NULL,&Dist,NULL,NULL);

Edited : its absolute, not relative positioning, oops

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!