From b3f472ae8c57ddcaffdf038d8c3039e6f8a02012 Mon Sep 17 00:00:00 2001 From: Andrew Arsenault Date: Sat, 16 Oct 2004 10:29:56 +0000 Subject: [PATCH] Ym2413a: Here are two files of a new feature I've wrote. It's called Character Scaling and has been in DDR since the 1st mix. What it does is read the dancing character's "character.ini" file and uses attributes stored there to adjust height, width and depth of the 3D object and animation bones thus adjusting the size of the character on screen. --- stepmania/src/ModelTypes.cpp | 27 +++++++++++++++++++++++++++ stepmania/src/RageModelGeometry.cpp | 26 +++++++++++++++++++++++++- 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/stepmania/src/ModelTypes.cpp b/stepmania/src/ModelTypes.cpp index f62b2d52a0..d81c8b19ef 100644 --- a/stepmania/src/ModelTypes.cpp +++ b/stepmania/src/ModelTypes.cpp @@ -195,6 +195,26 @@ bool msAnimation::LoadMilkshapeAsciiBones( CString sAniName, CString sPath ) msAnimation &Animation = *this; + //Ym2413a Added: Start + //Bone scaling loader. + static float fXScale = 1; + static float fYScale = 1; + static float fZScale = 1; + + if( sAniName == "default" ){ + IniFile ini; + if( ini.ReadFile( sDir+"character.ini" ) ) + { + if ( !ini.GetValue( "Attributes", "ScaleX", fXScale ) ) { + fXScale = 1; } + if ( !ini.GetValue( "Attributes", "ScaleY", fYScale ) ) { + fYScale = 1; } + if ( !ini.GetValue( "Attributes", "ScaleZ", fZScale ) ) { + fZScale = 1; } + } + } + //Ym2413a Added: End + bool bLoaded = false; while( f.GetLine( sLine ) > 0 ) { @@ -270,6 +290,13 @@ bool msAnimation::LoadMilkshapeAsciiBones( CString sAniName, CString sPath ) if (sscanf (sLine, "%f %f %f %f", &fTime, &Position[0], &Position[1], &Position[2]) != 4) THROW; + //Ym2413a Added: Start + //Perform rescaling of bone vectors. + Position[0] = Position[0]*fXScale; + Position[1] = Position[1]*fYScale; + Position[2] = Position[2]*fZScale; + //Ym2413a Added: End + msPositionKey key; key.fTime = fTime; key.Position = RageVector3( Position[0], Position[1], Position[2] ); diff --git a/stepmania/src/RageModelGeometry.cpp b/stepmania/src/RageModelGeometry.cpp index 3496283957..352a978736 100644 --- a/stepmania/src/RageModelGeometry.cpp +++ b/stepmania/src/RageModelGeometry.cpp @@ -4,7 +4,7 @@ #include "RageFile.h" #include "RageMath.h" #include "RageDisplay.h" - +#include "IniFile.h" // Added by Ym2413a, needed for code changes. RageModelGeometry::RageModelGeometry () { @@ -87,6 +87,24 @@ void RageModelGeometry::LoadMilkshapeAscii( CString sPath ) RageVec3ClearBounds( m_vMins, m_vMaxs ); + //Ym2413a Added: Start + //Vector scaling loader. + float fXScale; fXScale = 1; + float fYScale; fYScale = 1; + float fZScale; fZScale = 1; + + IniFile ini; + if( ini.ReadFile( sDir+"character.ini" ) ) + { + if ( !ini.GetValue( "Attributes", "ScaleX", fXScale ) ) { + fXScale = 1; } + if ( !ini.GetValue( "Attributes", "ScaleY", fYScale ) ) { + fYScale = 1; } + if ( !ini.GetValue( "Attributes", "ScaleZ", fZScale ) ) { + fZScale = 1; } + } + //Ym2413a Added: End + while( f.GetLine( sLine ) > 0 ) { iLineNum++; @@ -159,6 +177,12 @@ void RageModelGeometry::LoadMilkshapeAscii( CString sPath ) { THROW } + //Ym2413a Added: Start + //Perform rescaling of model vectors. + v.p[0] = v.p[0]*fXScale; + v.p[1] = v.p[1]*fYScale; + v.p[2] = v.p[2]*fZScale; + //Ym2413a Added: End // vertex.nFlags = nFlags; v.bone = (uint8_t) nIndex;