Ditectx 90 basic 3D Transformation Function

Source: Internet
Author: User

Basic Transformation

Translation matrix)

D3DX function used to create the translation matrix

D3DXMATIX * D3DXMatrixTranslation (

D3DXMATRIX * pOut, // result

FLOAT x, // Number of units to translate on x-axis

FLOAT y, // Number of units to translate on y-axis

FLOAT z // Number of units to translate on z-axis

)

Rotation matrix)

D3DXMATRIX * D3DXMatrixRotationX (

D3DXMATRIX * pOut, // result

FLOAT Angle // Angle of rotation measured in radians

};

Proportional Transformation Matrix(Scaling Matrix)

D3DXMATRIX * D3DXMatrixScaling (

D3DXMATRIX * pOut, // result.

FLOAT sx, // Number of units to translate on x-axis

FLOAT sy, // Number of units to translate on y-axis

FLOAT sz // Number of units to translate on z-axis

);

 Vector transformation Functions

The D3DXVec3TransformCoord function transforms the point and assumes that the first component of the vector is 1.

D3DXVECTOR * D3DVXec3TransformCoord (

D3DXVECTOR3 * pOut, // result

CONST D3DXVECTOR3 * pv, // The point to transform

CONT D3DXMATRIX * pM // The transformation matrix

);

D3DXMATRIX T (...); // Initialize a transformation matrix

D3DXVECTOR p (...); // Initialize a point

D3DXVec3TransformCoord (& p, & p, & T); // transform the point

D3DXVec3TransformNormal is used for vector transformation, and assuming that the first part of the trace is 0

D3DXVECTOR3 * D3DXVec3TransformNormal (

D3DXVECTOR3 * pOut, // result.

CONST D3DXVECTOR3 * pv, // The vector to transform

CONT D3DXMATRIX * pM // The transformation matrix

);

D3DXMATRIX T (...); // Initialize a transformation matrix

D3DXVECTOR v (...); // Initialize a vector

D3DXVec3TransformCoord (& v, & v, & T); // transform the point

Function used for vertex Array

D3DXVECTOR3 * WINAPI D3DXVec3TransformCoordArray (

D3DXVECTOR3 * pOut,

UINT OutStride,

CONST D3DXVECTOR3 * pV,

UINT VStride,

CONST D3DXMATRIX * pM,

UINT n

);

POut

[In, out] Pointer to the D3DXVECTOR3 structure that is the result of the operation.

OutStride

[In] Stride between vectors in the output data stream.

PV

[In] Pointer to the source D3DXVECTOR3 array.

VStride

[In] Stride between vectors in the input data stream.

PM

[In] Pointer to the source D3DXMATRIX structure.

N

[In] Number of elements in the array.

Used for Vector Array Transformation:

D3DXVECTOR3 * WINAPI D3DXVec3TransformNormalArray (
D3DXVECTOR3 * pOut,

UINT OutStride,

CONST D3DXVECTOR3 * pV,

UINT VStride,

CONST D3DXMATRIX * pM,

UINT n

);

POut

[In, out] Pointer to the D3DXVECTOR3 array that is the result of the operation.

OutStride

[In] Stride between vectors in the output data stream.

PV

[In] Pointer to the source D3DXVECTOR3 array.

VStride

[In] Stride between vectors in the input data stream.

PM

[In] Pointer to the source D3DXMATRIX structure. To transpose a normal with a non-affine matrix, this matrix shocould be a transposed-inverse transformation matrix.

N

[In] Number of elements in the array.

View DirectX9.0 3D SDK

DirectX 9.0 3D Game Development Programming Basics

Jiangxi University of Technology FangSH 2010-4- Organize

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.