#pragma once #define Clamp(x, min, max) x = (x 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 __forceinline bool operator < (const CTimeEvent & lhs, const CTimeEvent & rhs) { return lhs.m_fTime < rhs.m_fTime; } template __forceinline bool operator < (const CTimeEvent & lhs, const float & rhs) { return lhs.m_fTime < rhs; } template __forceinline bool operator < (const float & lhs, const CTimeEvent & rhs) { return lhs < rhs.m_fTime; } typedef CTimeEvent TTimeEventTypeCharacter; typedef CTimeEvent TTimeEventTypeShort; typedef CTimeEvent TTimeEventTypeFloat; typedef CTimeEvent TTimeEventTypeWord; typedef CTimeEvent TTimeEventTypeDoubleWord; typedef CTimeEvent TTimeEventTypeColor; typedef CTimeEvent TTimeEventTypeVector2; typedef CTimeEvent TTimeEventTypeVector3; typedef std::vector TTimeEventTable; typedef std::vector TTimeEventTablePosition; typedef std::vector TTimeEventTableCharacter; typedef std::vector TTimeEventTableShort; typedef std::vector TTimeEventTableFloat; typedef std::vector TTimeEventTableWord; typedef std::vector TTimeEventTableDoubleWord; typedef std::vector TTimeEventTableColor; typedef std::vector TTimeEventTableVector2; typedef std::vector TTimeEventTableVector3; // NOTE : TimeEventValue ÇÔ¼öµéÀº °ªÀ» ³Ñ°Ü ¹ÞÁö ¸»¾Æ¾ß ÇÏ´Â ¶§µµ ÀÖÀ¸¹Ç·Î // °ªÀÇ Á÷Á¢ ¸®ÅÏÀÌ ¾Æ´Ñ Æ÷ÀÎÅÍ ¸®ÅÏÀ¸·Î ÀÛ¼º Çß½À´Ï´Ù. - [levites] template __forceinline void GetTimeEventBlendValue(float fElapsedTime, std::vector >& 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 >::iterator iterator; std::pair 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 void InsertItemTimeEvent(std::vector > * pTable, float fTime, T fValue) { typedef std::vector >::iterator iterator; iterator itor = std::lower_bound(pTable->begin(), pTable->end(), fTime); CTimeEvent TimeEvent; TimeEvent.m_fTime = fTime; TimeEvent.m_Value = fValue; pTable->insert(itor, TimeEvent); }