mirror of
https://github.com/rvtr/ntr_bootrom.git
synced 2025-10-31 07:11:11 -04:00
674 lines
25 KiB
C
674 lines
25 KiB
C
//======================================================================
|
||
// IrisMTX.h
|
||
// 行列ライブラリ
|
||
//
|
||
// MTX関数は64bitの乗算を多用しますので、できるだけ
|
||
// GX関数を使用し、負荷を軽減するようにして下さい。
|
||
//
|
||
// Copyright (C) 2002-2003 NINTENDO Co.,Ltd.
|
||
//======================================================================
|
||
#ifndef _IRIS_MTX_H
|
||
#define _IRIS_MTX_H
|
||
|
||
#ifdef __cplusplus
|
||
extern "C" {
|
||
#endif
|
||
|
||
|
||
#include <IrisTarget.h>
|
||
#include <IrisTypes.h>
|
||
#include <IrisSinTable.h>
|
||
|
||
|
||
//======================================================================
|
||
// 汎用行列
|
||
//======================================================================
|
||
|
||
//----------------------------------------------------------------------
|
||
// 単位行列の生成
|
||
//
|
||
//・dstpが指す行列へ単位行列を生成します。
|
||
//
|
||
//・引数:
|
||
// dstp 行列格納バッファのポインタ
|
||
//
|
||
//・戻り値:なし
|
||
//----------------------------------------------------------------------
|
||
|
||
void MTX_Identity(Mtx *dstp);
|
||
void MTX33_Identity(Mtx33 *dstp);
|
||
void MTX44_Identity(Mtx44 *dstp);
|
||
|
||
//----------------------------------------------------------------------
|
||
// 行列のコピー
|
||
//
|
||
//・srcpが指す行列をdstpが指す行列へコピーします。
|
||
//
|
||
//・引数:
|
||
// srcp 転送元行列のポインタ
|
||
// dstp 転送先行列バッファのポインタ
|
||
//
|
||
//・戻り値:なし
|
||
//----------------------------------------------------------------------
|
||
|
||
// 4x3行列を指定行列へコピー
|
||
|
||
void MTX_Copy( const Mtx *srcp, Mtx *dstp);
|
||
void MTX_Copy2Mtx33(const Mtx *srcp, Mtx33 *dstp);
|
||
void MTX_Copy2Mtx44(const Mtx *srcp, Mtx44 *dstp);
|
||
|
||
// 3x3行列を指定行列へコピー
|
||
|
||
void MTX33_Copy( const Mtx33 *srcp, Mtx33 *dstp);
|
||
void MTX33_Copy2Mtx( const Mtx33 *srcp, Mtx *dstp);
|
||
void MTX33_Copy2Mtx44(const Mtx33 *srcp, Mtx44 *dstp);
|
||
|
||
// 4x4行列を指定行列へコピー
|
||
|
||
void MTX44_Copy( const Mtx44 *srcp, Mtx44 *dstp);
|
||
void MTX44_Copy2Mtx( const Mtx44 *srcp, Mtx *dstp);
|
||
void MTX44_Copy2Mtx33(const Mtx44 *srcp, Mtx33 *dstp);
|
||
|
||
//----------------------------------------------------------------------
|
||
// 行列の連結
|
||
//
|
||
//・src0pとsrc1pが指す行列の転結行列をdstpへ生成します。
|
||
//
|
||
//・引数:
|
||
// src0p 転送元行列のポインタ
|
||
// src1p 転送元行列のポインタ
|
||
// dstp 連結行列バッファのポインタ
|
||
//
|
||
//・戻り値:なし
|
||
//----------------------------------------------------------------------
|
||
|
||
void MTX_Concat(Mtx *src0p, Mtx *src1p, Mtx *dstp);
|
||
void MTX33_Concat(Mtx33 *src0p, Mtx33 *src1p, Mtx33 *dstp);
|
||
void MTX44_Concat(Mtx44 *src0p, Mtx44 *src1p, Mtx44 *dstp);
|
||
|
||
//----------------------------------------------------------------------
|
||
// 転置行列の生成
|
||
//
|
||
//・srcpが指す行列の転置行列をdstpが指す行列へ生成します。
|
||
//
|
||
//・引数:
|
||
// srcp 転置前行列のポインタ
|
||
// dstp 生成行列バッファのポインタ
|
||
//
|
||
//・戻り値:なし
|
||
//----------------------------------------------------------------------
|
||
|
||
void MTX_Transpose( Mtx *srcp, Mtx *dstp);
|
||
void MTX33_Transpose( Mtx33 *srcp, Mtx33 *dstp);
|
||
void MTX44_Transpose( Mtx44 *srcp, Mtx44 *dstp);
|
||
|
||
|
||
//======================================================================
|
||
// モデル行列
|
||
//======================================================================
|
||
|
||
//----------------------------------------------------------------------
|
||
// 平行移動行列の生成
|
||
//
|
||
//・平行移動行列をdstpが指す行列へ生成します。
|
||
//
|
||
//・引数:
|
||
// dstp 生成行列バッファのポインタ
|
||
// x X成分
|
||
// y Y成分
|
||
// z Z成分
|
||
//
|
||
//・戻り値:なし
|
||
//----------------------------------------------------------------------
|
||
|
||
void MTX_Translate(Mtx *dstp, s32 x, s32 y, s32 z);
|
||
void MTX44_Translate(Mtx44 *dstp, s32 x, s32 y, s32 z);
|
||
|
||
//----------------------------------------------------------------------
|
||
// 平行移動行列を前方から適用
|
||
//
|
||
//・srcpが指す行列に平行移動行列を前方から適用した行列を
|
||
// dstpが指す行列へ生成します。
|
||
//
|
||
//・引数:
|
||
// srcp 適用行列のポインタ
|
||
// dstp 生成行列バッファのポインタ
|
||
// x X成分
|
||
// y Y成分
|
||
// z Z成分
|
||
//
|
||
//・戻り値:なし
|
||
//----------------------------------------------------------------------
|
||
|
||
void MTX_TranslateBefore(Mtx *srcp, Mtx *dstp, s32 x, s32 y, s32 z);
|
||
void MTX44_TranslateBefore(Mtx44 *srcp, Mtx44 *dstp, s32 x, s32 y, s32 z);
|
||
|
||
//----------------------------------------------------------------------
|
||
// 平行移動行列を後方から適用
|
||
//
|
||
//・srcpが指す行列に平行移動行列を後方から適用した行列を
|
||
// dstpが指す行列へ生成します。
|
||
//
|
||
//・引数:
|
||
// srcp 適用行列のポインタ
|
||
// dstp 生成行列バッファのポインタ
|
||
// x X成分
|
||
// y Y成分
|
||
// z Z成分
|
||
//
|
||
//・戻り値:なし
|
||
//----------------------------------------------------------------------
|
||
|
||
void MTX_TranslateAfter(Mtx *srcp, Mtx *dstp, s32 x, s32 y, s32 z);
|
||
void MTX44_TranslateAfter(Mtx44 *srcp, Mtx44 *dstp, s32 x, s32 y, s32 z);
|
||
|
||
//----------------------------------------------------------------------
|
||
// スケール行列の生成
|
||
//
|
||
//・スケール行列をdstpが指す行列へ生成します。
|
||
//
|
||
//・引数:
|
||
// dstp 生成行列バッファのポインタ
|
||
// x X成分
|
||
// y Y成分
|
||
// z Z成分
|
||
//
|
||
//・戻り値:なし
|
||
//----------------------------------------------------------------------
|
||
|
||
void MTX_Scale(Mtx *dstp, s32 xS, s32 yS, s32 zS);
|
||
void MTX33_Scale(Mtx33 *dstp, s32 xS, s32 yS, s32 zS);
|
||
void MTX44_Scale(Mtx44 *dstp, s32 xS, s32 yS, s32 zS);
|
||
|
||
//----------------------------------------------------------------------
|
||
// スケール行列を前方から適用
|
||
//
|
||
//・srcpが指す行列にスケール行列を前方から適用した行列を
|
||
// dstpが指す行列へ生成します。
|
||
//
|
||
//・引数:
|
||
// srcp 適用行列のポインタ
|
||
// dstp 生成行列バッファのポインタ
|
||
// x X成分
|
||
// y Y成分
|
||
// z Z成分
|
||
//
|
||
//・戻り値:なし
|
||
//----------------------------------------------------------------------
|
||
|
||
void MTX_ScaleBefore(Mtx *srcp, Mtx *dstp, s32 xS, s32 yS, s32 zS);
|
||
void MTX33_ScaleBefore(Mtx33 *srcp, Mtx33 *dstp, s32 xS, s32 yS, s32 zS);
|
||
void MTX44_ScaleBefore(Mtx44 *srcp, Mtx44 *dstp, s32 xS, s32 yS, s32 zS);
|
||
|
||
//----------------------------------------------------------------------
|
||
// スケール行列を後方から適用
|
||
//
|
||
//・srcpが指す行列にスケール行列を後方から適用した行列を
|
||
// dstpが指す行列へ生成します。
|
||
//
|
||
//・引数:
|
||
// srcp 適用行列のポインタ
|
||
// dstp 生成行列バッファのポインタ
|
||
// x X成分
|
||
// y Y成分
|
||
// z Z成分
|
||
//
|
||
//・戻り値:なし
|
||
//----------------------------------------------------------------------
|
||
|
||
void MTX_ScaleAfter(Mtx *srcp, Mtx *dstp, s32 xS, s32 yS, s32 zS);
|
||
void MTX33_ScaleAfter(Mtx33 *srcp, Mtx33 *dstp, s32 xS, s32 yS, s32 zS);
|
||
void MTX44_ScaleAfter(Mtx44 *srcp, Mtx44 *dstp, s32 xS, s32 yS, s32 zS);
|
||
|
||
//----------------------------------------------------------------------
|
||
//
|
||
// 主軸回転行列の生成
|
||
//
|
||
//・主軸回転行列をdstpが指す行列へ生成します。
|
||
//
|
||
//・引数:
|
||
// dstp 生成行列バッファのポインタ
|
||
// theta 回転角度[256|1024|4096段階]
|
||
//
|
||
//・戻り値:なし
|
||
//----------------------------------------------------------------------
|
||
|
||
#define MTX_RotateX(dstp, theta) MTXxx_RotatePriv(_, X, SIN_NDIV_DEFAULT, dstp, theta)
|
||
#define MTX_RotateY(dstp, theta) MTXxx_RotatePriv(_, Y, SIN_NDIV_DEFAULT, dstp, theta)
|
||
#define MTX_RotateZ(dstp, theta) MTXxx_RotatePriv(_, Z, SIN_NDIV_DEFAULT, dstp, theta)
|
||
|
||
#define MTX33_RotateX(dstp, theta) MTXxx_RotatePriv(33_, X, SIN_NDIV_DEFAULT, dstp, theta)
|
||
#define MTX33_RotateY(dstp, theta) MTXxx_RotatePriv(33_, Y, SIN_NDIV_DEFAULT, dstp, theta)
|
||
#define MTX33_RotateZ(dstp, theta) MTXxx_RotatePriv(33_, Z, SIN_NDIV_DEFAULT, dstp, theta)
|
||
|
||
#define MTX44_RotateX(dstp, theta) MTXxx_RotatePriv(44_, X, SIN_NDIV_DEFAULT, dstp, theta)
|
||
#define MTX44_RotateY(dstp, theta) MTXxx_RotatePriv(44_, Y, SIN_NDIV_DEFAULT, dstp, theta)
|
||
#define MTX44_RotateZ(dstp, theta) MTXxx_RotatePriv(44_, Z, SIN_NDIV_DEFAULT, dstp, theta)
|
||
|
||
void MTX_RotateX256(Mtx *dstp, u32 theta);
|
||
void MTX_RotateY256(Mtx *dstp, u32 theta);
|
||
void MTX_RotateZ256(Mtx *dstp, u32 theta);
|
||
void MTX_RotateX1024(Mtx *dstp, u32 theta);
|
||
void MTX_RotateY1024(Mtx *dstp, u32 theta);
|
||
void MTX_RotateZ1024(Mtx *dstp, u32 theta);
|
||
void MTX_RotateX4096(Mtx *dstp, u32 theta);
|
||
void MTX_RotateY4096(Mtx *dstp, u32 theta);
|
||
void MTX_RotateZ4096(Mtx *dstp, u32 theta);
|
||
|
||
void MTX33_RotateX256(Mtx33 *dstp, u32 theta);
|
||
void MTX33_RotateY256(Mtx33 *dstp, u32 theta);
|
||
void MTX33_RotateZ256(Mtx33 *dstp, u32 theta);
|
||
void MTX33_RotateX1024(Mtx33 *dstp, u32 theta);
|
||
void MTX33_RotateY1024(Mtx33 *dstp, u32 theta);
|
||
void MTX33_RotateZ1024(Mtx33 *dstp, u32 theta);
|
||
void MTX33_RotateX4096(Mtx33 *dstp, u32 theta);
|
||
void MTX33_RotateY4096(Mtx33 *dstp, u32 theta);
|
||
void MTX33_RotateZ4096(Mtx33 *dstp, u32 theta);
|
||
|
||
void MTX44_RotateX256(Mtx44 *dstp, u32 theta);
|
||
void MTX44_RotateY256(Mtx44 *dstp, u32 theta);
|
||
void MTX44_RotateZ256(Mtx44 *dstp, u32 theta);
|
||
void MTX44_RotateX1024(Mtx44 *dstp, u32 theta);
|
||
void MTX44_RotateY1024(Mtx44 *dstp, u32 theta);
|
||
void MTX44_RotateZ1024(Mtx44 *dstp, u32 theta);
|
||
void MTX44_RotateX4096(Mtx44 *dstp, u32 theta);
|
||
void MTX44_RotateY4096(Mtx44 *dstp, u32 theta);
|
||
void MTX44_RotateZ4096(Mtx44 *dstp, u32 theta);
|
||
|
||
// 中間マクロ(下記のマクロは直接使用しないで下さい)
|
||
|
||
#define MTXxx_RotatePriv(xx_, axis, ndiv, dstp, theta) MTXxx_RotateNDiv(xx_, axis, ndiv, dstp, theta)
|
||
#define MTXxx_RotateNDiv(xx_, axis, ndiv, dstp, theta) MTX##xx_##Rotate##axis##ndiv( dstp, theta)
|
||
|
||
//----------------------------------------------------------------------
|
||
// 主軸回転行列(三角関数による回転角指定)の生成
|
||
//
|
||
//・主軸回転行列をdstpが指す行列へ生成します。
|
||
//・回転角度はサインとコサインにて指定します。
|
||
//
|
||
//・引数:
|
||
// dstp 生成行列バッファのポインタ
|
||
// sinA 回転角度のサイン
|
||
// cosA 回転角度のコサイン
|
||
//
|
||
//・戻り値:なし
|
||
//----------------------------------------------------------------------
|
||
|
||
void MTX_RotateXSinCos(Mtx *dstp, s32 sinA, s32 cosA);
|
||
void MTX_RotateYSinCos(Mtx *dstp, s32 sinA, s32 cosA);
|
||
void MTX_RotateZSinCos(Mtx *dstp, s32 sinA, s32 cosA);
|
||
|
||
void MTX33_RotateXSinCos(Mtx33 *dstp, s32 sinA, s32 cosA);
|
||
void MTX33_RotateYSinCos(Mtx33 *dstp, s32 sinA, s32 cosA);
|
||
void MTX33_RotateZSinCos(Mtx33 *dstp, s32 sinA, s32 cosA);
|
||
|
||
void MTX44_RotateXSinCos(Mtx44 *dstp, s32 sinA, s32 cosA);
|
||
void MTX44_RotateYSinCos(Mtx44 *dstp, s32 sinA, s32 cosA);
|
||
void MTX44_RotateZSinCos(Mtx44 *dstp, s32 sinA, s32 cosA);
|
||
|
||
//----------------------------------------------------------------------
|
||
// 任意軸回転行列の生成
|
||
//
|
||
//・任意軸回転行列をdstpが指す行列へ生成します。
|
||
//
|
||
//・通常版は平方根演算器と除算器を使用しますが、高速版は使用しません
|
||
// (高速版には単位ベクトルを渡して下さい)。
|
||
//
|
||
//・引数:
|
||
// dstp 生成行列バッファのポインタ
|
||
// axisp 回転軸ベクトルのポインタ
|
||
// theta 回転角度[256|1024|4096段階]
|
||
//
|
||
//・戻り値:なし
|
||
//
|
||
//※通常版は平方根演算器と除算器を使用するため、TCM上で実行したとしても
|
||
// ディスプレイリスト等のDMA転送とシステムバス上で衝突した場合には
|
||
// ストールしてしまいます。
|
||
//----------------------------------------------------------------------
|
||
|
||
#define MTX_RotateAxis( dstp, axisp, heta) MTXxx_RotateAxisPriv( _, SIN_NDIV_DEFAULT, dstp, axisp, theta)
|
||
#define MTX_RotateAxisFast(dstp, axisp, theta) MTXxx_RotateAxisPrivFast(_, SIN_NDIV_DEFAULT, dstp, axisp, theta)
|
||
|
||
#define MTX33_RotateAxis( dstp, axisp, heta) MTXxx_RotateAxisPriv( 33_, SIN_NDIV_DEFAULT, dstp, axisp, theta)
|
||
#define MTX33_RotateAxisFast(dstp, axisp, theta) MTXxx_RotateAxisPrivFast(33_, SIN_NDIV_DEFAULT, dstp, axisp, theta)
|
||
|
||
#define MTX44_RotateAxis( dstp, axisp, heta) MTXxx_RotateAxisPriv( 44_, SIN_NDIV_DEFAULT, dstp, axisp, theta)
|
||
#define MTX44_RotateAxisFast(dstp, axisp, theta) MTXxx_RotateAxisPrivFast(44_, SIN_NDIV_DEFAULT, dstp, axisp, theta)
|
||
|
||
void MTX_RotateAxis256(Mtx *dstp, const Vec *axisp, u32 theta);
|
||
void MTX_RotateAxis256Fast(Mtx *dstp, const Vec *axisp, u32 theta);
|
||
void MTX_RotateAxis1024(Mtx *dstp, const Vec *axisp, u32 theta);
|
||
void MTX_RotateAxis1024Fast(Mtx *dstp, const Vec *axisp, u32 theta);
|
||
void MTX_RotateAxis4096(Mtx *dstp, const Vec *axisp, u32 theta);
|
||
void MTX_RotateAxis4096Fast(Mtx *dstp, const Vec *axisp, u32 theta);
|
||
|
||
void MTX33_RotateAxis256(Mtx33 *dstp, const Vec *axisp, u32 theta);
|
||
void MTX33_RotateAxis256Fast(Mtx33 *dstp, const Vec *axisp, u32 theta);
|
||
void MTX33_RotateAxis1024(Mtx33 *dstp, const Vec *axisp, u32 theta);
|
||
void MTX33_RotateAxis1024Fast(Mtx33 *dstp, const Vec *axisp, u32 theta);
|
||
void MTX33_RotateAxis4096(Mtx33 *dstp, const Vec *axisp, u32 theta);
|
||
void MTX33_RotateAxis4096Fast(Mtx33 *dstp, const Vec *axisp, u32 theta);
|
||
|
||
void MTX44_RotateAxis256(Mtx44 *dstp, const Vec *axisp, u32 theta);
|
||
void MTX44_RotateAxis256Fast(Mtx44 *dstp, const Vec *axisp, u32 theta);
|
||
void MTX44_RotateAxis1024(Mtx44 *dstp, const Vec *axisp, u32 theta);
|
||
void MTX44_RotateAxis1024Fast(Mtx44 *dstp, const Vec *axisp, u32 theta);
|
||
void MTX44_RotateAxis4096(Mtx44 *dstp, const Vec *axisp, u32 theta);
|
||
void MTX44_RotateAxis4096Fast(Mtx44 *dstp, const Vec *axisp, u32 theta);
|
||
|
||
// 中間マクロ(下記のマクロは直接使用しないで下さい)
|
||
|
||
#define MTXxx_RotateAxisPriv( xx_, ndiv, dstp, axisp, theta) MTXxx_RotateAxisNDiv( xx_, ndiv, dstp, axisp, theta)
|
||
#define MTXxx_RotateAxisPrivFast(xx_, ndiv, dstp, axisp, theta) MTXxx_RotateAxisNDivFast(xx_, ndiv, dstp, axisp, theta)
|
||
#define MTXxx_RotateAxisNDiv( xx_, ndiv, dstp, axisp, theta) MTX##xx_##RotateAxis##ndiv( dstp, axisp, theta)
|
||
#define MTXxx_RotateAxisNDivFast(xx_, ndiv, dstp, axisp, theta) MTX##xx_##RotateAxis##ndiv##Fast( dstp, axisp, theta)
|
||
|
||
//----------------------------------------------------------------------
|
||
// 任意軸回転行列(三角関数による回転角指定)の生成
|
||
//
|
||
//・任意軸回転行列をdstpが指す行列へ生成します。
|
||
//・回転角度はサインとコサインにて指定します。
|
||
//
|
||
//・通常版は平方根演算器と除算器を使用しますが、高速版は使用しません
|
||
// (高速版には単位ベクトルを渡して下さい)。
|
||
//
|
||
//・引数:
|
||
// dstp 生成行列バッファのポインタ
|
||
// axisp 回転軸ベクトルのポインタ
|
||
// sinA 回転角度のサイン
|
||
// cosA 回転角度のコサイン
|
||
//
|
||
//・戻り値:なし
|
||
//
|
||
//※通常版は平方根演算器と除算器を使用するため、TCM上で実行したとしても
|
||
// ディスプレイリスト等のDMA転送とシステムバス上で衝突した場合には
|
||
// ストールしてしまいます。
|
||
//----------------------------------------------------------------------
|
||
|
||
void MTX_RotateAxisSinCos(Mtx *dstp, const Vec *axisp, s32 sinA, s32 cosA);
|
||
void MTX_RotateAxisSinCosFast(Mtx *dstp, const Vec *axisp, s32 sinA, s32 cosA);
|
||
|
||
void MTX33_RotateAxisSinCos(Mtx33 *dstp, const Vec *axisp, s32 sinA, s32 cosA);
|
||
void MTX33_RotateAxisSinCosFast(Mtx33 *dstp, const Vec *axisp, s32 sinA, s32 cosA);
|
||
|
||
void MTX44_RotateAxisSinCos(Mtx44 *dstp, const Vec *axisp, s32 sinA, s32 cosA);
|
||
void MTX44_RotateAxisSinCosFast(Mtx44 *dstp, const Vec *axisp, s32 sinA, s32 cosA);
|
||
|
||
//----------------------------------------------------------------------
|
||
// Z軸にアライメントする回転行列の生成
|
||
//
|
||
//・任意軸をZ軸の正方向と一致させる回転を行う行列を
|
||
// dstpが指す行列へ生成します。
|
||
//
|
||
// H = sqrt (X*X + Z*Z)
|
||
//
|
||
// [ 1 ] [ Z/H -X/H ] [ Z/H -X/H ]
|
||
// [ v ] [ H/1 -Y/1 ] [ 1 ] = [ v ] [ -YX/H H -YZ/H ]
|
||
// [ Y/1 H/1 ] [ X/H Z/H ] [ X Y Z ]
|
||
//
|
||
//・関数内で平方根演算器と除算器を使用します。
|
||
//
|
||
//・引数:
|
||
// dstp 生成行列バッファのポインタ
|
||
// vLookInvp 視線と逆方向の単位ベクトル(*_LookAt*() で得られます)
|
||
//
|
||
//※平方根演算器と除算器を使用するため、TCM上で実行したとしても
|
||
// ディスプレイリスト等のDMA転送とシステムバス上で衝突した場合には
|
||
// ストールしてしまいます。
|
||
//----------------------------------------------------------------------
|
||
|
||
void MTX_AlignZ(Mtx *dstp, const Vec *vLookInvp);
|
||
void MTX33_AlignZ(Mtx33 *dstp, const Vec *vLookInvp);
|
||
void MTX44_AlignZ(Mtx44 *dstp, const Vec *vLookInvp);
|
||
|
||
|
||
//----------------------------------------------------------------------
|
||
// クォータニオンから変換した回転行列の生成
|
||
//
|
||
//・クォータニオンから変換した回転行列をdstpが指す行列へ生成します。
|
||
//
|
||
//・通常版は除算器を使用しますが、高速版は使用しません
|
||
// (高速版には正規化クォータニオンを渡して下さい)。
|
||
//
|
||
//・引数:
|
||
// dstp 行列格納バッファのポインタ
|
||
// quatp クォータニオンのポインタ
|
||
//
|
||
//・戻り値:なし
|
||
//
|
||
//※通常版は除算器を使用するため、ディスプレイリスト等のDMA転送と
|
||
// 並列して実行するとストールが発生する可能性があります。
|
||
//----------------------------------------------------------------------
|
||
|
||
void MTX_QuatMtx(Mtx *dstp, const Quat *quatp);
|
||
void MTX_QuatMtxFast(Mtx *dstp, const Quat *quatp);
|
||
|
||
void MTX33_QuatMtx(Mtx33 *dstp, const Quat *quatp);
|
||
void MTX33_QuatMtxFast(Mtx33 *dstp, const Quat *quatp);
|
||
|
||
void MTX44_QuatMtx(Mtx44 *dstp, const Quat *quatp);
|
||
void MTX44_QuatMtxFast(Mtx44 *dstp, const Quat *quatp);
|
||
|
||
|
||
//======================================================================
|
||
// ビュー行列
|
||
//======================================================================
|
||
|
||
//----------------------------------------------------------------------
|
||
// 視界行列の生成
|
||
//
|
||
//・視界行列をdstpが指す行列へ生成します。
|
||
//
|
||
//・関数内でベクトルの正規化のために平方根演算器と除算器を使用します。
|
||
//
|
||
//・引数:
|
||
// dstp 生成行列バッファのポインタ
|
||
// eye 視点
|
||
// at 注視点
|
||
// vUp 上方向ベクトル
|
||
// vDst 0(NULLポインタ)以外を渡すと、視線逆方向ベクトルを返します
|
||
//
|
||
//・戻り値:なし
|
||
//
|
||
//※平方根演算器と除算器を使用するため、TCM上で実行したとしても
|
||
// ディスプレイリスト等のDMA転送とシステムバス上で衝突した場合には
|
||
// ストールしてしまいます。
|
||
//----------------------------------------------------------------------
|
||
|
||
void MTX_LookAt( Mtx *dstp, const Pos *eye, const Pos *at, const Vec *vUp, Vec *vDst);
|
||
void MTX_LookAtFast(Mtx *dstp, const Pos *eye, const Pos *at, const Vec *vUp, Vec *vDst);
|
||
|
||
|
||
//======================================================================
|
||
// 射影行列
|
||
//======================================================================
|
||
|
||
//----------------------------------------------------------------------
|
||
// 左右対称の透視射影行列の生成
|
||
//
|
||
//・左右対称の透視法視錐台の行列をdstpが指す行列へ生成します。
|
||
//
|
||
//・引数:
|
||
// dstp 生成行列バッファのポインタ
|
||
// fovy 縦方向の視野角度[256|1024|4096段階]
|
||
// aspect 横方向の視野を確定する縦横比(視野の 幅/高さ)
|
||
// near 視点からnearクリップ面までの距離(常に正)
|
||
// far 視点からfarクリップ面までの距離 (常に正)
|
||
// scaleW クリップ座標W値のスケールパラメータ(座標変換後の精度調整)
|
||
//
|
||
//・戻り値:なし
|
||
//
|
||
//※除算器を使用するため、TCM上で実行したとしても
|
||
// ディスプレイリスト等のDMA転送とシステムバス上で衝突した場合には
|
||
// ストールしてしまいます。
|
||
//----------------------------------------------------------------------
|
||
|
||
#define MTX44_Perspective(dstp, fovy, aspect, near, far, scaleW) MTX44_PerspectivePriv(SIN_NDIV_DEFAULT, dstp, fovy, aspect, near, far, scaleW)
|
||
|
||
void MTX44_Perspective256(Mtx44 *dstp, u32 fovy, s32 aspect, s32 near, s32 far, s32 scaleW);
|
||
void MTX44_Perspective1024(Mtx44 *dstp, u32 fovy, s32 aspect, s32 near, s32 far, s32 scaleW);
|
||
void MTX44_Perspective4096(Mtx44 *dstp, u32 fovy, s32 aspect, s32 near, s32 far, s32 scaleW);
|
||
|
||
// 中間マクロ(下記のマクロは直接使用しないで下さい)
|
||
|
||
#define MTX44_PerspectivePriv(ndiv, dstp, fovy, aspect, near, far, scaleW) MTX44_PerspectiveNDiv(ndiv, dstp, fovy, aspect, near, far, scaleW)
|
||
#define MTX44_PerspectiveNDiv(ndiv, dstp, fovy, aspect, near, far, scaleW) MTX44_Perspective##ndiv( dstp, fovy, aspect, near, far, scaleW)
|
||
|
||
//----------------------------------------------------------------------
|
||
// 左右対称の透視射影行列(三角関数による視野角指定)の生成
|
||
//
|
||
//・左右対称の透視法視錐台の行列をdstpが指す行列へ生成します。
|
||
//・回転角度はサインとコサインにて指定します。
|
||
//
|
||
//・引数:
|
||
// dstp 生成行列バッファのポインタ
|
||
// sinA 縦方向の視野角度のサイン
|
||
// cosA 縦方向の視野角度のコサイン(上位関数からの呼び出し高速化のため最後に渡す)
|
||
// aspect 横方向の視野を確定する縦横比(視野の 幅/高さ)
|
||
// near 視点からnearクリップ面までの距離(常に正)
|
||
// far 視点からfarクリップ面までの距離 (常に正)
|
||
// scaleW クリップ座標W値のスケールパラメータ(座標変換後の精度調整)
|
||
//
|
||
//・戻り値:なし
|
||
//
|
||
//※除算器を使用するため、TCM上で実行したとしても
|
||
// ディスプレイリスト等のDMA転送とシステムバス上で衝突した場合には
|
||
// ストールしてしまいます。
|
||
//----------------------------------------------------------------------
|
||
|
||
void MTX44_PerspectiveSinCos(Mtx44 *dstp, s32 sinA, s32 aspect, s32 near, s32 far, s32 scaleW, s32 cosA);
|
||
|
||
//----------------------------------------------------------------------
|
||
// 透視射影行列の生成
|
||
//
|
||
//・透視法視錐台の行列をdstpが指す行列へ生成します。
|
||
//
|
||
//・引数:
|
||
// dstp 生成行列バッファのポインタ
|
||
// t nearクリップ面上辺のy座標
|
||
// b nearクリップ面下辺のy座標
|
||
// l nearクリップ面左辺のx座標
|
||
// r nearクリップ面右辺のx座標
|
||
// n 視点からnearクリップ面までの距離(常に正)
|
||
// f 視点からfarクリップ面までの距離 (常に正)
|
||
// scaleW クリップ座標W値のスケールパラメータ(座標変換後の精度調整)
|
||
//
|
||
//・戻り値:なし
|
||
//
|
||
//※除算器を使用するため、TCM上で実行したとしても
|
||
// ディスプレイリスト等のDMA転送とシステムバス上で衝突した場合には
|
||
// ストールしてしまいます。
|
||
//----------------------------------------------------------------------
|
||
|
||
void MTX44_Frustum(Mtx44 *dstp, s32 t, s32 b, s32 l, s32 r, s32 n, s32 f, s32 scaleW);
|
||
|
||
//----------------------------------------------------------------------
|
||
// 正射影行列の生成
|
||
//
|
||
//・正射影の平行視体積の行列をdstpが指す行列へ生成します。
|
||
//
|
||
//・引数:
|
||
// dstp 生成行列バッファのポインタ
|
||
// t nearクリップ面上辺のy座標
|
||
// b nearクリップ面下辺のy座標
|
||
// l nearクリップ面左辺のx座標
|
||
// r nearクリップ面右辺のx座標
|
||
// n 視点からnearクリップ面までの距離(正負どちらでも可)
|
||
// f 視点からfarクリップ面までの距離 (正負どちらでも可)
|
||
// scaleW クリップ座標W値のスケールパラメータ(座標変換後の精度調整)
|
||
//
|
||
//・戻り値:なし
|
||
//
|
||
//※除算器を使用するため、TCM上で実行したとしても
|
||
// ディスプレイリスト等のDMA転送とシステムバス上で衝突した場合には
|
||
// ストールしてしまいます。
|
||
//----------------------------------------------------------------------
|
||
|
||
void MTX44_Ortho( Mtx44 *dstp, s32 t, s32 b, s32 l, s32 r, s32 n, s32 f, s32 scaleW);
|
||
|
||
|
||
//======================================================================
|
||
// 行列・ベクトル乗算
|
||
//======================================================================
|
||
|
||
//----------------------------------------------------------------------
|
||
// 3Dベクトルと行列の乗算
|
||
//
|
||
//・srcpが指す3Dベクトルをmultが指す行列で座標変換した結果を
|
||
// dstpが指す3Dベクトルへ格納します。
|
||
//
|
||
//・引数:
|
||
// mult 乗算行列
|
||
// srcp 乗算前のベクトル
|
||
// dstp 乗算後のベクトル
|
||
//
|
||
//・戻り値:なし
|
||
//----------------------------------------------------------------------
|
||
|
||
void MTX_MultVec( const Mtx *mult, Vec *srcp, Vec *dstp);
|
||
void MTX33_MultVec(const Mtx33 *mult, Vec *srcp, Vec *dstp);
|
||
void MTX44_MultVec(const Mtx44 *mult, Vec *srcp, Vec *dstp);
|
||
|
||
//----------------------------------------------------------------------
|
||
// 複数の3Dベクトルと行列の乗算
|
||
//
|
||
//・srcBasepが指す3Dベクトル群をmultが指す行列で座標変換した結果を
|
||
// dstBasepが指す3Dベクトル群へ格納します。
|
||
//
|
||
//・引数:
|
||
// mult 乗算行列
|
||
// srcBasep 乗算前のベクトル
|
||
// dstBasep 乗算後のベクトル
|
||
// count 回数
|
||
//
|
||
//・戻り値:なし
|
||
//----------------------------------------------------------------------
|
||
|
||
void MTX_MultVecArray( const Mtx *mult, Vec *srcBasep, Vec *dstBasep, u32 count);
|
||
void MTX33_MultVecArray(const Mtx33 *mult, Vec *srcBasep, Vec *dstBasep, u32 count);
|
||
void MTX44_MultVecArray(const Mtx44 *mult, Vec *srcBasep, Vec *dstBasep, u32 count);
|
||
|
||
|
||
//----------------------------------------------------------------------
|
||
// 3Dベクトルと行列のスケール回転成分との乗算
|
||
//
|
||
//・srcpが指す3Dベクトルをmultが指す行列のスケール回転成分で座標変換した結果を
|
||
// dstpが指す3Dベクトルへ格納します。
|
||
//
|
||
//・引数:
|
||
// mult 乗算行列のスケール回転成分
|
||
// srcp 乗算前のベクトル
|
||
// dstp 乗算後のベクトル
|
||
//
|
||
//・戻り値:なし
|
||
//----------------------------------------------------------------------
|
||
|
||
void MTX_MultVecSR( const Mtx *mult, Vec *srcp, Vec *dstp);
|
||
void MTX44_MultVecSR(const Mtx44 *mult, Vec *srcp, Vec *dstp);
|
||
|
||
//----------------------------------------------------------------------
|
||
// 複数の3Dベクトルと行列のスケール回転成分との乗算
|
||
//
|
||
//・srcBasepが指す3Dベクトル群をmultが指す行列のスケール回転成分で座標変換した結果を
|
||
// dstBasepが指す3Dベクトル群へ格納します。
|
||
//
|
||
//・引数:
|
||
// mult 乗算行列のスケール回転成分
|
||
// srcBasep 乗算前のベクトル
|
||
// dstBasep 乗算後のベクトル
|
||
// count 回数
|
||
//
|
||
//・戻り値:なし
|
||
//----------------------------------------------------------------------
|
||
|
||
void MTX_MultVecArraySR( const Mtx *mult, Vec *srcBasep, Vec *dstBasep, u32 count);
|
||
void MTX44_MultVecArraySR(const Mtx44 *mult, Vec *srcBasep, Vec *dstBasep, u32 count);
|
||
|
||
|
||
|
||
#ifdef __cplusplus
|
||
} // extern "C"
|
||
#endif
|
||
|
||
#endif // _IRIS_MTX_H
|