Rotating camera

Started by
6 comments, last by snoddas14 17 years ago
Hello, ive been doing some work with my camera recently. ive been able to get it strafe left/right and move forwar/backwords. Now im trying to get it to rotate. how i have it set up: Im listening for a user to push the left arrow button (VK_LEFT) then i call my function SetRotateX(0.2f) which *should* rotate the camera .2 to the right. but its not working and i know why... first, please take a look at this code, it contains my class, input function and my render function http://rafb.net/p/kX1mnc64.html on line 71, im setting the cameras position, but i am never setting if the camera should rotate or not. So basicly, im asking, how should i do this? ive read tutorials on how to bind "properties" (translation, scaling, and rotation) but all i do when i do that the triangle (that im rendering) is not visible. Thanks alot, fitfool
Advertisement
The link provided is just a blank page in your blog...

...A camera is essentially a view matrix and it sounds like you want to rotate the view direction (a vector in this matrix) around the Y-axis when a user hits a direction. You would also have to update the "right" vector which is an axis in your camera space by computing the cross product of the new direction vector and the up vector. This new view matrix should provide the desired effect.
-------------------------http://www.roachpuppy.com
...And this is why you don't past code on rafb.net that you want to keep for more than a few hours [smile] Try posting it here in [ source ] [ /source ] tags.
*////EDIT////*


i made like this!

//Globalsstatic float RotateX = 0.0f;//iput detctionif(KEYDOWN(keystate, DIK_D)){    RotateX+=0.1f;}//the camera position D3DXMatrixLookAtLH(&matView,                   &D3DXVECTOR3 (RotateX, 0.0f, Move),    // the camera position                   &D3DXVECTOR3 (0.0f, 0.0f, 0.0f),    // the look-at position                   &D3DXVECTOR3 (0.0f, 1.0f, 0.0f));    // the up direction


if you dont understand it i will give you beter explenations!
and i hope it will soulve your question!

[Edited by - snoddas14 on March 22, 2007 7:05:43 AM]
Quote:Original post by snoddas14
i made this!

*** Source Snippet Removed ***

if you dont understand it i will give you beter explenations!
and i hope it will soulve your question!


I think you're a bit confused as to what D3DXMatrixLookAtLH and it's lookat parameter in particular really does (or maybe I'm misunderstanding the point of it :-)). The lookat parameter is actually the point you want the camera to "focus" on. Take for example a ball floating in space, its center lying in (10,20,10). Then you would pass D3DXVECTOR3( 10.f, 20.f, 10.f) as the lookat parameter to "look at" the ball. If you want to make use of your Rotate* variables explicitely, you should use other means such as D3DXMatrixRotation*, and concatenate these onto your view transformation.
Woaw! good you said that to me, i did put the wrong thing on wrong place! i gona edit it!
ahah!
I see my problem.

I was manually trying to rotate the camera, ill do like snoddas said, and use the lookat function. I must have misunderstood what this function does...

Thanks a-lot, fit

[Edited by - fitfool on March 22, 2007 1:53:35 PM]
Np! i hope you enjoy it =)

i usaly dont do any good so im glad that i helpt!

This topic is closed to new replies.

Advertisement