coordinate system

Started by
1 comment, last by Jerry.Mouse 9 years, 11 months ago

Hello,

I have a small problem. I have a small triangle - see attachments "coordinatesystem.bmp":

v[0].pose = SlimDX::Vector3( -0.5f, +0.0f, 0.0f );
v[0].color = 0x000fff; //
v[1].pose = SlimDX::Vector3( +2.5f, +0.0f, 0.0f );
v[1].color = 0x000fff; //
v[2].pose = SlimDX::Vector3( +0.0f, +1.5f, 0.0f );
v[2].color = 0x000fff; //
Unfortunately, this triangle is depicted reverse. +X axis is on the left side, -X axis in on the righ side, +Y is Top, -Y is bottom.
+Z heading to me, out of screen and -Z heading to screen. see the attachments.
I am using only these commands:
sl_device->SetTransform( SlimDX::Direct3D9::TransformState::View,
SlimDX::Matrix::LookAtLH( SlimDX::Vector3( 0.0f, 0.0f, 15.0f ), //
SlimDX::Vector3( 0.0f, 0.0f, 1.0f ),
SlimDX::Vector3( 0.0f, +1.0f, 0.0f ) ) );
sl_device->SetTransform( SlimDX::Direct3D9::TransformState::Projection,
SlimDX::Matrix::PerspectiveFovLH( (float)Math::PI / 2, 1.76795f, 0.1f, 100.0f) );
If I use these commands:
sl_device->SetTransform( SlimDX::Direct3D9::TransformState::View,
SlimDX::Matrix::LookAtLH( SlimDX::Vector3( 0.0f, 0.0f, 15.0f ), //
SlimDX::Vector3( 0.0f, 0.0f, 1.0f ),
SlimDX::Vector3( 0.0f, +1.0f, 0.0f ) ) );
sl_device->SetTransform( SlimDX::Direct3D9::TransformState::World,
SlimDX::Matrix::Translation( 0.0f, 0.0f, 0.0f ) *
SlimDX::Matrix::RotationY( 0.785f ) *
SlimDX::Matrix::RotationX( 0.785f ) *
SlimDX::Matrix::RotationZ( 0.785f )
);
sl_device->SetTransform( SlimDX::Direct3D9::TransformState::Projection,
SlimDX::Matrix::PerspectiveFovLH( (float)Math::PI / 2, 1.76795f, 0.1f, 100.0f) );
Situation is identical see attachments "coordinatesystem2.bmp"
I supposed that SlimDX uses left-hand coordinate system. It is: +X is on the right side, -X is on the left side,+Y is top, -Y bottom,
+Z headings to my LCD monitor and -Z heading to me.
What is wrong ? I have somewhat reversed coordinate system.

Advertisement

+X axis is on the left side, -X axis in on the righ side, +Y is Top, -Y is bottom.
+Z heading to me, out of screen and -Z heading to screen

That's how you have the view matrix setup. Eyepoint along the +Z, looking at the origin. That puts the +X axis on the left in a LH system.

Try setting your view with Eye along -Z somewhere, looking at the origin.

EDIT: Not sure how you have your cullmode setup, but you have the vertices in ccw order.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

Thanks. It helped.

this is correct:

sl_device->SetRenderState( SlimDX::Direct3D9::RenderState::CullMode, SlimDX::Direct3D9::Cull::None );
sl_device->SetRenderState( SlimDX::Direct3D9::RenderState::Lighting, false );
sl_device->SetTransform( SlimDX::Direct3D9::TransformState::View,
SlimDX::Matrix::LookAtLH( SlimDX::Vector3( 0.0f, 0.0f, -15.0f ), //
SlimDX::Vector3( 0.0f, 0.0f, +15.0f ),
SlimDX::Vector3( 0.0f, +1.0f, 0.0f ) ) );
sl_device->SetTransform( SlimDX::Direct3D9::TransformState::World,
SlimDX::Matrix::Translation( 0.0f, 0.0f, 0.0f ) *
SlimDX::Matrix::RotationY( +0.3f ) *
SlimDX::Matrix::RotationX( -0.2f ) *
SlimDX::Matrix::RotationZ( 0.0f )
);

+X is on the right side, +Y is top, +Z is in LCD monitor.

This topic is closed to new replies.

Advertisement