Sign in to follow this  
Jerry.Mouse

coordinate system

Recommended Posts

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. 
 
 
 
 
 
 
 
 
 
 
 
 

 

Share this post


Link to post
Share on other sites

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

Edited by Buckeye

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this