• D3DXMATRIX


    在Direct3D中进行3D变换很多时候需要构造一个4*4的矩阵,D3DXMATRIX就用来表示这个矩阵。
    该类继承自结构体D3DMATRIX(注意二者写法不同,相差一个X)
    __________________________________________________________________
    结构体D3DMATRIX的定义(版本DX9):
    typedef struct _D3DMATRIX {
    union {
    struct {
    float _11, _12, _13, _14;
    float _21, _22, _23, _24;
    float _31, _32, _33, _34;
    float _41, _42, _43, _44;

    };
    float m[4][4];
    };
    } D3DMATRIX;

    __________________________________________________________________
    类D3DXMATRIX的定义如下(版本DX9):
    #ifdef __cplusplus
    typedef struct D3DXMATRIX : public D3DMATRIX
    {
    public:
    D3DXMATRIX() {};
    D3DXMATRIX( CONST FLOAT * );
    D3DXMATRIX( CONST D3DMATRIX& );
    D3DXMATRIX( CONST D3DXFLOAT16 * );
    D3DXMATRIX( 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 );


    // access grants
    FLOAT& operator () ( UINT Row, UINT Col );
    FLOAT operator () ( UINT Row, UINT Col ) const;

    // casting operators
    operator FLOAT* ();
    operator CONST FLOAT* () const;

    // assignment operators
    D3DXMATRIX& operator *= ( CONST D3DXMATRIX& );
    D3DXMATRIX& operator += ( CONST D3DXMATRIX& );
    D3DXMATRIX& operator -= ( CONST D3DXMATRIX& );
    D3DXMATRIX& operator *= ( FLOAT );
    D3DXMATRIX& operator /= ( FLOAT );

    // unary operators
    D3DXMATRIX operator + () const;
    D3DXMATRIX operator - () const;

    // binary operators
    D3DXMATRIX operator * ( CONST D3DXMATRIX& ) const;
    D3DXMATRIX operator + ( CONST D3DXMATRIX& ) const;
    D3DXMATRIX operator - ( CONST D3DXMATRIX& ) const;
    D3DXMATRIX operator * ( FLOAT ) const;
    D3DXMATRIX operator / ( FLOAT ) const;

    friend D3DXMATRIX operator * ( FLOAT, CONST D3DXMATRIX& );

    BOOL operator == ( CONST D3DXMATRIX& ) const;
    BOOL operator != ( CONST D3DXMATRIX& ) const;

    } D3DXMATRIX, *LPD3DXMATRIX;

    #else //!__cplusplus
    typedef struct _D3DMATRIX D3DXMATRIX, *LPD3DXMATRIX;
    #endif //!__cplusplus
    __________________________________________________________________
    可以看到该类封装了一些运算符函数,使其进行矩阵运算时,能够像数学中的矩阵运算一样方便。
    主要用于3D变换,如绘制流水线(Rending Pipeline)中的世界变换、取景变换、投影变换等。
  • 相关阅读:
    工作单元(UnitOfWork) 模式 (2) .NET Core
    工作单元(UnitOfWork) 模式 (1)
    WebAPI规范设计——违RESTful
    ASP.NET MVC / WebAPI 路由机制详解
    C#封装HttpClient工具类库(.NET4.5以上)
    centos7多网卡配置bond0 (mode6无需交换机做配置)
    linux windows 格式化一块大于2 TiB硬盘
    war包安装jenkins
    redis(一主两从三哨兵模式搭建)记录
    nginx + keepalived 主从模式
  • 原文地址:https://www.cnblogs.com/dragon2012/p/2940200.html
Copyright © 2020-2023  润新知