Files
itgmania212121/src/ModelTypes.h
T

179 lines
4.1 KiB
C++
Raw Normal View History

2011-03-17 01:47:30 -04:00
/* ModelTypes - Types defined in msLib.h. C arrays converted to use std::vector */
#ifndef MODEL_TYPES_H
#define MODEL_TYPES_H
#include "RageTypes.h"
2023-04-20 12:34:12 +02:00
#include <cstdint>
2023-04-20 19:02:13 +02:00
#include <vector>
2011-03-17 01:47:30 -04:00
struct msTriangle
{
2024-07-18 00:19:46 -07:00
std::uint16_t nVertexIndices[3];
2011-03-17 01:47:30 -04:00
};
struct msMesh
{
2024-07-18 00:19:46 -07:00
RString sName;
std::int8_t nMaterialIndex;
std::vector<RageModelVertex> Vertices;
2023-04-20 12:34:12 +02:00
// OPTIMIZATION: If all verts in a mesh are transformed by the same bone,
2011-03-17 01:47:30 -04:00
// then send the transform to the graphics card for the whole mesh instead
// of transforming each vertex on the CPU;
2024-07-18 00:19:46 -07:00
std::int8_t m_iBoneIndex; // -1 = no bone
std::vector<msTriangle> Triangles;
2011-03-17 01:47:30 -04:00
};
class RageTexture;
class AnimatedTexture
{
public:
AnimatedTexture();
~AnimatedTexture();
2024-08-07 00:32:13 -07:00
RageVector3 RadianToDegree(RageVector3 radian);
2011-03-17 01:47:30 -04:00
void LoadBlank();
2024-07-18 00:19:46 -07:00
void Load(const RString &sTexOrIniFile);
2011-03-17 01:47:30 -04:00
void Unload();
2024-07-18 00:19:46 -07:00
void Update(float fDelta);
2011-03-17 01:47:30 -04:00
RageTexture* GetCurrentTexture();
int GetNumStates() const;
2024-07-18 00:19:46 -07:00
void SetState(int iNewState);
2011-03-17 01:47:30 -04:00
float GetAnimationLengthSeconds() const;
2024-07-18 00:19:46 -07:00
void SetSecondsIntoAnimation(float fSeconds);
2011-03-17 01:47:30 -04:00
float GetSecondsIntoAnimation() const;
RageVector2 GetTextureTranslate();
2024-07-18 00:19:46 -07:00
bool m_bSphereMapped;
BlendMode m_BlendMode;
2011-03-17 01:47:30 -04:00
bool NeedsNormals() const { return m_bSphereMapped; }
private:
2024-07-18 00:19:46 -07:00
RageVector2 m_vTexOffset;
RageVector2 m_vTexVelocity;
2011-03-17 01:47:30 -04:00
int m_iCurState;
float m_fSecsIntoFrame;
struct AnimatedTextureState
{
2024-07-18 00:19:46 -07:00
AnimatedTextureState(RageTexture* pTexture_, float fDelaySecs_, RageVector2 vTranslate_)
: pTexture(pTexture_), fDelaySecs(fDelaySecs_), vTranslate(vTranslate_)
{
}
2011-03-17 01:47:30 -04:00
RageTexture* pTexture;
2024-07-18 00:19:46 -07:00
float fDelaySecs;
RageVector2 vTranslate;
2011-03-17 01:47:30 -04:00
};
std::vector<AnimatedTextureState> vFrames;
2011-03-17 01:47:30 -04:00
};
struct msMaterial
{
2024-07-18 00:19:46 -07:00
int nFlags;
2011-03-17 01:47:30 -04:00
RString sName;
RageColor Ambient;
RageColor Diffuse;
RageColor Specular;
RageColor Emissive;
float fShininess;
float fTransparency;
AnimatedTexture diffuse;
AnimatedTexture alpha;
bool NeedsNormals() const { return diffuse.NeedsNormals() || alpha.NeedsNormals() ; }
};
struct msPositionKey
{
float fTime;
RageVector3 Position;
2024-07-18 00:19:46 -07:00
msPositionKey() : fTime(0.0f) {}
2011-03-17 01:47:30 -04:00
};
struct msRotationKey
{
float fTime;
RageVector4 Rotation;
2024-07-18 00:19:46 -07:00
msRotationKey() : fTime(0.0f) {}
2011-03-17 01:47:30 -04:00
};
struct msBone
{
2024-07-18 00:19:46 -07:00
int nFlags;
RString sName;
RString sParentName;
RageVector3 Position;
RageVector3 Rotation;
std::vector<msPositionKey> PositionKeys;
std::vector<msRotationKey> RotationKeys;
2011-03-17 01:47:30 -04:00
2024-07-18 00:19:46 -07:00
msBone() : nFlags(0) {}
2011-03-17 01:47:30 -04:00
};
struct msAnimation
{
int FindBoneByName( const RString &sName ) const
{
2024-07-18 00:19:46 -07:00
for (unsigned i = 0; i < Bones.size(); i++)
{
if (Bones[i].sName == sName)
2011-03-17 01:47:30 -04:00
return i;
2024-07-18 00:19:46 -07:00
}
2011-03-17 01:47:30 -04:00
return -1;
}
bool LoadMilkshapeAsciiBones( RString sAniName, RString sPath );
2024-07-18 00:19:46 -07:00
std::vector<msBone> Bones;
int nTotalFrames = 0;
2011-03-17 01:47:30 -04:00
};
struct myBone_t
{
2024-07-18 00:19:46 -07:00
RageMatrix m_Relative;
RageMatrix m_Absolute;
RageMatrix m_Final;
2011-03-17 01:47:30 -04:00
};
#endif
/*
* (c) 2003-2004 Chris Danford
* All rights reserved.
2023-04-20 12:34:12 +02:00
*
2011-03-17 01:47:30 -04:00
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, and/or sell copies of the Software, and to permit persons to
* whom the Software is furnished to do so, provided that the above
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
2023-04-20 12:34:12 +02:00
*
2011-03-17 01:47:30 -04:00
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/