Jump to content
  • Advertisement
Sign in to follow this  
Horn

Simple rotation problem

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

The problem I'm having is when I rotate a model, it gets squished along the Y-Axis. The way my camera is setup I have it up 5 along the Y-Axis, looking at the origin, and the 'up' of is -1 Z.

//Init

PParams.Windowed = true;
PParams.SwapEffect = Microsoft.DirectX.Direct3D.SwapEffect.Discard;
PParams.EnableAutoDepthStencil = true;
PParams.AutoDepthStencilFormat = D3D.DepthFormat.D16;

D3Device = new D3D.Device(0, D3D.DeviceType.Hardware, 
this, 
D3D.CreateFlags.SoftwareVertexProcessing,
PParams);

D3Device.Transform.View = Matrix.LookAtLH(
new Vector3(0.0f, 5.0f, 0.0f), 
new Vector3(0.0f, 0.0f, 0.0f),
new Vector3(0.0f, 0.0f, -1.0f));

D3Device.Transform.Projection = Matrix.PerspectiveFovLH((float)(Math.PI / 4),
 this.Width / this.Height,
 1.0f, 100.0f);


//Drawing
Mat = Matrix.RotationY(Direction);
Device.Transform.World = Mat;
Model.Draw();


Share this post


Link to post
Share on other sites
Advertisement
I don't think it's a problem with the way the camera is set up.

Other stuff that may be wrong:
Are you doing any scaling or translating anywhere? The order in which you do matrix stuff is very important, otherwise weird things (like squishing) can happen.

Are you making sure the rotation is in Radians? That can mess stuff up too, but won't cause squishing.

Share this post


Link to post
Share on other sites
Nope. Thats all I do with the matrix stack. The Model.Draw() simply uses a Direct3D.Mesh and draws it.

Share this post


Link to post
Share on other sites
Could you please maybe do this for me.
Create a method/function called rotate and do

void RotateMesh(){
D3DXMatrixRotationY(...);
Direct3d.pDevice->SetTransform(...);
}
and then call it within your

BeginScene();
EndScene();

Share this post


Link to post
Share on other sites
The problem goes away if I set my aspect ratio to 1 (in the Matrix.LookAt function) and the window size to square (ex 600x600). So it appears that I'm having a problem with the aspect ratio of the model.

I played with the managed tutorial #6 (the model loading one) and setup the camera so that it was at 0,0,-5 instead of 0,3,-5 and theres the same problem.

Share this post


Link to post
Share on other sites
I solved the problem. When I was dividing 4 by 3 I was using integers (which would produce 1). I changed it to 4.0f / 3.0f and it works fine.

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.

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!