Jump to content
  • Advertisement
Sign in to follow this  
Zanzibar

AspectRation Camera

This topic is 3626 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 I'm trying something really simple, but I just won't succeed. It is already bothering me for a whole day and I don't see light at the end of the tunnel. I'm trying to get a straight view on my screen, devide my screen in 8 blocks and have 1 area filled with a silly bitmap. These are some of my calculations Camera stuff SetViewParameters(new Vector3(0.0f, 0.0f, -1f), new Vector3(0, 0, 0), new Vector3(0, 1, 0)); SetProjectionParameters((float)Math.DegreeToRadian(90), 800f/600f, 0f, 100.0f); Screen resolution is 800/600 so aspectratio returns 1.333 PointF Reso = new PointF(800, 600); Now this is how I scale and Position the little thingy. s = new Smurf(400, 150); s.Scale = new Vector3(((float)s.Width / Reso.X), ((float)s.Height / Reso.Y), 1); s.Position = new Vector3(-1 + ((float)s.Width / Reso.X), -1 + ((float)s.Height / Reso.Y), 0); The effect on the Y-axis is perfect. On the X-Axis, the effect is incorrect. It doesn't fill the entire area. When I change my camera to use an aspectRatio of 1, it stretched correct. SetProjectionParameters((float)Math.DegreeToRadian(90), 1f, 0f, 100.0f); What am I doing wrong. I don't see my mistake. Many thanks Alexader

Share this post


Link to post
Share on other sites
Advertisement
It's not clear how you apply s.Scale. But if you scale the object and then project it, you're applying the aspect ratio twice.

When you set the aspect ratio to 1, then you're applying the ratio once (which is what you want, I think).

BTW:
Quote:
SetProjectionParameters((float)Math.DegreeToRadian(90), 800f/600f, 0f, 100.0f);

You should never use a near plane setting of 0! Use 0.25 or 0.5 at a minimum!

Share this post


Link to post
Share on other sites
Hi

Thanks for the info, I switched the nearplane.

This is how I calculate the worldmatrix of the object. I use slimdx and C# as api.


protected virtual Matrix CalcWorldMatrix(){
return Matrix.Scaling(Scale.X, Scale.Y, Scale.Z) *
Matrix.RotationYawPitchRoll(Rotation.Y, Rotation.X, Rotation.Z) *
Matrix.Translation(Position.X, Position.Y, Position.Z);
}

What is actually the disadvantage of setting the aspectratio to 1?


Kind regards

Alexander

Share this post


Link to post
Share on other sites
You are right though about the double aspectratio.

When I make a bitmap of 150*400 it has less pixels than a bitmap of 400*150.
So I put the aspect ratio to 1 and now they are the same.
I'll continue the playing.

kind regards

Alexander

Share this post


Link to post
Share on other sites
Quote:
What is actually the disadvantage of setting the aspectratio to 1?

I wouldn't say it's a "disadvantage," but you'll have to remember to scale objects appropriately to look correct on the screen. I've never tried it but it may affect other sprites, text, etc.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!