making camera go up stairs fps type camera

Started by
21 comments, last by Anddos 13 years, 6 months ago
so how comes its not intersecting with the steps?, everthing looks right to me
:)
Advertisement
Sorry, screwed up in my first response and removed it. TransPos should be set to your camera position and TransLook should be set to a value directly below this position. Say if your camera is at 25,50,25 you would subtract say -9.8 (gravity constant in m/s) the TransLook would be 25,(50-9.8),25 (25,40.2,25).

This doesn't include any offset you will need to keep the camera off of the floor and/or stairs.

******************************************************************************************
Youtube Channel

It just seems the ray dosent move with the camera at all , and is picking random triangles when tested with the floor, i dont think this method will work :(

[Edited by - Anddos on October 19, 2010 9:24:54 PM]
:)
Quote:D3DXMatrixInverse(&i,NULL,&(bl2->BuildingWorld * gCamera->view()));

In my first post, I did misspeak (as mentioned above) and you should shoot a ray, not do a pick.

If your camera position is in world coordinates, and BuildingWorld is the world matrix for the mesh you're trying to shoot, you shouldn't be using the camera view matrix.

Try just D3DXMatrixInverse(&i,NULL,&bl2->BuildingWorld).

You want to move the camera position from the world to the object space of the mesh. The view matrix has nothing to do with that.

The camera position you shoot from should be the desired position (above the step), with the direction D3DXVECTOR3( 0, -1, 0 ), pointing down, not up (as you have it).

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

that was it buckeye, thats great now i can progres and thanks for clearing up the no need for view with no picking rays :)
:)
Quote:but it dosent seem to move with the camera

Just shooting a ray isn't going to move the camera for you.

Assuming you want the camera to be a fixed distance above the ground, get the distance from the ray position down to the mesh where you want the camera to be next. If that's less than the height you want the camera to have, move the camera up (and forward to it's new position).

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

Quote:Original post by Buckeye
Quote:but it dosent seem to move with the camera

Just shooting a ray isn't going to move the camera for you.

Assuming you want the camera to be a fixed distance above the ground, get the distance from the ray position down to the mesh where you want the camera to be next. If that's less than the height you want the camera to have, move the camera up and forward.


i forgot to add scaling to the rendering triangle

pm->RenderPickedTri(bl->Mesh,bl->BuildingScale*bl->BuildingWorld,FaceIndex);
:)
Good for you! [smile]

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

pritty sure the ray direction should point up , if its down the ray would point down and completely miss the steps , if its up its going to hit underneath the steps etc like this, then the Dist will change as it gets deeper in to the stairs etc, i need to just work with the Dist varible with the Camera.y etc..
i guess the ray would need to point down for going down the stairs, so 2 rays needed it think

like this

http://img169.imageshack.us/img169/225/underneathstepstri.jpg

[Edited by - Anddos on October 19, 2010 11:02:41 PM]
:)
Quote:if its down the ray would point down and completely miss the steps

There's obviously some information or assumption that you've made that you haven't stated. Isn't the camera above the steps?

It's been assumed that your camera position is somewhere around the player's eye position and "down" means toward the player's feet. From your original post about getting " the hieight y value of the step" (you mention y as height)it was assumed that ( 0, -1, 0 ) would be down. It was also assumed that the mesh you want to shoot is below the eye position as a player's eyes are normally above the terrain. You would shoot from the eye position down to the mesh to determine the distance between the eye position and whatever's below that position.

By the way, if you have a non-uniform scaling matrix, you can use that to transform a coordinate (the ray position), but you have to use an inverse transpose to transform a direction. Directions don't scale non-uniformly directly.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

This topic is closed to new replies.

Advertisement