# AspectRation Camera

This topic is 3775 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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 on other sites
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:

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

##### 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 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 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.

1. 1
Rutin
70
2. 2
3. 3
4. 4
5. 5

• 21
• 10
• 33
• 20
• 9
• ### Forum Statistics

• Total Topics
633430
• Total Posts
3011826
• ### Who's Online (See full list)

There are no registered users currently online

×