1 /*---------------------------------------------------------------------------* 2 Project: Matrix Vector Library, Graphics library 3 File: GeoTypes.h 4 5 Copyright 1998-2011 Nintendo. All rights reserved. 6 7 These coded instructions, statements, and computer programs contain 8 proprietary information of Nintendo of America Inc. and/or Nintendo 9 Company Ltd., and are protected by Federal copyright law. They may 10 not be disclosed to third parties or copied or duplicated in any form, 11 in whole or in part, without the prior written consent of Nintendo. 12 13 *---------------------------------------------------------------------------*/ 14 15 #ifndef __GEOTYPES_H__ 16 #define __GEOTYPES_H__ 17 18 #ifdef __cplusplus 19 extern "C" { 20 #endif 21 22 /// @addtogroup VEC 23 /// @{ 24 25 // ---------- Vector types: 26 27 /// \brief 3D vector, point. 28 typedef struct 29 { 30 f32 x; ///< X Component 31 f32 y; ///< Y Component 32 f32 z; ///< Z Component 33 34 } Vec, *VecPtr, Point3d, *Point3dPtr; 35 36 /// \brief 2D vector, point. 37 typedef struct Vec2{ 38 f32 x; ///< X component 39 f32 y; ///< Y component 40 } Vec2; 41 42 /// \brief Signed 16bit 3D vector. 43 typedef struct 44 { 45 46 s16 x; ///< X component 47 s16 y; ///< Y component 48 s16 z; ///< Z component 49 50 }S16Vec, *S16VecPtr; 51 52 /// @} 53 54 /// @addtogroup QUAT 55 /// @{ 56 57 /// \brief Quaternion. 58 typedef struct 59 { 60 /// x, y, and z components 61 f32 x, y, z, w; 62 63 } Quaternion, *QuaternionPtr, Qtrn, *QtrnPtr; 64 65 /// @} 66 67 /// @addtogroup MTX 68 /// @{ 69 70 // ---------- Array versions of matrix: 71 72 /// 3x4 matrix. 73 typedef f32 Mtx[3][4]; 74 75 /// 3x4 matrix pointer. 76 typedef f32 (*MtxPtr)[4]; 77 78 79 /// 4x3 reordered matrix. 80 /// This is used in specially optimized functions that use the 81 /// paired-single unit efficiently. 82 typedef f32 ROMtx[4][3]; 83 84 /// 4x3 reordered matrix pointer. 85 /// This is used in specially optimized functions that use the 86 /// paired-single unit efficiently. 87 typedef f32 (*ROMtxPtr)[3]; 88 89 90 /// \brief 4x4 matrix 91 /// Used for projection matrix 92 typedef f32 Mtx44[4][4]; 93 94 /// \brief 4x4 matrix pointer 95 /// Used for projection matrix 96 typedef f32 (*Mtx44Ptr)[4]; 97 98 /// @} 99 100 // Matrix-Vector Library (Structure Version) 101 102 // Note: pointer types are omitted intentionally due to const issue. 103 // (That is, "const MatPtr foo" is not the same as "const Mat *foo".) 104 105 // Avoid warning about anonymous members in types below 106 #ifdef __ghs__ 107 #pragma ghs nowarning 619 108 #pragma ghs nowarning 620 109 #endif 110 111 /// @addtogroup MAT 112 /// @{ 113 114 /// \brief 3x4 matrix 115 /// This provides an overloaded matrix structure to allow for multiple 116 /// access methods. 117 typedef struct _Mat34 118 { 119 union 120 { 121 struct 122 { 123 f32 _00, _01, _02, _03; 124 f32 _10, _11, _12, _13; 125 f32 _20, _21, _22, _23; 126 }; 127 f32 m[3][4]; 128 f32 a[12]; 129 Mtx mtx; 130 }; 131 } Mat34; 132 133 /// \brief 4x3 reordered matrix 134 /// This provides an overloaded matrix structure to allow for multiple 135 /// access methods. 136 typedef struct _Mat43 137 { 138 union 139 { 140 struct 141 { 142 f32 _00, _01, _02; 143 f32 _10, _11, _12; 144 f32 _20, _21, _22; 145 f32 _30, _31, _32; 146 }; 147 f32 m[4][3]; 148 f32 a[12]; 149 ROMtx mtx; 150 }; 151 } Mat43; 152 153 /// \brief 4x4 matrix 154 /// Used for projection matrix 155 /// This provides an overloaded matrix structure to allow for multiple 156 /// access methods. 157 typedef struct _Mat44 158 { 159 union 160 { 161 struct 162 { 163 f32 _00, _01, _02, _03; 164 f32 _10, _11, _12, _13; 165 f32 _20, _21, _22, _23; 166 f32 _30, _31, _32, _33; 167 }; 168 f32 m[4][4]; 169 f32 a[16]; 170 Mtx44 mtx; 171 }; 172 } Mat44; 173 174 #ifdef __ghs__ 175 #pragma ghs endnowarning 176 #pragma ghs endnowarning 177 #endif 178 179 /// 3x4 Matrix stack for the \ref Mat34 type. 180 typedef struct _Mat34Stack 181 { 182 183 u32 numMtx; ///< Size of the matrix stack. 184 Mat34 *stackBase; ///< Base pointer of the stack 185 Mat34 *stackPtr; ///< Current stack pointer. NULL if stack is empty. 186 187 } Mat34Stack; 188 189 /// @} 190 191 #ifdef __cplusplus 192 } 193 #endif 194 195 #endif // __GEOTYPES_H__ 196 197 198