Board logo

标题: D3DMATRIX的问题 [打印本页]

作者: 我市笨蛋    时间: 2005-9-30 20:31     标题: D3DMATRIX的问题

在Direct3D中 声明对象 D3DXMATRIXA16  mat;
请问在:
    mat._11; mat._12; mat._13; mat._14;
      mat._21; mat._22; mat._23; mat._24;
      mat._31; mat._32; mat._33; mat._34;
  
     每一个的值大小变化分别表示什么?(以一个三凌锥体为例 每一个值的变化图形怎么变)。
   mat._41   的大小表示X方向的位置
    mat._42   的大小表示Y方向的位置
    mat._43   的大小表示Z方向的位置
    mat._44   的大小表示图形的缩放
   这是对的吗?
作者: Nothing    时间: 2005-9-30 22:04

typedef struct _D3DXMATRIXA16 : public D3DXMATRIX
{
    _D3DXMATRIXA16();
    _D3DXMATRIXA16( CONST FLOAT * f);
    _D3DXMATRIXA16( CONST D3DMATRIX& m);
    _D3DXMATRIXA16( FLOAT _11, FLOAT _12, FLOAT _13, FLOAT _14,
                    FLOAT _21, FLOAT _22, FLOAT _23, FLOAT _24,
                    FLOAT _31, FLOAT _32, FLOAT _33, FLOAT _34,
                    FLOAT _41, FLOAT _42, FLOAT _43, FLOAT _44 );
    void* operator new(size_t s);
    void* operator new[](size_t s);

    // The two operators below are not virtual operators. If you cast
    //   to D3DXMATRIX, do not delete using them
    void operator delete(void* p);
    void operator delete[](void* p);

    struct _D3DXMATRIXA16& operator=(CONST D3DXMATRIX& rhs);
} _D3DXMATRIXA16;


Members

Remarks

A 16-byte aligned matrix, when used by Direct3D extensions (D3DX) math functions, has been optimized for improved performance on Intel Pentium 4 processors. Matrices are aligned independent of where they are created: on the program stack, in the heap, or in global scope. Alignment is accomplished using __declspec(align(16)), which works with Microsoft® Visual C++® .NET and with Visual C++ 6.0 only when the processor pack is installed. Unfortunately, there is no way to detect the processor pack, so byte alignment is turned on by default only with Visual C++ .NET.

Vectors and quaternions are not byte aligned in D3DX. When using vectors and quaternions with D3DX math functions, use _declspec(align(16)) to generate byte aligned vectors and quaternions, because they will perform significantly better. The definition of _declspec is shown here.

#define _ALIGN_16 __declspec(align(16))
Other compilers interpret D3DXMATRIXA16 as D3DXMATRIX. Using this structure on a compiler that does not actually align the matrix can be problematic because it will not expose bugs that ignore alignment. For example, if a D3DXMATRIXA16 object is inside a structure or class, a memcpy  might be done with tight packing (ignoring 16-byte boundaries). This would cause build breaks if the compiler were to sometime add matrix aligning.




欢迎光临 编程开发论坛 (http://bbs.lihuasoft.net/) Powered by Discuz! 6.0.0