• Advertisement
Sign in to follow this  

Problem with SlimDX / DX9 / Camera

This topic is 2172 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 don't really understand how "cameras" work with D3D9

First, how i set my camera up:

[code] public Camera()
{
this.eye = new Vector3(0.0f, 0.0f, 0.0f);
this.lookAt = new Vector3(0.0f, 0.0f, 1.0f);
this.up = new Vector3(0.0f, 1.0f, 0.0f);
viewMatrix = Matrix.LookAtLH(eye, lookAt, up);
projectionMatrix = Matrix.OrthoLH(1 * zoomLevel, 1 * zoomLevel, 0.0f, 1.0f);
}[/code]

And my vertices :

[code]
vertices = new VertexTexture[]
{
new VertexTexture()
{
Position = new Vector4(0.0f, 0.0f, 0.0f, 1.0f),
TextureCoord = new Vector2(0.0f, 1.0f)
},
new VertexTexture()
{
Position = new Vector4(0.0f, model.Height, 0.0f, 1.0f),
TextureCoord = new Vector2(0.0f, 0.0f)
},
new VertexTexture()
{
Position = new Vector4(model.Width, model.Height, 0.0f, 1.0f),
TextureCoord = new Vector2(1.0f, 0.0f)
},
new VertexTexture()
{
Position = new Vector4(model.Width, 0.0f, 0.0f, 1.0f),
TextureCoord = new Vector2(1.0f, 1.0f)
}
};[/code]

It works. I can move the camera, zoom, etc.

But the cameras properties seems weird to me ! I thought it would be something like:

[code] public Camera()
{
this.eye = new Vector3(0.0f, 0.0f, 1.0f);
this.lookAt = new Vector3(0.0f, 0.0f, 0.0f);
this.up = new Vector3(0.0f, 1.0f, 0.0f);
viewMatrix = Matrix.LookAtLH(eye, lookAt, up);
projectionMatrix = Matrix.OrthoLH(1 * zoomLevel, 1 * zoomLevel, 0.1f, 100.0f);
}[/code]

but with that parameters it doesn't work. Same if i change the Z coordinate for my plan (Which need to be set at 0 to work).

Now, i try to render other objects. I generate vertices for a sphere (it works fine on D3D 10, a 1 radius sphere generated around (0;0;0) ) but nothing appear on the screen

I played with the eye and lookat parameters but i can figure how to make it work, so, what i m doing wrong ?

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement