Sign in to follow this  
Esper S.

Help, my camera is not moving correctly!

Recommended Posts

Esper S.    124

Using DirectX10, I have made a camera that rotates and moves about just fine. The problem is that it seems to be moving relative to the world. Can someone please explain why the camera won't move correctly and the necessary steps to fix this? Thank you, everyone

Share this post


Link to post
Share on other sites
lomateron    491

The problem is that it seems to be moving relative to the world---- I don't see any problem there

Can someone please explain why the camera won't move correctly and the necessary steps to fix this?

Insufficient info, impossible to answer question.

Share this post


Link to post
Share on other sites
Esper S.    124

I'm sorry! I've never used posts like this before. What other info would be required?
The aim was for the camera to move relative to itself. So regardless of the camera's rotation, it still moves "forward" (into the screen?) instead of along the world's z-axis.

Share this post


Link to post
Share on other sites
lomateron    491

do you have a 3d vector that defines the position of your camera? 

do you have another 3d vector that defines were is the camera looking to?

Share this post


Link to post
Share on other sites
Esper S.    124

Whoa, that would be helpful! I have D3DXVECTOR3 position, but how would you make one for camera target? Where the camera is looking will change constantly due to mouse input.

Also, what would I do to make the camera go forward in that direction?

Share this post


Link to post
Share on other sites
lomateron    491

what are you using to learn about directx 10?

 

What I used to start learning directx10 helped me a lot on defining and using those two vectors

 

I used the "Microsoft DirectX SDK (June 2010)"

If you have it go to the windows -Start- button, write in the search bar "directx documentation for c++" 

then go to -samples and tutorials- and then to the -direct3D 10- tutorials

read and you will see how easy is to make a camera

Share this post


Link to post
Share on other sites
Norman Barrows    7179


Where the camera is looking will change constantly due to mouse input.
Also, what would I do to make the camera go forward in that direction?

 

there are a number of ways to store camera position and direction. an eye point and a lookat point is one. an x,y,z location and x,y,z rotations is another. matrices and quaternions are other possibilities. i use an x,y,z location, and x and y rotation for a FPS type game.

 

use mouse delta to update x and y rotation values.

 

to move in 2d:

x+=speed*cos(y rotation);

z+=speed*sin(y rotation);

y=heightmap_of(x,z);

 

3d is a bit more complex. the delta values for x,y,and z are the 3d unit direction vector of the camera * speed, projected onto the x,y,and z axes.

Share this post


Link to post
Share on other sites
Norman Barrows    7179


I will do my best! btw, I've been using Rastertek tutorials. They're really good! 

 

watch out for bugs / errors / omissions / just plain wrong code. i've noticed a few. frustum culling had some as i recall. but overall, Rastertek is probably better than most out there.

Share this post


Link to post
Share on other sites
Muzzy A    737

Changing the translation of the view matrix should do everything just fine for you. Seems to me like you were changing the inverse camera's translation.

Share this post


Link to post
Share on other sites
Tispe    1468

You can have Camera Position and Direction vectors. If you press your forward key, then the new camera position would be "(Position+Direction)*ElapsedTime". The direction should be normalized.

 

You can use delta mouse to rotate direction vector.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this