| 215 | } |
| 216 | |
| 217 | F32 xMat3x3LookVec(xMat3x3* m, const xVec3* at) |
| 218 | { |
| 219 | F32 vec_len = xVec3Normalize(&m->at, at); |
| 220 | xVec3Inv(&m->at, &m->at); |
| 221 | |
| 222 | if (FABS(1.0f - m->at.y) < 0.00001f) |
| 223 | { |
| 224 | m->right.x = 1.0f; |
| 225 | m->right.y = 0.0f; |
| 226 | m->right.z = 0.0f; |
| 227 | m->up.x = 0.0f; |
| 228 | m->up.y = 0.0f; |
| 229 | m->up.z = 1.0f; |
| 230 | m->at.x = 0.0f; |
| 231 | m->at.y = -1.0f; |
| 232 | m->at.z = 0.0f; |
| 233 | return vec_len; |
| 234 | } |
| 235 | if (FABS(1.0f + m->at.y) < 0.00001f) |
| 236 | { |
| 237 | m->right.x = -1.0f; |
| 238 | m->right.y = 0.0f; |
| 239 | m->right.z = 0.0f; |
| 240 | m->up.x = 0.0f; |
| 241 | m->up.y = 0.0f; |
| 242 | m->up.z = -1.0f; |
| 243 | m->at.x = 0.0f; |
| 244 | m->at.y = 1.0f; |
| 245 | m->at.z = 0.0f; |
| 246 | return vec_len; |
| 247 | } |
| 248 | if ((FABS(at->z) < 0.00001f) && (FABS(at->x) < 0.00001f)) |
| 249 | { |
| 250 | m->right.x = 1.0f; |
| 251 | m->right.y = 0.0f; |
| 252 | m->right.z = 0.0f; |
| 253 | m->up.x = 0.0f; |
| 254 | m->up.y = 1.0f; |
| 255 | m->up.z = 0.0f; |
| 256 | m->at.x = 0.0f; |
| 257 | m->at.y = 0.0f; |
| 258 | m->at.z = 1.0f; |
| 259 | return 0.0f; |
| 260 | } |
| 261 | m->right.x = m->at.z; |
| 262 | m->right.y = 0.0f; |
| 263 | m->right.z = -m->at.x; |
| 264 | xVec3Normalize((xVec3*)m, (xVec3*)m); |
| 265 | xVec3Cross(&m->up, &m->at, (xVec3*)m); |
| 266 | xVec3Cross((xVec3*)m, &m->up, &m->at); |
| 267 | m->flags = 0; |
| 268 | return vec_len; |
| 269 | } |
| 270 | |
| 271 | void xMat3x3Euler(xMat3x3* m, const xVec3* ypr) |
| 272 | { |
no test coverage detected