79 lines
1.7 KiB
C++
79 lines
1.7 KiB
C++
#include "entityinfo.h"
|
|
#include "intrin.h"
|
|
#include "globals.h"
|
|
|
|
int m_iEntityToObj[ m_iMaxEntityCount ] =
|
|
{
|
|
OI_MAGE,
|
|
OI_YETI1,
|
|
OI_YETI2,
|
|
|
|
OI_MAGE2,
|
|
|
|
OI_ISLE_FIRST + 1,
|
|
OI_ISLE_FIRST + 2,
|
|
OI_ISLE_FIRST + 3,
|
|
OI_ISLE_FIRST + 4,
|
|
|
|
OI_OUTRO1,
|
|
OI_OUTRO2,
|
|
OI_OUTRO3,
|
|
ObjectCount
|
|
};
|
|
|
|
#ifdef EXTRACODE
|
|
int m_iEntityCount= 0;
|
|
char m_pcEntityData[65536];
|
|
SEntityInfo m_EntityInfos[ m_iMaxEntityCount ];
|
|
#else
|
|
#include "entitydata.h"
|
|
#endif
|
|
|
|
void SetEntityPos( int iTime )
|
|
{
|
|
for( int i= 0; i < m_iEntityCount; ++i )
|
|
{
|
|
int iObj = m_iEntityToObj[ i ];
|
|
SEntityInfo& ti= m_EntityInfos[ i ];
|
|
|
|
if ( iObj < 0 || ObjectCount <= iObj )
|
|
break;
|
|
|
|
if( iTime < ti.m_iTimeStart || iTime > ti.m_iTimeStart + ti.m_iTimeLength )
|
|
{
|
|
D3DXMATRIX matResult;
|
|
D3DXMatrixScaling( &matResult, 0.0f, 0.0f, 0.0f );
|
|
|
|
g_Objects[ iObj ].SetTransformation( matResult );
|
|
continue;
|
|
}
|
|
|
|
D3DXVECTOR3 v3Pos= ti.m_v3Pos;
|
|
|
|
if( iTime >= ti.m_iTimeStart + ti.m_iTimeLength )
|
|
{
|
|
v3Pos+= ti.m_v3Move;
|
|
}
|
|
else if( iTime > ti.m_iTimeStart )
|
|
{
|
|
float fFac= (float)( ti.m_iTimeStart - iTime )/ (float)ti.m_iTimeLength;
|
|
v3Pos+= ti.m_v3Move * ( 0.5f - 0.5f * cos( fFac * c_PI ) );
|
|
}
|
|
|
|
if( v3Pos.y > 300.0f || iTime > 304 * 1000 )
|
|
{
|
|
v3Pos.y= -300.0f;
|
|
}
|
|
|
|
D3DXMATRIX matResult;
|
|
D3DXMATRIX mat;
|
|
D3DXMatrixScaling( &matResult, ti.m_v3Scale.x, ti.m_v3Scale.y, ti.m_v3Scale.z );
|
|
D3DXMatrixRotationYawPitchRoll( &mat, ti.m_v3Rot.x, ti.m_v3Rot.y, ti.m_v3Rot.z );
|
|
D3DXMatrixMultiply( &matResult,&matResult,&mat);
|
|
D3DXMatrixTranslation( &mat, v3Pos.x, v3Pos.y, v3Pos.z );
|
|
D3DXMatrixMultiply( &matResult,&matResult,&mat);
|
|
|
|
g_Objects[ iObj ].SetTransformation( matResult );
|
|
iObj++;
|
|
}
|
|
} |