port 2A step 4: platform skeleton + rest of the 2V3 header closure

- Mirror the remaining non-Python 2V3 closure headers (98 more, 173 total): EffectLib,
  EterGrnLib, SpeedTreeLib, SphereLib, PRTerrainLib, EterImageLib, EterBase/Poly, cipher/tea,
  EterLib Grp*/IME/Input/MSWindow/StateManager, GameLib actor/map/race headers, EterPack.
- SDK shims: granny.h, SpeedTreeRT.h, imm.h, Dimm.h (the SDK MIDL header, not mirrored),
  dinput/d3dx8 additions; D3D8 render-state enums, FVF macros and the COM resource hierarchy;
  more Win32 GDI/handle types with layout static_asserts.
- PORT edits for MSVC-permissive code (typename, friend visibility, <algorithm>, pointer→uintptr_t)
  and PRTerrainLib/StdAfx.h dropping the ScriptLib/Python include.
- port_logic links the vendored cryptopp/minilzo.
- extension/src/platform: port_platform target with 103 generated stub files (1917 function
  stubs, 146 static members) from the new platform_stub.py (clang -ast-dump-filter);
  MT_PLATFORM_STUB() marks every unimplemented body. libmtgodot links port_platform and
  port_gate.sh builds it.

Gate: macOS, Android, iOS, Windows (mingw) PASS; Linux BLOCKED (no toolchain).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
shenlei
2026-09-22 21:46:24 +09:00
co-authored by Claude Opus 5
parent fc47582017
commit 9a8e11f3dd
220 changed files with 24287 additions and 25 deletions
+69
View File
@@ -0,0 +1,69 @@
#pragma once
#include "../MilesLib/Type.h"
#include "ParticleSystemData.h"
#include "EffectMesh.h"
#include "SimpleLightData.h"
class CEffectData
{
public:
typedef std::vector<CParticleSystemData*> TParticleVector;
typedef std::vector<CEffectMeshScript*> TMeshVector;
typedef std::vector<CLightData*> TLightVector;
public:
CEffectData();
virtual ~CEffectData();
void Clear();
bool LoadScript(const char * c_szFileName);
bool LoadSoundScriptData(const char * c_szFileName);
DWORD GetParticleCount();
CParticleSystemData * GetParticlePointer(DWORD dwPosition);
DWORD GetMeshCount();
CEffectMeshScript * GetMeshPointer(DWORD dwPosition);
DWORD GetLightCount();
CLightData * GetLightPointer(DWORD dwPosition);
NSound::TSoundInstanceVector * GetSoundInstanceVector();
float GetBoundingSphereRadius();
D3DXVECTOR3 GetBoundingSpherePosition();
const char * GetFileName() const;
protected:
void __ClearParticleDataVector();
void __ClearLightDataVector();
void __ClearMeshDataVector();
// FIXME : 이 부분은 그다지 맘에 들지 않는다. 좋은 아이디어를 찾아내어 고치자.
// 상위가 (특화된) 상위의 인터페이스 때문에 모양이 바뀌어야 한다는 것은 옳지 못하다. - [levites]
virtual CParticleSystemData * AllocParticle();
virtual CEffectMeshScript * AllocMesh();
virtual CLightData * AllocLight();
protected:
TParticleVector m_ParticleVector;
TMeshVector m_MeshVector;
TLightVector m_LightVector;
NSound::TSoundInstanceVector m_SoundInstanceVector;
float m_fBoundingSphereRadius;
D3DXVECTOR3 m_v3BoundingSpherePosition;
std::string m_strFileName;
public:
static void DestroySystem();
static CEffectData* New();
static void Delete(CEffectData* pkData);
static CDynamicPool<CEffectData> ms_kPool;
};
@@ -0,0 +1,37 @@
#pragma once
#include "Type.h"
class CEffectElementBase
{
public:
CEffectElementBase();
virtual ~CEffectElementBase();
void Clear();
bool isData();
BOOL LoadScript(CTextFileLoader & rTextFileLoader);
void GetPosition(float fTime, D3DXVECTOR3 & rPosition);
float GetStartTime();
/*
bool isVisible(float fTime);
void GetAlpha(float fTime, float * pAlpha);
void GetScale(float fTime, float * pScale);
*/
protected:
virtual void OnClear() = 0;
virtual bool OnIsData() = 0;
virtual BOOL OnLoadScript(CTextFileLoader & rTextFileLoader) = 0;
protected:
float m_fStartTime;
TTimeEventTablePosition m_TimeEventTablePosition;
/*
TTimeEventTable m_TimeEventTableVisible;
TTimeEventTableFloat m_TimeEventAlpha;
TTimeEventTableFloat m_TimeEventScale;
*/
};
@@ -0,0 +1,46 @@
#pragma once
#include "EffectElementBase.h"
class CEffectElementBaseInstance
{
public:
CEffectElementBaseInstance();
virtual ~CEffectElementBaseInstance();
void SetDataPointer(CEffectElementBase * pElement);
void Initialize();
void Destroy();
void SetLocalMatrixPointer(const D3DXMATRIX * c_pMatrix);
bool Update(float fElapsedTime);
void Render();
bool isActive();
void SetActive();
void SetDeactive();
protected:
virtual void OnSetDataPointer(CEffectElementBase * pElement) = 0;
virtual void OnInitialize() = 0;
virtual void OnDestroy() = 0;
virtual bool OnUpdate(float fElapsedTime) = 0;
virtual void OnRender() = 0;
protected:
const D3DXMATRIX * mc_pmatLocal;
bool m_isActive;
float m_fLocalTime;
DWORD m_dwStartTime;
float m_fElapsedTime;
float m_fRemainingTime;
bool m_bStart;
private:
CEffectElementBase * m_pBase;
};
@@ -0,0 +1,90 @@
#pragma once
#include "../EterLib/GrpObjectInstance.h"
#include "../EterLib/Pool.h"
#include "../MilesLib/Type.h"
#include "EffectElementBaseInstance.h"
#include "EffectData.h"
#include "EffectMeshInstance.h"
#include "ParticleSystemInstance.h"
#include "SimpleLightInstance.h"
class CEffectInstance : public CGraphicObjectInstance
{
public:
typedef std::vector<CEffectElementBaseInstance*> TEffectElementInstanceVector;
enum
{
ID = EFFECT_OBJECT
};
int GetType() const
{
return CEffectInstance::ID;
}
bool GetBoundingSphere(D3DXVECTOR3 & v3Center, float & fRadius);
static void DestroySystem();
static CEffectInstance* New();
static void Delete(CEffectInstance* pkEftInst);
static void ResetRenderingEffectCount();
static int GetRenderingEffectCount();
public:
CEffectInstance();
virtual ~CEffectInstance();
bool LessRenderOrder(CEffectInstance* pkEftInst);
void SetEffectDataPointer(CEffectData * pEffectData);
void Clear();
BOOL isAlive();
void SetActive();
void SetDeactive();
void SetGlobalMatrix(const D3DXMATRIX & c_rmatGlobal);
void UpdateSound();
void OnUpdate();
void OnRender();
void OnBlendRender() {} // Not used
void OnRenderToShadowMap() {} // Not used
void OnRenderShadow() {} // Not used
void OnRenderPCBlocker() {} // Not used
protected:
void __Initialize();
void __SetParticleData(CParticleSystemData * pData);
void __SetMeshData(CEffectMeshScript * pMesh);
void __SetLightData(CLightData * pData);
virtual void OnUpdateCollisionData(const CStaticCollisionDataVector * pscdVector) {} // Not used
virtual void OnUpdateHeighInstance(CAttributeInstance * pAttributeInstance) {}
virtual bool OnGetObjectHeight(float fX, float fY, float * pfHeight) { return false; }
protected:
BOOL m_isAlive;
DWORD m_dwFrame;
D3DXMATRIX m_matGlobal;
CEffectData * m_pkEftData;
std::vector<CParticleSystemInstance*> m_ParticleInstanceVector;
std::vector<CEffectMeshInstance*> m_MeshInstanceVector;
std::vector<CLightInstance*> m_LightInstanceVector;
NSound::TSoundInstanceVector * m_pSoundInstanceVector;
float m_fBoundingSphereRadius;
D3DXVECTOR3 m_v3BoundingSpherePosition;
float m_fLastTime;
public:
static CDynamicPool<CEffectInstance> ms_kPool;
static int ms_iRenderingEffectCount;
};
@@ -0,0 +1,86 @@
#pragma once
#include "EffectInstance.h"
class CEffectManager : public CScreen, public CSingleton<CEffectManager>
{
public:
enum EEffectType
{
EFFECT_TYPE_NONE = 0,
EFFECT_TYPE_PARTICLE = 1,
EFFECT_TYPE_ANIMATION_TEXTURE = 2,
EFFECT_TYPE_MESH = 3,
EFFECT_TYPE_SIMPLE_LIGHT = 4,
EFFECT_TYPE_MAX_NUM = 4,
};
typedef std::map<DWORD, CEffectData*> TEffectDataMap;
typedef std::map<DWORD, CEffectInstance*> TEffectInstanceMap;
public:
CEffectManager();
virtual ~CEffectManager();
void Destroy();
void UpdateSound();
void Update();
void Render();
void GetInfo(std::string* pstInfo);
bool IsAliveEffect(DWORD dwInstanceIndex);
// Register
BOOL RegisterEffect(const char * c_szFileName,bool isExistDelete=false,bool isNeedCache=false);
BOOL RegisterEffect2(const char * c_szFileName, DWORD* pdwRetCRC, bool isNeedCache=false);
void DeleteAllInstances();
// Usage
int CreateEffect(DWORD dwID, const D3DXVECTOR3 & c_rv3Position, const D3DXVECTOR3 & c_rv3Rotation);
int CreateEffect(const char * c_szFileName, const D3DXVECTOR3 & c_rv3Position, const D3DXVECTOR3 & c_rv3Rotation);
void CreateEffectInstance(DWORD dwInstanceIndex, DWORD dwID);
BOOL SelectEffectInstance(DWORD dwInstanceIndex);
bool DestroyEffectInstance(DWORD dwInstanceIndex);
void DeactiveEffectInstance(DWORD dwInstanceIndex);
void SetEffectTextures(DWORD dwID, std::vector<std::string> textures);
void SetEffectInstancePosition(const D3DXVECTOR3 & c_rv3Position);
void SetEffectInstanceRotation(const D3DXVECTOR3 & c_rv3Rotation);
void SetEffectInstanceGlobalMatrix(const D3DXMATRIX & c_rmatGlobal);
void ShowEffect();
void HideEffect();
// Temporary function
DWORD GetRandomEffect();
int GetEmptyIndex();
bool GetEffectData(DWORD dwID, CEffectData ** ppEffect);
bool GetEffectData(DWORD dwID, const CEffectData ** c_ppEffect);
// Area에 직접 찍는 Effect용 함수... EffectInstance의 Pointer를 반환한다.
// EffectManager 내부 EffectInstanceMap을 이용하지 않는다.
void CreateUnsafeEffectInstance(DWORD dwEffectDataID, CEffectInstance ** ppEffectInstance);
bool DestroyUnsafeEffectInstance(CEffectInstance * pEffectInstance);
int GetRenderingEffectCount();
protected:
void __Initialize();
void __DestroyEffectInstanceMap();
void __DestroyEffectCacheMap();
void __DestroyEffectDataMap();
protected:
bool m_isDisableSortRendering;
TEffectDataMap m_kEftDataMap;
TEffectInstanceMap m_kEftInstMap;
TEffectInstanceMap m_kEftCacheMap;
CEffectInstance * m_pSelectedEffectInstance;
};
+157
View File
@@ -0,0 +1,157 @@
#pragma once
#include <d3dx8.h>
#include "../EterLib/GrpScreen.h"
#include "../EterLib/Resource.h"
#include "../EterLib/GrpImageInstance.h"
#include "../EterLib/TextFileLoader.h"
#include "Type.h"
#include "EffectElementBase.h"
class CEffectMesh : public CResource
{
public:
typedef struct SEffectFrameData
{
BYTE byChangedFrame;
float fVisibility;
DWORD dwVertexCount;
DWORD dwTextureVertexCount;
DWORD dwIndexCount;
std::vector<TPTVertex> PDTVertexVector;
} TEffectFrameData;
typedef struct SEffectMeshData
{
char szObjectName[32];
char szDiffuseMapFileName[128];
std::vector<TEffectFrameData> EffectFrameDataVector;
std::vector<CGraphicImage*> pImageVector;
static SEffectMeshData* New();
static void Delete(SEffectMeshData* pkData);
static void DestroySystem();
static CDynamicPool<SEffectMeshData> ms_kPool;
} TEffectMeshData;
// About Resource Code
public:
typedef CRef<CEffectMesh> TRef;
public:
static TType Type();
public:
CEffectMesh(const char * c_szFileName);
virtual ~CEffectMesh();
DWORD GetFrameCount();
DWORD GetMeshCount();
TEffectMeshData * GetMeshDataPointer(DWORD dwMeshIndex);
std::vector<CGraphicImage*>* GetTextureVectorPointer(DWORD dwMeshIndex);
std::vector<CGraphicImage*>& GetTextureVectorReference(DWORD dwMeshIndex);
// Exceptional function for tool
BOOL GetMeshElementPointer(DWORD dwMeshIndex, TEffectMeshData ** ppMeshData);
protected:
bool OnLoad(int iSize, const void * c_pvBuf);
void OnClear();
bool OnIsEmpty() const;
bool OnIsType(TType type);
BOOL __LoadData_Ver001(int iSize, const BYTE * c_pbBuf);
BOOL __LoadData_Ver002(int iSize, const BYTE * c_pbBuf);
protected:
int m_iGeomCount;
int m_iFrameCount;
std::vector<TEffectMeshData *> m_pEffectMeshDataVector;
bool m_isData;
};
class CEffectMeshScript : public CEffectElementBase
{
public:
typedef struct SMeshData
{
BYTE byBillboardType;
BOOL bBlendingEnable;
BYTE byBlendingSrcType;
BYTE byBlendingDestType;
BOOL bTextureAlphaEnable;
BYTE byColorOperationType;
D3DXCOLOR ColorFactor;
BOOL bTextureAnimationLoopEnable;
float fTextureAnimationFrameDelay;
DWORD dwTextureAnimationStartFrame;
TTimeEventTableFloat TimeEventAlpha;
SMeshData()
{
TimeEventAlpha.clear();
}
} TMeshData;
typedef std::vector<TMeshData> TMeshDataVector;
public:
CEffectMeshScript();
virtual ~CEffectMeshScript();
const char * GetMeshFileName();
void ReserveMeshData(DWORD dwMeshCount);
bool CheckMeshIndex(DWORD dwMeshIndex);
bool GetMeshDataPointer(DWORD dwMeshIndex, TMeshData ** ppMeshData);
int GetMeshDataCount();
int GetBillboardType(DWORD dwMeshIndex);
BOOL isBlendingEnable(DWORD dwMeshIndex);
BYTE GetBlendingSrcType(DWORD dwMeshIndex);
BYTE GetBlendingDestType(DWORD dwMeshIndex);
BOOL isTextureAlphaEnable(DWORD dwMeshIndex);
BOOL GetColorOperationType(DWORD dwMeshIndex, BYTE * pbyType);
BOOL GetColorFactor(DWORD dwMeshIndex, D3DXCOLOR * pColor);
BOOL GetTimeTableAlphaPointer(DWORD dwMeshIndex, TTimeEventTableFloat ** pTimeEventAlpha);
BOOL isMeshAnimationLoop();
BOOL GetMeshAnimationLoopCount();
float GetMeshAnimationFrameDelay();
BOOL isTextureAnimationLoop(DWORD dwMeshIndex);
float GetTextureAnimationFrameDelay(DWORD dwMeshIndex);
DWORD GetTextureAnimationStartFrame(DWORD dwMeshIndex);
protected:
void OnClear();
bool OnIsData();
BOOL OnLoadScript(CTextFileLoader & rTextFileLoader);
protected:
BOOL m_isMeshAnimationLoop;
int m_iMeshAnimationLoopCount;
float m_fMeshAnimationFrameDelay;
TMeshDataVector m_MeshDataVector;
std::string m_strMeshFileName;
public:
static void DestroySystem();
static CEffectMeshScript* New();
static void Delete(CEffectMeshScript* pkData);
static CDynamicPool<CEffectMeshScript> ms_kPool;
};
@@ -0,0 +1,50 @@
#pragma once
#include "../EterLib/GrpScreen.h"
#include "../EterLib/GrpImageInstance.h"
#include "EffectElementBaseInstance.h"
#include "FrameController.h"
#include "EffectMesh.h"
class CEffectMeshInstance : public CEffectElementBaseInstance
{
public:
// NOTE : Mesh 단위 텍스춰 데이타의 인스턴스이다.
typedef struct STextureInstance
{
CFrameController TextureFrameController;
std::vector<CGraphicImageInstance*> TextureInstanceVector;
} TTextureInstance;
public:
CEffectMeshInstance();
virtual ~CEffectMeshInstance();
public:
static void DestroySystem();
static CEffectMeshInstance* New();
static void Delete(CEffectMeshInstance* pkMeshInstance);
static CDynamicPool<CEffectMeshInstance> ms_kPool;
protected:
void OnSetDataPointer(CEffectElementBase * pElement);
void OnInitialize();
void OnDestroy();
bool OnUpdate(float fElapsedTime);
void OnRender();
BOOL isActive();
protected:
CEffectMeshScript * m_pMeshScript;
CEffectMesh * m_pEffectMesh;
CFrameController m_MeshFrameController;
std::vector<TTextureInstance> m_TextureInstanceVector;
CEffectMesh::TRef m_roMesh;
};
@@ -0,0 +1,283 @@
#pragma once
#include "Type.h"
#include "../EterBase/Random.h"
#include "../EterLib/Pool.h"
class CParticleInstance;
namespace NEffectUpdateDecorator
{
class CDecoratorData
{
public:
float fTime;
float fElapsedTime;
CParticleInstance * pInstance;
CDecoratorData(float fTime, float fElapsedTime, CParticleInstance * pInstance)
: fTime(fTime), fElapsedTime(fElapsedTime), pInstance(pInstance)
{}
};
class CBaseDecorator
{
friend class CParticleSystemData;
public:
CBaseDecorator() :m_NextDecorator(0), m_PrevDecorator(0) {}
virtual ~CBaseDecorator(){}
void Excute(const CDecoratorData & d)
{
CBaseDecorator* pd = this;
while(pd)
{
CBaseDecorator* pNextDecorator = pd->m_NextDecorator;
pd->__Excute(d);
pd = pNextDecorator;
}
}
CBaseDecorator * AddChainFront(CBaseDecorator * pd)
{
pd->m_NextDecorator = this;
m_PrevDecorator = pd;
return pd;
}
void DeleteThis()
{
//return;
if (m_NextDecorator)
m_NextDecorator->DeleteThis();
delete this;
}
CBaseDecorator * Clone(CParticleInstance* pFirstInstance, CParticleInstance* pInstance)
{
CBaseDecorator * pNewDecorator = __Clone(pFirstInstance, pInstance);
CBaseDecorator * pSrc = this;
CBaseDecorator * pDest = pNewDecorator;
while (pSrc->m_NextDecorator)
{
pDest->m_NextDecorator = pSrc->m_NextDecorator->__Clone(pFirstInstance, pInstance);
pDest->m_NextDecorator->m_PrevDecorator = pDest;
pSrc = pSrc->m_NextDecorator;
pDest = pDest->m_NextDecorator;
}
return pNewDecorator;
}
protected:
virtual void __Excute(const CDecoratorData & d) = 0;
virtual CBaseDecorator* __Clone(CParticleInstance* pFirstInstance, CParticleInstance* pInstance) = 0;
void RemoveMe()
{
m_PrevDecorator->m_NextDecorator = m_NextDecorator;
m_NextDecorator->m_PrevDecorator=m_PrevDecorator;
delete this;
}
CBaseDecorator * m_NextDecorator;
CBaseDecorator * m_PrevDecorator;
};
class CHeaderDecorator : public CBaseDecorator, public CPooledObject<CHeaderDecorator>
{
public:
CHeaderDecorator() {}
virtual ~CHeaderDecorator() {}
protected:
virtual void __Excute(const CDecoratorData&) {}
virtual CBaseDecorator* __Clone(CParticleInstance*, CParticleInstance*) { return new CHeaderDecorator; }
};
class CNullDecorator : public CBaseDecorator, public CPooledObject<CNullDecorator>
{
public:
CNullDecorator(){}
virtual ~CNullDecorator(){}
protected:
virtual void __Excute(const CDecoratorData & d) {}
virtual CBaseDecorator* __Clone(CParticleInstance*, CParticleInstance* ) { return new CNullDecorator; }
};
template <class T> class CTimeEventDecorator : public CBaseDecorator, public CPooledObject<CTimeEventDecorator<T> >
{
public:
typedef CTimeEvent<T> TTimeEventType;
typedef std::vector<TTimeEventType> TTimeEventContainerType;
CTimeEventDecorator(const TTimeEventContainerType& TimeEventContainer, T * pValue = 0)
: it_start(TimeEventContainer.begin()),
it_cur(TimeEventContainer.begin()),
it_next(TimeEventContainer.begin()),
it_end(TimeEventContainer.end()),
pData(pValue)
{
if (it_start == it_end)
*pValue = T();
else
++it_next;
}
virtual ~CTimeEventDecorator() {}
void SetData( T * pValue ) { pData = pValue; }
protected:
//CTimeEventDecorator(CTimeEventDecorator<T>& ted, CParticleInstance * pFirstInstance, CParticleInstance * pInstance);
CTimeEventDecorator(CTimeEventDecorator<T>& ted, CParticleInstance* pFirstInstance, CParticleInstance* pInstance)
: it_start(ted.it_start),
it_end(ted.it_end),
it_cur(ted.it_cur),
it_next(ted.it_next),
// PORT: was (DWORD) casts (ILP32 Win32); uintptr_t keeps the pointer width on 64-bit targets.
pData((T*)( (unsigned char*)ted.pData - (uintptr_t)pFirstInstance + (uintptr_t)pInstance))
{
if (it_start == it_end)
*pData = T();
}
virtual CBaseDecorator* __Clone(CParticleInstance* pFirstInstance, CParticleInstance* pInstance) { return new CTimeEventDecorator(*this, pFirstInstance, pInstance); }
virtual void __Excute(const CDecoratorData & d)
{
if (it_start==it_end)
{
RemoveMe();
}
else if (it_cur->m_fTime>d.fTime)
{
*pData = it_cur->m_Value;
}
else
{
while (it_next!=it_end && it_next->m_fTime<=d.fTime)
++it_cur, ++it_next;
if (it_next == it_end)
{
// setting value
*pData = it_cur->m_Value;
RemoveMe();
}
else
{
float length = it_next->m_fTime - it_cur->m_fTime;
//*pData = it_cur->m_Value + (it_next->m_Value - it_cur->m_Value)*(d.fTime-it_cur->m_fTime)/length;
*pData = it_cur->m_Value*(1-(d.fTime-it_cur->m_fTime)/length) ;
*pData += it_next->m_Value * ((d.fTime-it_cur->m_fTime)/length);
}
}
}
typename TTimeEventContainerType::const_iterator it_start;
typename TTimeEventContainerType::const_iterator it_end;
typename TTimeEventContainerType::const_iterator it_cur;
typename TTimeEventContainerType::const_iterator it_next;
T * pData;
};
typedef CTimeEventDecorator<float> CScaleValueDecorator;
typedef CTimeEventDecorator<float> CColorValueDecorator;
typedef CTimeEventDecorator<DWORDCOLOR> CColorAllDecorator;
typedef CTimeEventDecorator<float> CAirResistanceValueDecorator;
typedef CTimeEventDecorator<float> CGravityValueDecorator;
typedef CTimeEventDecorator<float> CRotationSpeedValueDecorator;
class CTextureAnimationCWDecorator : public CBaseDecorator, public CPooledObject<CTextureAnimationCWDecorator>
{
public:
CTextureAnimationCWDecorator(float fFrameTime, DWORD n, BYTE * pIdx) :n(n),pIdx(pIdx),fFrameTime(fFrameTime),fLastFrameTime(fFrameTime){}
virtual ~CTextureAnimationCWDecorator(){}
protected:
virtual CBaseDecorator* __Clone(CParticleInstance* pfi, CParticleInstance* pi) { return new CTextureAnimationCWDecorator(fFrameTime,n,(BYTE*)((unsigned char*)pi+((BYTE*)pIdx-(BYTE*)pfi))); }
virtual void __Excute(const CDecoratorData & d)
{
fLastFrameTime -= d.fElapsedTime;
while (fLastFrameTime<0.0f)
{
fLastFrameTime += fFrameTime;
if (++(*pIdx) >= n)
*pIdx = 0;
}
}
DWORD n;
float fLastFrameTime;
float fFrameTime;
BYTE* pIdx;
};
class CTextureAnimationCCWDecorator : public CBaseDecorator, public CPooledObject<CTextureAnimationCCWDecorator>
{
public:
CTextureAnimationCCWDecorator(float fFrameTime, BYTE n, BYTE * pIdx) :n(n),pIdx(pIdx),fFrameTime(fFrameTime),fLastFrameTime(fFrameTime){}
virtual ~CTextureAnimationCCWDecorator(){}
protected:
virtual CBaseDecorator* __Clone(CParticleInstance* pfi, CParticleInstance* pi) { return new CTextureAnimationCCWDecorator(fFrameTime,n,(BYTE*)((unsigned char*)pi+((BYTE*)pIdx-(BYTE*)pfi))); }
virtual void __Excute(const CDecoratorData & d)
{
fLastFrameTime -= d.fElapsedTime;
while (fLastFrameTime<0.0f)
{
fLastFrameTime += fFrameTime;
if (--(*pIdx) >= n && n != 0) // Because variable is unsigned..
*pIdx = BYTE(n - 1);
}
}
BYTE n;
float fLastFrameTime;
float fFrameTime;
BYTE* pIdx;
};
class CTextureAnimationRandomDecorator : public CBaseDecorator, public CPooledObject<CTextureAnimationRandomDecorator>
{
public:
CTextureAnimationRandomDecorator(float fFrameTime, BYTE n, BYTE * pIdx) :n(n),pIdx(pIdx),fFrameTime(fFrameTime),fLastFrameTime(fFrameTime){}
virtual ~CTextureAnimationRandomDecorator(){}
protected:
virtual CBaseDecorator* __Clone(CParticleInstance* pfi, CParticleInstance* pi) { return new CTextureAnimationRandomDecorator(fFrameTime,n,(BYTE*)((unsigned char*)pi+((BYTE*)pIdx-(BYTE*)pfi))); }
virtual void __Excute(const CDecoratorData & d)
{
fLastFrameTime -= d.fElapsedTime;
if (fLastFrameTime<0.0f && n!=0)
{
*pIdx = (BYTE)random_range(0,n-1);
}
while (fLastFrameTime<0.0f)
fLastFrameTime += fFrameTime;
}
BYTE n;
float fLastFrameTime;
float fFrameTime;
BYTE* pIdx;
};
class CAirResistanceDecorator : public CBaseDecorator, public CPooledObject<CAirResistanceDecorator>
{
public:
CAirResistanceDecorator(){}
virtual ~CAirResistanceDecorator(){}
protected:
virtual void __Excute(const CDecoratorData & d);
virtual CBaseDecorator* __Clone(CParticleInstance* pfi, CParticleInstance* pi);
};
class CGravityDecorator : public CBaseDecorator, public CPooledObject<CGravityDecorator>
{
public:
CGravityDecorator(){}
virtual ~CGravityDecorator(){}
protected:
virtual void __Excute(const CDecoratorData& d);
virtual CBaseDecorator* __Clone(CParticleInstance* pfi, CParticleInstance* pi);
};
class CRotationDecorator : public CBaseDecorator, public CPooledObject<CRotationDecorator>
{
public:
CRotationDecorator(){}
virtual ~CRotationDecorator()
{
}
protected:
virtual void __Excute(const CDecoratorData& d);
virtual CBaseDecorator* __Clone(CParticleInstance* pfi, CParticleInstance* pi) ;
};
}
@@ -0,0 +1,95 @@
#pragma once
#include "Type.h"
class CEmitterProperty
{
friend class CParticleSystemData;
friend class CParticleSystemInstance;
public:
enum
{
EMITTER_SHAPE_POINT,
EMITTER_SHAPE_ELLIPSE,
EMITTER_SHAPE_SQUARE,
EMITTER_SHAPE_SPHERE,
};
enum
{
EMITTER_ADVANCED_TYPE_FREE,
EMITTER_ADVANCED_TYPE_OUTER,
EMITTER_ADVANCED_TYPE_INNER,
};
public:
CEmitterProperty();
virtual ~CEmitterProperty();
void Clear();
DWORD GetMaxEmissionCount()
{
return m_dwMaxEmissionCount;
}
float GetCycleLength()
{
return m_fCycleLength;
}
BOOL isCycleLoop()
{
return m_bCycleLoopFlag;
}
int GetLoopCount()
{
return m_iLoopCount;
}
BYTE GetEmitterShape();
BYTE GetEmitterAdvancedType();
BOOL isEmitFromEdge();
void GetEmittingSize(float fTime, float * pfValue);
void GetEmittingAngularVelocity(float fTime, float * pfValue);
void GetEmittingDirectionX(float fTime, float * pfValue);
void GetEmittingDirectionY(float fTime, float * pfValue);
void GetEmittingDirectionZ(float fTime, float * pfValue);
void GetEmittingVelocity(float fTime, float * pfValue);
void GetEmissionCountPerSecond(float fTime, float * pfValue);
void GetParticleLifeTime(float fTime, float * pfValue);
void GetParticleSizeX(float fTime, float * pfValue);
void GetParticleSizeY(float fTime, float * pfValue);
/////
DWORD m_dwMaxEmissionCount;
float m_fCycleLength;
BOOL m_bCycleLoopFlag;
int m_iLoopCount;
BYTE m_byEmitterShape;
BYTE m_byEmitterAdvancedType;
BOOL m_bEmitFromEdgeFlag;
D3DXVECTOR3 m_v3EmittingSize;
float m_fEmittingRadius;
D3DXVECTOR3 m_v3EmittingDirection;
//TTimeEventTableFloat m_TimeEventEmittingRadius;
TTimeEventTableFloat m_TimeEventEmittingSize;
TTimeEventTableFloat m_TimeEventEmittingAngularVelocity;
TTimeEventTableFloat m_TimeEventEmittingDirectionX;
TTimeEventTableFloat m_TimeEventEmittingDirectionY;
TTimeEventTableFloat m_TimeEventEmittingDirectionZ;
TTimeEventTableFloat m_TimeEventEmittingVelocity;
TTimeEventTableFloat m_TimeEventEmissionCountPerSecond;
TTimeEventTableFloat m_TimeEventLifeTime;
TTimeEventTableFloat m_TimeEventSizeX;
TTimeEventTableFloat m_TimeEventSizeY;
};
@@ -0,0 +1,38 @@
#pragma once
class CFrameController
{
public:
CFrameController();
virtual ~CFrameController();
void Clear();
void Update(float fElapsedTime);
void SetCurrentFrame(DWORD dwFrame);
BYTE GetCurrentFrame();
void SetMaxFrame(DWORD dwMaxFrame);
void SetFrameTime(float fTime);
void SetStartFrame(DWORD dwStartFrame);
void SetLoopFlag(BOOL bFlag);
void SetLoopCount(int iLoopCount);
void SetActive(BOOL bFlag);
BOOL isActive(DWORD dwMainFrame = 0);
protected:
// Dynamic
BOOL m_isActive;
DWORD m_dwcurFrame;
float m_fLastFrameTime;
int m_iLoopCount;
// Static
BOOL m_isLoop;
DWORD m_dwMaxFrame;
float m_fFrameTime;
DWORD m_dwStartFrame;
};
@@ -0,0 +1,91 @@
#pragma once
#include "../EterLib/GrpBase.h"
#include "../EterLib/Pool.h"
#include "EffectUpdateDecorator.h"
class CParticleProperty;
class CEmitterProperty;
class CParticleInstance
{
friend class CParticleSystemData;
friend class CParticleSystemInstance;
friend class NEffectUpdateDecorator::CBaseDecorator;
friend class NEffectUpdateDecorator::CAirResistanceDecorator;
friend class NEffectUpdateDecorator::CGravityDecorator;
friend class NEffectUpdateDecorator::CRotationDecorator;
public:
CParticleInstance();
~CParticleInstance();
float GetRadiusApproximation();
BOOL Update(float fElapsedTime, float fAngle);
//virtual void Transform(const D3DXMATRIX * c_matLocal, const float c_fZRotation)=0;
//virtual void Transform(const D3DXMATRIX * c_matLocal = NULL)=0;
//virtual TPTVertex * GetParticleMeshPointer() = 0;
//__forceinline float GetLifePercentage()
//{
// return m_fLifePercentage;
//return (m_fLifeTime - m_fLastLifeTime) / m_fLifeTime;
//}
//virtual void DeleteThis() = 0;
protected:
//float m_fLifePercentage;
D3DXVECTOR3 m_v3StartPosition;
D3DXVECTOR3 m_v3Position;
D3DXVECTOR3 m_v3LastPosition;
D3DXVECTOR3 m_v3Velocity;
D3DXVECTOR2 m_v2HalfSize;
D3DXVECTOR2 m_v2Scale;
float m_fRotation;
#ifdef WORLD_EDITOR
D3DXCOLOR m_Color;
#else
DWORDCOLOR m_dcColor;
#endif
BYTE m_byTextureAnimationType;
float m_fLastFrameTime;
BYTE m_byFrameIndex;
float m_fLifeTime;
float m_fLastLifeTime;
CParticleProperty * m_pParticleProperty;
CEmitterProperty * m_pEmitterProperty;
float m_fAirResistance;
float m_fRotationSpeed;
float m_fGravity;
NEffectUpdateDecorator::CBaseDecorator * m_pDecorator;
public:
static CParticleInstance* New();
static void DestroySystem();
void Transform(const D3DXMATRIX * c_matLocal=NULL);
void Transform(const D3DXMATRIX * c_matLocal, const float c_fZRotation);
TPTVertex * GetParticleMeshPointer();
void DeleteThis();
void Destroy();
protected:
void __Initialize();
TPTVertex m_ParticleMesh[4];
public:
static CDynamicPool<CParticleInstance> ms_kPool;
};
@@ -0,0 +1,96 @@
#pragma once
#include <vector>
#include "../EterLib/GrpImageInstance.h"
#include "Type.h"
class CParticleProperty
{
friend class CParticleSystemData;
friend class CParticleSystemInstance;
public:
enum
{
ROTATION_TYPE_NONE,
ROTATION_TYPE_TIME_EVENT,
ROTATION_TYPE_CW,
ROTATION_TYPE_CCW,
ROTATION_TYPE_RANDOM_DIRECTION,
};
enum
{
TEXTURE_ANIMATION_TYPE_NONE,
TEXTURE_ANIMATION_TYPE_CW,
TEXTURE_ANIMATION_TYPE_CCW,
TEXTURE_ANIMATION_TYPE_RANDOM_FRAME,
TEXTURE_ANIMATION_TYPE_RANDOM_DIRECTION,
};
public:
CParticleProperty();
virtual ~CParticleProperty();
void Clear();
void InsertTexture(const char * c_szFileName);
bool SetTexture(const char * c_szFileName);
__forceinline BYTE GetTextureAnimationType()
{
return m_byTexAniType;
}
__forceinline DWORD GetTextureAnimationFrameCount()
{
return m_ImageVector.size();
}
__forceinline float GetTextureAnimationFrameDelay()
{
return m_fTexAniDelay;
}
BYTE m_byTexAniType;
float m_fTexAniDelay;
BOOL m_bTexAniRandomStartFrameFlag;
BYTE m_bySrcBlendType;
BYTE m_byDestBlendType;
BYTE m_byColorOperationType;
BYTE m_byBillboardType;
BYTE m_byRotationType;
float m_fRotationSpeed;
WORD m_wRotationRandomStartingBegin;
WORD m_wRotationRandomStartingEnd;
BOOL m_bAttachFlag;
BOOL m_bStretchFlag;
TTimeEventTableFloat m_TimeEventGravity;
TTimeEventTableFloat m_TimeEventAirResistance;
TTimeEventTableFloat m_TimeEventScaleX;
TTimeEventTableFloat m_TimeEventScaleY;
#ifdef WORLD_EDITOR
TTimeEventTableFloat m_TimeEventColorRed;
TTimeEventTableFloat m_TimeEventColorGreen;
TTimeEventTableFloat m_TimeEventColorBlue;
TTimeEventTableFloat m_TimeEventAlpha;
std::vector<std::string> m_TextureNameVector;
#else
TTimeEventTableColor m_TimeEventColor;
#endif
TTimeEventTableFloat m_TimeEventRotation;
std::vector<CGraphicImage*> m_ImageVector;
CParticleProperty & operator = ( const CParticleProperty& c_ParticleProperty );
// pre-transformed variables
D3DXVECTOR3 m_v3ZAxis;
};
@@ -0,0 +1,41 @@
#pragma once
#include "../EterLib/TextFileLoader.h"
#include "EffectElementBase.h"
#include "EmitterProperty.h"
#include "ParticleProperty.h"
//#include "ParticleInstance.h"
class CParticleInstance;
class CParticleSystemData : public CEffectElementBase
{
public:
virtual ~CParticleSystemData();
CParticleSystemData();
CEmitterProperty * GetEmitterPropertyPointer();
CParticleProperty * GetParticlePropertyPointer();
void ChangeTexture(const char * c_szFileName);
void BuildDecorator(CParticleInstance * pInstance);
protected:
BOOL OnLoadScript(CTextFileLoader & rTextFileLoader);
void OnClear();
bool OnIsData();
CEmitterProperty m_EmitterProperty;
CParticleProperty m_ParticleProperty;
public:
static void DestroySystem();
static CParticleSystemData* New();
static void Delete(CParticleSystemData* pkData);
static CDynamicPool<CParticleSystemData> ms_kPool;
};
@@ -0,0 +1,87 @@
#pragma once
#include "EffectElementBaseInstance.h"
#include "ParticleInstance.h"
#include "ParticleProperty.h"
#include "../EterLib/GrpScreen.h"
#include "../EterLib/StateManager.h"
#include "../EterLib/GrpImageInstance.h"
#include "EmitterProperty.h"
class CParticleSystemData; // PORT: MSVC makes the friend declarations in the included headers visible; ISO C++ needs this
class CParticleSystemInstance : public CEffectElementBaseInstance
{
public:
static void DestroySystem();
static CParticleSystemInstance* New();
static void Delete(CParticleSystemInstance* pkData);
static CDynamicPool<CParticleSystemInstance> ms_kPool;
public:
template <typename T>
inline void ForEachParticleRendering(T & FunObj)
{
DWORD dwFrameIndex;
for(dwFrameIndex=0; dwFrameIndex<m_kVct_pkImgInst.size(); dwFrameIndex++)
{
STATEMANAGER.SetTexture(0, m_kVct_pkImgInst[dwFrameIndex]->GetTextureReference().GetD3DTexture());
TParticleInstanceList::iterator itor = m_ParticleInstanceListVector[dwFrameIndex].begin();
for (; itor != m_ParticleInstanceListVector[dwFrameIndex].end(); ++itor)
{
if (!InFrustum(*itor))
return;
FunObj(*itor);
}
}
}
CParticleSystemInstance();
virtual ~CParticleSystemInstance();
void OnSetDataPointer(CEffectElementBase * pElement);
void CreateParticles(float fElapsedTime);
inline bool InFrustum(CParticleInstance * pInstance)
{
if (m_pParticleProperty->m_bAttachFlag)
return CScreen::GetFrustum().ViewVolumeTest(Vector3d(
pInstance->m_v3Position.x + mc_pmatLocal->_41,
pInstance->m_v3Position.y + mc_pmatLocal->_42,
pInstance->m_v3Position.z + mc_pmatLocal->_43
),pInstance->GetRadiusApproximation())!=VS_OUTSIDE;
else
return CScreen::GetFrustum().ViewVolumeTest(Vector3d(pInstance->m_v3Position.x,pInstance->m_v3Position.y,pInstance->m_v3Position.z),pInstance->GetRadiusApproximation())!=VS_OUTSIDE;
}
DWORD GetEmissionCount();
protected:
void OnInitialize();
void OnDestroy();
bool OnUpdate(float fElapsedTime);
void OnRender();
protected:
float m_fEmissionResidue;
DWORD m_dwCurrentEmissionCount;
int m_iLoopCount;
typedef std::list<CParticleInstance*> TParticleInstanceList;
typedef std::vector<TParticleInstanceList> TParticleInstanceListVector;
TParticleInstanceListVector m_ParticleInstanceListVector;
typedef std::vector<CGraphicImageInstance*> TImageInstanceVector;
TImageInstanceVector m_kVct_pkImgInst;
CParticleSystemData * m_pData;
CParticleProperty * m_pParticleProperty;
CEmitterProperty * m_pEmitterProperty;
};
@@ -0,0 +1,57 @@
#pragma once
#include <d3dx8.h>
#include "../EterLib/TextFileLoader.h"
#include "Type.h"
#include "EffectElementBase.h"
class CLightData : public CEffectElementBase
{
friend class CLightInstance;
public:
CLightData();
virtual ~CLightData();
void GetRange(float fTime, float& rRange);
float GetDuration();
BOOL isLoop()
{
return m_bLoopFlag;
}
int GetLoopCount()
{
return m_iLoopCount;
}
void InitializeLight(D3DLIGHT8& light);
protected:
void OnClear();
bool OnIsData();
BOOL OnLoadScript(CTextFileLoader & rTextFileLoader);
protected:
float m_fMaxRange;
float m_fDuration;
TTimeEventTableFloat m_TimeEventTableRange;
D3DXCOLOR m_cAmbient;
D3DXCOLOR m_cDiffuse;
BOOL m_bLoopFlag;
int m_iLoopCount;
float m_fAttenuation0;
float m_fAttenuation1;
float m_fAttenuation2;
public:
static void DestroySystem();
static CLightData* New();
static void Delete(CLightData* pkData);
static CDynamicPool<CLightData> ms_kPool;
};
@@ -0,0 +1,39 @@
#pragma once
#include "../EterLib/GrpScreen.h"
#include "EffectElementBaseInstance.h"
#include "SimpleLightData.h"
class CLightInstance : public CEffectElementBaseInstance
{
public:
friend class CLightData;
CLightInstance();
virtual ~CLightInstance();
protected:
void OnSetDataPointer(CEffectElementBase * pElement);
void OnInitialize();
void OnDestroy();
bool OnUpdate(float fElapsedTime);
void OnRender();
DWORD m_LightID;
CLightData * m_pData;
DWORD m_dwRangeIndex;
DWORD m_iLoopCount;
public:
static void DestroySystem();
static CLightInstance* New();
static void Delete(CLightInstance* pkData);
static CDynamicPool<CLightInstance> ms_kPool;
};
+283
View File
@@ -0,0 +1,283 @@
#pragma once
#define Clamp(x, min, max) x = (x<min ? min : x<max ? x : max);
#define GRAVITY D3DXVECTOR3(0.0f, 0.0f, -9.8f)
#define MAX_FRAME 20
#define MAX_TEXTURE 20
typedef struct _FVF_POINT
{
float x, y, z;
} FVF_POINT;
#ifndef D3DFVF_POINT
#define D3DFVF_POINT (D3DFVF_XYZ)
#endif
typedef struct _FVF_PT
{
float x, y, z;
float tu, tv;
} FVF_PT;
#ifndef D3DFVF_PT
#define D3DFVF_PT (D3DFVF_XYZ|D3DFVF_TEX1)
#endif
typedef struct _FVF_PDT
{
float x, y, z;
DWORD color;
float tu, tv;
} FVF_PDT;
#ifndef D3DFVF_PDT
#define D3DFVF_PDT (D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1)
#endif
inline FVF_PDT _FVF_PDT(float x, float y, float z, DWORD dif, float u, float v)
{
FVF_PDT result;
result.x = x; result.y = y; result.z = z; result.color = dif; result.tu = u; result.tv = v;
return result;
}
enum EEffectType
{
EFFECT_TYPE_PARTICLE = 1,
EFFECT_TYPE_ANIMATION_TEXTURE = 2,
EFFECT_TYPE_MESH = 3,
EFFECT_TYPE_SIMPLE_LIGHT = 4,
};
enum EMeshBillBoardType
{
MESH_BILLBOARD_TYPE_NONE,
MESH_BILLBOARD_TYPE_ALL,
MESH_BILLBOARD_TYPE_Y,
MESH_BILLBOARD_TYPE_MOVE
};
enum EBillBoardType
{
BILLBOARD_TYPE_NONE,
BILLBOARD_TYPE_ALL,
BILLBOARD_TYPE_Y,
BILLBOARD_TYPE_LIE, // 바닥에 누은 형상
BILLBOARD_TYPE_2FACE, // / and \
BILLBOARD_TYPE_3FACE, // / and \ and -
//BILLBOARD_TYPE_RAY, // 잔상
};
enum EMovingType
{
MOVING_TYPE_DIRECT,
MOVING_TYPE_BEZIER_CURVE,
};
///////////////////////////////////////////////////////////////////////////////////////////////////////
typedef struct SEffectPosition
{
float m_fTime;
D3DXVECTOR3 m_vecPosition;
// For Bezier Curve
int m_iMovingType;
D3DXVECTOR3 m_vecControlPoint;
} TEffectPosition;
inline bool operator < (const SEffectPosition & lhs, const SEffectPosition & rhs)
{
return lhs.m_fTime < rhs.m_fTime;
}
inline bool operator < (const float & lhs, const SEffectPosition & rhs)
{
return lhs < rhs.m_fTime;
}
inline bool operator < (const SEffectPosition & lhs, const float & rhs)
{
return lhs.m_fTime < rhs;
}
template<typename T>
class CTimeEvent
{
public:
CTimeEvent(){}
~CTimeEvent(){}
float m_fTime;
T m_Value;
};
#define AG_MASK 0xff00ff00
#define RB_MASK 0x00ff00ff
struct DWORDCOLOR
{
DWORD m_dwColor;
DWORDCOLOR()
{
}
DWORDCOLOR(const DWORDCOLOR& r)
: m_dwColor(r.m_dwColor)
{}
DWORDCOLOR& operator = (const DWORDCOLOR& r)
{
m_dwColor = r.m_dwColor;
return *this;
}
DWORDCOLOR& operator *= (float f)
{
DWORD idx = DWORD(f * 256);
m_dwColor =
(((DWORD)(((m_dwColor & AG_MASK)>>8) * idx)) & AG_MASK)
+((DWORD)(((m_dwColor & RB_MASK) * idx)>>8) & RB_MASK);
//m_dwColor =
// ((DWORD)((m_dwColor & AG_MASK) * f) & AG_MASK)
// +((DWORD)((m_dwColor & RB_MASK) * f) & RB_MASK);
return *this;
}
DWORDCOLOR& operator += (const DWORDCOLOR& r)
{
m_dwColor += r.m_dwColor;
return *this;
}
operator DWORD()
{
return m_dwColor;
}
};
#undef AG_MASK
#undef RB_MASK
inline DWORDCOLOR operator * (DWORDCOLOR dc, float f)
{
DWORDCOLOR tmp(dc);
tmp *= f;
return tmp;
}
inline DWORDCOLOR operator * (float f, DWORDCOLOR dc)
{
DWORDCOLOR tmp(dc);
tmp *= f;
return tmp;
}
template <typename T>
__forceinline bool operator < (const CTimeEvent<T> & lhs, const CTimeEvent<T> & rhs)
{
return lhs.m_fTime < rhs.m_fTime;
}
template <typename T>
__forceinline bool operator < (const CTimeEvent<T> & lhs, const float & rhs)
{
return lhs.m_fTime < rhs;
}
template <typename T>
__forceinline bool operator < (const float & lhs, const CTimeEvent<T> & rhs)
{
return lhs < rhs.m_fTime;
}
typedef CTimeEvent<char> TTimeEventTypeCharacter;
typedef CTimeEvent<short> TTimeEventTypeShort;
typedef CTimeEvent<float> TTimeEventTypeFloat;
typedef CTimeEvent<WORD> TTimeEventTypeWord;
typedef CTimeEvent<DWORD> TTimeEventTypeDoubleWord;
typedef CTimeEvent<DWORDCOLOR> TTimeEventTypeColor;
typedef CTimeEvent<D3DXVECTOR2> TTimeEventTypeVector2;
typedef CTimeEvent<D3DXVECTOR3> TTimeEventTypeVector3;
typedef std::vector<float> TTimeEventTable;
typedef std::vector<TEffectPosition> TTimeEventTablePosition;
typedef std::vector<TTimeEventTypeCharacter> TTimeEventTableCharacter;
typedef std::vector<TTimeEventTypeShort> TTimeEventTableShort;
typedef std::vector<TTimeEventTypeFloat> TTimeEventTableFloat;
typedef std::vector<TTimeEventTypeWord> TTimeEventTableWord;
typedef std::vector<TTimeEventTypeDoubleWord> TTimeEventTableDoubleWord;
typedef std::vector<TTimeEventTypeColor> TTimeEventTableColor;
typedef std::vector<TTimeEventTypeVector2> TTimeEventTableVector2;
typedef std::vector<TTimeEventTypeVector3> TTimeEventTableVector3;
// NOTE : TimeEventValue 함수들은 값을 넘겨 받지 말아야 하는 때도 있으므로
// 값의 직접 리턴이 아닌 포인터 리턴으로 작성 했습니다. - [levites]
template <typename T>
__forceinline void GetTimeEventBlendValue(float fElapsedTime, std::vector<CTimeEvent<T> >& rVector, T * pReturnValue)
{
if (rVector.empty())
{
*pReturnValue = T();
return;
}
if(rVector.begin()+1==rVector.end())
{
*pReturnValue = rVector.front().m_Value;
return;
}
if (fElapsedTime < rVector.front().m_fTime)
{
*pReturnValue = rVector.front().m_Value;
return;
}
if (fElapsedTime > rVector.back().m_fTime)
{
*pReturnValue = rVector.back().m_Value;
return;
}
typedef typename std::vector<CTimeEvent<T> >::iterator iterator;
std::pair<iterator, iterator> result = std::equal_range(rVector.begin(), rVector.end(), fElapsedTime);
if (result.first != result.second)
*pReturnValue = result.first->m_Value;
else
{
--result.first;
float Head = (result.second->m_fTime - fElapsedTime) / (result.second->m_fTime - result.first->m_fTime);
*pReturnValue = T((result.first->m_Value-result.second->m_Value)*Head+(result.second->m_Value));
}
}
extern BOOL GetTokenTimeEventFloat(CTextFileLoader & rTextFileLoader, const char * c_szKey, TTimeEventTableFloat * pTimeEventTableFloat);
//extern void InsertItemTimeEventFloat(TTimeEventTableFloat * pTable, float fTime, float fValue);
template <typename T>
void InsertItemTimeEvent(std::vector<CTimeEvent<T> > * pTable, float fTime, T fValue)
{
typedef typename std::vector<CTimeEvent<T> >::iterator iterator; // PORT: added typename (MSVC accepts it without)
iterator itor = std::lower_bound(pTable->begin(), pTable->end(), fTime);
CTimeEvent<T> TimeEvent;
TimeEvent.m_fTime = fTime;
TimeEvent.m_Value = fValue;
pTable->insert(itor, TimeEvent);
}