Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

jeffakew

View won't move correctly

This topic is 6921 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

Hi, My problem is that when i rotate the view into my world and then try to move in that direction i move in the orignal direction before i rotated around. What i want is to be able to rotate the Y axis then move forward in the direction I am looking. It''s really diificult to explain so here is the .exe and .cpp: http://www.4unet.co.uk/myhome/christineaskew/myworld.zip also here is code for doing the transformation: cur_ang.y+=VYRot //the current position //x and z initalized to x=4000.0f z=4000.0f ie centre of grid cur_pos.y=200.0f; //mul pitch and steer simply to make them bigger so movement is faster cur_pos.x+=steer*8.0f cur_pos.z+=pitch*5.0f float decay=1.0f-delt; // decay the speed and control positions gradually back towards zero //lift*=decay; pitch*=decay; steer*=decay; // matRotateZ matRotateX currently unused //this is on one line!! D3DMATRIX matTrans,matRotateY,matRotateZ,matRotateX,view; //set translate matrix this is on one line!! D3DUtil_SetTranslateMatrix(matTrans,cur_pos.x,cur_pos.y,cur_pos.z); //set rotation matrix D3DUtil_SetRotateYMatrix( matRotateY,cur_ang.y); //combine and store in view matrix D3DMath_MatrixMultiply(view,matRotateY,matTrans); //set the view into the world lpDevice->SetTransfor(D3DTRANSFORMSTATE_VIEW,&view); Its kind of messed up because some code wont fit on one line. I''ve only been using D3D for a few days and this problem is driving me mad but it must be really easy to solve. Thanks alot.

Share this post


Link to post
Share on other sites
Advertisement
Sorry i should of told you the keys the arrow keys are for direction and n and m are for rotation and space will stop rotation.

Share this post


Link to post
Share on other sites
Yay! Finally I get to give back a little to people on this message board!

Well jeffakew, I''ve got an answer for you. I had a problem like this quite a while ago (with D3DX, but the concepts the same). I couldn''t move the camera around properly in a 3D world. Thanks to SpellBound though, I got it cleared up. Here''s the link to the topic...

http://www.gamedev.net/community/forums/Topic.asp?topic_id=8673&forum_id=10&Topic_Title=&forum_title=DirectX%2FOpenGL%2FGlide%2FGenesis3D

Read that over, you might find the answer to your problem there. I would have made changes to your source, but it doesn''t compile because it''s missing stdafx.h and cube.h. Also, here''s the link to my demo that I wrote a while ago with source that also just might have the answer to your problem.

members.xoom.com/Doddler/StarFighter3D.zip

I think that''s the right one. Take a look at it... It''s messy, but it''s got what your looking for.

-Doddler

Share this post


Link to post
Share on other sites
It works great!! I read that stuff and got it all sorted in less than 30 minutes.

Thank you so much. You''ve probably saved me many days of hassle.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!