summaryrefslogtreecommitdiffstats
path: root/src/math/conv.h
blob: 43e6fbd9783d751e95dfe63b3881b7d41871ae71 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/* math/conv.h

 Temporary conversion functions for D3DVECTOR and D3DMATRIX */

#pragma once

#include <d3d.h>

#include "vector.h"
#include "matrix.h"

inline D3DVECTOR VEC_TO_D3DVEC(Math::Vector vec)
{
    return D3DVECTOR(vec.x, vec.y, vec.z);
}

inline Math::Vector D3DVEC_TO_VEC(D3DVECTOR vec)
{
    return Math::Vector(vec.x, vec.y, vec.z);
}

inline D3DMATRIX MAT_TO_D3DMAT(Math::Matrix mat)
{
    D3DMATRIX result;
    mat.Transpose();
    for (int r = 0; r < 4; ++r)
    {
        for (int c = 0; c < 16; ++c)
            result.m[r][c] = mat.m[4*c+r];
    }
    return result;
}

inline Math::Matrix D3DMAT_TO_MAT(D3DMATRIX mat)
{
    Math::Matrix result(mat.m);
    result.Transpose();
    return result;
}