2003-05-05 04:43:11 +00:00
|
|
|
#include "global.h"
|
|
|
|
|
/*
|
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
Class: DancingCharacters
|
|
|
|
|
|
|
|
|
|
Desc: See header.
|
|
|
|
|
|
|
|
|
|
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
|
|
|
|
|
Chris Danford
|
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "DancingCharacters.h"
|
|
|
|
|
#include "GameConstantsAndTypes.h"
|
|
|
|
|
#include "RageDisplay.h"
|
|
|
|
|
#include "RageUtil.h"
|
|
|
|
|
#include "RageMath.h"
|
|
|
|
|
#include "PrefsManager.h"
|
2003-06-07 22:20:39 +00:00
|
|
|
#include "GameState.h"
|
|
|
|
|
#include "song.h"
|
2003-05-05 04:43:11 +00:00
|
|
|
|
|
|
|
|
|
2003-06-07 22:20:39 +00:00
|
|
|
|
|
|
|
|
const float CAMERA_REST_DISTANCE = 32.f;
|
|
|
|
|
const float CAMERA_SWEEP_DISTANCE = 26.f;
|
|
|
|
|
const float CAMERA_SWEEP_HEIGHT_VARIANCE = 28.f;
|
|
|
|
|
const float CAMERA_SWEEP_PAN_Y_RANGE_DEGREES = 80.f;
|
|
|
|
|
const float CAMERA_SWEEP_PAN_Y_VARIANCE_DEGREES = 20.f;
|
|
|
|
|
const float CAMERA_STILL_DISTANCE = 20.f;
|
|
|
|
|
const float CAMERA_STILL_PAN_Y_RANGE_DEGREES = 45.f;
|
|
|
|
|
const float CAMERA_STILL_HEIGHT_VARIANCE = 6.f;
|
|
|
|
|
const float LOOK_AT_HEIGHT = -9.f;
|
2003-05-05 04:43:11 +00:00
|
|
|
|
|
|
|
|
const float MODEL_X[NUM_PLAYERS] = { -8, 8 };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DancingCharacters::DancingCharacters()
|
|
|
|
|
{
|
|
|
|
|
if( PREFSMAN->m_bShowDancingCharacters )
|
|
|
|
|
{
|
|
|
|
|
m_Character[PLAYER_1].SetX( MODEL_X[PLAYER_1] );
|
2003-06-07 11:54:44 +00:00
|
|
|
m_Character[PLAYER_1].LoadMilkshapeAscii( "C:\\My Documents\\Dev\\ddrpc char hacking\\DDRPCRip\\models\\char0000\\model.txt" );
|
2003-06-07 18:09:20 +00:00
|
|
|
m_Character[PLAYER_1].LoadMilkshapeAsciiBones( "rest", "C:\\My Documents\\Dev\\ddrpc char hacking\\DDRPCRip\\models\\rest.bones.txt" );
|
|
|
|
|
m_Character[PLAYER_1].LoadMilkshapeAsciiBones( "warmup", "C:\\My Documents\\Dev\\ddrpc char hacking\\DDRPCRip\\models\\warmup.bones.txt" );
|
2003-06-07 22:20:39 +00:00
|
|
|
m_Character[PLAYER_1].LoadMilkshapeAsciiBones( "dance", "C:\\My Documents\\Dev\\ddrpc char hacking\\DDRPCRip\\models\\dance0001.bones.txt" );
|
2003-06-07 18:09:20 +00:00
|
|
|
m_Character[PLAYER_1].PlayAnimation( "rest" );
|
2003-05-05 04:43:11 +00:00
|
|
|
this->AddChild( &m_Character[PLAYER_1] );
|
|
|
|
|
|
|
|
|
|
m_Character[PLAYER_2].SetX( MODEL_X[PLAYER_2] );
|
2003-06-07 11:54:44 +00:00
|
|
|
m_Character[PLAYER_2].LoadMilkshapeAscii( "C:\\My Documents\\Dev\\ddrpc char hacking\\DDRPCRip\\models\\char0011\\model.txt" );
|
2003-06-07 18:09:20 +00:00
|
|
|
m_Character[PLAYER_2].LoadMilkshapeAsciiBones( "rest", "C:\\My Documents\\Dev\\ddrpc char hacking\\DDRPCRip\\models\\rest.bones.txt" );
|
|
|
|
|
m_Character[PLAYER_2].LoadMilkshapeAsciiBones( "warmup", "C:\\My Documents\\Dev\\ddrpc char hacking\\DDRPCRip\\models\\warmup.bones.txt" );
|
2003-06-07 22:20:39 +00:00
|
|
|
m_Character[PLAYER_2].LoadMilkshapeAsciiBones( "dance", "C:\\My Documents\\Dev\\ddrpc char hacking\\DDRPCRip\\models\\dance0001.bones.txt" );
|
2003-06-07 18:09:20 +00:00
|
|
|
m_Character[PLAYER_2].PlayAnimation( "rest" );
|
2003-05-05 04:43:11 +00:00
|
|
|
this->AddChild( &m_Character[PLAYER_2] );
|
|
|
|
|
}
|
2003-06-07 22:20:39 +00:00
|
|
|
|
|
|
|
|
// initial camera sweep is still
|
|
|
|
|
m_CameraDistance = CAMERA_REST_DISTANCE;
|
|
|
|
|
m_CameraPanYStart = 0;
|
|
|
|
|
m_CameraPanYEnd = 0;
|
|
|
|
|
m_fCameraHeightStart = LOOK_AT_HEIGHT;
|
|
|
|
|
m_fCameraHeightEnd = LOOK_AT_HEIGHT;
|
|
|
|
|
m_fThisCameraStartBeat = 0;
|
|
|
|
|
m_fThisCameraEndBeat = GAMESTATE->m_pCurSong->m_fFirstBeat;
|
|
|
|
|
|
2003-05-05 04:43:11 +00:00
|
|
|
}
|
|
|
|
|
|
2003-06-07 22:20:39 +00:00
|
|
|
int Neg1OrPos1() { return rand()%2 ? -1 : +1; }
|
|
|
|
|
|
2003-05-05 04:43:11 +00:00
|
|
|
void DancingCharacters::Update( float fDelta )
|
|
|
|
|
{
|
2003-06-07 22:20:39 +00:00
|
|
|
if( !GAMESTATE->m_bFreeze )
|
|
|
|
|
ActorFrame::Update( fDelta );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static bool bWasHereWeGo = false;
|
|
|
|
|
bool bIsHereWeGo = GAMESTATE->m_bPastHereWeGo;
|
|
|
|
|
if( !bWasHereWeGo && bIsHereWeGo )
|
2003-06-07 18:09:20 +00:00
|
|
|
{
|
2003-06-07 22:20:39 +00:00
|
|
|
m_Character[PLAYER_1].PlayAnimation( "warmup" );
|
|
|
|
|
m_Character[PLAYER_2].PlayAnimation( "warmup" );
|
2003-06-07 18:09:20 +00:00
|
|
|
}
|
2003-06-07 22:20:39 +00:00
|
|
|
bWasHereWeGo = bIsHereWeGo;
|
2003-05-05 04:43:11 +00:00
|
|
|
|
2003-06-07 22:20:39 +00:00
|
|
|
static float fLastBeat = GAMESTATE->m_fSongBeat;
|
|
|
|
|
float fThisBeat = GAMESTATE->m_fSongBeat;
|
|
|
|
|
if( fLastBeat < GAMESTATE->m_pCurSong->m_fFirstBeat &&
|
|
|
|
|
fThisBeat >= GAMESTATE->m_pCurSong->m_fFirstBeat )
|
|
|
|
|
{
|
|
|
|
|
m_Character[PLAYER_1].PlayAnimation( "dance" );
|
|
|
|
|
m_Character[PLAYER_2].PlayAnimation( "dance" );
|
|
|
|
|
}
|
|
|
|
|
fLastBeat = fThisBeat;
|
2003-05-05 04:43:11 +00:00
|
|
|
|
2003-06-07 22:20:39 +00:00
|
|
|
|
|
|
|
|
// time for a new sweep?
|
|
|
|
|
if( GAMESTATE->m_fSongBeat > m_fThisCameraEndBeat )
|
|
|
|
|
{
|
|
|
|
|
if( rand()%2 )
|
|
|
|
|
{
|
|
|
|
|
m_CameraDistance = CAMERA_SWEEP_DISTANCE;
|
|
|
|
|
m_CameraPanYStart = m_CameraPanYEnd = RandomInt(-1,1) * CAMERA_SWEEP_PAN_Y_RANGE_DEGREES;
|
|
|
|
|
m_fCameraHeightStart = m_fCameraHeightEnd = LOOK_AT_HEIGHT;
|
|
|
|
|
|
|
|
|
|
m_CameraPanYEnd += RandomInt(-1,1) * CAMERA_SWEEP_PAN_Y_VARIANCE_DEGREES;
|
|
|
|
|
m_fCameraHeightStart = m_fCameraHeightEnd = m_fCameraHeightStart + RandomInt(-1,1) * CAMERA_SWEEP_HEIGHT_VARIANCE;
|
|
|
|
|
|
|
|
|
|
float fCameraHeightVariance = RandomInt(-1,1) * CAMERA_SWEEP_HEIGHT_VARIANCE;
|
|
|
|
|
m_fCameraHeightStart -= fCameraHeightVariance;
|
|
|
|
|
m_fCameraHeightEnd += fCameraHeightVariance;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
m_CameraDistance = CAMERA_STILL_DISTANCE;
|
|
|
|
|
m_CameraPanYStart = m_CameraPanYEnd = Neg1OrPos1() * CAMERA_STILL_PAN_Y_RANGE_DEGREES;
|
|
|
|
|
m_fCameraHeightStart = m_fCameraHeightEnd = LOOK_AT_HEIGHT + Neg1OrPos1() * CAMERA_STILL_HEIGHT_VARIANCE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int iCurBeat = (int)GAMESTATE->m_fSongBeat;
|
|
|
|
|
iCurBeat -= iCurBeat%8;
|
|
|
|
|
|
|
|
|
|
m_fThisCameraStartBeat = iCurBeat;
|
|
|
|
|
m_fThisCameraEndBeat = iCurBeat + 8;
|
|
|
|
|
}
|
2003-05-05 04:43:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DancingCharacters::DrawPrimitives()
|
|
|
|
|
{
|
2003-06-07 22:20:39 +00:00
|
|
|
DISPLAY->EnterPerspective( 45, false );
|
|
|
|
|
|
|
|
|
|
float fPercentIntoSweep = SCALE(GAMESTATE->m_fSongBeat, m_fThisCameraStartBeat, m_fThisCameraEndBeat, 0.f, 1.f );
|
|
|
|
|
float fCameraPanY = SCALE( fPercentIntoSweep, 0.f, 1.f, m_CameraPanYStart, m_CameraPanYEnd );
|
|
|
|
|
float fCameraHeight = SCALE( fPercentIntoSweep, 0.f, 1.f, m_fCameraHeightStart, m_fCameraHeightEnd );
|
|
|
|
|
|
|
|
|
|
RageVector3 m_CameraPoint( 0, fCameraHeight, -m_CameraDistance );
|
|
|
|
|
RageVec3TransformCoord( &m_CameraPoint, &m_CameraPoint, &RageMatrixRotationY(fCameraPanY) );
|
|
|
|
|
|
|
|
|
|
RageVector3 m_LookAt( 0, LOOK_AT_HEIGHT, 0 );
|
|
|
|
|
|
2003-05-05 04:43:11 +00:00
|
|
|
DISPLAY->LookAt(
|
2003-06-07 22:20:39 +00:00
|
|
|
m_CameraPoint,
|
|
|
|
|
m_LookAt,
|
2003-05-05 04:43:11 +00:00
|
|
|
RageVector3(0,1,0) );
|
|
|
|
|
|
2003-05-15 06:09:19 +00:00
|
|
|
DISPLAY->SetLighting( true );
|
2003-05-05 04:43:11 +00:00
|
|
|
DISPLAY->SetLightDirectional(
|
|
|
|
|
0,
|
|
|
|
|
RageColor(0.4f,0.4f,0.4f,1),
|
|
|
|
|
RageColor(0.8f,0.8f,0.8f,0.8f),
|
|
|
|
|
RageColor(0.8f,0.8f,0.8f,0.8f),
|
|
|
|
|
RageVector3(+1, 0, +1) );
|
|
|
|
|
|
|
|
|
|
ActorFrame::DrawPrimitives();
|
|
|
|
|
|
|
|
|
|
DISPLAY->SetLightOff( 0 );
|
2003-05-15 06:09:19 +00:00
|
|
|
DISPLAY->SetLighting( false );
|
2003-05-05 04:43:11 +00:00
|
|
|
|
|
|
|
|
DISPLAY->ExitPerspective();
|
|
|
|
|
}
|