cleanup Model, remove MathUtil files, fix col major/row major errors
This commit is contained in:
@@ -197,7 +197,7 @@ $(RageFile)
|
||||
Actors = \
|
||||
Actor.cpp Actor.h ActorCollision.h ActorFrame.cpp ActorFrame.h ActorScroller.cpp ActorScroller.h \
|
||||
ActorUtil.cpp ActorUtil.h BitmapText.cpp BitmapText.h Milkshape.h Model.cpp Model.h ModelTypes.cpp ModelTypes.h \
|
||||
Quad.h Sprite.cpp Sprite.h mathlib.c mathlib.h
|
||||
Quad.h Sprite.cpp Sprite.h
|
||||
|
||||
GlobalSingletons = \
|
||||
AnnouncerManager.cpp AnnouncerManager.h Bookkeeper.h Bookkeeper.cpp FontManager.cpp FontManager.h GameManager.cpp GameManager.h \
|
||||
|
||||
+74
-83
@@ -11,7 +11,6 @@
|
||||
*/
|
||||
#include "Model.h"
|
||||
#include "ModelTypes.h"
|
||||
#include "mathlib.h"
|
||||
#include "RageMath.h"
|
||||
#include "RageDisplay.h"
|
||||
#include "RageUtil.h"
|
||||
@@ -139,8 +138,8 @@ bool Model::LoadMilkshapeAscii( CString sPath )
|
||||
break;
|
||||
}
|
||||
|
||||
msVec3 Vertex;
|
||||
msVec2 uv;
|
||||
RageVector3 Vertex;
|
||||
RageVector2 uv;
|
||||
if (sscanf (szLine, "%d %f %f %f %f %f %d",
|
||||
&nFlags,
|
||||
&Vertex[0], &Vertex[1], &Vertex[2],
|
||||
@@ -178,7 +177,7 @@ bool Model::LoadMilkshapeAscii( CString sPath )
|
||||
break;
|
||||
}
|
||||
|
||||
vector<msVec3> Normals;
|
||||
vector<RageVector3> Normals;
|
||||
Normals.resize( nNumNormals );
|
||||
for (j = 0; j < nNumNormals; j++)
|
||||
{
|
||||
@@ -188,14 +187,14 @@ bool Model::LoadMilkshapeAscii( CString sPath )
|
||||
break;
|
||||
}
|
||||
|
||||
msVec3 Normal;
|
||||
RageVector3 Normal;
|
||||
if (sscanf (szLine, "%f %f %f", &Normal[0], &Normal[1], &Normal[2]) != 3)
|
||||
{
|
||||
bError = true;
|
||||
break;
|
||||
}
|
||||
|
||||
VectorNormalize (Normal);
|
||||
RageVec3Normalize( (RageVector3*)&Normal, (RageVector3*)&Normal );
|
||||
Normals[j] = Normal;
|
||||
}
|
||||
|
||||
@@ -245,7 +244,7 @@ bool Model::LoadMilkshapeAscii( CString sPath )
|
||||
{
|
||||
|
||||
msVertex& Vertex = mesh.Vertices[ nIndices[k] ];
|
||||
msVec3& Normal = Normals[ nNormalIndices[k] ];
|
||||
RageVector3& Normal = Normals[ nNormalIndices[k] ];
|
||||
Vertex.Normal = Normal;
|
||||
}
|
||||
|
||||
@@ -291,8 +290,8 @@ bool Model::LoadMilkshapeAscii( CString sPath )
|
||||
bError = true;
|
||||
break;
|
||||
}
|
||||
msVec4 Ambient;
|
||||
if (sscanf (szLine, "%f %f %f %f", &Ambient.v[0], &Ambient.v[1], &Ambient.v[2], &Ambient.v[3]) != 4)
|
||||
RageVector4 Ambient;
|
||||
if (sscanf (szLine, "%f %f %f %f", &Ambient[0], &Ambient[1], &Ambient[2], &Ambient[3]) != 4)
|
||||
{
|
||||
bError = true;
|
||||
break;
|
||||
@@ -305,8 +304,8 @@ bool Model::LoadMilkshapeAscii( CString sPath )
|
||||
bError = true;
|
||||
break;
|
||||
}
|
||||
msVec4 Diffuse;
|
||||
if (sscanf (szLine, "%f %f %f %f", &Diffuse.v[0], &Diffuse.v[1], &Diffuse.v[2], &Diffuse.v[3]) != 4)
|
||||
RageVector4 Diffuse;
|
||||
if (sscanf (szLine, "%f %f %f %f", &Diffuse[0], &Diffuse[1], &Diffuse[2], &Diffuse[3]) != 4)
|
||||
{
|
||||
bError = true;
|
||||
break;
|
||||
@@ -319,8 +318,8 @@ bool Model::LoadMilkshapeAscii( CString sPath )
|
||||
bError = true;
|
||||
break;
|
||||
}
|
||||
msVec4 Specular;
|
||||
if (sscanf (szLine, "%f %f %f %f", &Specular.v[0], &Specular.v[1], &Specular.v[2], &Specular.v[3]) != 4)
|
||||
RageVector4 Specular;
|
||||
if (sscanf (szLine, "%f %f %f %f", &Specular[0], &Specular[1], &Specular[2], &Specular[3]) != 4)
|
||||
{
|
||||
bError = true;
|
||||
break;
|
||||
@@ -333,8 +332,8 @@ bool Model::LoadMilkshapeAscii( CString sPath )
|
||||
bError = true;
|
||||
break;
|
||||
}
|
||||
msVec4 Emissive;
|
||||
if (sscanf (szLine, "%f %f %f %f", &Emissive.v[0], &Emissive.v[1], &Emissive.v[2], &Emissive.v[3]) != 4)
|
||||
RageVector4 Emissive;
|
||||
if (sscanf (szLine, "%f %f %f %f", &Emissive[0], &Emissive[1], &Emissive[2], &Emissive[3]) != 4)
|
||||
{
|
||||
bError = true;
|
||||
break;
|
||||
@@ -480,7 +479,7 @@ bool Model::LoadMilkshapeAsciiBones( CString sAniName, CString sPath )
|
||||
strcpy( Bone.szParentName, szName );
|
||||
|
||||
// flags, position, rotation
|
||||
msVec3 Position, Rotation;
|
||||
RageVector3 Position, Rotation;
|
||||
if( f.GetLine( szLine ) <= 0 )
|
||||
{
|
||||
bError = true;
|
||||
@@ -488,8 +487,8 @@ bool Model::LoadMilkshapeAsciiBones( CString sAniName, CString sPath )
|
||||
}
|
||||
if (sscanf (szLine, "%d %f %f %f %f %f %f",
|
||||
&nFlags,
|
||||
&Position.v[0], &Position.v[1], &Position.v[2],
|
||||
&Rotation.v[0], &Rotation.v[1], &Rotation.v[2]) != 7)
|
||||
&Position[0], &Position[1], &Position[2],
|
||||
&Rotation[0], &Rotation[1], &Rotation[2]) != 7)
|
||||
{
|
||||
bError = true;
|
||||
break;
|
||||
@@ -528,7 +527,9 @@ bool Model::LoadMilkshapeAsciiBones( CString sAniName, CString sPath )
|
||||
break;
|
||||
}
|
||||
|
||||
msPositionKey key = { fTime, { Position[0], Position[1], Position[2] } };
|
||||
msPositionKey key;
|
||||
key.fTime = fTime;
|
||||
key.Position = RageVector3( Position[0], Position[1], Position[2] );
|
||||
Bone.PositionKeys[j] = key;
|
||||
}
|
||||
|
||||
@@ -560,7 +561,9 @@ bool Model::LoadMilkshapeAsciiBones( CString sAniName, CString sPath )
|
||||
break;
|
||||
}
|
||||
|
||||
msRotationKey key = { fTime, { Rotation[0], Rotation[1], Rotation[2] } };
|
||||
msRotationKey key;
|
||||
key.fTime = fTime;
|
||||
key.Rotation = RageVector3( Rotation[0], Rotation[1], Rotation[2] );
|
||||
Bone.RotationKeys[j] = key;
|
||||
}
|
||||
}
|
||||
@@ -655,12 +658,9 @@ void Model::DrawPrimitives()
|
||||
{
|
||||
int bone = originalVert.nBoneIndex;
|
||||
|
||||
VectorRotate (originalVert.Normal, m_pBones[bone].mFinal, tempVert.n);
|
||||
RageVec3TransformNormal( &tempVert.n, &originalVert.Normal, &m_pBones[bone].mFinal );
|
||||
|
||||
VectorRotate (originalVert.Vertex, m_pBones[bone].mFinal, tempVert.p);
|
||||
tempVert.p[0] += m_pBones[bone].mFinal[0][3];
|
||||
tempVert.p[1] += m_pBones[bone].mFinal[1][3];
|
||||
tempVert.p[2] += m_pBones[bone].mFinal[2][3];
|
||||
RageVec3TransformCoord( &tempVert.p, &originalVert.Vertex, &m_pBones[bone].mFinal );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -709,25 +709,28 @@ void Model::PlayAnimation( CString sAniName, float fPlayRate )
|
||||
for (i = 0; i < nBoneCount; i++)
|
||||
{
|
||||
msBone *pBone = &m_pCurAnimation->Bones[i];
|
||||
msVec3 vRot;
|
||||
vRot[0] = pBone->Rotation[0] * 180 / (float) Q_PI;
|
||||
vRot[1] = pBone->Rotation[1] * 180 / (float) Q_PI;
|
||||
vRot[2] = pBone->Rotation[2] * 180 / (float) Q_PI;
|
||||
AngleMatrix (vRot, m_pBones[i].mRelative);
|
||||
m_pBones[i].mRelative[0][3] = pBone->Position[0];
|
||||
m_pBones[i].mRelative[1][3] = pBone->Position[1];
|
||||
m_pBones[i].mRelative[2][3] = pBone->Position[2];
|
||||
RageVector3 vRot;
|
||||
vRot[0] = pBone->Rotation[0] * 180 / (float) PI;
|
||||
vRot[1] = pBone->Rotation[1] * 180 / (float) PI;
|
||||
vRot[2] = pBone->Rotation[2] * 180 / (float) PI;
|
||||
|
||||
RageMatrixAngles( &m_pBones[i].mRelative, vRot );
|
||||
|
||||
m_pBones[i].mRelative.m[3][0] = pBone->Position[0];
|
||||
m_pBones[i].mRelative.m[3][1] = pBone->Position[1];
|
||||
m_pBones[i].mRelative.m[3][2] = pBone->Position[2];
|
||||
|
||||
int nParentBone = m_pCurAnimation->FindBoneByName( pBone->szParentName );
|
||||
if (nParentBone != -1)
|
||||
{
|
||||
R_ConcatTransforms (m_pBones[nParentBone].mAbsolute, m_pBones[i].mRelative, m_pBones[i].mAbsolute);
|
||||
memcpy (m_pBones[i].mFinal, m_pBones[i].mAbsolute, sizeof (matrix_t));
|
||||
RageMatrixMultiply( &m_pBones[i].mAbsolute, &m_pBones[nParentBone].mAbsolute, &m_pBones[i].mRelative );
|
||||
|
||||
m_pBones[i].mFinal = m_pBones[i].mAbsolute;
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy (m_pBones[i].mAbsolute, m_pBones[i].mRelative, sizeof (matrix_t));
|
||||
memcpy (m_pBones[i].mFinal, m_pBones[i].mRelative, sizeof (matrix_t));
|
||||
m_pBones[i].mAbsolute = m_pBones[i].mRelative;
|
||||
m_pBones[i].mFinal = m_pBones[i].mRelative;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -739,33 +742,21 @@ void Model::PlayAnimation( CString sAniName, float fPlayRate )
|
||||
msVertex *pVertex = &pMesh->Vertices[j];
|
||||
if (pVertex->nBoneIndex != -1)
|
||||
{
|
||||
pVertex->Vertex[0] -= m_pBones[pVertex->nBoneIndex].mAbsolute[0][3];
|
||||
pVertex->Vertex[1] -= m_pBones[pVertex->nBoneIndex].mAbsolute[1][3];
|
||||
pVertex->Vertex[2] -= m_pBones[pVertex->nBoneIndex].mAbsolute[2][3];
|
||||
msVec3 vTmp;
|
||||
VectorIRotate (pVertex->Vertex, m_pBones[pVertex->nBoneIndex].mAbsolute, vTmp);
|
||||
VectorCopy (vTmp, pVertex->Vertex);
|
||||
pVertex->Vertex[0] -= m_pBones[pVertex->nBoneIndex].mAbsolute.m[3][0];
|
||||
pVertex->Vertex[1] -= m_pBones[pVertex->nBoneIndex].mAbsolute.m[3][1];
|
||||
pVertex->Vertex[2] -= m_pBones[pVertex->nBoneIndex].mAbsolute.m[3][2];
|
||||
RageVector3 vTmp;
|
||||
|
||||
RageMatrix inverse;
|
||||
RageMatrixTranspose( &inverse, &m_pBones[pVertex->nBoneIndex].mAbsolute ); // transpose = inverse for rotation matrices
|
||||
RageVec3TransformNormal( &vTmp, &pVertex->Vertex, &inverse );
|
||||
|
||||
pVertex->Vertex = vTmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MakeMatrix( matrix_t out, const RageMatrix &in )
|
||||
{
|
||||
out[0][0] = in.m[0][0];
|
||||
out[1][0] = in.m[1][0];
|
||||
out[2][0] = in.m[2][0];
|
||||
out[3][0] = in.m[3][0];
|
||||
out[0][1] = in.m[0][1];
|
||||
out[1][1] = in.m[1][1];
|
||||
out[2][1] = in.m[2][1];
|
||||
out[3][1] = in.m[3][1];
|
||||
out[0][2] = in.m[0][2];
|
||||
out[1][2] = in.m[1][2];
|
||||
out[2][2] = in.m[2][2];
|
||||
out[3][2] = in.m[3][2];
|
||||
}
|
||||
|
||||
float Model::GetCurFrame() { return m_fCurrFrame; };
|
||||
|
||||
void Model::SetFrame( float fNewFrame )
|
||||
@@ -802,12 +793,12 @@ Model::AdvanceFrame (float dt)
|
||||
int nRotationKeyCount = pBone->RotationKeys.size();
|
||||
if (nPositionKeyCount == 0 && nRotationKeyCount == 0)
|
||||
{
|
||||
memcpy (m_pBones[i].mFinal, m_pBones[i].mAbsolute, sizeof (matrix_t));
|
||||
m_pBones[i].mFinal = m_pBones[i].mAbsolute;
|
||||
}
|
||||
else
|
||||
{
|
||||
msVec3 vPos;
|
||||
msVec4 vRot;
|
||||
RageVector3 vPos;
|
||||
RageVector3 vRot;
|
||||
//
|
||||
// search for the adjacent position keys
|
||||
//
|
||||
@@ -832,17 +823,17 @@ Model::AdvanceFrame (float dt)
|
||||
}
|
||||
else if (pLastPositionKey == 0)
|
||||
{
|
||||
VectorCopy (pThisPositionKey->Position, vPos);
|
||||
vPos = pThisPositionKey->Position;
|
||||
}
|
||||
else if (pThisPositionKey == 0)
|
||||
{
|
||||
VectorCopy (pLastPositionKey->Position, vPos);
|
||||
vPos = pLastPositionKey->Position;
|
||||
}
|
||||
//
|
||||
// search for the adjacent rotation keys
|
||||
//
|
||||
matrix_t m;
|
||||
memset( m, 0, sizeof(m) );
|
||||
RageMatrix m;
|
||||
RageMatrixIdentity( &m );
|
||||
msRotationKey *pLastRotationKey = 0, *pThisRotationKey = 0;
|
||||
for (j = 0; j < nRotationKeyCount; j++)
|
||||
{
|
||||
@@ -863,36 +854,36 @@ Model::AdvanceFrame (float dt)
|
||||
RageQuatFromHPR( &q2, RageVector3(pThisRotationKey->Rotation) * (180 / PI) );
|
||||
RageQuatSlerp( &q, q1, q2, s );
|
||||
|
||||
RageMatrix mm;
|
||||
RageMatrixFromQuat( &mm, q );
|
||||
MakeMatrix( m, mm );
|
||||
RageMatrixFromQuat( &m, q );
|
||||
}
|
||||
else if (pLastRotationKey == 0)
|
||||
{
|
||||
vRot[0] = pThisRotationKey->Rotation[0] * 180 / (float) Q_PI;
|
||||
vRot[1] = pThisRotationKey->Rotation[1] * 180 / (float) Q_PI;
|
||||
vRot[2] = pThisRotationKey->Rotation[2] * 180 / (float) Q_PI;
|
||||
AngleMatrix (vRot, m);
|
||||
vRot[0] = pThisRotationKey->Rotation[0] * 180 / (float) PI;
|
||||
vRot[1] = pThisRotationKey->Rotation[1] * 180 / (float) PI;
|
||||
vRot[2] = pThisRotationKey->Rotation[2] * 180 / (float) PI;
|
||||
RageMatrixAngles( &m, vRot );
|
||||
}
|
||||
else if (pThisRotationKey == 0)
|
||||
{
|
||||
vRot[0] = pLastRotationKey->Rotation[0] * 180 / (float) Q_PI;
|
||||
vRot[1] = pLastRotationKey->Rotation[1] * 180 / (float) Q_PI;
|
||||
vRot[2] = pLastRotationKey->Rotation[2] * 180 / (float) Q_PI;
|
||||
AngleMatrix (vRot, m);
|
||||
vRot[0] = pLastRotationKey->Rotation[0] * 180 / (float) PI;
|
||||
vRot[1] = pLastRotationKey->Rotation[1] * 180 / (float) PI;
|
||||
vRot[2] = pLastRotationKey->Rotation[2] * 180 / (float) PI;
|
||||
RageMatrixAngles( &m, vRot );
|
||||
}
|
||||
m[0][3] = vPos[0];
|
||||
m[1][3] = vPos[1];
|
||||
m[2][3] = vPos[2];
|
||||
R_ConcatTransforms (m_pBones[i].mRelative, m, m_pBones[i].mRelativeFinal);
|
||||
m.m[3][0] = vPos[0];
|
||||
m.m[3][1] = vPos[1];
|
||||
m.m[3][2] = vPos[2];
|
||||
|
||||
RageMatrixMultiply( &m_pBones[i].mRelativeFinal, &m_pBones[i].mRelative, &m );
|
||||
|
||||
int nParentBone = m_pCurAnimation->FindBoneByName( pBone->szParentName );
|
||||
if (nParentBone == -1)
|
||||
{
|
||||
memcpy (m_pBones[i].mFinal, m_pBones[i].mRelativeFinal, sizeof (matrix_t));
|
||||
m_pBones[i].mFinal = m_pBones[i].mRelativeFinal;
|
||||
}
|
||||
else
|
||||
{
|
||||
R_ConcatTransforms (m_pBones[nParentBone].mFinal, m_pBones[i].mRelativeFinal, m_pBones[i].mFinal);
|
||||
RageMatrixMultiply( &m_pBones[i].mFinal, &m_pBones[nParentBone].mFinal, &m_pBones[i].mRelativeFinal );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,15 +19,6 @@
|
||||
|
||||
struct msModel;
|
||||
|
||||
typedef float matrix_t[3][4];
|
||||
typedef struct
|
||||
{
|
||||
matrix_t mRelative;
|
||||
matrix_t mAbsolute;
|
||||
matrix_t mRelativeFinal;
|
||||
matrix_t mFinal;
|
||||
} myBone_t;
|
||||
|
||||
|
||||
class Model : public Actor
|
||||
{
|
||||
|
||||
+30
-38
@@ -36,22 +36,7 @@ typedef unsigned char byte;
|
||||
typedef unsigned short word;
|
||||
#endif /* word */
|
||||
|
||||
|
||||
typedef struct msVec2 {
|
||||
float v[2];
|
||||
operator float* () { return v; };
|
||||
operator const float* () const { return v; };
|
||||
} msVec2;
|
||||
typedef struct msVec3 {
|
||||
float v[3];
|
||||
operator float* () { return v; };
|
||||
operator const float* () const { return v; };
|
||||
} msVec3;
|
||||
typedef struct msVec4 {
|
||||
float v[4];
|
||||
operator float* () { return v; };
|
||||
operator const float* () const { return v; };
|
||||
} msVec4;
|
||||
#include "RageTypes.h"
|
||||
|
||||
|
||||
/* msFlag */
|
||||
@@ -62,33 +47,33 @@ typedef enum {
|
||||
/* msVertex */
|
||||
typedef struct msVertex
|
||||
{
|
||||
// byte nFlags;
|
||||
msVec3 Vertex;
|
||||
msVec2 uv;
|
||||
msVec3 Normal;
|
||||
// byte nFlags; // we don't care about saving this flag
|
||||
RageVector3 Vertex;
|
||||
RageVector2 uv;
|
||||
RageVector3 Normal;
|
||||
char nBoneIndex;
|
||||
} msVertex;
|
||||
|
||||
/* msTriangle */
|
||||
typedef struct
|
||||
{
|
||||
// word nFlags;
|
||||
// word nFlags; // we don't care about saving this flag
|
||||
word nVertexIndices[3];
|
||||
// word nNormalIndices[3];
|
||||
// msVec3 Normal;
|
||||
// byte nSmoothingGroup;
|
||||
// word nNormalIndices[3]; // we don't care about this. Use the normals in each vertex
|
||||
// msVec3 Normal; // we don't care about per-triangle normals. Each vertex has its own
|
||||
// byte nSmoothingGroup; // we don't care about this, so don't save it
|
||||
} msTriangle;
|
||||
|
||||
/* msMesh */
|
||||
typedef struct msMesh
|
||||
{
|
||||
// byte nFlags;
|
||||
// byte nFlags; // we don't care about saving this flag
|
||||
char szName[MS_MAX_NAME];
|
||||
char nMaterialIndex;
|
||||
|
||||
vector<msVertex> Vertices;
|
||||
|
||||
// vector<msVec3> Normals;
|
||||
// vector<msVec3> Normals; // each vertex holds its own normal
|
||||
|
||||
vector<msTriangle> Triangles;
|
||||
} msMesh;
|
||||
@@ -124,10 +109,10 @@ typedef struct msMaterial
|
||||
{
|
||||
int nFlags;
|
||||
char szName[MS_MAX_NAME];
|
||||
msVec4 Ambient;
|
||||
msVec4 Diffuse;
|
||||
msVec4 Specular;
|
||||
msVec4 Emissive;
|
||||
RageVector4 Ambient;
|
||||
RageVector4 Diffuse;
|
||||
RageVector4 Specular;
|
||||
RageVector4 Emissive;
|
||||
float fShininess;
|
||||
float fTransparency;
|
||||
char szDiffuseTexture[MS_MAX_PATH];
|
||||
@@ -140,14 +125,14 @@ typedef struct msMaterial
|
||||
typedef struct msPositionKey
|
||||
{
|
||||
float fTime;
|
||||
msVec3 Position;
|
||||
RageVector3 Position;
|
||||
} msPositionKey;
|
||||
|
||||
/* msRotationKey */
|
||||
typedef struct msRotationKey
|
||||
{
|
||||
float fTime;
|
||||
msVec3 Rotation;
|
||||
RageVector3 Rotation;
|
||||
} msRotationKey;
|
||||
|
||||
/* msBone */
|
||||
@@ -156,8 +141,8 @@ typedef struct msBone
|
||||
int nFlags;
|
||||
char szName[MS_MAX_NAME];
|
||||
char szParentName[MS_MAX_NAME];
|
||||
msVec3 Position;
|
||||
msVec3 Rotation;
|
||||
RageVector3 Position;
|
||||
RageVector3 Rotation;
|
||||
|
||||
vector<msPositionKey> PositionKeys;
|
||||
|
||||
@@ -186,12 +171,19 @@ struct msAnimation
|
||||
return -1;
|
||||
}
|
||||
|
||||
// not used
|
||||
// int nFrame;
|
||||
// int nFrame; // not used in SM. We keep track of this outside this structure.
|
||||
int nTotalFrames;
|
||||
|
||||
msVec3 Position;
|
||||
msVec3 Rotation;
|
||||
RageVector3 Position;
|
||||
RageVector3 Rotation;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
RageMatrix mRelative;
|
||||
RageMatrix mAbsolute;
|
||||
RageMatrix mRelativeFinal;
|
||||
RageMatrix mFinal;
|
||||
} myBone_t;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -298,15 +298,17 @@ void PaneDisplay::SetContent( PaneContents c )
|
||||
str = ssprintf( "%.0f", val );
|
||||
}
|
||||
|
||||
int p;
|
||||
|
||||
/* If this is a high score name that was set during this game, use the player's name. */
|
||||
for( int p=0; p < NUM_PLAYERS; ++p )
|
||||
for( p=0; p < NUM_PLAYERS; ++p )
|
||||
if( str == RANKING_TO_FILL_IN_MARKER[p] )
|
||||
str = PROFILEMAN->GetPlayerName( (PlayerNumber)p );
|
||||
|
||||
m_textContents[c].SetText( str );
|
||||
|
||||
const unsigned num = NUM_ITEM_COLORS( g_Contents[c].name );
|
||||
for( unsigned p = 0; p < num; ++p )
|
||||
for( p = 0; p < num; ++p )
|
||||
{
|
||||
const CString metric = ITEM_COLOR(g_Contents[c].name, p);
|
||||
CStringArray spec;
|
||||
|
||||
@@ -52,11 +52,18 @@ void RageVec3Normalize( RageVector3* pOut, const RageVector3* pV )
|
||||
|
||||
void RageVec3TransformCoord( RageVector3* pOut, const RageVector3* pV, const RageMatrix* pM )
|
||||
{
|
||||
RageVector4 temp( pV->x, pV->y, pV->z, 1.0f );
|
||||
RageVector4 temp( pV->x, pV->y, pV->z, 1.0f ); // translate
|
||||
RageVec4TransformCoord( &temp, &temp, pM );
|
||||
*pOut = RageVector3( temp.x/temp.w, temp.y/temp.w, temp.z/temp.w );
|
||||
}
|
||||
|
||||
void RageVec3TransformNormal( RageVector3* pOut, const RageVector3* pV, const RageMatrix* pM )
|
||||
{
|
||||
RageVector4 temp( pV->x, pV->y, pV->z, 0.0f ); // don't translate
|
||||
RageVec4TransformCoord( &temp, &temp, pM );
|
||||
*pOut = RageVector3( temp.x, temp.y, temp.z );
|
||||
}
|
||||
|
||||
#define m00 m[0][0]
|
||||
#define m01 m[0][1]
|
||||
#define m02 m[0][2]
|
||||
@@ -405,11 +412,13 @@ void RageMatrixFromQuat( RageMatrix* pOut, const RageVector4 q )
|
||||
float yz = q.y * (q.z + q.z);
|
||||
|
||||
float zz = q.z * (q.z + q.z);
|
||||
// careful. The param order is row-major, which is the
|
||||
// transpose of the order shown in the OpenGL docs.
|
||||
*pOut = RageMatrix(
|
||||
1.0f-(yy+zz), xy-wz, xz+wy, 0,
|
||||
xy+wz, 1-(xx+zz), yz-wx, 0,
|
||||
xz-wy, yz+wx, 1-(xx+yy), 0,
|
||||
0, 0, 0, 1 );
|
||||
1-(yy+zz), xy+wz, xz-wy, 0,
|
||||
xy-wz, 1-(xx+zz), yz+wx, 0,
|
||||
xz+wy, yz-wx, 1-(xx+yy), 0,
|
||||
0, 0, 0, 1 );
|
||||
}
|
||||
|
||||
void RageQuatSlerp(RageVector4 *pOut, const RageVector4 &from, const RageVector4 &to, float t)
|
||||
@@ -500,3 +509,39 @@ RageMatrix RageMatrixIdentity()
|
||||
return m;
|
||||
}
|
||||
|
||||
void RageMatrixAngles( RageMatrix* pOut, const RageVector3 &angles )
|
||||
{
|
||||
float angle;
|
||||
float sr, sp, sy, cr, cp, cy;
|
||||
|
||||
angle = angles[2] * (PI*2 / 360);
|
||||
sy = sin(angle);
|
||||
cy = cos(angle);
|
||||
angle = angles[1] * (PI*2 / 360);
|
||||
sp = sin(angle);
|
||||
cp = cos(angle);
|
||||
angle = angles[0] * (PI*2 / 360);
|
||||
sr = sin(angle);
|
||||
cr = cos(angle);
|
||||
|
||||
RageMatrixIdentity( pOut );
|
||||
|
||||
|
||||
// matrix = (Z * Y) * X
|
||||
pOut->m[0][0] = cp*cy;
|
||||
pOut->m[0][1] = cp*sy;
|
||||
pOut->m[0][2] = -sp;
|
||||
pOut->m[1][0] = sr*sp*cy+cr*-sy;
|
||||
pOut->m[1][1] = sr*sp*sy+cr*cy;
|
||||
pOut->m[1][2] = sr*cp;
|
||||
pOut->m[2][0] = (cr*sp*cy+-sr*-sy);
|
||||
pOut->m[2][1] = (cr*sp*sy+-sr*cy);
|
||||
pOut->m[2][2] = cr*cp;
|
||||
}
|
||||
|
||||
void RageMatrixTranspose( RageMatrix* pOut, const RageMatrix* pIn )
|
||||
{
|
||||
for( int i=0; i<4; i++)
|
||||
for( int j=0; j<4; j++)
|
||||
pOut->m[j][i] = pIn->m[i][j];
|
||||
}
|
||||
@@ -4,13 +4,21 @@
|
||||
-----------------------------------------------------------------------------
|
||||
File: RageMath.h
|
||||
|
||||
Desc: .
|
||||
Desc: Math utility functions. Most of these prototypes
|
||||
match up with the D3DX math functions. Take a function name,
|
||||
replace "Rage" with "D3DX" and look it up in the D3D SDK docs
|
||||
for details.
|
||||
|
||||
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
|
||||
Chris Danford
|
||||
-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#define PI ((float)3.1415926535897932384626433832795)
|
||||
#define DegreeToRadian( degree ) ((degree) * (PI / 180.0f))
|
||||
#define RadianToDegree( radian ) ((radian) * (180.0f / PI))
|
||||
|
||||
|
||||
struct RageVector2;
|
||||
struct RageVector3;
|
||||
struct RageVector4;
|
||||
@@ -22,6 +30,7 @@ void RageVec3AddToBounds( const RageVector3 &p, RageVector3 &mins, RageVector3 &
|
||||
void RageVec2Normalize( RageVector2* pOut, const RageVector2* pV );
|
||||
void RageVec3Normalize( RageVector3* pOut, const RageVector3* pV );
|
||||
void RageVec3TransformCoord( RageVector3* pOut, const RageVector3* pV, const RageMatrix* pM );
|
||||
void RageVec3TransformNormal( RageVector3* pOut, const RageVector3* pV, const RageMatrix* pM );
|
||||
void RageVec4TransformCoord( RageVector4* pOut, const RageVector4* pV, const RageMatrix* pM );
|
||||
void RageMatrixIdentity( RageMatrix* pOut );
|
||||
RageMatrix RageMatrixIdentity();
|
||||
@@ -47,5 +56,7 @@ RageMatrix RageLookAt(
|
||||
float eyex, float eyey, float eyez,
|
||||
float centerx, float centery, float centerz,
|
||||
float upx, float upy, float upz );
|
||||
void RageMatrixAngles( RageMatrix* pOut, const RageVector3 &angles );
|
||||
void RageMatrixTranspose( RageMatrix* pOut, const RageMatrix* pIn );
|
||||
|
||||
#endif
|
||||
|
||||
@@ -228,6 +228,12 @@ struct RageModelVertex // doesn't have color. Relies on material color
|
||||
RageVector2 t; // texture coordinates
|
||||
};
|
||||
|
||||
// RageMatrix elements are specified in row-major order. This
|
||||
// means that the translate terms are located in the fourth row and the
|
||||
// projection terms in the fourth column. This is consistent with the way
|
||||
// MAX, Direct3D, and OpenGL all handle matrices. Even though the OpenGL
|
||||
// documentation is in column-major form, the OpenGL code is designed to
|
||||
// handle matrix operations in row-major form.
|
||||
struct RageMatrix
|
||||
{
|
||||
public:
|
||||
@@ -249,30 +255,6 @@ public:
|
||||
|
||||
RageMatrix GetTranspose() const;
|
||||
|
||||
// ---These are not used. Maybe I'll implement them later...---
|
||||
// // assignment operators
|
||||
// RageMatrix& operator *= ( const RageMatrix& );
|
||||
// RageMatrix& operator += ( const RageMatrix& );
|
||||
// RageMatrix& operator -= ( const RageMatrix& );
|
||||
// RageMatrix& operator *= ( float );
|
||||
// RageMatrix& operator /= ( float );
|
||||
//
|
||||
// // unary operators
|
||||
// RageMatrix operator + () const;
|
||||
// RageMatrix operator - () const;
|
||||
//
|
||||
// // binary operators
|
||||
// RageMatrix operator * ( const RageMatrix& ) const;
|
||||
// RageMatrix operator + ( const RageMatrix& ) const;
|
||||
// RageMatrix operator - ( const RageMatrix& ) const;
|
||||
// RageMatrix operator * ( float ) const;
|
||||
// RageMatrix operator / ( float ) const;
|
||||
//
|
||||
// friend RageMatrix operator * ( float, const RageMatrix& );
|
||||
//
|
||||
// bool operator == ( const RageMatrix& ) const;
|
||||
// bool operator != ( const RageMatrix& ) const;
|
||||
|
||||
float m[4][4];
|
||||
};
|
||||
|
||||
|
||||
@@ -48,10 +48,6 @@ inline unsigned long max(unsigned long a, unsigned int b) { return a > b? a:b; }
|
||||
|
||||
#define clamp(val,low,high) ( max( (low), min((val),(high)) ) )
|
||||
|
||||
#define PI ((float)3.1415926535897932384626433832795)
|
||||
#define DegreeToRadian( degree ) ((degree) * (PI / 180.0f))
|
||||
#define RadianToDegree( radian ) ((radian) * (180.0f / PI))
|
||||
|
||||
// Scales x so that l1 corresponds to l2 and h1 corresponds to h2. Does not modify x, MUST assign the result to something!
|
||||
#define SCALE(x, l1, h1, l2, h2) (((x) - (l1)) / ((h1) - (l1)) * ((h2) - (l2)) + (l2))
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ IntDir=.\../Debug6
|
||||
TargetDir=\stepmania\itg\Program
|
||||
TargetName=StepMania-debug
|
||||
SOURCE="$(InputPath)"
|
||||
PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
|
||||
PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
|
||||
PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi
|
||||
# End Special Build Tool
|
||||
|
||||
@@ -102,8 +102,8 @@ IntDir=.\Debug
|
||||
TargetDir=\stepmania\stepmania
|
||||
TargetName=default
|
||||
SOURCE="$(InputPath)"
|
||||
PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp \
|
||||
/Fo$(IntDir)\
|
||||
PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp \
|
||||
/Fo$(IntDir)\
|
||||
PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi ia32.vdi
|
||||
# End Special Build Tool
|
||||
|
||||
@@ -143,7 +143,7 @@ IntDir=.\../Release6
|
||||
TargetDir=\stepmania\stepmania\Program
|
||||
TargetName=StepMania
|
||||
SOURCE="$(InputPath)"
|
||||
PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
|
||||
PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
|
||||
PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi
|
||||
# End Special Build Tool
|
||||
|
||||
@@ -184,8 +184,8 @@ IntDir=.\StepMania___Xbox_Release
|
||||
TargetDir=\stepmania\stepmania
|
||||
TargetName=default
|
||||
SOURCE="$(InputPath)"
|
||||
PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp \
|
||||
/Fo$(IntDir)\
|
||||
PreLink_Cmds=disasm\verinc cl /Zl /nologo /c \
|
||||
verstub.cpp /Fo$(IntDir)\
|
||||
PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi ia32.vdi
|
||||
# End Special Build Tool
|
||||
|
||||
@@ -1871,6 +1871,25 @@ SOURCE=.\MsdFile.cpp
|
||||
|
||||
SOURCE=.\MsdFile.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\XmlFile.cpp
|
||||
|
||||
!IF "$(CFG)" == "StepMania - Win32 Debug"
|
||||
|
||||
!ELSEIF "$(CFG)" == "StepMania - Xbox Debug"
|
||||
|
||||
!ELSEIF "$(CFG)" == "StepMania - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "StepMania - Xbox Release"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\XmlFile.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "StepMania"
|
||||
|
||||
|
||||
@@ -1866,12 +1866,6 @@ cl /Zl /nologo /c verstub.cpp /Fo"$(IntDir)"\
|
||||
<File
|
||||
RelativePath=".\Sprite.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="mathlib.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="mathlib.h">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Global Singletons"
|
||||
|
||||
@@ -1,147 +0,0 @@
|
||||
/***
|
||||
*
|
||||
* Copyright (c) 1998, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
****/
|
||||
|
||||
#ifdef WIN32
|
||||
#pragma warning( disable : 4244 )
|
||||
#pragma warning( disable : 4237 )
|
||||
#pragma warning( disable : 4305 )
|
||||
#endif
|
||||
|
||||
#ifndef true
|
||||
#define true 1
|
||||
#endif /* true */
|
||||
#ifndef false
|
||||
#define false 0
|
||||
#endif /* false */
|
||||
|
||||
#include "mathlib.h"
|
||||
|
||||
|
||||
int VectorCompare (vec3_t v1, vec3_t v2)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0 ; i<3 ; i++)
|
||||
{
|
||||
if (fabs(v1[i]-v2[i]) > EQUAL_EPSILON)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
vec_t VectorNormalize (vec3_t v)
|
||||
{
|
||||
int i;
|
||||
double length;
|
||||
|
||||
if ( fabs(v[1] - 0.000215956) < 0.0001)
|
||||
i=1;
|
||||
|
||||
length = 0;
|
||||
for (i=0 ; i< 3 ; i++)
|
||||
length += v[i]*v[i];
|
||||
length = sqrt (length);
|
||||
if (length == 0)
|
||||
return 0;
|
||||
|
||||
for (i=0 ; i< 3 ; i++)
|
||||
v[i] /= length;
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
void AngleMatrix (const vec3_t angles, float matrix[3][4] )
|
||||
{
|
||||
float angle;
|
||||
float sr, sp, sy, cr, cp, cy;
|
||||
|
||||
angle = angles[2] * (Q_PI*2 / 360);
|
||||
sy = sin(angle);
|
||||
cy = cos(angle);
|
||||
angle = angles[1] * (Q_PI*2 / 360);
|
||||
sp = sin(angle);
|
||||
cp = cos(angle);
|
||||
angle = angles[0] * (Q_PI*2 / 360);
|
||||
sr = sin(angle);
|
||||
cr = cos(angle);
|
||||
|
||||
// matrix = (Z * Y) * X
|
||||
matrix[0][0] = cp*cy;
|
||||
matrix[1][0] = cp*sy;
|
||||
matrix[2][0] = -sp;
|
||||
matrix[0][1] = sr*sp*cy+cr*-sy;
|
||||
matrix[1][1] = sr*sp*sy+cr*cy;
|
||||
matrix[2][1] = sr*cp;
|
||||
matrix[0][2] = (cr*sp*cy+-sr*-sy);
|
||||
matrix[1][2] = (cr*sp*sy+-sr*cy);
|
||||
matrix[2][2] = cr*cp;
|
||||
matrix[0][3] = 0.0;
|
||||
matrix[1][3] = 0.0;
|
||||
matrix[2][3] = 0.0;
|
||||
}
|
||||
|
||||
void R_ConcatTransforms (const float in1[3][4], const float in2[3][4], float out[3][4])
|
||||
{
|
||||
out[0][0] = in1[0][0] * in2[0][0] + in1[0][1] * in2[1][0] +
|
||||
in1[0][2] * in2[2][0];
|
||||
out[0][1] = in1[0][0] * in2[0][1] + in1[0][1] * in2[1][1] +
|
||||
in1[0][2] * in2[2][1];
|
||||
out[0][2] = in1[0][0] * in2[0][2] + in1[0][1] * in2[1][2] +
|
||||
in1[0][2] * in2[2][2];
|
||||
out[0][3] = in1[0][0] * in2[0][3] + in1[0][1] * in2[1][3] +
|
||||
in1[0][2] * in2[2][3] + in1[0][3];
|
||||
out[1][0] = in1[1][0] * in2[0][0] + in1[1][1] * in2[1][0] +
|
||||
in1[1][2] * in2[2][0];
|
||||
out[1][1] = in1[1][0] * in2[0][1] + in1[1][1] * in2[1][1] +
|
||||
in1[1][2] * in2[2][1];
|
||||
out[1][2] = in1[1][0] * in2[0][2] + in1[1][1] * in2[1][2] +
|
||||
in1[1][2] * in2[2][2];
|
||||
out[1][3] = in1[1][0] * in2[0][3] + in1[1][1] * in2[1][3] +
|
||||
in1[1][2] * in2[2][3] + in1[1][3];
|
||||
out[2][0] = in1[2][0] * in2[0][0] + in1[2][1] * in2[1][0] +
|
||||
in1[2][2] * in2[2][0];
|
||||
out[2][1] = in1[2][0] * in2[0][1] + in1[2][1] * in2[1][1] +
|
||||
in1[2][2] * in2[2][1];
|
||||
out[2][2] = in1[2][0] * in2[0][2] + in1[2][1] * in2[1][2] +
|
||||
in1[2][2] * in2[2][2];
|
||||
out[2][3] = in1[2][0] * in2[0][3] + in1[2][1] * in2[1][3] +
|
||||
in1[2][2] * in2[2][3] + in1[2][3];
|
||||
}
|
||||
|
||||
|
||||
|
||||
void VectorRotate (const vec3_t in1, const float in2[3][4], vec3_t out)
|
||||
{
|
||||
out[0] = DotProduct(in1, in2[0]);
|
||||
out[1] = DotProduct(in1, in2[1]);
|
||||
out[2] = DotProduct(in1, in2[2]);
|
||||
}
|
||||
|
||||
|
||||
// rotate by the inverse of the matrix
|
||||
void VectorIRotate (const vec3_t in1, const float in2[3][4], vec3_t out)
|
||||
{
|
||||
out[0] = in1[0]*in2[0][0] + in1[1]*in2[1][0] + in1[2]*in2[2][0];
|
||||
out[1] = in1[0]*in2[0][1] + in1[1]*in2[1][1] + in1[2]*in2[2][1];
|
||||
out[2] = in1[0]*in2[0][2] + in1[1]*in2[1][2] + in1[2]*in2[2][2];
|
||||
}
|
||||
|
||||
|
||||
void VectorTransform (const vec3_t in1, const float in2[3][4], vec3_t out)
|
||||
{
|
||||
out[0] = DotProduct(in1, in2[0]) + in2[0][3];
|
||||
out[1] = DotProduct(in1, in2[1]) + in2[1][3];
|
||||
out[2] = DotProduct(in1, in2[2]) + in2[2][3];
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
/***
|
||||
*
|
||||
* Copyright (c) 1998, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
****/
|
||||
|
||||
#ifndef __MATHLIB__
|
||||
#define __MATHLIB__
|
||||
|
||||
// mathlib.h
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef float vec_t;
|
||||
typedef vec_t vec3_t[3]; // x,y,z
|
||||
typedef vec_t vec4_t[4]; // x,y,z,w
|
||||
|
||||
|
||||
#define Q_PI 3.14159265358979323846
|
||||
|
||||
// Use this definition globally
|
||||
#define ON_EPSILON 0.01
|
||||
#define EQUAL_EPSILON 0.001
|
||||
|
||||
int VectorCompare (vec3_t v1, vec3_t v2);
|
||||
|
||||
#define DotProduct(x,y) ((x)[0]*(y)[0]+(x)[1]*(y)[1]+(x)[2]*(y)[2])
|
||||
#define VectorCopy(a,b) {(b)[0]=(a)[0];(b)[1]=(a)[1];(b)[2]=(a)[2];}
|
||||
|
||||
|
||||
vec_t VectorNormalize (vec3_t v);
|
||||
|
||||
void AngleMatrix (const vec3_t angles, float matrix[3][4] );
|
||||
void R_ConcatTransforms (const float in1[3][4], const float in2[3][4], float out[3][4]);
|
||||
|
||||
void VectorIRotate (const vec3_t in1, const float in2[3][4], vec3_t out);
|
||||
void VectorRotate (const vec3_t in1, const float in2[3][4], vec3_t out);
|
||||
|
||||
void VectorTransform (const vec3_t in1, const float in2[3][4], vec3_t out);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user