Coordinate System and transformation in OpenGL and d3d

Source: Internet
Author: User

OpenGL uses the right-hand coordinate system and d3d uses the left-hand coordinate system. The four fingers of the hand are directed to the palm of the hand, and the thumb points to the Z axis. Therefore, during coordinate transformation, OpenGL rotates counter-clockwise, while direct 3D rotates clockwise. (Point of origin along the axis)
The method of judgment is to give your thumb to yourself and hold your hand in four fingers.

In d3d, the right multiplication matrix is used to change the sitting mark. Therefore, the order of matrix concatenation is from left to right.
D3dxmatrixmultiply (& matworld, & matrotation, & mattranslation); // rotate first, then translate
M_pdevice-> settransform (d3dts_world, & matworld );

Glmatrixmode (gl_modelview );
Glloadidentity ();
Glmultmatrixf (n);/* apply transformation N */
Glmultmatrixf (m);/* apply transformation m */
Glmultmatrixf (l);/* apply transformation L */
Glbegin (gl_points );
Glvertex3f (V);/* draw transformed vertex v */
Glend ();

In OpenGL, with this code, the modelview matrix successively contains I, n, nm, and finally NML, where I
Represents the identity matrix. The transformed vertex is nmlv. Thus, the vertex transformation is
N (m (LV)-that is, V is multiplied first by L, the resulting LV is multiplied by m, and the resulting mlv
Is multiplied by N. notice that the transformations to vertex v divide tively occur in the opposite order
They were specified. (actually, only a single multiplication of a vertex by the modelview matrix occurs;
In this example, the n, m, and l matrices are already multiplied into a single matrix before it's applied to v.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.