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:
@@ -18,9 +18,10 @@ set(MT_PORT_SHIMS ${CMAKE_CURRENT_SOURCE_DIR}/common/shim/sdk)
|
||||
if(NOT WIN32)
|
||||
list(APPEND MT_PORT_SHIMS ${CMAKE_CURRENT_SOURCE_DIR}/common/shim/win32)
|
||||
endif()
|
||||
# EterBase/lzo.h includes <lzo/lzo1x.h>; third_party/minilzo provides that path.
|
||||
list(APPEND MT_PORT_SHIMS ${CMAKE_CURRENT_SOURCE_DIR}/../../third_party/minilzo)
|
||||
target_include_directories(port_logic PUBLIC ${MT_PORT_SHIMS})
|
||||
# Libraries 40250 links that are vendored as-is: <lzo/lzo1x.h> (EterBase/lzo.h), <cryptopp/*>
|
||||
# (EterBase/cipher.h).
|
||||
target_link_libraries(port_logic PUBLIC mt3p::minilzo mt3p::cryptopp)
|
||||
# 40250 sources carry MSVC `#pragma warning(...)` lines verbatim, and non-literal printf formats
|
||||
# (EterImageLib/StdAfx.h) that the Android toolchain turns into errors.
|
||||
set(MT_PORT_WARNING_FLAGS)
|
||||
@@ -83,10 +84,13 @@ foreach(hdr IN LISTS MT_PORT_HEADERS)
|
||||
endforeach()
|
||||
add_library(port_header_gate OBJECT ${MT_PORT_GATE_SOURCES})
|
||||
target_include_directories(port_header_gate PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${MT_PORT_SHIMS})
|
||||
target_link_libraries(port_header_gate PRIVATE mt3p::minilzo mt3p::cryptopp)
|
||||
target_compile_features(port_header_gate PRIVATE cxx_std_20)
|
||||
target_compile_options(port_header_gate PRIVATE ${MT_PORT_WARNING_FLAGS})
|
||||
add_dependencies(port_logic port_header_gate)
|
||||
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../platform ${CMAKE_CURRENT_BINARY_DIR}/../platform)
|
||||
|
||||
if(BUILD_TESTING AND CMAKE_SYSTEM_NAME STREQUAL CMAKE_HOST_SYSTEM_NAME)
|
||||
add_executable(port_common_test ${CMAKE_CURRENT_SOURCE_DIR}/../../tests/port_common_test.cpp)
|
||||
target_link_libraries(port_common_test PRIVATE port_logic)
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
@@ -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;
|
||||
};
|
||||
@@ -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);
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
#ifndef __POLY_POLY_H__
|
||||
#define __POLY_POLY_H__
|
||||
|
||||
#include "SymTable.h"
|
||||
|
||||
#pragma warning ( push, 3 )
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <list>
|
||||
|
||||
#pragma warning ( pop )
|
||||
|
||||
#define POLY_MAXVALUE 0
|
||||
#define POLY_NONE POLY_MAXVALUE
|
||||
#define POLY_ROOT POLY_MAXVALUE + 1
|
||||
#define POLY_MUL POLY_MAXVALUE + 2
|
||||
#define POLY_PLU POLY_MAXVALUE + 3
|
||||
#define POLY_POW POLY_MAXVALUE + 4
|
||||
#define POLY_MIN POLY_MAXVALUE + 5
|
||||
#define POLY_DIV POLY_MAXVALUE + 6
|
||||
#define POLY_OPEN POLY_MAXVALUE + 7
|
||||
#define POLY_CLOSE POLY_MAXVALUE + 8
|
||||
#define POLY_NUM POLY_MAXVALUE + 9
|
||||
#define POLY_ID POLY_MAXVALUE + 10
|
||||
#define POLY_EOS POLY_MAXVALUE + 11
|
||||
#define POLY_COS POLY_MAXVALUE + 12
|
||||
#define POLY_SIN POLY_MAXVALUE + 13
|
||||
#define POLY_TAN POLY_MAXVALUE + 14
|
||||
#define POLY_COSEC POLY_MAXVALUE + 15
|
||||
#define POLY_CSC POLY_COSEC
|
||||
#define POLY_SEC POLY_MAXVALUE + 16
|
||||
#define POLY_COT POLY_MAXVALUE + 17
|
||||
#define POLY_PI POLY_ID
|
||||
#define POLY_EXP POLY_ID
|
||||
#define POLY_LOG POLY_MAXVALUE + 18
|
||||
#define POLY_LN POLY_MAXVALUE + 19
|
||||
#define POLY_LOG10 POLY_MAXVALUE + 20
|
||||
|
||||
#define POLY_ABS POLY_MAXVALUE + 21
|
||||
#define POLY_MINF POLY_MAXVALUE + 22
|
||||
#define POLY_MAXF POLY_MAXVALUE + 23
|
||||
#define POLY_IRAND POLY_MAXVALUE + 24
|
||||
#define POLY_FRAND POLY_MAXVALUE + 25
|
||||
#define POLY_MOD POLY_MAXVALUE + 26
|
||||
#define POLY_FLOOR POLY_MAXVALUE + 27
|
||||
|
||||
#define POLY_MAXSTACK 100
|
||||
|
||||
class CPoly
|
||||
{
|
||||
public:
|
||||
enum ERandomType
|
||||
{
|
||||
RANDOM_TYPE_FREELY,
|
||||
RANDOM_TYPE_FORCE_MIN,
|
||||
RANDOM_TYPE_FORCE_MAX,
|
||||
};
|
||||
|
||||
public:
|
||||
CPoly();
|
||||
virtual ~CPoly();
|
||||
|
||||
int Analyze(const char * pszStr = NULL);
|
||||
float Eval();
|
||||
void SetRandom(int iRandomType);
|
||||
void SetStr(const std::string & str);
|
||||
int SetVar(const std::string & strName, double dVar);
|
||||
int GetVarCount();
|
||||
const char * GetVarName(unsigned int dwIndex);
|
||||
void Clear();
|
||||
|
||||
protected:
|
||||
int my_irandom(double start, double end);
|
||||
double my_frandom(double start, double end);
|
||||
|
||||
void init();
|
||||
int insert(const std::string & s, int tok);
|
||||
int find(const std::string & s);
|
||||
void emit(int t,int tval);
|
||||
void match(int t);
|
||||
void expo();
|
||||
void factor();
|
||||
void term();
|
||||
int iToken;
|
||||
double iNumToken;
|
||||
int iLookAhead;
|
||||
int lexan();
|
||||
int iErrorPos;
|
||||
void error();
|
||||
void expr();
|
||||
bool ErrorOccur;
|
||||
unsigned int uiLookPos;
|
||||
|
||||
// NOTE: list is slight faster than vector, why?!
|
||||
std::vector<int> tokenBase;
|
||||
std::vector<double> numBase;
|
||||
std::vector<CSymTable *> lSymbol;
|
||||
std::vector<int> SymbolIndex;
|
||||
int STSize;
|
||||
int MathSymbolCount;
|
||||
std::string strData;
|
||||
int m_iRandomType;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,17 @@
|
||||
#ifndef __POLY_SYMTABLE_H__
|
||||
#define __POLY_SYMTABLE_H__
|
||||
|
||||
#include <string>
|
||||
|
||||
class CSymTable
|
||||
{
|
||||
public:
|
||||
CSymTable(int aTok, std::string aStr);
|
||||
virtual ~CSymTable();
|
||||
|
||||
double dVal;
|
||||
int token;
|
||||
std::string strlex;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,62 @@
|
||||
#ifndef __CIPHER_H__
|
||||
#define __CIPHER_H__
|
||||
|
||||
#ifdef _IMPROVED_PACKET_ENCRYPTION_
|
||||
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable: 4100 4127 4189 4231 4512 4706)
|
||||
#include <cryptopp/cryptlib.h>
|
||||
#pragma warning(pop)
|
||||
// Forward declaration
|
||||
class KeyAgreement;
|
||||
|
||||
//THEMIDA
|
||||
// Communication channel encryption handler.
|
||||
class Cipher {
|
||||
public:
|
||||
explicit Cipher();
|
||||
~Cipher();
|
||||
|
||||
void CleanUp();
|
||||
|
||||
// Returns agreed value length in CryptoPP::bytes, or zero on failure.
|
||||
size_t Prepare(void* buffer, size_t* length);
|
||||
// Try to activate cipher algorithm with agreement data received from peer.
|
||||
bool Activate(bool polarity, size_t agreed_length,
|
||||
const void* buffer, size_t length);
|
||||
|
||||
// Encrypts the given block of data. (no padding required)
|
||||
void Encrypt(void* buffer, size_t length) {
|
||||
assert(activated_);
|
||||
if (!activated_) {
|
||||
return;
|
||||
}
|
||||
encoder_->ProcessData((CryptoPP::byte*)buffer, (const CryptoPP::byte*)buffer, length);
|
||||
}
|
||||
// Decrypts the given block of data. (no padding required)
|
||||
void Decrypt(void* buffer, size_t length) {
|
||||
assert(activated_);
|
||||
if (!activated_) {
|
||||
return;
|
||||
}
|
||||
decoder_->ProcessData((CryptoPP::byte*)buffer, (const CryptoPP::byte*)buffer, length);
|
||||
}
|
||||
|
||||
bool activated() const { return activated_; }
|
||||
|
||||
void set_activated(bool value) { activated_ = value; }
|
||||
|
||||
private:
|
||||
bool SetUp(bool polarity);
|
||||
|
||||
bool activated_;
|
||||
|
||||
CryptoPP::SymmetricCipher* encoder_;
|
||||
CryptoPP::SymmetricCipher* decoder_;
|
||||
|
||||
KeyAgreement* key_agreement_;
|
||||
};
|
||||
|
||||
#endif // _IMPROVED_PACKET_ENCRYPTION_
|
||||
|
||||
#endif // __CIPHER_H__
|
||||
@@ -0,0 +1,19 @@
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* TEA is a 64-bit symmetric block cipher with a 128-bit key, developed
|
||||
by David J. Wheeler and Roger M. Needham, and described in their
|
||||
paper at <URL:http://www.cl.cam.ac.uk/ftp/users/djw3/tea.ps>.
|
||||
|
||||
This implementation is based on their code in
|
||||
<URL:http://www.cl.cam.ac.uk/ftp/users/djw3/xtea.ps> */
|
||||
|
||||
#define TEA_KEY_LENGTH 16
|
||||
|
||||
int tea_encrypt(unsigned long *dest, const unsigned long *src, const unsigned long *key, int size);
|
||||
int tea_decrypt(unsigned long *dest, const unsigned long *src, const unsigned long *key, int size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
@@ -0,0 +1,304 @@
|
||||
#pragma once
|
||||
|
||||
#pragma warning(disable:4786)
|
||||
|
||||
#include <deque>
|
||||
#include "Thing.h"
|
||||
#include "ModelInstance.h"
|
||||
|
||||
class CGrannyLODController : public CGraphicBase
|
||||
{
|
||||
public:
|
||||
static void SetMinLODMode(bool isEnable);
|
||||
|
||||
public:
|
||||
struct FSetLocalTime
|
||||
{
|
||||
float fLocalTime;
|
||||
void operator() (CGrannyLODController * pController)
|
||||
{
|
||||
pController->SetLocalTime(fLocalTime);
|
||||
}
|
||||
};
|
||||
|
||||
struct FUpdateTime
|
||||
{
|
||||
float fElapsedTime;
|
||||
|
||||
void operator() (CGrannyLODController * pController)
|
||||
{
|
||||
if (pController->isModelInstance())
|
||||
pController->UpdateTime(fElapsedTime);
|
||||
}
|
||||
};
|
||||
|
||||
struct FUpdateLODLevel
|
||||
{
|
||||
float fDistanceFromCenter;
|
||||
float fDistanceFromCamera;
|
||||
|
||||
void operator() (CGrannyLODController * pController)
|
||||
{
|
||||
if (pController->isModelInstance())
|
||||
pController->UpdateLODLevel(fDistanceFromCenter, fDistanceFromCamera);
|
||||
}
|
||||
};
|
||||
|
||||
struct FRenderWithOneTexture
|
||||
{
|
||||
void operator() (CGrannyLODController * pController)
|
||||
{
|
||||
if (pController->isModelInstance())
|
||||
pController->RenderWithOneTexture();
|
||||
}
|
||||
};
|
||||
|
||||
struct FBlendRenderWithOneTexture
|
||||
{
|
||||
void operator() (CGrannyLODController * pController)
|
||||
{
|
||||
if (pController->isModelInstance())
|
||||
pController->BlendRenderWithOneTexture();
|
||||
}
|
||||
};
|
||||
|
||||
struct FRenderWithTwoTexture
|
||||
{
|
||||
void operator() (CGrannyLODController * pController)
|
||||
{
|
||||
if (pController->isModelInstance())
|
||||
pController->RenderWithTwoTexture();
|
||||
}
|
||||
};
|
||||
|
||||
struct FBlendRenderWithTwoTexture
|
||||
{
|
||||
void operator() (CGrannyLODController * pController)
|
||||
{
|
||||
if (pController->isModelInstance())
|
||||
pController->BlendRenderWithTwoTexture();
|
||||
}
|
||||
};
|
||||
|
||||
struct FRenderToShadowMap
|
||||
{
|
||||
void operator() (CGrannyLODController * pController)
|
||||
{
|
||||
if (pController->isModelInstance())
|
||||
pController->RenderToShadowMap();
|
||||
}
|
||||
};
|
||||
|
||||
struct FRenderShadow
|
||||
{
|
||||
void operator() (CGrannyLODController * pController)
|
||||
{
|
||||
if (pController->isModelInstance())
|
||||
pController->RenderShadow();
|
||||
}
|
||||
};
|
||||
|
||||
struct FDeform
|
||||
{
|
||||
const D3DXMATRIX * mc_pWorldMatrix;
|
||||
|
||||
void operator() (CGrannyLODController * pController)
|
||||
{
|
||||
if (pController->isModelInstance())
|
||||
pController->Deform(mc_pWorldMatrix);
|
||||
}
|
||||
};
|
||||
struct FDeformNoSkin
|
||||
{
|
||||
const D3DXMATRIX * mc_pWorldMatrix;
|
||||
|
||||
void operator() (CGrannyLODController * pController)
|
||||
{
|
||||
if (pController->isModelInstance())
|
||||
pController->DeformNoSkin(mc_pWorldMatrix);
|
||||
}
|
||||
};
|
||||
struct FDeformAll
|
||||
{
|
||||
const D3DXMATRIX * mc_pWorldMatrix;
|
||||
|
||||
void operator() (CGrannyLODController * pController)
|
||||
{
|
||||
if (pController->isModelInstance())
|
||||
pController->DeformAll(mc_pWorldMatrix);
|
||||
}
|
||||
};
|
||||
|
||||
struct FCreateDeviceObjects
|
||||
{
|
||||
void operator() (CGrannyLODController * pController)
|
||||
{
|
||||
if (pController->isModelInstance())
|
||||
pController->CreateDeviceObjects();
|
||||
}
|
||||
};
|
||||
|
||||
struct FDestroyDeviceObjects
|
||||
{
|
||||
void operator() (CGrannyLODController * pController)
|
||||
{
|
||||
if (pController->isModelInstance())
|
||||
pController->DestroyDeviceObjects();
|
||||
}
|
||||
};
|
||||
|
||||
struct FBoundBox
|
||||
{
|
||||
D3DXVECTOR3* m_vtMin;
|
||||
D3DXVECTOR3* m_vtMax;
|
||||
|
||||
FBoundBox(D3DXVECTOR3 * vtMin, D3DXVECTOR3 * vtMax)
|
||||
{
|
||||
m_vtMin = vtMin;
|
||||
m_vtMax = vtMax;
|
||||
}
|
||||
|
||||
void operator() (CGrannyLODController * pController)
|
||||
{
|
||||
if (pController->isModelInstance())
|
||||
pController->GetBoundBox(m_vtMin, m_vtMax);
|
||||
}
|
||||
};
|
||||
|
||||
struct FResetLocalTime
|
||||
{
|
||||
void operator() (CGrannyLODController * pController)
|
||||
{
|
||||
if (pController->isModelInstance())
|
||||
pController->ResetLocalTime();
|
||||
}
|
||||
};
|
||||
|
||||
struct FReloadTexture
|
||||
{
|
||||
void operator () (CGrannyLODController * pController)
|
||||
{
|
||||
if (pController->isModelInstance())
|
||||
pController->ReloadTexture();
|
||||
}
|
||||
};
|
||||
|
||||
struct FSetMotionPointer
|
||||
{
|
||||
const CGrannyMotion * m_pMotion;
|
||||
float m_speedRatio;
|
||||
float m_blendTime;
|
||||
int m_loopCount;
|
||||
|
||||
void operator() (CGrannyLODController * pController)
|
||||
{
|
||||
if (pController->isModelInstance())
|
||||
pController->SetMotionPointer(m_pMotion, m_blendTime, m_loopCount, m_speedRatio);
|
||||
}
|
||||
};
|
||||
|
||||
struct FChangeMotionPointer
|
||||
{
|
||||
const CGrannyMotion * m_pMotion;
|
||||
float m_speedRatio;
|
||||
int m_loopCount;
|
||||
|
||||
void operator() (CGrannyLODController * pController)
|
||||
{
|
||||
if (pController->isModelInstance())
|
||||
pController->ChangeMotionPointer(m_pMotion, m_loopCount, m_speedRatio);
|
||||
}
|
||||
};
|
||||
|
||||
struct FEndStopMotionPointer
|
||||
{
|
||||
const CGrannyMotion * m_pMotion;
|
||||
|
||||
void operator () (CGrannyLODController * pController)
|
||||
{
|
||||
if (pController->isModelInstance())
|
||||
pController->SetMotionAtEnd();
|
||||
}
|
||||
};
|
||||
|
||||
CGrannyLODController();
|
||||
virtual ~CGrannyLODController();
|
||||
|
||||
void Clear();
|
||||
|
||||
void CreateDeviceObjects();
|
||||
void DestroyDeviceObjects();
|
||||
|
||||
void AddModel(CGraphicThing * pThing, int iSrcModel, CGrannyLODController * pSkelLODController=NULL);
|
||||
void AttachModelInstance(CGrannyLODController * pSrcLODController, const char * c_szBoneName);
|
||||
void DetachModelInstance(CGrannyLODController * pSrcLODController);
|
||||
void SetLODLimits(float fNearLOD, float fFarLOD);
|
||||
void SetLODLevel(BYTE bLODLevel);
|
||||
BYTE GetLODLevel() { return m_bLODLevel; }
|
||||
void SetMaterialImagePointer(const char* c_szImageName, CGraphicImage* pImage);
|
||||
void SetMaterialData(const char* c_szImageName, const SMaterialData& c_rkMaterialData);
|
||||
void SetSpecularInfo(const char* c_szMtrlName, BOOL bEnable, float fPower);
|
||||
|
||||
void RenderWithOneTexture();
|
||||
void RenderWithTwoTexture();
|
||||
void BlendRenderWithOneTexture();
|
||||
void BlendRenderWithTwoTexture();
|
||||
|
||||
void Update(float fElapsedTime, float fDistanceFromCenter, float fDistanceFromCamera);
|
||||
void UpdateLODLevel(float fDistanceFromCenter, float fDistanceFromCamera);
|
||||
void UpdateTime(float fElapsedTime);
|
||||
|
||||
void UpdateSkeleton(const D3DXMATRIX * c_pWorldMatrix, float fElapsedTime);
|
||||
void Deform(const D3DXMATRIX * c_pWorldMatrix);
|
||||
void DeformNoSkin(const D3DXMATRIX * c_pWorldMatrix);
|
||||
void DeformAll(const D3DXMATRIX * c_pWorldMatrix);
|
||||
|
||||
void RenderToShadowMap();
|
||||
void RenderShadow();
|
||||
void ReloadTexture();
|
||||
|
||||
void GetBoundBox(D3DXVECTOR3 * vtMin, D3DXVECTOR3 * vtMax);
|
||||
bool Intersect(const D3DXMATRIX * c_pMatrix, float * u, float * v, float * t);
|
||||
|
||||
void SetLocalTime(float fLocalTime);
|
||||
void ResetLocalTime();
|
||||
|
||||
void SetMotionPointer(const CGrannyMotion * c_pMotion, float fBlendTime, int iLoopCount, float speedRatio);
|
||||
void ChangeMotionPointer(const CGrannyMotion * c_pMotion, int iLoopCount, float speedRatio);
|
||||
void SetMotionAtEnd();
|
||||
|
||||
BOOL isModelInstance();
|
||||
CGrannyModelInstance* GetModelInstance();
|
||||
bool HaveBlendThing() { return 0 != GetModelInstance() ? GetModelInstance()->HaveBlendThing() : false; } // NOTE: GetModelInstance() == 0일 때 클라 크래쉬나는 문제 수정(2012. 05. 07)
|
||||
|
||||
protected:
|
||||
void SetCurrentModelInstance(CGrannyModelInstance * pgrnModelInstance);
|
||||
void RefreshAttachedModelInstance();
|
||||
|
||||
void __ReserveSharedDeformableVertexBuffer(DWORD deformableVertexCount);
|
||||
|
||||
protected:
|
||||
float m_fLODDistance;
|
||||
DWORD m_dwLODAniFPS;
|
||||
|
||||
//// Attaching Link Data
|
||||
// Data of Parent Side
|
||||
typedef struct SAttachingModelData
|
||||
{
|
||||
CGrannyLODController * pkLODController;
|
||||
std::string strBoneName;
|
||||
} TAttachingModelData;
|
||||
|
||||
std::vector<TAttachingModelData> m_AttachedModelDataVector;
|
||||
// Data of Child Side
|
||||
CGrannyLODController * m_pAttachedParentModel;
|
||||
|
||||
BYTE m_bLODLevel;
|
||||
CGrannyModelInstance * m_pCurrentModelInstance;
|
||||
|
||||
// WORK
|
||||
std::deque<CGrannyModelInstance *> m_que_pkModelInst;
|
||||
|
||||
CGraphicVertexBuffer* m_pkSharedDeformableVertexBuffer;
|
||||
// END_OF_WORK
|
||||
};
|
||||
@@ -0,0 +1,120 @@
|
||||
#pragma once
|
||||
|
||||
#include <granny.h>
|
||||
#include <windows.h>
|
||||
#include <d3d8.h>
|
||||
|
||||
#include "../EterLib/ReferenceObject.h"
|
||||
#include "../EterLib/Ref.h"
|
||||
#include "../EterLib/GrpImageInstance.h"
|
||||
#include "Util.h"
|
||||
|
||||
class CGrannyMaterial : public CReferenceObject
|
||||
{
|
||||
public:
|
||||
typedef CRef<CGrannyMaterial> TRef;
|
||||
|
||||
static void CreateSphereMap(UINT uMapIndex, const char* c_szSphereMapImageFileName);
|
||||
static void DestroySphereMap();
|
||||
|
||||
public:
|
||||
enum EType
|
||||
{
|
||||
TYPE_DIFFUSE_PNT,
|
||||
TYPE_BLEND_PNT,
|
||||
TYPE_MAX_NUM
|
||||
};
|
||||
|
||||
public:
|
||||
static void TranslateSpecularMatrix(float fAddX, float fAddY, float fAddZ);
|
||||
|
||||
private:
|
||||
static D3DXMATRIX ms_matSpecular;
|
||||
static D3DXVECTOR3 ms_v3SpecularTrans;
|
||||
|
||||
public:
|
||||
CGrannyMaterial();
|
||||
virtual ~CGrannyMaterial();
|
||||
|
||||
void Destroy();
|
||||
void Copy(CGrannyMaterial& rkMtrl);
|
||||
bool IsEqual(granny_material * pgrnMaterial) const;
|
||||
bool IsIn(const char* c_szImageName, int* iStage);
|
||||
void SetSpecularInfo(BOOL bFlag, float fPower, BYTE uSphereMapIndex);
|
||||
|
||||
void ApplyRenderState();
|
||||
void RestoreRenderState();
|
||||
|
||||
protected:
|
||||
void Initialize();
|
||||
|
||||
public:
|
||||
bool CreateFromGrannyMaterialPointer(granny_material* pgrnMaterial);
|
||||
void SetImagePointer(int iStage, CGraphicImage* pImage);
|
||||
|
||||
CGrannyMaterial::EType GetType() const;
|
||||
CGraphicImage * GetImagePointer(int iStage) const;
|
||||
|
||||
const CGraphicTexture * GetDiffuseTexture() const;
|
||||
const CGraphicTexture * GetOpacityTexture() const;
|
||||
|
||||
LPDIRECT3DTEXTURE8 GetD3DTexture(int iStage) const;
|
||||
|
||||
bool IsTwoSided() const { return m_bTwoSideRender; }
|
||||
|
||||
|
||||
protected:
|
||||
CGraphicImage * __GetImagePointer(const char * c_szFileName);
|
||||
|
||||
BOOL __IsSpecularEnable() const;
|
||||
float __GetSpecularPower() const;
|
||||
|
||||
void __ApplyDiffuseRenderState();
|
||||
void __RestoreDiffuseRenderState();
|
||||
void __ApplySpecularRenderState();
|
||||
void __RestoreSpecularRenderState();
|
||||
|
||||
protected:
|
||||
granny_material * m_pgrnMaterial;
|
||||
CGraphicImage::TRef m_roImage[2];
|
||||
EType m_eType;
|
||||
|
||||
float m_fSpecularPower;
|
||||
BOOL m_bSpecularEnable;
|
||||
bool m_bTwoSideRender;
|
||||
DWORD m_dwLastCullRenderStateForTwoSideRendering;
|
||||
BYTE m_bSphereMapIndex;
|
||||
|
||||
|
||||
void (CGrannyMaterial::*m_pfnApplyRenderState)();
|
||||
void (CGrannyMaterial::*m_pfnRestoreRenderState)();
|
||||
|
||||
private:
|
||||
enum
|
||||
{
|
||||
SPHEREMAP_NUM = 10,
|
||||
};
|
||||
static CGraphicImageInstance ms_akSphereMapInstance[SPHEREMAP_NUM];
|
||||
};
|
||||
|
||||
class CGrannyMaterialPalette
|
||||
{
|
||||
public:
|
||||
CGrannyMaterialPalette();
|
||||
virtual ~CGrannyMaterialPalette();
|
||||
|
||||
void Clear();
|
||||
void Copy(const CGrannyMaterialPalette& rkMtrlPalSrc);
|
||||
|
||||
DWORD RegisterMaterial(granny_material* pgrnMaterial);
|
||||
void SetMaterialImagePointer(const char* c_szMtrlName, CGraphicImage* pImage);
|
||||
void SetMaterialData(const char* c_szMtrlName, const SMaterialData& c_rkMaterialData);
|
||||
void SetSpecularInfo(const char* c_szMtrlName, BOOL bEnable, float fPower);
|
||||
|
||||
CGrannyMaterial& GetMaterialRef(DWORD mtrlIndex);
|
||||
|
||||
DWORD GetMaterialCount() const;
|
||||
|
||||
protected:
|
||||
std::vector<CGrannyMaterial::TRef> m_mtrlVector;
|
||||
};
|
||||
@@ -0,0 +1,98 @@
|
||||
#pragma once
|
||||
|
||||
#include "Material.h"
|
||||
|
||||
extern granny_data_type_definition GrannyPNT3322VertexType[5];
|
||||
|
||||
struct granny_pnt3322_vertex
|
||||
{
|
||||
granny_real32 Position[3];
|
||||
granny_real32 Normal[3];
|
||||
granny_real32 UV0[2];
|
||||
granny_real32 UV1[2];
|
||||
};
|
||||
|
||||
class CGrannyMesh
|
||||
{
|
||||
public:
|
||||
enum EType
|
||||
{
|
||||
TYPE_RIGID,
|
||||
TYPE_DEFORM,
|
||||
TYPE_MAX_NUM
|
||||
};
|
||||
|
||||
typedef struct STriGroupNode
|
||||
{
|
||||
STriGroupNode * pNextTriGroupNode;
|
||||
int idxPos;
|
||||
int triCount;
|
||||
DWORD mtrlIndex;
|
||||
} TTriGroupNode;
|
||||
|
||||
public:
|
||||
CGrannyMesh();
|
||||
virtual ~CGrannyMesh();
|
||||
|
||||
bool IsEmpty() const;
|
||||
bool CreateFromGrannyMeshPointer(granny_skeleton* pgrnSkeleton, granny_mesh* pgrnMesh, int vtxBasePos, int idxBasePos, CGrannyMaterialPalette& rkMtrlPal);
|
||||
void LoadIndices(void* dstBaseIndices);
|
||||
void LoadPNTVertices(void* dstBaseVertices);
|
||||
void NEW_LoadVertices(void* dstBaseVertices);
|
||||
void Destroy();
|
||||
|
||||
void SetPNT2Mesh();
|
||||
|
||||
void DeformPNTVertices(void* dstBaseVertices, D3DXMATRIX* boneMatrices, granny_mesh_binding* pgrnMeshBinding) const;
|
||||
bool CanDeformPNTVertices() const;
|
||||
bool IsTwoSide() const;
|
||||
|
||||
int GetVertexCount() const;
|
||||
|
||||
// WORK
|
||||
int * GetDefaultBoneIndices() const;
|
||||
// END_OF_WORK
|
||||
|
||||
int GetVertexBasePosition() const;
|
||||
int GetIndexBasePosition() const;
|
||||
|
||||
const granny_mesh * GetGrannyMeshPointer() const;
|
||||
const CGrannyMesh::TTriGroupNode * GetTriGroupNodeList(CGrannyMaterial::EType eMtrlType) const;
|
||||
|
||||
void RebuildTriGroupNodeList();
|
||||
void ReloadMaterials();
|
||||
|
||||
protected:
|
||||
void Initialize();
|
||||
|
||||
bool LoadMaterials(CGrannyMaterialPalette& rkMtrlPal);
|
||||
bool LoadTriGroupNodeList(CGrannyMaterialPalette& rkMtrlPal);
|
||||
|
||||
protected:
|
||||
// Granny Mesh Data
|
||||
granny_data_type_definition * m_pgrnMeshType;
|
||||
granny_mesh * m_pgrnMesh;
|
||||
|
||||
// WORK
|
||||
granny_mesh_binding * m_pgrnMeshBindingTemp;
|
||||
// END_OF_WORK
|
||||
|
||||
granny_mesh_deformer * m_pgrnMeshDeformer;
|
||||
|
||||
// Granny Material Data
|
||||
std::vector<DWORD> m_mtrlIndexVector;
|
||||
|
||||
// TriGroups Data
|
||||
TTriGroupNode * m_triGroupNodes;
|
||||
TTriGroupNode * m_triGroupNodeLists[CGrannyMaterial::TYPE_MAX_NUM];
|
||||
|
||||
int m_vtxBasePos;
|
||||
int m_idxBasePos;
|
||||
|
||||
bool m_canDeformPNTVertex;
|
||||
bool m_isTwoSide;
|
||||
private:
|
||||
bool m_bHaveBlendThing;
|
||||
public:
|
||||
bool HaveBlendThing() { return m_bHaveBlendThing; }
|
||||
};
|
||||
@@ -0,0 +1,98 @@
|
||||
#pragma once
|
||||
|
||||
#include "../EterLib/GrpVertexBuffer.h"
|
||||
#include "../EterLib/GrpIndexBuffer.h"
|
||||
|
||||
#include "Mesh.h"
|
||||
|
||||
class CGrannyModel : public CReferenceObject
|
||||
{
|
||||
public:
|
||||
typedef struct SMeshNode
|
||||
{
|
||||
int iMesh;
|
||||
const CGrannyMesh * pMesh;
|
||||
SMeshNode * pNextMeshNode;
|
||||
} TMeshNode;
|
||||
|
||||
public:
|
||||
CGrannyModel();
|
||||
virtual ~CGrannyModel();
|
||||
|
||||
bool IsEmpty() const;
|
||||
bool CreateFromGrannyModelPointer(granny_model* pgrnModel);
|
||||
bool CreateDeviceObjects();
|
||||
void DestroyDeviceObjects();
|
||||
void Destroy();
|
||||
|
||||
int GetRigidVertexCount() const;
|
||||
int GetDeformVertexCount() const;
|
||||
int GetVertexCount() const;
|
||||
|
||||
bool CanDeformPNTVertices() const;
|
||||
void DeformPNTVertices(void* dstBaseVertices, D3DXMATRIX* boneMatrices, const std::vector<granny_mesh_binding*>& c_rvct_pgrnMeshBinding) const;
|
||||
|
||||
int GetIdxCount();
|
||||
int GetMeshCount() const;
|
||||
CGrannyMesh * GetMeshPointer(int iMesh);
|
||||
granny_model * GetGrannyModelPointer();
|
||||
const CGrannyMesh* GetMeshPointer(int iMesh) const;
|
||||
|
||||
LPDIRECT3DVERTEXBUFFER8 GetPNTD3DVertexBuffer() const;
|
||||
LPDIRECT3DINDEXBUFFER8 GetD3DIndexBuffer() const;
|
||||
|
||||
const CGrannyModel::TMeshNode* GetMeshNodeList(CGrannyMesh::EType eMeshType, CGrannyMaterial::EType eMtrlType) const;
|
||||
|
||||
bool LockVertices(void** indicies, void** vertices) const;
|
||||
void UnlockVertices() const;
|
||||
|
||||
const CGrannyMaterialPalette& GetMaterialPalette() const;
|
||||
|
||||
protected:
|
||||
bool LoadMeshs();
|
||||
bool LoadPNTVertices();
|
||||
bool LoadIndices();
|
||||
void Initialize();
|
||||
|
||||
BOOL CheckMeshIndex(int iIndex) const;
|
||||
void AppendMeshNode(CGrannyMesh::EType eMeshType, CGrannyMaterial::EType eMtrlType, int iMesh);
|
||||
|
||||
protected:
|
||||
// Granny Data
|
||||
granny_model * m_pgrnModel;
|
||||
|
||||
// Static Data
|
||||
CGrannyMesh * m_meshs;
|
||||
|
||||
CGraphicVertexBuffer m_pntVtxBuf; // for rigid mesh
|
||||
CGraphicIndexBuffer m_idxBuf;
|
||||
|
||||
TMeshNode * m_meshNodes;
|
||||
TMeshNode * m_meshNodeLists[CGrannyMesh::TYPE_MAX_NUM][CGrannyMaterial::TYPE_MAX_NUM];
|
||||
|
||||
int m_deformVtxCount;
|
||||
int m_rigidVtxCount;
|
||||
int m_vtxCount;
|
||||
int m_idxCount;
|
||||
|
||||
int m_meshNodeSize;
|
||||
int m_meshNodeCapacity;
|
||||
|
||||
bool m_canDeformPNVertices;
|
||||
|
||||
CGrannyMaterialPalette m_kMtrlPal;
|
||||
private:
|
||||
bool m_bHaveBlendThing;
|
||||
public:
|
||||
bool HaveBlendThing() { return m_bHaveBlendThing; }
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// New members to support PNT2 type models
|
||||
protected:
|
||||
bool __LoadVertices();
|
||||
protected:
|
||||
DWORD m_dwFvF;
|
||||
// New members to support PNT2 type models
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
};
|
||||
@@ -0,0 +1,202 @@
|
||||
#pragma once
|
||||
|
||||
//#define CACHE_DEFORMED_VERTEX
|
||||
#include "../EterLib/GrpImage.h"
|
||||
#include "../EterLib/GrpCollisionObject.h"
|
||||
|
||||
#include "Model.h"
|
||||
#include "Motion.h"
|
||||
|
||||
class CGrannyModelInstance : public CGraphicCollisionObject
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
ANIFPS_MIN = 30,
|
||||
ANIFPS_MAX = 120,
|
||||
};
|
||||
public:
|
||||
static void DestroySystem();
|
||||
|
||||
static CGrannyModelInstance* New();
|
||||
static void Delete(CGrannyModelInstance* pkInst);
|
||||
|
||||
static CDynamicPool<CGrannyModelInstance> ms_kPool;
|
||||
|
||||
public:
|
||||
struct FCreateDeviceObjects
|
||||
{
|
||||
void operator() (CGrannyModelInstance * pModelInstance)
|
||||
{pModelInstance->CreateDeviceObjects();}
|
||||
};
|
||||
|
||||
struct FDestroyDeviceObjects
|
||||
{
|
||||
void operator() (CGrannyModelInstance * pModelInstance)
|
||||
{pModelInstance->DestroyDeviceObjects();}
|
||||
};
|
||||
|
||||
public:
|
||||
CGrannyModelInstance();
|
||||
virtual ~CGrannyModelInstance();
|
||||
|
||||
bool IsEmpty();
|
||||
void Clear();
|
||||
|
||||
bool CreateDeviceObjects();
|
||||
void DestroyDeviceObjects();
|
||||
|
||||
// Update & Render
|
||||
void Update(DWORD dwAniFPS);
|
||||
void UpdateLocalTime(float fElapsedTime);
|
||||
void UpdateTransform(D3DXMATRIX * pMatrix, float fSecondsElapsed);
|
||||
|
||||
void UpdateSkeleton(const D3DXMATRIX * c_pWorldMatrix, float fLocalTime);
|
||||
void DeformNoSkin(const D3DXMATRIX * c_pWorldMatrix);
|
||||
void Deform(const D3DXMATRIX * c_pWorldMatrix);
|
||||
|
||||
// FIXME : 현재는 하드웨어의 한계로 2장의 텍스춰로 제한이 되어있는 상태이기에 이런
|
||||
// 불안정한 아키텍춰가 가능하지만, 궁극적인 방향은 (모델 텍스춰 전부) + (효과용 텍스춰)
|
||||
// 이런식의 자동 셋팅이 이뤄져야 되지 않나 생각합니다. - [levites]
|
||||
// NOTE : 내부에 if문을 포함 시키기 보다는 조금은 번거롭지만 이렇게 함수 콜 자체를 분리
|
||||
// 시키는 것이 퍼포먼스 적인 측면에서는 더 나은 것 같습니다. - [levites]
|
||||
// NOTE : 건물은 무조건 OneTexture. 캐릭터는 경우에 따라 TwoTexture.
|
||||
void RenderWithOneTexture();
|
||||
void RenderWithTwoTexture();
|
||||
void BlendRenderWithOneTexture();
|
||||
void BlendRenderWithTwoTexture();
|
||||
void RenderWithoutTexture();
|
||||
|
||||
// Model
|
||||
CGrannyModel* GetModel();
|
||||
void SetMaterialImagePointer(const char* c_szImageName, CGraphicImage* pImage);
|
||||
void SetMaterialData(const char* c_szImageName, const SMaterialData& c_rkMaterialData);
|
||||
void SetSpecularInfo(const char* c_szMtrlName, BOOL bEnable, float fPower);
|
||||
|
||||
void SetMainModelPointer(CGrannyModel* pkModel, CGraphicVertexBuffer* pkSharedDefromableVertexBuffer);
|
||||
void SetLinkedModelPointer(CGrannyModel* pkModel, CGraphicVertexBuffer* pkSharedDefromableVertexBuffer, CGrannyModelInstance** ppkSkeletonInst);
|
||||
|
||||
// Motion
|
||||
void SetMotionPointer(const CGrannyMotion* pMotion, float blendTime=0.0f, int loopCount=0, float speedRatio=1.0f);
|
||||
void ChangeMotionPointer(const CGrannyMotion* pMotion, int loopCount=0, float speedRatio=1.0f);
|
||||
void SetMotionAtEnd();
|
||||
bool IsMotionPlaying();
|
||||
|
||||
void CopyMotion(CGrannyModelInstance * pModelInstance, bool bIsFreeSourceControl=false);
|
||||
|
||||
// Time
|
||||
void SetLocalTime(float fLocalTime);
|
||||
int ResetLocalTime();
|
||||
float GetLocalTime();
|
||||
float GetNextTime();
|
||||
|
||||
// WORK
|
||||
DWORD GetDeformableVertexCount();
|
||||
DWORD GetVertexCount();
|
||||
|
||||
// END_OF_WORK
|
||||
|
||||
// Bone & Attaching
|
||||
const float * GetBoneMatrixPointer(int iBone) const;
|
||||
const float * GetCompositeBoneMatrixPointer(int iBone) const;
|
||||
bool GetMeshMatrixPointer(int iMesh, const D3DXMATRIX ** c_ppMatrix) const;
|
||||
bool GetBoneIndexByName(const char * c_szBoneName, int * pBoneIndex) const;
|
||||
void SetParentModelInstance(const CGrannyModelInstance* c_pParentModelInstance, const char * c_szBoneName);
|
||||
void SetParentModelInstance(const CGrannyModelInstance* c_pParentModelInstance, int iBone);
|
||||
|
||||
// Collision Detection
|
||||
bool Intersect(const D3DXMATRIX * c_pMatrix, float * pu, float * pv, float * pt);
|
||||
void MakeBoundBox(TBoundBox* pBoundBox, const float* mat, const float* OBBMin, const float* OBBMax, D3DXVECTOR3* vtMin, D3DXVECTOR3* vtMax);
|
||||
void GetBoundBox(D3DXVECTOR3 * vtMin, D3DXVECTOR3* vtMax);
|
||||
|
||||
// Reload Texture
|
||||
void ReloadTexture();
|
||||
|
||||
|
||||
protected:
|
||||
void __Initialize();
|
||||
|
||||
void __DestroyModelInstance();
|
||||
void __DestroyMeshMatrices();
|
||||
void __DestroyDynamicVertexBuffer();
|
||||
|
||||
|
||||
void __CreateModelInstance();
|
||||
void __CreateMeshMatrices();
|
||||
void __CreateDynamicVertexBuffer();
|
||||
|
||||
// WORK
|
||||
void __DestroyWorldPose();
|
||||
void __CreateWorldPose(CGrannyModelInstance* pkSrcModelInst);
|
||||
|
||||
bool __CreateMeshBindingVector(CGrannyModelInstance* pkDstModelInst);
|
||||
void __DestroyMeshBindingVector();
|
||||
|
||||
int* __GetMeshBoneIndices(unsigned int iMeshBinding) const;
|
||||
|
||||
bool __IsDeformableVertexBuffer();
|
||||
void __SetSharedDeformableVertexBuffer(CGraphicVertexBuffer* pkSharedDeformableVertexBuffer);
|
||||
|
||||
IDirect3DVertexBuffer8* __GetDeformableD3DVertexBufferPtr();
|
||||
CGraphicVertexBuffer& __GetDeformableVertexBufferRef();
|
||||
|
||||
granny_world_pose* __GetWorldPosePtr() const;
|
||||
// END_OF_WORK
|
||||
|
||||
|
||||
// Update & Render
|
||||
void UpdateWorldPose();
|
||||
void UpdateWorldMatrices(const D3DXMATRIX * c_pWorldMatrix);
|
||||
void DeformPNTVertices(void * pvDest);
|
||||
|
||||
void RenderMeshNodeListWithOneTexture(CGrannyMesh::EType eMeshType, CGrannyMaterial::EType eMtrlType);
|
||||
void RenderMeshNodeListWithTwoTexture(CGrannyMesh::EType eMeshType, CGrannyMaterial::EType eMtrlType);
|
||||
void RenderMeshNodeListWithoutTexture(CGrannyMesh::EType eMeshType, CGrannyMaterial::EType eMtrlType);
|
||||
|
||||
protected:
|
||||
// Static Data
|
||||
CGrannyModel * m_pModel;
|
||||
|
||||
// Granny Data
|
||||
granny_model_instance * m_pgrnModelInstance;
|
||||
|
||||
//granny_world_pose * m_pgrnWorldPose; // 현재 월드 포즈 포인터
|
||||
|
||||
granny_control * m_pgrnCtrl;
|
||||
granny_animation * m_pgrnAni;
|
||||
|
||||
// Meshes' Transform Data
|
||||
D3DXMATRIX * m_meshMatrices;
|
||||
|
||||
|
||||
// Attaching Data
|
||||
const CGrannyModelInstance * mc_pParentInstance;
|
||||
int m_iParentBoneIndex;
|
||||
|
||||
// Game Data
|
||||
float m_fLocalTime;
|
||||
float m_fSecondsElapsed;
|
||||
|
||||
DWORD m_dwOldUpdateFrame;
|
||||
|
||||
CGrannyMaterialPalette m_kMtrlPal;
|
||||
|
||||
// WORK
|
||||
granny_world_pose* m_pgrnWorldPoseReal; // 실제 메모리는 여기에 할당
|
||||
std::vector<granny_mesh_binding*> m_vct_pgrnMeshBinding;
|
||||
|
||||
// Dynamic Vertex Buffer
|
||||
CGraphicVertexBuffer* m_pkSharedDeformableVertexBuffer;
|
||||
CGraphicVertexBuffer m_kLocalDeformableVertexBuffer;
|
||||
bool m_isDeformableVertexBuffer;
|
||||
// END_OF_WORK
|
||||
|
||||
// TEST
|
||||
CGrannyModelInstance** m_ppkSkeletonInst;
|
||||
// END_OF_TEST
|
||||
#ifdef _TEST
|
||||
D3DXMATRIX TEST_matWorld;
|
||||
#endif
|
||||
public:
|
||||
bool HaveBlendThing() { return m_pModel->HaveBlendThing(); }
|
||||
};
|
||||
@@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
class CGrannyMotion
|
||||
{
|
||||
public:
|
||||
CGrannyMotion();
|
||||
virtual ~CGrannyMotion();
|
||||
|
||||
bool IsEmpty();
|
||||
|
||||
void Destroy();
|
||||
bool BindGrannyAnimation(granny_animation* pgrnAni);
|
||||
|
||||
granny_animation * GetGrannyAnimationPointer() const;
|
||||
|
||||
const char * GetName() const;
|
||||
float GetDuration() const;
|
||||
void GetTextTrack(const char * c_szTextTrackName, int * pCount, float * pArray) const;
|
||||
|
||||
protected:
|
||||
void Initialize();
|
||||
|
||||
protected:
|
||||
granny_animation * m_pgrnAni;
|
||||
};
|
||||
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
#pragma warning(disable:4786) // character 255 넘어가는거 끄기
|
||||
|
||||
//#include <crtdbg.h>
|
||||
#include <granny.h>
|
||||
|
||||
#include "../EterBase/Utils.h"
|
||||
#include "../EterBase/Debug.h"
|
||||
#include "../EterBase/Stl.h"
|
||||
|
||||
#include "Util.h"
|
||||
|
||||
// Armadillo nanomite protection
|
||||
#ifndef NANOBEGIN
|
||||
#ifdef __BORLANDC__
|
||||
#define NANOBEGIN __emit__ (0xEB,0x03,0xD6,0xD7,0x01)
|
||||
#define NANOEND __emit__ (0xEB,0x03,0xD6,0xD7,0x00)
|
||||
#else
|
||||
#define NANOBEGIN __asm _emit 0xEB __asm _emit 0x03 __asm _emit 0xD6 __asm _emit 0xD7 __asm _emit 0x01
|
||||
#define NANOEND __asm _emit 0xEB __asm _emit 0x03 __asm _emit 0xD6 __asm _emit 0xD7 __asm _emit 0x00
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,49 @@
|
||||
#pragma once
|
||||
|
||||
#include "Model.h"
|
||||
#include "Motion.h"
|
||||
|
||||
class CGraphicThing : public CResource
|
||||
{
|
||||
public:
|
||||
typedef CRef<CGraphicThing> TRef;
|
||||
|
||||
public:
|
||||
static CGraphicThing::TType Type();
|
||||
|
||||
public:
|
||||
CGraphicThing(const char * c_szFileName);
|
||||
virtual ~CGraphicThing();
|
||||
|
||||
virtual bool CreateDeviceObjects();
|
||||
virtual void DestroyDeviceObjects();
|
||||
|
||||
bool CheckModelIndex(int iModel) const;
|
||||
CGrannyModel * GetModelPointer(int iModel);
|
||||
int GetModelCount() const;
|
||||
|
||||
bool CheckMotionIndex(int iMotion) const;
|
||||
CGrannyMotion * GetMotionPointer(int iMotion);
|
||||
int GetMotionCount() const;
|
||||
|
||||
protected:
|
||||
void Initialize();
|
||||
|
||||
bool LoadModels();
|
||||
bool LoadMotions();
|
||||
|
||||
protected:
|
||||
bool OnLoad(int iSize, const void* c_pvBuf);
|
||||
void OnClear();
|
||||
bool OnIsEmpty() const;
|
||||
bool OnIsType(TType type);
|
||||
|
||||
protected:
|
||||
granny_file * m_pgrnFile;
|
||||
granny_file_info * m_pgrnFileInfo;
|
||||
|
||||
granny_animation * m_pgrnAni;
|
||||
|
||||
CGrannyModel * m_models;
|
||||
CGrannyMotion * m_motions;
|
||||
};
|
||||
@@ -0,0 +1,158 @@
|
||||
#pragma once
|
||||
|
||||
#include "../EterBase/Stl.h"
|
||||
#include "../EterLib/GrpObjectInstance.h"
|
||||
#include "../EterLib/GrpShadowTexture.h"
|
||||
|
||||
#include "LODController.h"
|
||||
|
||||
const int DONTUSEVALUE = -1;
|
||||
class CGraphicThingInstance : public CGraphicObjectInstance
|
||||
{
|
||||
public:
|
||||
typedef struct SModelThingSet
|
||||
{
|
||||
void Clear()
|
||||
{
|
||||
stl_wipe(m_pLODThingRefVector);
|
||||
}
|
||||
|
||||
std::vector<CGraphicThing::TRef *> m_pLODThingRefVector;
|
||||
} TModelThingSet;
|
||||
|
||||
public:
|
||||
enum
|
||||
{
|
||||
ID = THING_OBJECT
|
||||
};
|
||||
int GetType() const { return ID; }
|
||||
|
||||
CGraphicThingInstance();
|
||||
virtual ~CGraphicThingInstance();
|
||||
|
||||
void DeformNoSkin();
|
||||
|
||||
void UpdateLODLevel();
|
||||
void UpdateTime();
|
||||
void DeformAll(); // 모든 LOD 디폼
|
||||
|
||||
bool LessRenderOrder(CGraphicThingInstance* pkThingInst);
|
||||
|
||||
bool Picking(const D3DXVECTOR3 & v, const D3DXVECTOR3 & dir, float & out_x, float & out_y);
|
||||
|
||||
void OnInitialize();
|
||||
|
||||
bool CreateDeviceObjects();
|
||||
void DestroyDeviceObjects();
|
||||
|
||||
void ReserveModelInstance(int iCount);
|
||||
void ReserveModelThing(int iCount);
|
||||
|
||||
bool CheckModelInstanceIndex(int iModelInstance);
|
||||
bool CheckModelThingIndex(int iModelThing);
|
||||
bool CheckMotionThingIndex(DWORD dwMotionKey);
|
||||
bool GetMotionThingPointer(DWORD dwKey, CGraphicThing ** ppMotion);
|
||||
bool IsMotionThing();
|
||||
|
||||
void RegisterModelThing(int iModelThing, CGraphicThing * pModelThing);
|
||||
void RegisterLODThing(int iModelThing, CGraphicThing * pModelThing);
|
||||
void RegisterMotionThing(DWORD dwMotionKey, CGraphicThing * pMotionThing);
|
||||
|
||||
bool SetModelInstance(int iDstModelInstance, int iSrcModelThing, int iSrcModel,int iSkelInstance = DONTUSEVALUE);
|
||||
void SetEndStopMotion();
|
||||
void SetMotionAtEnd();
|
||||
|
||||
void AttachModelInstance(int iDstModelInstance, const char * c_szBoneName, int iSrcModelInstance);
|
||||
void AttachModelInstance(int iDstModelInstance, const char * c_szBoneName, CGraphicThingInstance & rsrcInstance, int iSrcModelInstance);
|
||||
void DetachModelInstance(int iDstModelInstance, CGraphicThingInstance & rSrcInstance, int SrcModelInstance);
|
||||
bool FindBoneIndex(int iModelInstance, const char* c_szBoneName, int * iRetBone);
|
||||
bool GetBonePosition(int iModelIndex, int iBoneIndex, float * pfx, float * pfy, float * pfz);
|
||||
|
||||
void ResetLocalTime();
|
||||
void InsertDelay(float fDelay);
|
||||
|
||||
void SetMaterialImagePointer(UINT ePart, const char* c_szImageName, CGraphicImage* pImage);
|
||||
void SetMaterialData(UINT ePart, const char* c_szImageName, SMaterialData kMaterialData);
|
||||
void SetSpecularInfo(UINT ePart, const char* c_szMtrlName, BOOL bEnable, float fPower);
|
||||
|
||||
void __SetLocalTime(float fLocalTime); // Only Used by Tools
|
||||
float GetLastLocalTime();
|
||||
float GetLocalTime();
|
||||
float GetSecondElapsed();
|
||||
float GetAverageSecondElapsed();
|
||||
|
||||
BYTE GetLODLevel(DWORD dwModelInstance);
|
||||
float GetHeight();
|
||||
|
||||
void RenderWithOneTexture();
|
||||
void RenderWithTwoTexture();
|
||||
void BlendRenderWithOneTexture();
|
||||
void BlendRenderWithTwoTexture();
|
||||
|
||||
DWORD GetLODControllerCount() const;
|
||||
CGrannyLODController * GetLODControllerPointer(DWORD dwModelIndex) const;
|
||||
CGrannyLODController * GetLODControllerPointer(DWORD dwModelIndex);
|
||||
|
||||
void ReloadTexture();
|
||||
|
||||
public:
|
||||
CGraphicThing* GetBaseThingPtr();
|
||||
|
||||
bool SetMotion(DWORD dwMotionKey, float blendTime = 0.0f, int loopCount = 0, float speedRatio=1.0f);
|
||||
bool ChangeMotion(DWORD dwMotionKey, int loopCount = 0, float speedRatio=1.0f);
|
||||
bool Intersect(float * pu, float * pv, float * pt);
|
||||
void GetBoundBox(D3DXVECTOR3 * vtMin, D3DXVECTOR3 * vtMax);
|
||||
BOOL GetBoundBox(DWORD dwModelInstanceIndex, D3DXVECTOR3 * vtMin, D3DXVECTOR3 * vtMax);
|
||||
BOOL GetBoneMatrix(DWORD dwModelInstanceIndex, DWORD dwBoneIndex, D3DXMATRIX ** ppMatrix);
|
||||
BOOL GetCompositeBoneMatrix(DWORD dwModelInstanceIndex, DWORD dwBoneIndex, D3DXMATRIX ** ppMatrix);
|
||||
void UpdateTransform(D3DXMATRIX * pMatrix, float fSecondsElapsed = 0.0f, int iModelInstanceIndex = 0);
|
||||
void ProjectShadow(const CGraphicShadowTexture & c_rShadowTexture);
|
||||
|
||||
public:
|
||||
void BuildBoundingSphere();
|
||||
void BuildBoundingAABB();
|
||||
virtual void CalculateBBox();
|
||||
virtual bool GetBoundingSphere(D3DXVECTOR3 & v3Center, float & fRadius);
|
||||
virtual bool GetBoundingAABB(D3DXVECTOR3 & v3Min, D3DXVECTOR3 & v3Max);
|
||||
|
||||
protected:
|
||||
void OnClear();
|
||||
void OnDeform();
|
||||
void OnUpdate();
|
||||
void OnRender();
|
||||
void OnBlendRender();
|
||||
void OnRenderToShadowMap();
|
||||
void OnRenderShadow();
|
||||
void OnRenderPCBlocker();
|
||||
|
||||
protected:
|
||||
bool m_bUpdated;
|
||||
float m_fLastLocalTime;
|
||||
float m_fLocalTime;
|
||||
float m_fDelay;
|
||||
float m_fSecondElapsed;
|
||||
float m_fAverageSecondElapsed;
|
||||
float m_fRadius;
|
||||
D3DXVECTOR3 m_v3Center;
|
||||
D3DXVECTOR3 m_v3Min, m_v3Max;
|
||||
|
||||
std::vector<CGrannyLODController *> m_LODControllerVector;
|
||||
std::vector<TModelThingSet> m_modelThingSetVector;
|
||||
std::map<DWORD, CGraphicThing::TRef *> m_roMotionThingMap;
|
||||
|
||||
protected:
|
||||
virtual void OnUpdateCollisionData(const CStaticCollisionDataVector * pscdVector);
|
||||
virtual void OnUpdateHeighInstance(CAttributeInstance * pAttributeInstance);
|
||||
virtual bool OnGetObjectHeight(float fX, float fY, float * pfHeight);
|
||||
|
||||
public:
|
||||
static void CreateSystem(UINT uCapacity);
|
||||
static void DestroySystem();
|
||||
|
||||
static CGraphicThingInstance* New();
|
||||
static void Delete(CGraphicThingInstance* pkInst);
|
||||
|
||||
static CDynamicPool<CGraphicThingInstance> ms_kPool;
|
||||
|
||||
bool HaveBlendThing();
|
||||
};
|
||||
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
// bool GrannyMeshGetTextureAnimation(granny_mesh* pgrnMesh, float* puVelocity, float* pvVelocity);
|
||||
// bool GrannyMeshIsTextureAnimation(granny_mesh* pgrnMesh);
|
||||
bool GrannyMeshIsDeform(granny_mesh* pgrnMesh);
|
||||
|
||||
class CGraphicImage;
|
||||
|
||||
struct SMaterialData
|
||||
{
|
||||
CGraphicImage * pImage;
|
||||
float fSpecularPower;
|
||||
BOOL isSpecularEnable;
|
||||
BYTE bSphereMapIndex;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
#ifndef __INC_ETERIMAGELIB_IMAGE_H__
|
||||
#define __INC_ETERIMAGELIB_IMAGE_H__
|
||||
|
||||
#include <windows.h>
|
||||
#include <string>
|
||||
|
||||
#pragma pack(push)
|
||||
#pragma pack(1)
|
||||
struct TGA_HEADER
|
||||
{
|
||||
char idLen; // 0
|
||||
char palType; // 파레트있으면 1, 없음 0
|
||||
char imgType; // 파레트있으면 1, 없음 2
|
||||
WORD colorBegin; // 0
|
||||
WORD colorCount; // 파레트 있으면 256, 없음 0
|
||||
char palEntrySize; // 파레트 있으면 24, 없음 0
|
||||
WORD left;
|
||||
WORD top;
|
||||
WORD width;
|
||||
WORD height;
|
||||
char colorBits;
|
||||
char desc;
|
||||
};
|
||||
#define IMAGEDESC_ORIGIN_MASK 0x30
|
||||
#define IMAGEDESC_TOPLEFT 0x20
|
||||
#define IMAGEDESC_BOTLEFT 0x00
|
||||
#define IMAGEDESC_BOTRIGHT 0x10
|
||||
#define IMAGEDESC_TOPRIGHT 0x30
|
||||
#pragma pack(pop)
|
||||
|
||||
class CImage
|
||||
{
|
||||
public:
|
||||
CImage();
|
||||
CImage(CImage & image);
|
||||
|
||||
virtual ~CImage();
|
||||
|
||||
void Destroy();
|
||||
|
||||
void Create(int width, int height);
|
||||
|
||||
void Clear(DWORD color = 0);
|
||||
|
||||
int GetWidth() const;
|
||||
int GetHeight() const;
|
||||
|
||||
DWORD * GetBasePointer();
|
||||
DWORD * GetLinePointer(int line);
|
||||
|
||||
void PutImage(int x, int y, CImage* pImage);
|
||||
void FlipTopToBottom();
|
||||
|
||||
void SetFileName(const char* c_szFileName);
|
||||
|
||||
const std::string & GetFileNameString();
|
||||
|
||||
bool IsEmpty() const;
|
||||
|
||||
protected:
|
||||
void Initialize();
|
||||
|
||||
protected:
|
||||
DWORD * m_pdwColors;
|
||||
int m_width;
|
||||
int m_height;
|
||||
|
||||
std::string m_stFileName;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,37 @@
|
||||
#ifndef __INC_ETERIMAGELIB_TGAIMAGE_H__
|
||||
#define __INC_ETERIMAGELIB_TGAIMAGE_H__
|
||||
|
||||
#include "Image.h"
|
||||
|
||||
class CTGAImage : public CImage
|
||||
{
|
||||
public:
|
||||
enum ETGAImageFlags
|
||||
{
|
||||
FLAG_RLE_COMPRESS = (1 << 0)
|
||||
};
|
||||
|
||||
CTGAImage();
|
||||
CTGAImage(CImage &image);
|
||||
virtual ~CTGAImage();
|
||||
|
||||
virtual void Create(int width, int height);
|
||||
virtual bool LoadFromMemory(int iSize, const BYTE * c_pbMem);
|
||||
virtual bool LoadFromDiskFile(const char * c_szFileName);
|
||||
virtual bool SaveToDiskFile(const char* c_szFileName);
|
||||
|
||||
void SetCompressed(bool isCompress = true);
|
||||
void SetAlphaChannel(bool isExist = true);
|
||||
|
||||
TGA_HEADER & GetHeader();
|
||||
protected:
|
||||
int GetRawPixelCount(const DWORD * data);
|
||||
int GetRLEPixelCount(const DWORD * data);
|
||||
|
||||
protected:
|
||||
TGA_HEADER m_Header;
|
||||
DWORD m_dwFlag;
|
||||
DWORD * m_pdwEndPtr;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,149 @@
|
||||
#pragma once
|
||||
|
||||
#include "GrpScreen.h"
|
||||
|
||||
#include "../EterBase/Singleton.h"
|
||||
#include "../SphereLib/spherepack.h"
|
||||
|
||||
class CGraphicObjectInstance;
|
||||
template <class T>
|
||||
struct RangeTester : public SpherePackCallback
|
||||
{
|
||||
T * f;
|
||||
float dist;
|
||||
RangeTester(T * fn, float distance=-1)
|
||||
: f(fn), dist(distance)
|
||||
{}
|
||||
|
||||
virtual ~RangeTester()
|
||||
{}
|
||||
|
||||
|
||||
virtual void RayTraceCallback(const Vector3d &p1, // source pos of ray
|
||||
const Vector3d &dir, // dest pos of ray
|
||||
float distance,
|
||||
const Vector3d §,
|
||||
SpherePack *sphere)
|
||||
{
|
||||
#ifdef SPHERELIB_STRICT
|
||||
if (sphere->IS_SPHERE)
|
||||
puts("RangeTester::RayTraceCallback");
|
||||
#endif
|
||||
if (dist<=0.0f || dist>=distance)
|
||||
(*f)((CGraphicObjectInstance *)sphere->GetUserData());
|
||||
};
|
||||
|
||||
|
||||
virtual void VisibilityCallback(const Frustum &f,SpherePack *sphere,ViewState state){};
|
||||
|
||||
virtual void RangeTestCallback(const Vector3d &p,float distance,SpherePack *sphere,ViewState state)
|
||||
{
|
||||
#ifdef SPHERELIB_STRICT
|
||||
if (sphere->IS_SPHERE)
|
||||
puts("RangeTester::RangeTestCallback");
|
||||
#endif
|
||||
if (state!=VS_OUTSIDE)
|
||||
(*f)((CGraphicObjectInstance *)sphere->GetUserData());
|
||||
}
|
||||
|
||||
virtual void PointTest2dCallback(const Vector3d &p, SpherePack *sphere,ViewState state)
|
||||
{
|
||||
#ifdef SPHERELIB_STRICT
|
||||
if (sphere->IS_SPHERE)
|
||||
puts("RangeTester::PointTest2dCallback");
|
||||
#endif
|
||||
if (state!=VS_OUTSIDE)
|
||||
{
|
||||
#ifdef SPHERELIB_STRICT
|
||||
puts("FIND!!");
|
||||
#endif
|
||||
(*f)((CGraphicObjectInstance *)sphere->GetUserData());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class CCullingManager : public CSingleton<CCullingManager>, public SpherePackCallback, private CScreen
|
||||
{
|
||||
public:
|
||||
typedef SpherePack * CullingHandle;
|
||||
typedef std::vector<CGraphicObjectInstance *> TRangeList;
|
||||
|
||||
CCullingManager();
|
||||
virtual ~CCullingManager();
|
||||
|
||||
virtual void RayTraceCallback(const Vector3d &p1, // source pos of ray
|
||||
const Vector3d &dir, // dest pos of ray
|
||||
float distance,
|
||||
const Vector3d §,
|
||||
SpherePack *sphere);
|
||||
|
||||
|
||||
virtual void VisibilityCallback(const Frustum &f,SpherePack *sphere,ViewState state);
|
||||
|
||||
void RangeTestCallback(const Vector3d &p,float distance,SpherePack *sphere,ViewState state);
|
||||
|
||||
void Reset();
|
||||
void Update();
|
||||
void Process();
|
||||
|
||||
void FindRange(const Vector3d &p, float radius);
|
||||
void FindRay(const Vector3d &p1, const Vector3d &dir);
|
||||
void FindRayDistance(const Vector3d &p1, const Vector3d &dir, float distance);
|
||||
|
||||
void RangeTest(const Vector3d& p, float radius, SpherePackCallback* callback)
|
||||
{
|
||||
m_Factory->RangeTest(p, radius, callback);
|
||||
}
|
||||
|
||||
void PointTest2d(const Vector3d& p, SpherePackCallback* callback)
|
||||
{
|
||||
m_Factory->PointTest2d(p, callback);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void ForInRange2d(const Vector3d& p, T* pFunc)
|
||||
{
|
||||
RangeTester<T> r(pFunc);
|
||||
m_Factory->PointTest2d(p, &r);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void ForInRange(const Vector3d &p, float radius, T* pFunc)
|
||||
{
|
||||
RangeTester<T> r(pFunc);
|
||||
m_Factory->RangeTest(p, radius, &r/*this*/);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void ForInRay(const Vector3d &p1, const Vector3d &dir, T* pFunc)
|
||||
{
|
||||
RangeTester<T> r(pFunc);
|
||||
/*Vector3d p2;
|
||||
//p2.Set(p.x+(dir.x*50000.0f),p.y+(dir.y*50000.0f),p.z+(dir.z*50000.0f));
|
||||
p2.x = p.x+50000.0f*dir.x;
|
||||
p2.y = p.y+50000.0f*dir.y;
|
||||
p2.z = p.z+50000.0f*dir.z;
|
||||
// p + (50000.0f*dir);//(p.x+(dir.x*50000.0f),p.y+(dir.y*50000.0f),p.z+(dir.z*50000.0f));*/
|
||||
m_Factory->RayTrace(p1, dir, &r/*this*/);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void ForInRayDistance(const Vector3d &p, const Vector3d &dir, float distance, T* pFunc)
|
||||
{
|
||||
RangeTester<T> r(pFunc, distance);
|
||||
m_Factory->RayTrace(p, dir, &r/*this*/);
|
||||
}
|
||||
|
||||
CullingHandle Register(CGraphicObjectInstance * ob);
|
||||
void Unregister(CullingHandle h);
|
||||
|
||||
TRangeList::iterator begin() { return m_list.begin(); }
|
||||
TRangeList::iterator end() { return m_list.end(); }
|
||||
|
||||
protected:
|
||||
TRangeList m_list;
|
||||
|
||||
float m_RayFarDistance;
|
||||
|
||||
SpherePackFactory * m_Factory;
|
||||
};
|
||||
@@ -0,0 +1,103 @@
|
||||
// Decal.h: interface for the CDecal class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_DECAL_H__E3D27DFC_30CB_4995_B9B9_396B5E8A5F02__INCLUDED_)
|
||||
#define AFX_DECAL_H__E3D27DFC_30CB_4995_B9B9_396B5E8A5F02__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include "GrpBase.h"
|
||||
|
||||
class CDecal
|
||||
{
|
||||
public:
|
||||
|
||||
enum
|
||||
{
|
||||
MAX_DECAL_VERTICES = 256,
|
||||
};
|
||||
|
||||
CDecal();
|
||||
virtual ~CDecal();
|
||||
|
||||
void Clear();
|
||||
|
||||
virtual void Make(D3DXVECTOR3 v3Center, D3DXVECTOR3 v3Normal, D3DXVECTOR3 v3Tangent, float fWidth, float fHeight, float fDepth) = 0;
|
||||
// virtual void Update();
|
||||
virtual void Render();
|
||||
|
||||
protected:
|
||||
//
|
||||
D3DXVECTOR3 m_v3Center;
|
||||
D3DXVECTOR3 m_v3Normal;
|
||||
|
||||
// Clip Plane
|
||||
D3DXPLANE m_v4LeftPlane;
|
||||
D3DXPLANE m_v4RightPlane;
|
||||
D3DXPLANE m_v4BottomPlane;
|
||||
D3DXPLANE m_v4TopPlane;
|
||||
D3DXPLANE m_v4FrontPlane;
|
||||
D3DXPLANE m_v4BackPlane;
|
||||
|
||||
// 개수
|
||||
DWORD m_dwVertexCount;
|
||||
DWORD m_dwPrimitiveCount;
|
||||
|
||||
// 버택스 버퍼와 인댁스 버퍼
|
||||
// CGraphicVertexBuffer m_GraphicVertexBuffer;
|
||||
// CGraphicIndexBuffer m_GraphicIndexBuffer;
|
||||
|
||||
// 버택스 버퍼와 인댁스 버퍼 대신에 배열 만들고 DrawIndexedPrimitiveUP로 그리자.
|
||||
typedef struct
|
||||
{
|
||||
WORD m_wMinIndex;
|
||||
DWORD m_dwVertexCount;
|
||||
DWORD m_dwPrimitiveCount;
|
||||
DWORD m_dwVBOffset;
|
||||
} TTRIANGLEFANSTRUCT;
|
||||
|
||||
std::vector<TTRIANGLEFANSTRUCT> m_TriangleFanStructVector;
|
||||
|
||||
TPDTVertex m_Vertices[MAX_DECAL_VERTICES];
|
||||
WORD m_Indices[MAX_DECAL_VERTICES];
|
||||
|
||||
const float m_cfDecalEpsilon;
|
||||
|
||||
protected:
|
||||
bool AddPolygon(DWORD dwAddCount, const D3DXVECTOR3 *c_pv3Vertex, const D3DXVECTOR3 *c_pv3Normal);
|
||||
void ClipMesh(DWORD dwPrimitiveCount, const D3DXVECTOR3 *c_pv3Vertex, const D3DXVECTOR3 *c_pv3Normal);
|
||||
DWORD ClipPolygon(DWORD dwVertexCount,
|
||||
const D3DXVECTOR3 *c_pv3Vertex,
|
||||
const D3DXVECTOR3 *c_pv3Normal,
|
||||
D3DXVECTOR3 *c_pv3NewVertex,
|
||||
D3DXVECTOR3 *c_pv3NewNormal) const;
|
||||
static DWORD ClipPolygonAgainstPlane(const D3DXPLANE& v4Plane,
|
||||
DWORD dwVertexCount,
|
||||
const D3DXVECTOR3 *c_pv3Vertex,
|
||||
const D3DXVECTOR3 *c_pv3Normal,
|
||||
D3DXVECTOR3 *c_pv3NewVertex,
|
||||
D3DXVECTOR3 *c_pv3NewNormal);
|
||||
};
|
||||
/*
|
||||
|
||||
class CDecalManager : public CSingleton<CDecalManager>
|
||||
{
|
||||
public:
|
||||
CDecalManager();
|
||||
~CDecalManager();
|
||||
|
||||
void Add(CDecal * pDecal);
|
||||
void Remove(CDecal * pDecal);
|
||||
void Update();
|
||||
void Render();
|
||||
|
||||
private:
|
||||
std::vector<CDecal *> m_DecalPtrVector;
|
||||
|
||||
};
|
||||
|
||||
*/
|
||||
#endif // !defined(AFX_DECAL_H__E3D27DFC_30CB_4995_B9B9_396B5E8A5F02__INCLUDED_)
|
||||
@@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
|
||||
#include "GrpDIB.h"
|
||||
|
||||
class CBlockTexture;
|
||||
|
||||
class CDibBar
|
||||
{
|
||||
public:
|
||||
CDibBar();
|
||||
virtual ~CDibBar();
|
||||
|
||||
bool Create(HDC hdc, DWORD dwWidth, DWORD dwHeight);
|
||||
void Invalidate();
|
||||
void SetClipRect(const RECT & c_rRect);
|
||||
void ClearBar();
|
||||
void Render(int ix, int iy);
|
||||
|
||||
protected:
|
||||
DWORD __NearTextureSize(DWORD dwSize);
|
||||
void __DivideTextureSize(DWORD dwSize, DWORD dwMax, DWORD * pdwxStep, DWORD * pdwxCount, DWORD * pdwxRest);
|
||||
CBlockTexture * __BuildTextureBlock(DWORD dwxPos, DWORD dwyPos, DWORD dwImageWidth, DWORD dwImageHeight, DWORD dwTextureWidth, DWORD dwTextureHeight);
|
||||
void __BuildTextureBlockList(DWORD dwWidth, DWORD dwHeight, DWORD dwMax=256);
|
||||
|
||||
virtual void OnCreate(){}
|
||||
|
||||
protected:
|
||||
CGraphicDib m_dib;
|
||||
std::vector<CBlockTexture *> m_kVec_pkBlockTexture;
|
||||
|
||||
DWORD m_dwWidth;
|
||||
DWORD m_dwHeight;
|
||||
};
|
||||
@@ -0,0 +1,63 @@
|
||||
#ifndef __INC_YMIR_ETERLIB_FILELOADERTHREAD_H__
|
||||
#define __INC_YMIR_ETERLIB_FILELOADERTHREAD_H__
|
||||
|
||||
#include <deque>
|
||||
#include "Thread.h"
|
||||
#include "Mutex.h"
|
||||
#include "../EterBase/MappedFile.h"
|
||||
|
||||
class CFileLoaderThread
|
||||
{
|
||||
public:
|
||||
typedef struct SData
|
||||
{
|
||||
std::string stFileName;
|
||||
|
||||
CMappedFile File;
|
||||
LPVOID pvBuf;
|
||||
DWORD dwSize;
|
||||
} TData;
|
||||
|
||||
public:
|
||||
CFileLoaderThread();
|
||||
~CFileLoaderThread();
|
||||
|
||||
int Create(void * arg);
|
||||
|
||||
public:
|
||||
void Request(std::string & c_rstFileName);
|
||||
bool Fetch(TData ** ppData);
|
||||
void Shutdown();
|
||||
|
||||
protected:
|
||||
static UINT CALLBACK EntryPoint(void * pThis);
|
||||
UINT Run(void * arg);
|
||||
|
||||
void * Arg() const { return m_pArg; }
|
||||
void Arg(void * arg) { m_pArg = arg; }
|
||||
|
||||
HANDLE m_hThread;
|
||||
|
||||
private:
|
||||
void * m_pArg;
|
||||
unsigned m_uThreadID;
|
||||
|
||||
protected:
|
||||
UINT Setup();
|
||||
UINT Execute(void * pvArg);
|
||||
void Destroy();
|
||||
void Process();
|
||||
|
||||
private:
|
||||
std::deque<TData *> m_pRequestDeque;
|
||||
Mutex m_RequestMutex;
|
||||
|
||||
std::deque<TData *> m_pCompleteDeque;
|
||||
Mutex m_CompleteMutex;
|
||||
|
||||
HANDLE m_hSemaphore;
|
||||
int m_iRestSemCount;
|
||||
bool m_bShutdowned;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
class CGraphicColor
|
||||
{
|
||||
public:
|
||||
CGraphicColor(const CGraphicColor& c_rSrcColor);
|
||||
CGraphicColor(float r, float g, float b, float a);
|
||||
CGraphicColor(DWORD color);
|
||||
|
||||
CGraphicColor();
|
||||
~CGraphicColor();
|
||||
|
||||
void Clear();
|
||||
|
||||
void Set(float r, float g, float b, float a);
|
||||
void Set(const CGraphicColor& c_rSrcColor);
|
||||
void Set(DWORD color);
|
||||
|
||||
void Blend(float p, const CGraphicColor& c_rSrcColor, const CGraphicColor& c_rDstColor);
|
||||
|
||||
DWORD GetPackValue() const;
|
||||
|
||||
protected:
|
||||
float m_r;
|
||||
float m_g;
|
||||
float m_b;
|
||||
float m_a;
|
||||
};
|
||||
@@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
|
||||
#include "GrpColor.h"
|
||||
#include "Pool.h"
|
||||
|
||||
class CGraphicColorInstance
|
||||
{
|
||||
public:
|
||||
CGraphicColorInstance();
|
||||
virtual ~CGraphicColorInstance();
|
||||
|
||||
void Clear();
|
||||
|
||||
void SetColorReference(const CGraphicColor& c_rSrcColor);
|
||||
void BlendColorReference(DWORD blendTime, const CGraphicColor& c_rDstColor);
|
||||
|
||||
void Update();
|
||||
|
||||
const CGraphicColor& GetCurrentColorReference() const;
|
||||
|
||||
protected:
|
||||
DWORD GetCurrentTime();
|
||||
|
||||
protected:
|
||||
CGraphicColor m_srcColor;
|
||||
CGraphicColor m_dstColor;
|
||||
CGraphicColor m_curColor;
|
||||
|
||||
DWORD m_baseTime;
|
||||
DWORD m_blendTime;
|
||||
};
|
||||
|
||||
typedef CDynamicPool<CGraphicColorInstance> TGraphicColorInstancePool;
|
||||
@@ -0,0 +1,35 @@
|
||||
#pragma once
|
||||
|
||||
class CGraphicDib
|
||||
{
|
||||
public:
|
||||
CGraphicDib();
|
||||
virtual ~CGraphicDib();
|
||||
|
||||
void Destroy();
|
||||
bool Create(HDC hDC, int width, int height);
|
||||
|
||||
void SetBkMode(int iBkMode);
|
||||
void TextOut(int ix, int iy, const char * c_szText);
|
||||
void Put(HDC hDC, int x, int y);
|
||||
|
||||
int GetWidth();
|
||||
int GetHeight();
|
||||
|
||||
void* GetPointer();
|
||||
|
||||
HDC GetDCHandle();
|
||||
|
||||
protected:
|
||||
void Initialize();
|
||||
|
||||
protected:
|
||||
HDC m_hDC;
|
||||
HBITMAP m_hBmp;
|
||||
BITMAPINFO m_bmi;
|
||||
|
||||
int m_width;
|
||||
int m_height;
|
||||
|
||||
void * m_pvBuf;
|
||||
};
|
||||
@@ -0,0 +1,74 @@
|
||||
#pragma once
|
||||
|
||||
#include "GrpBase.h"
|
||||
#include "GrpDetector.h"
|
||||
#include "StateManager.h"
|
||||
|
||||
class CGraphicDevice : public CGraphicBase
|
||||
{
|
||||
public:
|
||||
enum EDeviceState
|
||||
{
|
||||
DEVICESTATE_OK,
|
||||
DEVICESTATE_BROKEN,
|
||||
DEVICESTATE_NEEDS_RESET,
|
||||
DEVICESTATE_NULL
|
||||
};
|
||||
|
||||
enum ECreateReturnValues
|
||||
{
|
||||
CREATE_OK = (1 << 0),
|
||||
CREATE_NO_DIRECTX = (1 << 1),
|
||||
CREATE_GET_DEVICE_CAPS = (1 << 2),
|
||||
CREATE_GET_DEVICE_CAPS2 = (1 << 3),
|
||||
CREATE_DEVICE = (1 << 4),
|
||||
CREATE_REFRESHRATE = (1 << 5),
|
||||
CREATE_ENUM = (1 << 6), // 2003. 01. 09. myevan 모드 리스트 얻기 실패
|
||||
CREATE_DETECT = (1 << 7), // 2003. 01. 09. myevan 모드 선택 실패
|
||||
CREATE_NO_TNL = (1 << 8),
|
||||
CREATE_BAD_DRIVER = (1 << 9),
|
||||
CREATE_FORMAT = (1 << 10),
|
||||
};
|
||||
|
||||
CGraphicDevice();
|
||||
virtual ~CGraphicDevice();
|
||||
|
||||
void InitBackBufferCount(UINT uBackBufferCount);
|
||||
|
||||
void Destroy();
|
||||
int Create(HWND hWnd, int hres, int vres, bool Windowed = true, int bit = 32, int ReflashRate = 0);
|
||||
|
||||
EDeviceState GetDeviceState();
|
||||
bool Reset();
|
||||
|
||||
void EnableWebBrowserMode(const RECT& c_rcWebPage);
|
||||
void DisableWebBrowserMode();
|
||||
void MoveWebBrowserRect(const RECT& c_rcWebPage);
|
||||
|
||||
bool ResizeBackBuffer(UINT uWidth, UINT uHeight);
|
||||
void RegisterWarningString(UINT uiMsg, const char * c_szString);
|
||||
|
||||
protected:
|
||||
void __Initialize();
|
||||
bool __IsInDriverBlackList(D3D_CAdapterInfo& rkD3DAdapterInfo);
|
||||
void __WarningMessage(HWND hWnd, UINT uiMsg);
|
||||
|
||||
void __InitializeDefaultIndexBufferList();
|
||||
void __DestroyDefaultIndexBufferList();
|
||||
bool __CreateDefaultIndexBufferList();
|
||||
bool __CreateDefaultIndexBuffer(UINT eDefIB, UINT uIdxCount, const WORD* c_awIndices);
|
||||
|
||||
void __InitializePDTVertexBufferList();
|
||||
void __DestroyPDTVertexBufferList();
|
||||
bool __CreatePDTVertexBufferList();
|
||||
|
||||
DWORD CreatePTStreamVertexShader();
|
||||
DWORD CreatePNTStreamVertexShader();
|
||||
DWORD CreatePNT2StreamVertexShader();
|
||||
DWORD CreateDoublePNTStreamVertexShader();
|
||||
|
||||
protected:
|
||||
DWORD m_uBackBufferCount;
|
||||
std::map<UINT, std::string> m_kMap_strWarningMessage;
|
||||
CStateManager* m_pStateManager;
|
||||
};
|
||||
@@ -0,0 +1,61 @@
|
||||
#pragma once
|
||||
|
||||
#include "GrpImageInstance.h"
|
||||
|
||||
class CGraphicExpandedImageInstance : public CGraphicImageInstance
|
||||
{
|
||||
public:
|
||||
static DWORD Type();
|
||||
static void DeleteExpandedImageInstance(CGraphicExpandedImageInstance * pkInstance)
|
||||
{
|
||||
pkInstance->Destroy();
|
||||
ms_kPool.Free(pkInstance);
|
||||
}
|
||||
|
||||
enum ERenderingMode
|
||||
{
|
||||
RENDERING_MODE_NORMAL,
|
||||
RENDERING_MODE_SCREEN,
|
||||
RENDERING_MODE_COLOR_DODGE,
|
||||
RENDERING_MODE_MODULATE,
|
||||
};
|
||||
|
||||
public:
|
||||
CGraphicExpandedImageInstance();
|
||||
virtual ~CGraphicExpandedImageInstance();
|
||||
|
||||
void Destroy();
|
||||
|
||||
void SetDepth(float fDepth);
|
||||
void SetOrigin();
|
||||
void SetOrigin(float fx, float fy);
|
||||
void SetRotation(float fRotation);
|
||||
void SetScale(float fx, float fy);
|
||||
void SetRenderingRect(float fLeft, float fTop, float fRight, float fBottom);
|
||||
void SetRenderingMode(int iMode);
|
||||
|
||||
protected:
|
||||
void Initialize();
|
||||
|
||||
void OnRender();
|
||||
void OnSetImagePointer();
|
||||
|
||||
BOOL OnIsType(DWORD dwType);
|
||||
|
||||
protected:
|
||||
float m_fDepth;
|
||||
D3DXVECTOR2 m_v2Origin;
|
||||
D3DXVECTOR2 m_v2Scale;
|
||||
float m_fRotation;
|
||||
RECT m_RenderingRect;
|
||||
int m_iRenderingMode;
|
||||
|
||||
public:
|
||||
static void CreateSystem(UINT uCapacity);
|
||||
static void DestroySystem();
|
||||
|
||||
static CGraphicExpandedImageInstance* New();
|
||||
static void Delete(CGraphicExpandedImageInstance* pkImgInst);
|
||||
|
||||
static CDynamicPool<CGraphicExpandedImageInstance> ms_kPool;
|
||||
};
|
||||
@@ -0,0 +1,81 @@
|
||||
#pragma once
|
||||
|
||||
#include "GrpTexture.h"
|
||||
#include "GrpImageTexture.h"
|
||||
#include "GrpDIB.h"
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
class CGraphicFontTexture : public CGraphicTexture
|
||||
{
|
||||
public:
|
||||
typedef std::pair<WORD,wchar_t> TCharacterKey;
|
||||
|
||||
typedef struct SCharacterInfomation
|
||||
{
|
||||
short index;
|
||||
short width;
|
||||
short height;
|
||||
float left;
|
||||
float top;
|
||||
float right;
|
||||
float bottom;
|
||||
float advance;
|
||||
} TCharacterInfomation;
|
||||
|
||||
typedef std::vector<TCharacterInfomation*> TPCharacterInfomationVector;
|
||||
|
||||
public:
|
||||
CGraphicFontTexture();
|
||||
virtual ~CGraphicFontTexture();
|
||||
|
||||
void Destroy();
|
||||
bool Create(const char* c_szFontName, int fontSize, bool bItalic);
|
||||
|
||||
bool CreateDeviceObjects();
|
||||
void DestroyDeviceObjects();
|
||||
|
||||
bool CheckTextureIndex(DWORD dwTexture);
|
||||
void SelectTexture(DWORD dwTexture);
|
||||
|
||||
bool UpdateTexture();
|
||||
|
||||
TCharacterInfomation* GetCharacterInfomation(WORD codePage, wchar_t keyValue);
|
||||
TCharacterInfomation* UpdateCharacterInfomation(TCharacterKey code);
|
||||
|
||||
bool IsEmpty() const;
|
||||
|
||||
protected:
|
||||
void Initialize();
|
||||
|
||||
bool AppendTexture();
|
||||
|
||||
HFONT GetFont(WORD codePage);
|
||||
|
||||
protected:
|
||||
typedef std::vector<CGraphicImageTexture*> TGraphicImageTexturePointerVector;
|
||||
typedef std::map<TCharacterKey, TCharacterInfomation> TCharacterInfomationMap;
|
||||
typedef std::map<WORD, HFONT> TFontMap;
|
||||
|
||||
protected:
|
||||
CGraphicDib m_dib;
|
||||
|
||||
HFONT m_hFontOld;
|
||||
HFONT m_hFont;
|
||||
|
||||
TGraphicImageTexturePointerVector m_pFontTextureVector;
|
||||
|
||||
TCharacterInfomationMap m_charInfoMap;
|
||||
|
||||
TFontMap m_fontMap;
|
||||
|
||||
int m_x;
|
||||
int m_y;
|
||||
int m_step;
|
||||
bool m_isDirty;
|
||||
|
||||
TCHAR m_fontName[LF_FACESIZE];
|
||||
LONG m_fontSize;
|
||||
bool m_bItalic;
|
||||
};
|
||||
@@ -0,0 +1,127 @@
|
||||
#pragma once
|
||||
|
||||
#include "../EterBase/Singleton.h"
|
||||
|
||||
#include "GrpBase.h"
|
||||
#include "Util.h"
|
||||
#include "Pool.h"
|
||||
|
||||
#include <deque>
|
||||
|
||||
typedef DWORD TLightID;
|
||||
|
||||
enum ELightType
|
||||
{
|
||||
LIGHT_TYPE_STATIC, // Continuously turning on light
|
||||
LIGHT_TYPE_DYNAMIC, // Immediately turning off light
|
||||
};
|
||||
|
||||
class CLightBase
|
||||
{
|
||||
public:
|
||||
CLightBase() {};
|
||||
virtual ~CLightBase() {};
|
||||
|
||||
void SetCurrentTime();
|
||||
|
||||
protected:
|
||||
static float ms_fCurTime;
|
||||
};
|
||||
|
||||
class CLight : public CGraphicBase, public CLightBase
|
||||
{
|
||||
public:
|
||||
CLight();
|
||||
virtual ~CLight();
|
||||
|
||||
void Initialize();
|
||||
void Clear();
|
||||
|
||||
void Update();
|
||||
|
||||
void SetParameter(TLightID id, const D3DLIGHT8 & c_rLight);
|
||||
|
||||
void SetDistance(float fDistance);
|
||||
float GetDistance() const { return m_fDistance; }
|
||||
|
||||
TLightID GetLightID() { return m_LightID; }
|
||||
|
||||
BOOL isEdited() { return m_isEdited; }
|
||||
void SetDeviceLight(BOOL bActive);
|
||||
|
||||
void SetDiffuseColor(float fr, float fg, float fb, float fa = 1.0f);
|
||||
void SetAmbientColor(float fr, float fg, float fb, float fa = 1.0f);
|
||||
void SetRange(float fRange);
|
||||
void SetPosition(float fx, float fy, float fz);
|
||||
|
||||
const D3DVECTOR & GetPosition() const;
|
||||
|
||||
void BlendDiffuseColor(const D3DXCOLOR & c_rColor, float fBlendTime, float fDelayTime = 0.0f);
|
||||
void BlendAmbientColor(const D3DXCOLOR & c_rColor, float fBlendTime, float fDelayTime = 0.0f);
|
||||
void BlendRange(float fRange, float fBlendTime, float fDelayTime = 0.0f);
|
||||
|
||||
private:
|
||||
TLightID m_LightID; // Light ID. equal to D3D light index
|
||||
|
||||
D3DLIGHT8 m_d3dLight;
|
||||
BOOL m_isEdited;
|
||||
float m_fDistance;
|
||||
|
||||
TTransitorColor m_DiffuseColorTransitor;
|
||||
TTransitorColor m_AmbientColorTransitor;
|
||||
TTransitorFloat m_RangeTransitor;
|
||||
};
|
||||
|
||||
class CLightManager : public CGraphicBase, public CLightBase, public CSingleton<CLightManager>
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
LIGHT_LIMIT_DEFAULT = 3,
|
||||
// LIGHT_MAX_NUM = 32,
|
||||
};
|
||||
|
||||
typedef std::deque<TLightID> TLightIDDeque;
|
||||
typedef std::map<TLightID, CLight *> TLightMap;
|
||||
typedef std::vector<CLight *> TLightSortVector;
|
||||
|
||||
public:
|
||||
CLightManager();
|
||||
virtual ~CLightManager();
|
||||
|
||||
void Destroy();
|
||||
|
||||
void Initialize();
|
||||
|
||||
// NOTE : FlushLight후 렌더링
|
||||
// 그 후 반드시 RestoreLight를 해줘야만 한다.
|
||||
void Update();
|
||||
void FlushLight();
|
||||
void RestoreLight();
|
||||
|
||||
/////
|
||||
void RegisterLight(ELightType LightType, TLightID * poutLightID, D3DLIGHT8 & LightData);
|
||||
CLight * GetLight(TLightID LightID);
|
||||
void DeleteLight(TLightID LightID);
|
||||
/////
|
||||
|
||||
void SetCenterPosition(const D3DXVECTOR3 & c_rv3Position);
|
||||
void SetLimitLightCount(DWORD dwLightCount);
|
||||
void SetSkipIndex(DWORD dwSkipIndex);
|
||||
|
||||
protected:
|
||||
TLightIDDeque m_NonUsingLightIDDeque;
|
||||
|
||||
TLightMap m_LightMap;
|
||||
TLightSortVector m_LightSortVector;
|
||||
|
||||
D3DXVECTOR3 m_v3CenterPosition;
|
||||
DWORD m_dwLimitLightCount;
|
||||
DWORD m_dwSkipIndex;
|
||||
|
||||
protected:
|
||||
TLightID NewLightID();
|
||||
void ReleaseLightID(TLightID LightID);
|
||||
|
||||
CDynamicPool<CLight> m_LightPool;
|
||||
};
|
||||
@@ -0,0 +1,77 @@
|
||||
#pragma once
|
||||
|
||||
#include "GrpImage.h"
|
||||
#include "Pool.h"
|
||||
|
||||
class CGraphicMarkInstance
|
||||
{
|
||||
public:
|
||||
static DWORD Type();
|
||||
BOOL IsType(DWORD dwType);
|
||||
|
||||
void SetImageFileName(const char* c_szFileName);
|
||||
const std::string& GetImageFileName();
|
||||
|
||||
public:
|
||||
CGraphicMarkInstance();
|
||||
virtual ~CGraphicMarkInstance();
|
||||
|
||||
void Destroy();
|
||||
|
||||
void Render();
|
||||
|
||||
void SetDepth(float fDepth);
|
||||
void SetDiffuseColor(float fr, float fg, float fb, float fa);
|
||||
void SetPosition(float fx, float fy);
|
||||
void SetIndex(UINT uIndex);
|
||||
void SetScale(float fScale);
|
||||
|
||||
void Load();
|
||||
bool IsEmpty() const;
|
||||
|
||||
int GetWidth();
|
||||
int GetHeight();
|
||||
|
||||
CGraphicTexture * GetTexturePointer();
|
||||
const CGraphicTexture & GetTextureReference() const;
|
||||
CGraphicImage * GetGraphicImagePointer();
|
||||
|
||||
bool operator == (const CGraphicMarkInstance & rhs) const;
|
||||
|
||||
protected:
|
||||
enum
|
||||
{
|
||||
MARK_WIDTH = 16,
|
||||
MARK_HEIGHT = 12,
|
||||
};
|
||||
|
||||
void Initialize();
|
||||
|
||||
virtual void OnRender();
|
||||
virtual void OnSetImagePointer();
|
||||
|
||||
virtual BOOL OnIsType(DWORD dwType);
|
||||
|
||||
void SetImagePointer(CGraphicImage * pImage);
|
||||
|
||||
protected:
|
||||
D3DXCOLOR m_DiffuseColor;
|
||||
D3DXVECTOR2 m_v2Position;
|
||||
|
||||
UINT m_uIndex;
|
||||
|
||||
FLOAT m_fScale;
|
||||
FLOAT m_fDepth;
|
||||
|
||||
CGraphicImage::TRef m_roImage;
|
||||
std::string m_stImageFileName;
|
||||
|
||||
public:
|
||||
static void CreateSystem(UINT uCapacity);
|
||||
static void DestroySystem();
|
||||
|
||||
static CGraphicMarkInstance* New();
|
||||
static void Delete(CGraphicMarkInstance* pkImgInst);
|
||||
|
||||
static CDynamicPool<CGraphicMarkInstance> ms_kPool;
|
||||
};
|
||||
@@ -0,0 +1,122 @@
|
||||
#pragma once
|
||||
|
||||
float CrossProduct2D(float x1, float y1, float x2, float y2);
|
||||
|
||||
bool IsInTriangle2D(float ax, float ay, float bx, float by, float cx, float cy, float tx, float ty);
|
||||
|
||||
D3DXVECTOR3* D3DXVec3Rotation(D3DXVECTOR3* pvtOut, const D3DXVECTOR3* c_pvtSrc, const D3DXQUATERNION* c_pqtRot);
|
||||
D3DXVECTOR3* D3DXVec3Translation(D3DXVECTOR3* pvtOut, const D3DXVECTOR3* c_pvtSrc, const D3DXVECTOR3* c_pvtTrans);
|
||||
|
||||
void GetRotationFromMatrix(D3DXVECTOR3 * pRotation, const D3DXMATRIX * c_pMatrix);
|
||||
void GetPivotAndRotationFromMatrix(D3DXMATRIX * pMatrix, D3DXVECTOR3 * pPivot, D3DXVECTOR3 * pRotation);
|
||||
void ExtractMovement(D3DXMATRIX * pTargetMatrix, D3DXMATRIX * pSourceMatrix);
|
||||
|
||||
inline D3DXVECTOR3* D3DXVec3Blend(D3DXVECTOR3* pvtOut, const D3DXVECTOR3* c_pvtSrc1, const D3DXVECTOR3* c_pvtSrc2, float d)
|
||||
{
|
||||
pvtOut->x=c_pvtSrc1->x+d*(c_pvtSrc2->x-c_pvtSrc1->x);
|
||||
pvtOut->y=c_pvtSrc1->y+d*(c_pvtSrc2->y-c_pvtSrc1->y);
|
||||
pvtOut->z=c_pvtSrc1->z+d*(c_pvtSrc2->z-c_pvtSrc1->z);
|
||||
|
||||
return pvtOut;
|
||||
}
|
||||
|
||||
inline D3DXQUATERNION* D3DXQuaternionBlend(D3DXQUATERNION* pqtOut, const D3DXQUATERNION* c_pqtSrc1, const D3DXQUATERNION* c_pqtSrc2, float d)
|
||||
{
|
||||
pqtOut->x=c_pqtSrc1->x+d*(c_pqtSrc2->x-c_pqtSrc1->x);
|
||||
pqtOut->y=c_pqtSrc1->y+d*(c_pqtSrc2->y-c_pqtSrc1->y);
|
||||
pqtOut->z=c_pqtSrc1->z+d*(c_pqtSrc2->z-c_pqtSrc1->z);
|
||||
pqtOut->w=c_pqtSrc1->w+d*(c_pqtSrc2->w-c_pqtSrc1->w);
|
||||
return pqtOut;
|
||||
}
|
||||
|
||||
inline float ClampDegree(float fDegree)
|
||||
{
|
||||
if (fDegree >= 360.0f)
|
||||
fDegree -= 360.0f;
|
||||
if (fDegree < 0.0f)
|
||||
fDegree += 360.0f;
|
||||
|
||||
return fDegree;
|
||||
}
|
||||
|
||||
inline float GetVector3Distance(const D3DXVECTOR3 & c_rv3Source, const D3DXVECTOR3 & c_rv3Target)
|
||||
{
|
||||
return (c_rv3Source.x-c_rv3Target.x)*(c_rv3Source.x-c_rv3Target.x) + (c_rv3Source.y-c_rv3Target.y)*(c_rv3Source.y-c_rv3Target.y);
|
||||
}
|
||||
|
||||
inline D3DXQUATERNION SafeRotationNormalizedArc(const D3DXVECTOR3 & vFrom , const D3DXVECTOR3 & vTo)
|
||||
{
|
||||
if (vFrom == vTo)
|
||||
return D3DXQUATERNION(0.0f,0.0f,0.0f,1.0f);
|
||||
if (vFrom == -vTo)
|
||||
return D3DXQUATERNION(0.0f,0.0f,1.0f,0.0f);
|
||||
D3DXVECTOR3 c;
|
||||
D3DXVec3Cross(&c, &vFrom, &vTo);
|
||||
float d = D3DXVec3Dot(&vFrom, &vTo);
|
||||
float s = sqrtf((1+d)*2);
|
||||
|
||||
return D3DXQUATERNION(c.x/s,c.y/s,c.z/s,s*0.5f);
|
||||
}
|
||||
|
||||
inline D3DXQUATERNION RotationNormalizedArc(const D3DXVECTOR3 & vFrom , const D3DXVECTOR3 & vTo)
|
||||
|
||||
{
|
||||
D3DXVECTOR3 c;
|
||||
D3DXVec3Cross(&c, &vFrom, &vTo);
|
||||
float d = D3DXVec3Dot(&vFrom, &vTo);
|
||||
float s = sqrtf((1+d)*2);
|
||||
|
||||
return D3DXQUATERNION(c.x/s,c.y/s,c.z/s,s*0.5f);
|
||||
}
|
||||
|
||||
inline D3DXQUATERNION RotationArc(const D3DXVECTOR3 & vFrom , const D3DXVECTOR3 & vTo)
|
||||
{
|
||||
D3DXVECTOR3 vnFrom, vnTo;
|
||||
D3DXVec3Normalize(&vnFrom, &vFrom);
|
||||
D3DXVec3Normalize(&vnTo, &vTo);
|
||||
return RotationNormalizedArc(vnFrom, vnTo);
|
||||
}
|
||||
|
||||
inline float square_distance_between_linesegment_and_point(const D3DXVECTOR3& p1,const D3DXVECTOR3& p2,const D3DXVECTOR3& x)
|
||||
{
|
||||
const auto v1 = p2 - p1;
|
||||
float l = D3DXVec3LengthSq(&v1);
|
||||
const auto v2 = x - p1;
|
||||
const auto v3 = p2 - p1;
|
||||
float d = D3DXVec3Dot(&(v2),&(v3));
|
||||
if (d<=0.0f)
|
||||
{
|
||||
return D3DXVec3LengthSq(&(v2));
|
||||
}
|
||||
else if (d>=l)
|
||||
{
|
||||
const auto v4 = x - p2;
|
||||
return D3DXVec3LengthSq(&(v4));
|
||||
}
|
||||
else
|
||||
{
|
||||
D3DXVECTOR3 c;
|
||||
return D3DXVec3LengthSq(D3DXVec3Cross(&c,&(v2),&(v3)))/l;
|
||||
}
|
||||
}
|
||||
|
||||
inline D3DXVECTOR3 * Vec3TransformQuaternionSafe(D3DXVECTOR3* pvout, const D3DXVECTOR3* pv, const D3DXQUATERNION* pq)
|
||||
{
|
||||
D3DXVECTOR3 v;
|
||||
D3DXVec3Cross(&v,pv,(D3DXVECTOR3*)pq);
|
||||
v *= -2*pq->w;
|
||||
v += (pq->w*pq->w - D3DXVec3LengthSq((D3DXVECTOR3*)pq))*(*pv);
|
||||
v += 2*D3DXVec3Dot((D3DXVECTOR3*)pq,pv)*(*(D3DXVECTOR3*)pq);
|
||||
*pvout = v;
|
||||
return pvout;
|
||||
}
|
||||
|
||||
inline D3DXVECTOR3 * Vec3TransformQuaternion(D3DXVECTOR3* pvout, const D3DXVECTOR3* pv, const D3DXQUATERNION* pq)
|
||||
{
|
||||
D3DXVec3Cross(pvout,pv,(D3DXVECTOR3*)pq);
|
||||
*pvout *= -2*pq->w;
|
||||
*pvout += (pq->w*pq->w - D3DXVec3LengthSq((D3DXVECTOR3*)pq))*(*pv);
|
||||
*pvout += 2*D3DXVec3Dot((D3DXVECTOR3*)pq,pv)*(*(D3DXVECTOR3*)pq);
|
||||
|
||||
return pvout;
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
#pragma once
|
||||
|
||||
#include "GrpColorInstance.h"
|
||||
#include "GrpScreen.h"
|
||||
#include "CullingManager.h"
|
||||
#include "CollisionData.h"
|
||||
#include "AttributeInstance.h"
|
||||
|
||||
enum
|
||||
{
|
||||
THING_OBJECT = 0xadf21f13,
|
||||
TREE_OBJECT = 0x8ac9f7a6,
|
||||
ACTOR_OBJECT = 0x29a76c24,
|
||||
EFFECT_OBJECT = 0x1cfa97c6,
|
||||
DUNGEON_OBJECT = 0x18326035,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
PORTAL_ID_MAX_NUM = 8,
|
||||
};
|
||||
|
||||
class CGraphicObjectInstance : public CGraphicCollisionObject
|
||||
{
|
||||
public:
|
||||
CGraphicObjectInstance();
|
||||
virtual ~CGraphicObjectInstance();
|
||||
virtual int GetType() const = 0;
|
||||
|
||||
public:
|
||||
const D3DXVECTOR3 & GetPosition() const;
|
||||
const D3DXVECTOR3 & GetScale() const;
|
||||
float GetRotation();
|
||||
float GetYaw();
|
||||
float GetPitch();
|
||||
float GetRoll();
|
||||
|
||||
void SetPosition(float x, float y, float z);
|
||||
void SetPosition(const D3DXVECTOR3 & newposition);
|
||||
void SetScale(float x, float y, float z);
|
||||
void SetRotation(float fRotation);
|
||||
void SetRotation(float fYaw, float fPitch, float fRoll);
|
||||
void SetRotationQuaternion(const D3DXQUATERNION &q);
|
||||
void SetRotationMatrix(const D3DXMATRIX & m);
|
||||
|
||||
void Clear();
|
||||
void Update();
|
||||
bool Render();
|
||||
void BlendRender();
|
||||
void RenderToShadowMap();
|
||||
void RenderShadow();
|
||||
void RenderPCBlocker();
|
||||
void Deform();
|
||||
void Transform();
|
||||
|
||||
void Show();
|
||||
void Hide();
|
||||
bool isShow();
|
||||
|
||||
// Camera Block
|
||||
void BlockCamera(bool bBlock) {m_BlockCamera = bBlock;}
|
||||
bool BlockCamera() { return m_BlockCamera; }
|
||||
|
||||
// Ray Test
|
||||
bool isIntersect(const CRay & c_rRay, float * pu, float * pv, float * pt);
|
||||
|
||||
// Bounding Box
|
||||
D3DXVECTOR4 & GetWTBBoxVertex(const unsigned char & c_rucNumTBBoxVertex);
|
||||
D3DXVECTOR3 & GetTBBoxMin() { return m_v3TBBoxMin; }
|
||||
D3DXVECTOR3 & GetTBBoxMax() { return m_v3TBBoxMax; }
|
||||
D3DXVECTOR3 & GetBBoxMin() { return m_v3BBoxMin; }
|
||||
D3DXVECTOR3 & GetBBoxMax() { return m_v3BBoxMax; }
|
||||
|
||||
// Matrix
|
||||
D3DXMATRIX & GetTransform();
|
||||
const D3DXMATRIX& GetWorldMatrix() { return m_worldMatrix; }
|
||||
|
||||
// Portal
|
||||
void SetPortal(DWORD dwIndex, int iID);
|
||||
int GetPortal(DWORD dwIndex);
|
||||
|
||||
// Initialize
|
||||
void Initialize();
|
||||
virtual void OnInitialize();
|
||||
|
||||
// Bounding Sphere
|
||||
public:
|
||||
void UpdateBoundingSphere();
|
||||
void RegisterBoundingSphere();
|
||||
virtual bool GetBoundingSphere(D3DXVECTOR3 & v3Center, float & fRadius) = 0;
|
||||
|
||||
virtual void OnRender() = 0;
|
||||
virtual void OnBlendRender() = 0;
|
||||
virtual void OnRenderToShadowMap() = 0;
|
||||
virtual void OnRenderShadow() = 0;
|
||||
virtual void OnRenderPCBlocker() = 0;
|
||||
virtual void OnClear(){}
|
||||
virtual void OnUpdate(){}
|
||||
virtual void OnDeform(){}
|
||||
|
||||
protected:
|
||||
D3DXVECTOR3 m_v3Position;
|
||||
D3DXVECTOR3 m_v3Scale;
|
||||
|
||||
float m_fYaw;
|
||||
float m_fPitch;
|
||||
float m_fRoll;
|
||||
|
||||
D3DXMATRIX m_mRotation;
|
||||
|
||||
bool m_isVisible;
|
||||
D3DXMATRIX m_worldMatrix;
|
||||
|
||||
// Camera Block
|
||||
bool m_BlockCamera;
|
||||
|
||||
// Bounding Box
|
||||
D3DXVECTOR4 m_v4TBBox[8];
|
||||
D3DXVECTOR3 m_v3TBBoxMin, m_v3TBBoxMax;
|
||||
D3DXVECTOR3 m_v3BBoxMin, m_v3BBoxMax;
|
||||
|
||||
// Portal
|
||||
BYTE m_abyPortalID[PORTAL_ID_MAX_NUM];
|
||||
|
||||
// Culling
|
||||
CCullingManager::CullingHandle m_CullingHandle;
|
||||
|
||||
// Static Collision Data
|
||||
public:
|
||||
void AddCollision(const CStaticCollisionData * pscd, const D3DXMATRIX * pMat);
|
||||
void ClearCollision();
|
||||
bool CollisionDynamicSphere(const CDynamicSphereInstance & s) const;
|
||||
bool MovementCollisionDynamicSphere(const CDynamicSphereInstance & s) const;
|
||||
D3DXVECTOR3 GetCollisionMovementAdjust(const CDynamicSphereInstance & s) const;
|
||||
|
||||
void UpdateCollisionData(const CStaticCollisionDataVector * pscdVector = 0);
|
||||
|
||||
protected:
|
||||
CCollisionInstanceVector m_StaticCollisionInstanceVector;
|
||||
virtual void OnUpdateCollisionData(const CStaticCollisionDataVector * pscdVector) = 0;
|
||||
|
||||
// using in WorldEditor
|
||||
public:
|
||||
DWORD GetCollisionInstanceCount();
|
||||
CBaseCollisionInstance * GetCollisionInstanceData(DWORD dwIndex);
|
||||
|
||||
// Height Data
|
||||
public:
|
||||
void SetHeightInstance(CAttributeInstance * pAttributeInstance);
|
||||
void ClearHeightInstance();
|
||||
|
||||
void UpdateHeightInstance(CAttributeInstance * pAttributeInstance = 0);
|
||||
|
||||
bool IsObjectHeight();
|
||||
bool GetObjectHeight(float fX, float fY, float * pfHeight);
|
||||
|
||||
protected:
|
||||
CAttributeInstance * m_pHeightAttributeInstance;
|
||||
virtual void OnUpdateHeighInstance(CAttributeInstance * pAttributeInstance) = 0;
|
||||
virtual bool OnGetObjectHeight(float fX, float fY, float * pfHeight) = 0;
|
||||
};
|
||||
@@ -0,0 +1,35 @@
|
||||
#pragma once
|
||||
|
||||
#include "GrpTexture.h"
|
||||
|
||||
class CGraphicShadowTexture : public CGraphicTexture
|
||||
{
|
||||
public:
|
||||
CGraphicShadowTexture();
|
||||
virtual ~CGraphicShadowTexture();
|
||||
|
||||
void Destroy();
|
||||
|
||||
bool Create(int width, int height);
|
||||
|
||||
void Begin();
|
||||
void End();
|
||||
void Set(int stage = 0) const;
|
||||
|
||||
const D3DXMATRIX& GetLightVPMatrixReference() const;
|
||||
LPDIRECT3DTEXTURE8 GetD3DTexture() const;
|
||||
|
||||
protected:
|
||||
void Initialize();
|
||||
|
||||
protected:
|
||||
D3DXMATRIX m_d3dLightVPMatrix;
|
||||
D3DVIEWPORT8 m_d3dOldViewport;
|
||||
|
||||
LPDIRECT3DTEXTURE8 m_lpd3dShadowTexture;
|
||||
LPDIRECT3DSURFACE8 m_lpd3dShadowSurface;
|
||||
LPDIRECT3DSURFACE8 m_lpd3dDepthSurface;
|
||||
|
||||
LPDIRECT3DSURFACE8 m_lpd3dOldBackBufferSurface;
|
||||
LPDIRECT3DSURFACE8 m_lpd3dOldDepthBufferSurface;
|
||||
};
|
||||
@@ -0,0 +1,38 @@
|
||||
#pragma once
|
||||
|
||||
#include "GrpImage.h"
|
||||
|
||||
class CGraphicSubImage : public CGraphicImage
|
||||
{
|
||||
public:
|
||||
typedef CRef<CGraphicImage> TRef;
|
||||
|
||||
public:
|
||||
static TType Type();
|
||||
static char m_SearchPath[256];
|
||||
|
||||
public:
|
||||
CGraphicSubImage(const char* c_szFileName);
|
||||
virtual ~CGraphicSubImage();
|
||||
|
||||
bool CreateDeviceObjects();
|
||||
|
||||
bool SetImageFileName(const char* c_szFileName);
|
||||
|
||||
void SetRectPosition(int left, int top, int right, int bottom);
|
||||
|
||||
void SetRectReference(const RECT& c_rRect);
|
||||
|
||||
static void SetSearchPath(const char * c_szFileName);
|
||||
|
||||
protected:
|
||||
void SetImagePointer(CGraphicImage* pImage);
|
||||
|
||||
bool OnLoad(int iSize, const void* c_pvBuf);
|
||||
void OnClear();
|
||||
bool OnIsEmpty() const;
|
||||
bool OnIsType(TType type);
|
||||
|
||||
protected:
|
||||
CGraphicImage::TRef m_roImage;
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
|
||||
#include "Resource.h"
|
||||
#include "Ref.h"
|
||||
#include "GrpFontTexture.h"
|
||||
|
||||
class CGraphicText : public CResource
|
||||
{
|
||||
public:
|
||||
typedef CRef<CGraphicText> TRef;
|
||||
|
||||
public:
|
||||
static TType Type();
|
||||
|
||||
public:
|
||||
CGraphicText(const char* c_szFileName);
|
||||
virtual ~CGraphicText();
|
||||
|
||||
virtual bool CreateDeviceObjects();
|
||||
virtual void DestroyDeviceObjects();
|
||||
|
||||
CGraphicFontTexture * GetFontTexturePointer();
|
||||
|
||||
protected:
|
||||
bool OnLoad(int iSize, const void * c_pvBuf);
|
||||
void OnClear();
|
||||
bool OnIsEmpty() const;
|
||||
bool OnIsType(TType type);
|
||||
|
||||
protected:
|
||||
CGraphicFontTexture m_fontTexture;
|
||||
};
|
||||
@@ -0,0 +1,134 @@
|
||||
#ifndef __INC_ETERLIB_GRPTEXTINSTANCE_H__
|
||||
#define __INC_ETERLIB_GRPTEXTINSTANCE_H__
|
||||
|
||||
#include "Pool.h"
|
||||
#include "GrpText.h"
|
||||
|
||||
class CGraphicTextInstance
|
||||
{
|
||||
public:
|
||||
typedef CDynamicPool<CGraphicTextInstance> TPool;
|
||||
|
||||
public:
|
||||
enum EHorizontalAlign
|
||||
{
|
||||
HORIZONTAL_ALIGN_LEFT = 0x01,
|
||||
HORIZONTAL_ALIGN_CENTER = 0x02,
|
||||
HORIZONTAL_ALIGN_RIGHT = 0x03,
|
||||
};
|
||||
enum EVerticalAlign
|
||||
{
|
||||
VERTICAL_ALIGN_TOP = 0x10,
|
||||
VERTICAL_ALIGN_CENTER = 0x20,
|
||||
VERTICAL_ALIGN_BOTTOM = 0x30
|
||||
};
|
||||
|
||||
public:
|
||||
static void Hyperlink_UpdateMousePos(int x, int y);
|
||||
static int Hyperlink_GetText(char* buf, int len);
|
||||
|
||||
public:
|
||||
CGraphicTextInstance();
|
||||
virtual ~CGraphicTextInstance();
|
||||
|
||||
void Destroy();
|
||||
|
||||
void Update();
|
||||
void Render(RECT * pClipRect = NULL);
|
||||
|
||||
void ShowCursor();
|
||||
void HideCursor();
|
||||
|
||||
void ShowOutLine();
|
||||
void HideOutLine();
|
||||
|
||||
void SetColor(DWORD color);
|
||||
void SetColor(float r, float g, float b, float a = 1.0f);
|
||||
|
||||
void SetOutLineColor(DWORD color);
|
||||
void SetOutLineColor(float r, float g, float b, float a = 1.0f);
|
||||
|
||||
void SetHorizonalAlign(int hAlign);
|
||||
void SetVerticalAlign(int vAlign);
|
||||
void SetMax(int iMax);
|
||||
void SetTextPointer(CGraphicText* pText);
|
||||
void SetValueString(const std::string& c_stValue);
|
||||
void SetValue(const char* c_szValue, size_t len = -1);
|
||||
void SetPosition(float fx, float fy, float fz = 0.0f);
|
||||
void SetSecret(bool Value);
|
||||
void SetOutline(bool Value);
|
||||
void SetFeather(bool Value);
|
||||
void SetMultiLine(bool Value);
|
||||
void SetLimitWidth(float fWidth);
|
||||
|
||||
void GetTextSize(int* pRetWidth, int* pRetHeight);
|
||||
const std::string& GetValueStringReference();
|
||||
WORD GetTextLineCount();
|
||||
|
||||
int PixelPositionToCharacterPosition(int iPixelPosition);
|
||||
int GetHorizontalAlign();
|
||||
|
||||
protected:
|
||||
void __Initialize();
|
||||
int __DrawCharacter(CGraphicFontTexture * pFontTexture, WORD codePage, wchar_t text, DWORD dwColor);
|
||||
void __GetTextPos(DWORD index, float* x, float* y);
|
||||
int __GetTextTag(const wchar_t * src, int maxLen, int & tagLen, std::wstring & extraInfo);
|
||||
|
||||
protected:
|
||||
struct SHyperlink
|
||||
{
|
||||
short sx;
|
||||
short ex;
|
||||
std::wstring text;
|
||||
|
||||
SHyperlink() : sx(0), ex(0) { }
|
||||
};
|
||||
|
||||
protected:
|
||||
DWORD m_dwTextColor;
|
||||
DWORD m_dwOutLineColor;
|
||||
|
||||
WORD m_textWidth;
|
||||
WORD m_textHeight;
|
||||
|
||||
BYTE m_hAlign;
|
||||
BYTE m_vAlign;
|
||||
|
||||
WORD m_iMax;
|
||||
float m_fLimitWidth;
|
||||
|
||||
bool m_isCursor;
|
||||
bool m_isSecret;
|
||||
bool m_isMultiLine;
|
||||
|
||||
bool m_isOutline;
|
||||
float m_fFontFeather;
|
||||
|
||||
/////
|
||||
|
||||
std::string m_stText;
|
||||
D3DXVECTOR3 m_v3Position;
|
||||
|
||||
private:
|
||||
bool m_isUpdate;
|
||||
bool m_isUpdateFontTexture;
|
||||
|
||||
CGraphicText::TRef m_roText;
|
||||
CGraphicFontTexture::TPCharacterInfomationVector m_pCharInfoVector;
|
||||
std::vector<DWORD> m_dwColorInfoVector;
|
||||
std::vector<SHyperlink> m_hyperlinkVector;
|
||||
|
||||
public:
|
||||
static void CreateSystem(UINT uCapacity);
|
||||
static void DestroySystem();
|
||||
|
||||
static CGraphicTextInstance* New();
|
||||
static void Delete(CGraphicTextInstance* pkInst);
|
||||
|
||||
static CDynamicPool<CGraphicTextInstance> ms_kPool;
|
||||
};
|
||||
|
||||
extern const char* FindToken(const char* begin, const char* end);
|
||||
extern int ReadToken(const char* token);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,208 @@
|
||||
#pragma once
|
||||
|
||||
#include <imm.h>
|
||||
|
||||
#pragma comment(lib, "imm32.lib")
|
||||
|
||||
#include "Dimm.h"
|
||||
|
||||
class IIMEEventSink
|
||||
{
|
||||
public:
|
||||
virtual bool OnWM_CHAR( WPARAM wParam, LPARAM lParam ) = 0;
|
||||
virtual void OnUpdate() = 0;
|
||||
|
||||
virtual void OnChangeCodePage() = 0;
|
||||
|
||||
virtual void OnOpenCandidateList() = 0;
|
||||
virtual void OnCloseCandidateList() = 0;
|
||||
|
||||
virtual void OnOpenReadingWnd() = 0;
|
||||
virtual void OnCloseReadingWnd() = 0;
|
||||
};
|
||||
|
||||
class CIME
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
IMEREADING_MAXLEN = 128,
|
||||
IMESTR_MAXLEN = 1024,
|
||||
IMECANDIDATE_MAXLEN = 32768,
|
||||
MAX_CANDLIST = 10,
|
||||
MAX_CANDIDATE_LENGTH = 256
|
||||
};
|
||||
|
||||
public:
|
||||
CIME();
|
||||
virtual ~CIME();
|
||||
|
||||
bool Initialize(HWND hWnd);
|
||||
void Uninitialize(void);
|
||||
|
||||
static void Clear();
|
||||
|
||||
void SetMax(int iMax);
|
||||
void SetUserMax(int iMax);
|
||||
void SetText(const char* c_szText, int len);
|
||||
int GetText(std::string & rstrText, bool addCodePage=false);
|
||||
const char* GetCodePageText();
|
||||
int GetCodePage();
|
||||
|
||||
// Candidate List
|
||||
int GetCandidateCount();
|
||||
int GetCandidatePageCount();
|
||||
int GetCandidate(DWORD index, std::string & rstrText);
|
||||
int GetCandidateSelection();
|
||||
|
||||
// Reading Information
|
||||
int GetReading(std::string & rstrText);
|
||||
int GetReadingError();
|
||||
|
||||
void SetInputMode(DWORD dwMode);
|
||||
DWORD GetInputMode();
|
||||
|
||||
bool IsIMEEnabled();
|
||||
void EnableIME(bool bEnable=true);
|
||||
void DisableIME();
|
||||
|
||||
void EnableCaptureInput();
|
||||
void DisableCaptureInput();
|
||||
bool IsCaptureEnabled();
|
||||
|
||||
void SetNumberMode();
|
||||
void SetStringMode();
|
||||
bool __IsWritable(wchar_t key);
|
||||
void AddExceptKey(wchar_t key);
|
||||
void ClearExceptKey();
|
||||
|
||||
void PasteTextFromClipBoard();
|
||||
void EnablePaste(bool bFlag);
|
||||
void PasteString(const char * str);
|
||||
static void FinalizeString(bool bSend = false);
|
||||
|
||||
void UseDefaultIME();
|
||||
|
||||
static int GetCurPos();
|
||||
static int GetCompLen();
|
||||
static int GetULBegin();
|
||||
static int GetULEnd();
|
||||
|
||||
static void CloseCandidateList();
|
||||
static void CloseReadingInformation();
|
||||
static void ChangeInputLanguage();
|
||||
static void ChangeInputLanguageWorker();
|
||||
|
||||
LRESULT WMInputLanguage(HWND hWnd, UINT uiMsg, WPARAM wParam, LPARAM lParam);
|
||||
LRESULT WMStartComposition(HWND hWnd, UINT uiMsg, WPARAM wParam, LPARAM lParam);
|
||||
LRESULT WMComposition(HWND hWnd, UINT uiMsg, WPARAM wParam, LPARAM lParam);
|
||||
LRESULT WMEndComposition(HWND hWnd, UINT uiMsg, WPARAM wParam, LPARAM lParam);
|
||||
LRESULT WMNotify(HWND hWnd, UINT uiMsg, WPARAM wParam, LPARAM lParam);
|
||||
LRESULT WMChar(HWND hWnd, UINT uiMsg, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
protected:
|
||||
void IncCurPos();
|
||||
void DecCurPos();
|
||||
void SetCurPos(int offset);
|
||||
void DelCurPos();
|
||||
|
||||
protected:
|
||||
static void CheckInputLocale();
|
||||
static void CheckToggleState();
|
||||
static void SetSupportLevel( DWORD dwImeLevel );
|
||||
|
||||
void InsertString(wchar_t* szString, int iSize);
|
||||
|
||||
void OnChar(wchar_t c);
|
||||
|
||||
UINT GetCodePageFromLang( LANGID langid );
|
||||
void ResultProcess(HIMC hImc);
|
||||
void CompositionProcessBuilding(HIMC hImc);
|
||||
void CompositionProcess(HIMC hImc);
|
||||
void AttributeProcess(HIMC hImc);
|
||||
void CandidateProcess(HIMC hImc);
|
||||
void ReadingProcess(HIMC hImc);
|
||||
|
||||
bool IsMax(const wchar_t* wInput, int len);
|
||||
|
||||
DWORD GetImeId(UINT uIndex = 0);
|
||||
bool GetReadingWindowOrientation();
|
||||
static void SetupImeApi();
|
||||
|
||||
static INPUTCONTEXT* (WINAPI * _ImmLockIMC)( HIMC );
|
||||
static BOOL (WINAPI * _ImmUnlockIMC)( HIMC );
|
||||
static LPVOID (WINAPI * _ImmLockIMCC)( HIMCC );
|
||||
static BOOL (WINAPI * _ImmUnlockIMCC)( HIMCC );
|
||||
|
||||
static UINT (WINAPI * _GetReadingString)( HIMC, UINT, LPWSTR, PINT, BOOL*, PUINT );
|
||||
static BOOL (WINAPI * _ShowReadingWindow)( HIMC, BOOL );
|
||||
|
||||
protected:
|
||||
HIMC m_hOrgIMC;
|
||||
int m_max;
|
||||
int m_userMax;
|
||||
|
||||
BOOL m_bOnlyNumberMode;
|
||||
|
||||
std::vector<wchar_t> m_exceptKey;
|
||||
|
||||
bool m_bEnablePaste;
|
||||
bool m_bUseDefaultIME;
|
||||
|
||||
|
||||
public:
|
||||
static bool ms_bInitialized;
|
||||
static bool ms_bDisableIMECompletely;
|
||||
static bool ms_bUILessMode;
|
||||
static bool ms_bImeEnabled;
|
||||
static bool ms_bCaptureInput;
|
||||
static bool ms_bChineseIME;
|
||||
static bool ms_bUseIMMCandidate;
|
||||
|
||||
static HWND ms_hWnd;
|
||||
static HKL ms_hklCurrent;
|
||||
static char ms_szKeyboardLayout[KL_NAMELENGTH+1];
|
||||
static OSVERSIONINFOA ms_stOSVI;
|
||||
|
||||
static HINSTANCE ms_hImm32Dll;
|
||||
static HINSTANCE ms_hCurrentImeDll;
|
||||
static DWORD ms_dwImeState;
|
||||
|
||||
static DWORD ms_adwId[2];
|
||||
|
||||
// IME Level
|
||||
static DWORD ms_dwIMELevel;
|
||||
static DWORD ms_dwIMELevelSaved;
|
||||
|
||||
// Candidate List
|
||||
static bool ms_bCandidateList;
|
||||
static DWORD ms_dwCandidateCount;
|
||||
static bool ms_bVerticalCandidate;
|
||||
static int ms_iCandListIndexBase;
|
||||
static WCHAR ms_wszCandidate[CIME::MAX_CANDLIST][MAX_CANDIDATE_LENGTH];
|
||||
static DWORD ms_dwCandidateSelection;
|
||||
static DWORD ms_dwCandidatePageSize;
|
||||
|
||||
// Reading Information
|
||||
static bool ms_bReadingInformation;
|
||||
static int ms_iReadingError;
|
||||
static bool ms_bHorizontalReading;
|
||||
static std::vector<wchar_t> ms_wstrReading;
|
||||
|
||||
// Indicator
|
||||
static wchar_t* ms_wszCurrentIndicator;
|
||||
|
||||
static IIMEEventSink* ms_pEvent;
|
||||
|
||||
wchar_t m_wszComposition[IMESTR_MAXLEN];
|
||||
static wchar_t m_wText[IMESTR_MAXLEN];
|
||||
|
||||
static int ms_compLen;
|
||||
static int ms_curpos;
|
||||
static int ms_lastpos;
|
||||
static int ms_ulbegin;
|
||||
static int ms_ulend;
|
||||
|
||||
static UINT ms_uOutputCodePage;
|
||||
static UINT ms_uInputCodePage;
|
||||
};
|
||||
@@ -0,0 +1,41 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef SAFE_RELEASE
|
||||
#define SAFE_RELEASE(p) { if (p) { (p)->Release(); (p)=NULL; } }
|
||||
#endif
|
||||
|
||||
class CInputDevice
|
||||
{
|
||||
public:
|
||||
CInputDevice();
|
||||
virtual ~CInputDevice();
|
||||
|
||||
HRESULT CreateDevice(HWND hWnd);
|
||||
|
||||
protected:
|
||||
static LPDIRECTINPUT8 ms_lpDI;
|
||||
};
|
||||
|
||||
class CInputKeyboard : public CInputDevice
|
||||
{
|
||||
public:
|
||||
CInputKeyboard();
|
||||
virtual ~CInputKeyboard();
|
||||
|
||||
bool InitializeKeyboard(HWND hWnd);
|
||||
void UpdateKeyboard();
|
||||
void ResetKeyboard();
|
||||
|
||||
bool IsPressed(int iIndex);
|
||||
void KeyDown(int iIndex);
|
||||
void KeyUp(int iIndex);
|
||||
|
||||
protected:
|
||||
virtual void OnKeyDown(int iIndex) = 0;
|
||||
virtual void OnKeyUp(int iIndex) = 0;
|
||||
|
||||
protected:
|
||||
static LPDIRECTINPUTDEVICE8 ms_lpKeyboard;
|
||||
static bool ms_bPressedKey[256];
|
||||
static char ms_diks[256];
|
||||
};
|
||||
@@ -0,0 +1,125 @@
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// CLensFlare Class
|
||||
//
|
||||
// (c) 2003 IDV, Inc.
|
||||
//
|
||||
// *** INTERACTIVE DATA VISUALIZATION (IDV) PROPRIETARY INFORMATION ***
|
||||
//
|
||||
// This software is supplied under the terms of a license agreement or
|
||||
// nondisclosure agreement with Interactive Data Visualization and may
|
||||
// not be copied or disclosed except in accordance with the terms of
|
||||
// that agreement.
|
||||
//
|
||||
// Copyright (c) 2001-2003 IDV, Inc.
|
||||
// All Rights Reserved.
|
||||
//
|
||||
// IDV, Inc.
|
||||
// 1233 Washington St. Suite 610
|
||||
// Columbia, SC 29201
|
||||
// Voice: (803) 799-1699
|
||||
// Fax: (803) 931-0320
|
||||
// Web: http://www.idvinc.com
|
||||
//
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// Preprocessor
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "GrpImageInstance.h"
|
||||
#include "GrpScreen.h"
|
||||
|
||||
#include <float.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// Constants
|
||||
|
||||
const float c_fHalfMaxBright = 0.45f;
|
||||
const float c_fDistanceScale = 1.0f;
|
||||
const int c_nDepthTestDimension = 15;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// CFlare
|
||||
|
||||
class CFlare
|
||||
{
|
||||
public:
|
||||
void Draw(float fBrightScale, int nWidth, int nHeight, int nX, int nY);
|
||||
void Init(std::string strPath);
|
||||
|
||||
CFlare();
|
||||
virtual ~CFlare();
|
||||
|
||||
private:
|
||||
struct SFlarePiece
|
||||
{
|
||||
SFlarePiece() :
|
||||
m_fPosition(0.0f),
|
||||
m_fWidth(0.0f),
|
||||
m_pColor(NULL)
|
||||
{
|
||||
}
|
||||
CGraphicImageInstance m_imageInstance;
|
||||
float m_fPosition; // -1.0 = light location, 0.0 = center, 1.0 = far end of flare
|
||||
float m_fWidth; // height = width
|
||||
float * m_pColor;
|
||||
};
|
||||
|
||||
std::vector<SFlarePiece *> m_vFlares;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// CLensFlare
|
||||
class CLensFlare : public CScreen
|
||||
{
|
||||
public:
|
||||
CLensFlare();
|
||||
virtual ~CLensFlare();
|
||||
|
||||
void Compute(const D3DXVECTOR3 & c_rv3LightDirection); // D3DTS_VIEW로 부터 카메라 방향을 얻어오므로, 카메라 설정 뒤에 해야 함.
|
||||
|
||||
void DrawBeforeFlare();
|
||||
void DrawAfterFlare();
|
||||
void DrawFlare();
|
||||
|
||||
void SetMainFlare(std::string strSunFile, float fSunSize);
|
||||
void Initialize(std::string strPath);
|
||||
|
||||
void SetFlareLocation(double dX, double dY);
|
||||
|
||||
void SetVisible(bool bState) { m_bFlareVisible = bState; }
|
||||
bool IsVisible() { return m_bFlareVisible; }
|
||||
|
||||
void SetBrightnesses(float fBeforeBright, float fAfterBright);
|
||||
|
||||
void ReadControlPixels();
|
||||
void AdjustBrightness();
|
||||
|
||||
void CharacterizeFlare(bool bEnabled, bool bShowMainFlare, float fMaxBrightness, const D3DXCOLOR & c_rColor);
|
||||
|
||||
protected:
|
||||
float Interpolate(float fStart, float fEnd, float fPercent);
|
||||
|
||||
private:
|
||||
float m_afFlarePos[2], m_afFlareWinPos[2];
|
||||
float m_fBeforeBright, m_fAfterBright;
|
||||
bool m_bFlareVisible, m_bDrawFlare, m_bDrawBrightScreen;
|
||||
float m_fSunSize;
|
||||
CFlare m_cFlare;
|
||||
float * m_pControlPixels;
|
||||
float * m_pTestPixels;
|
||||
bool m_bEnabled;
|
||||
bool m_bShowMainFlare;
|
||||
float m_fMaxBrightness;
|
||||
float m_afColor[4];
|
||||
|
||||
CGraphicImageInstance m_SunFlareImageInstance;
|
||||
|
||||
void ReadDepthPixels(float * pPixels);
|
||||
void ClampBrightness();
|
||||
};
|
||||
@@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include "MSWindow.h"
|
||||
|
||||
class CMSApplication : public CMSWindow
|
||||
{
|
||||
public:
|
||||
CMSApplication();
|
||||
virtual ~CMSApplication();
|
||||
|
||||
void Initialize(HINSTANCE hInstance);
|
||||
|
||||
void MessageLoop();
|
||||
|
||||
bool IsMessage();
|
||||
bool MessageProcess();
|
||||
|
||||
protected:
|
||||
void ClearWindowClass();
|
||||
|
||||
LRESULT WindowProcedure(HWND hWnd, UINT uiMsg, WPARAM wParam, LPARAM lParam);
|
||||
};
|
||||
@@ -0,0 +1,59 @@
|
||||
#pragma once
|
||||
|
||||
#include "../EterBase/Stl.h"
|
||||
|
||||
class CMSWindow
|
||||
{
|
||||
public:
|
||||
CMSWindow();
|
||||
|
||||
virtual ~CMSWindow();
|
||||
|
||||
void Destroy();
|
||||
bool Create(const char* c_szName, int brush=BLACK_BRUSH, DWORD cs=0, DWORD ws=WS_OVERLAPPEDWINDOW, HICON hIcon=NULL, int iCursorResource=32512);
|
||||
|
||||
void Show();
|
||||
void Hide();
|
||||
|
||||
void SetVisibleMode(bool isVisible);
|
||||
|
||||
void SetPosition(int x, int y);
|
||||
void SetCenterPosition();
|
||||
|
||||
void SetText(const char* c_szText);
|
||||
|
||||
void AdjustSize(int width, int height);
|
||||
void SetSize(int width, int height);
|
||||
|
||||
bool IsVisible();
|
||||
bool IsActive();
|
||||
|
||||
void GetMousePosition(POINT* ppt);
|
||||
void GetClientRect(RECT* prc);
|
||||
void GetWindowRect(RECT* prc);
|
||||
|
||||
int GetScreenWidth();
|
||||
int GetScreenHeight();
|
||||
|
||||
HWND GetWindowHandle();
|
||||
HINSTANCE GetInstance();
|
||||
|
||||
virtual LRESULT WindowProcedure(HWND hWnd, UINT uiMsg, WPARAM wParam, LPARAM lParam);
|
||||
virtual void OnSize(WPARAM wParam, LPARAM lParam);
|
||||
|
||||
protected:
|
||||
const char* RegisterWindowClass(DWORD style, int brush, WNDPROC pfnWndProc, HICON hIcon=NULL, int iCursorResource=32512);
|
||||
|
||||
protected:
|
||||
typedef std::set<char*, stl_sz_less> TWindowClassSet;
|
||||
|
||||
protected:
|
||||
HWND m_hWnd;
|
||||
RECT m_rect;
|
||||
bool m_isActive;
|
||||
bool m_isVisible;
|
||||
|
||||
protected:
|
||||
static TWindowClassSet ms_stWCSet;
|
||||
static HINSTANCE ms_hInstance;
|
||||
};
|
||||
@@ -0,0 +1,113 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef _IMPROVED_PACKET_ENCRYPTION_
|
||||
#include "../EterBase/cipher.h"
|
||||
#endif
|
||||
#include "../EterBase/tea.h"
|
||||
#include "NetAddress.h"
|
||||
|
||||
class CNetworkStream
|
||||
{
|
||||
public:
|
||||
CNetworkStream();
|
||||
virtual ~CNetworkStream();
|
||||
|
||||
void SetRecvBufferSize(int recvBufSize);
|
||||
void SetSendBufferSize(int sendBufSize);
|
||||
|
||||
#ifndef _IMPROVED_PACKET_ENCRYPTION_
|
||||
void SetSecurityMode(bool isSecurityMode, const char* c_szTeaKey);
|
||||
void SetSecurityMode(bool isSecurityMode, const char* c_szTeaEncryptKey, const char* c_szTeaDecryptKey);
|
||||
#endif
|
||||
bool IsSecurityMode();
|
||||
|
||||
int GetRecvBufferSize();
|
||||
|
||||
void Clear();
|
||||
void ClearRecvBuffer();
|
||||
|
||||
void Process();
|
||||
|
||||
bool Connect(const CNetworkAddress& c_rkNetAddr, int limitSec = 3);
|
||||
bool Connect(const char* c_szAddr, int port, int limitSec = 3);
|
||||
bool Connect(DWORD dwAddr, int port, int limitSec = 3);
|
||||
void Disconnect();
|
||||
|
||||
bool Peek(int len);
|
||||
bool Peek(int len, char* pDestBuf);
|
||||
bool Recv(int len);
|
||||
bool Recv(int len, char* pDestBuf);
|
||||
bool Send(int len, const char* pSrcBuf);
|
||||
|
||||
bool Peek(int len, void* pDestBuf);
|
||||
bool Recv(int len, void* pDestBuf);
|
||||
|
||||
bool Send(int len, const void* pSrcBuf);
|
||||
bool SendFlush(int len, const void* pSrcBuf);
|
||||
|
||||
bool IsOnline();
|
||||
|
||||
void SetPacketSequenceMode(bool isOn);
|
||||
bool SendSequence();
|
||||
|
||||
protected:
|
||||
virtual void OnConnectSuccess();
|
||||
virtual void OnConnectFailure();
|
||||
virtual void OnRemoteDisconnect();
|
||||
virtual void OnDisconnect();
|
||||
virtual bool OnProcess();
|
||||
|
||||
bool __SendInternalBuffer();
|
||||
bool __RecvInternalBuffer();
|
||||
|
||||
void __PopSendBuffer();
|
||||
|
||||
int __GetSendBufferSize();
|
||||
|
||||
#ifdef _IMPROVED_PACKET_ENCRYPTION_
|
||||
size_t Prepare(void* buffer, size_t* length);
|
||||
bool Activate(size_t agreed_length, const void* buffer, size_t length);
|
||||
void ActivateCipher();
|
||||
#endif
|
||||
|
||||
private:
|
||||
time_t m_connectLimitTime;
|
||||
|
||||
char* m_recvTEABuf;
|
||||
int m_recvTEABufInputPos;
|
||||
int m_recvTEABufSize;
|
||||
|
||||
char* m_recvBuf;
|
||||
int m_recvBufSize;
|
||||
int m_recvBufInputPos;
|
||||
int m_recvBufOutputPos;
|
||||
|
||||
char* m_sendBuf;
|
||||
int m_sendBufSize;
|
||||
int m_sendBufInputPos;
|
||||
int m_sendBufOutputPos;
|
||||
|
||||
char* m_sendTEABuf;
|
||||
int m_sendTEABufSize;
|
||||
int m_sendTEABufInputPos;
|
||||
|
||||
bool m_isOnline;
|
||||
|
||||
#ifdef _IMPROVED_PACKET_ENCRYPTION_
|
||||
Cipher m_cipher;
|
||||
#else
|
||||
// Obsolete encryption stuff here
|
||||
bool m_isSecurityMode;
|
||||
char m_szEncryptKey[TEA_KEY_LENGTH]; // Client 에서 보낼 패킷을 Encrypt 할때 사용하는 Key
|
||||
char m_szDecryptKey[TEA_KEY_LENGTH]; // Server 에서 전송된 패킷을 Decrypt 할때 사용하는 Key
|
||||
#endif
|
||||
|
||||
SOCKET m_sock;
|
||||
|
||||
CNetworkAddress m_addr;
|
||||
|
||||
// Sequence
|
||||
DWORD m_iSequence;
|
||||
bool m_bUseSequence;
|
||||
std::vector<BYTE> m_kVec_bSequenceTable;
|
||||
};
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "../EterBase/Debug.h"
|
||||
#include <algorithm> // PORT: std::find below; MSVC's headers pulled it in transitively
|
||||
|
||||
//#define DYNAMIC_POOL_STRICT
|
||||
|
||||
|
||||
@@ -0,0 +1,264 @@
|
||||
#pragma once
|
||||
|
||||
#include "../EterBase/Timer.h"
|
||||
#include "../EterBase/Debug.h"
|
||||
|
||||
/*
|
||||
class CProfiler : public CSingleton<CProfiler>
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
STACK_DATA_MAX_NUM = 64,
|
||||
};
|
||||
|
||||
public:
|
||||
typedef struct SProfileStackData
|
||||
{
|
||||
int iCallStep;
|
||||
long iStartTime;
|
||||
long iEndTime;
|
||||
|
||||
std::string strName;
|
||||
} TProfileStackData;
|
||||
typedef struct SProfileAccumulationData
|
||||
{
|
||||
int iStartTime;
|
||||
int iCallingCount;
|
||||
int iCollapsedTime;
|
||||
|
||||
std::string strName;
|
||||
} TProfileAccumulationData;
|
||||
|
||||
typedef std::map<std::string, CGraphicTextInstance*> TGraphicTextInstanceMap;
|
||||
typedef std::map<std::string, TProfileAccumulationData> TProfileAccumulationDataMap;
|
||||
|
||||
public:
|
||||
CProfiler()
|
||||
{
|
||||
Clear();
|
||||
m_ProfileAccumulationDataMap.clear();
|
||||
}
|
||||
virtual ~CProfiler()
|
||||
{
|
||||
}
|
||||
|
||||
void Clear()
|
||||
{
|
||||
m_ProfileStackDataCount = 0;
|
||||
m_iCallStep = 0;
|
||||
|
||||
TProfileAccumulationDataMap::iterator itor = m_ProfileAccumulationDataMap.begin();
|
||||
for (; itor != m_ProfileAccumulationDataMap.end(); ++itor)
|
||||
{
|
||||
TProfileAccumulationData & rData = itor->second;
|
||||
rData.iCallingCount = 0;
|
||||
rData.iCollapsedTime = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void Push(const char * c_szName)
|
||||
{
|
||||
assert(m_ProfileStackDataCount < STACK_DATA_MAX_NUM);
|
||||
TProfileStackData & rProfileStackData = m_ProfileStackDatas[m_ProfileStackDataCount++];
|
||||
|
||||
rProfileStackData.iCallStep = m_iCallStep;
|
||||
rProfileStackData.iStartTime = ELTimer_GetMSec();
|
||||
rProfileStackData.strName = c_szName;
|
||||
|
||||
++m_iCallStep;
|
||||
|
||||
TGraphicTextInstanceMap::iterator itor = m_GraphicTextInstanceMap.find(c_szName);
|
||||
|
||||
if (m_GraphicTextInstanceMap.end() == itor)
|
||||
{
|
||||
CGraphicTextInstance * pGraphicTextInstance = CGraphicTextInstance::New();
|
||||
|
||||
CResource * pResource = CResourceManager::Instance().GetResourcePointer("굴림체.fnt");
|
||||
pGraphicTextInstance->Clear();
|
||||
pGraphicTextInstance->SetTextPointer(static_cast<CGraphicText*>(pResource));
|
||||
|
||||
m_GraphicTextInstanceMap.insert(TGraphicTextInstanceMap::value_type(c_szName, pGraphicTextInstance));
|
||||
}
|
||||
}
|
||||
void Pop(const char * c_szName)
|
||||
{
|
||||
TProfileStackData * pProfileStackData;
|
||||
|
||||
if (!GetProfileStackDataPointer(c_szName, &pProfileStackData))
|
||||
{
|
||||
assert(!"The name doesn't exist");
|
||||
return;
|
||||
}
|
||||
|
||||
pProfileStackData->iEndTime = ELTimer_GetMSec();
|
||||
|
||||
--m_iCallStep;
|
||||
}
|
||||
|
||||
void PushAccumulation(const char * c_szName)
|
||||
{
|
||||
TProfileAccumulationDataMap::iterator itor = m_ProfileAccumulationDataMap.find(c_szName);
|
||||
|
||||
if (itor == m_ProfileAccumulationDataMap.end())
|
||||
{
|
||||
TProfileAccumulationData ProfileAccumulationData;
|
||||
ProfileAccumulationData.iCollapsedTime = 0;
|
||||
ProfileAccumulationData.iCallingCount = 0;
|
||||
ProfileAccumulationData.strName = c_szName;
|
||||
m_ProfileAccumulationDataMap.insert(TProfileAccumulationDataMap::value_type(c_szName, ProfileAccumulationData));
|
||||
|
||||
itor = m_ProfileAccumulationDataMap.find(c_szName);
|
||||
|
||||
/////
|
||||
|
||||
CGraphicTextInstance * pGraphicTextInstance = m_GraphicTextInstancePool.Alloc();
|
||||
|
||||
CResource * pResource = CResourceManager::Instance().GetResourcePointer("굴림체.fnt");
|
||||
pGraphicTextInstance->Clear();
|
||||
pGraphicTextInstance->SetTextPointer(static_cast<CGraphicText*>(pResource));
|
||||
|
||||
m_GraphicTextInstanceMap.insert(TGraphicTextInstanceMap::value_type(c_szName, pGraphicTextInstance));
|
||||
}
|
||||
|
||||
TProfileAccumulationData & rData = itor->second;
|
||||
rData.iStartTime = ELTimer_GetMSec();
|
||||
}
|
||||
|
||||
void PopAccumulation(const char * c_szName)
|
||||
{
|
||||
TProfileAccumulationDataMap::iterator itor = m_ProfileAccumulationDataMap.find(c_szName);
|
||||
|
||||
if (itor == m_ProfileAccumulationDataMap.end())
|
||||
return;
|
||||
|
||||
TProfileAccumulationData & rData = itor->second;
|
||||
rData.iCollapsedTime += ELTimer_GetMSec() - rData.iStartTime;
|
||||
++rData.iCallingCount;
|
||||
}
|
||||
|
||||
void ProfileByConsole()
|
||||
{
|
||||
for (int i = 0; i < m_ProfileStackDataCount; ++i)
|
||||
{
|
||||
TProfileStackData & rProfileStackData = m_ProfileStackDatas[i];
|
||||
|
||||
// for (int i = 0; i < rProfileStackData.iCallStep; ++i)
|
||||
// Tracef("\t");
|
||||
|
||||
Tracef("%-10s: %2d\t", rProfileStackData.strName.c_str(), rProfileStackData.iEndTime - rProfileStackData.iStartTime);
|
||||
}
|
||||
Tracef("\n");
|
||||
}
|
||||
|
||||
void ProfileOneStackDataByConsole(const char * c_szName)
|
||||
{
|
||||
TProfileStackData * pProfileStackData;
|
||||
|
||||
if (!GetProfileStackDataPointer(c_szName, &pProfileStackData))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Tracef("%-10s: %3d\n", pProfileStackData->strName.c_str(), pProfileStackData->iEndTime - pProfileStackData->iStartTime);
|
||||
}
|
||||
|
||||
void ProfileOneAccumulationDataByConsole(const char * c_szName)
|
||||
{
|
||||
TProfileAccumulationDataMap::iterator itor = m_ProfileAccumulationDataMap.find(c_szName);
|
||||
if (itor == m_ProfileAccumulationDataMap.end())
|
||||
return;
|
||||
|
||||
TProfileAccumulationData & rData = itor->second;
|
||||
Tracef("%-10s : [CollapsedTime : %3d] / [CallingCount : %3d]\n", rData.strName.c_str(),
|
||||
rData.iCollapsedTime,
|
||||
rData.iCallingCount);
|
||||
}
|
||||
|
||||
void ProfileByScreen()
|
||||
{
|
||||
float fxPosition = 0;
|
||||
float fyPosition = 10;
|
||||
|
||||
char szText[128];
|
||||
|
||||
for (int i = 0; i < m_ProfileStackDataCount; ++i)
|
||||
{
|
||||
TProfileStackData & rProfileStackData = m_ProfileStackDatas[i];
|
||||
|
||||
TGraphicTextInstanceMap::iterator itor = m_GraphicTextInstanceMap.find(rProfileStackData.strName);
|
||||
|
||||
if (m_GraphicTextInstanceMap.end() != itor)
|
||||
{
|
||||
CGraphicTextInstance * pGraphicTextInstance = itor->second;
|
||||
|
||||
fxPosition = 10 + (float) rProfileStackData.iCallStep * 10 * 4;
|
||||
|
||||
sprintf(szText, "%-10s : %3d", rProfileStackData.strName.c_str(), rProfileStackData.iEndTime - rProfileStackData.iStartTime);
|
||||
|
||||
pGraphicTextInstance->SetColor(0.7f, 0.7f, 0.7f);
|
||||
pGraphicTextInstance->SetValue(szText, strlen(szText));
|
||||
pGraphicTextInstance->SetPosition(fxPosition, fyPosition);
|
||||
pGraphicTextInstance->Update();
|
||||
pGraphicTextInstance->Render();
|
||||
|
||||
fyPosition += 17;
|
||||
}
|
||||
}
|
||||
|
||||
fxPosition = 10;
|
||||
fyPosition += 10;
|
||||
TProfileAccumulationDataMap::iterator itor = m_ProfileAccumulationDataMap.begin();
|
||||
for (; itor != m_ProfileAccumulationDataMap.end(); ++itor)
|
||||
{
|
||||
TProfileAccumulationData & rData = itor->second;
|
||||
TGraphicTextInstanceMap::iterator itor = m_GraphicTextInstanceMap.find(rData.strName);
|
||||
|
||||
if (m_GraphicTextInstanceMap.end() != itor)
|
||||
{
|
||||
CGraphicTextInstance * pGraphicTextInstance = itor->second;
|
||||
|
||||
sprintf(szText, "%-10s : [CollapsedTime : %3d] / [CallingCount : %3d]", rData.strName.c_str(),
|
||||
rData.iCollapsedTime,
|
||||
rData.iCallingCount);
|
||||
|
||||
pGraphicTextInstance->SetColor(0.7f, 0.7f, 0.7f);
|
||||
pGraphicTextInstance->SetValue(szText, strlen(szText));
|
||||
pGraphicTextInstance->SetPosition(fxPosition, fyPosition);
|
||||
pGraphicTextInstance->Update();
|
||||
pGraphicTextInstance->Render();
|
||||
|
||||
fyPosition += 17;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
bool GetProfileStackDataPointer(const char * c_szName, TProfileStackData ** ppProfileStackData)
|
||||
{
|
||||
for (int i = 0; i < m_ProfileStackDataCount; ++i)
|
||||
{
|
||||
if (0 == m_ProfileStackDatas[i].strName.compare(c_szName))
|
||||
{
|
||||
*ppProfileStackData = &m_ProfileStackDatas[i];
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected:
|
||||
// Profile Stack Data
|
||||
int m_ProfileStackDataCount;
|
||||
TProfileStackData m_ProfileStackDatas[STACK_DATA_MAX_NUM];
|
||||
|
||||
// Profile Increase Data
|
||||
TProfileAccumulationDataMap m_ProfileAccumulationDataMap;
|
||||
|
||||
int m_iCallStep;
|
||||
|
||||
TGraphicTextInstanceMap m_GraphicTextInstanceMap;
|
||||
};
|
||||
*/
|
||||
@@ -0,0 +1,73 @@
|
||||
#pragma once
|
||||
|
||||
#include "Resource.h"
|
||||
#include "FileLoaderThread.h"
|
||||
|
||||
#include <set>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
class CResourceManager : public CSingleton<CResourceManager>
|
||||
{
|
||||
public:
|
||||
CResourceManager();
|
||||
virtual ~CResourceManager();
|
||||
|
||||
void LoadStaticCache(const char* c_szFileName);
|
||||
|
||||
void DestroyDeletingList();
|
||||
void Destroy();
|
||||
|
||||
void BeginThreadLoading();
|
||||
void EndThreadLoading();
|
||||
|
||||
CResource * InsertResourcePointer(DWORD dwFileCRC, CResource* pResource);
|
||||
CResource * FindResourcePointer(DWORD dwFileCRC);
|
||||
CResource * GetResourcePointer(const char * c_szFileName);
|
||||
CResource * GetTypeResourcePointer(const char * c_szFileName, int iType=-1);
|
||||
|
||||
// 추가
|
||||
bool isResourcePointerData(DWORD dwFileCRC);
|
||||
|
||||
void RegisterResourceNewFunctionPointer(const char* c_szFileExt, CResource* (*pResNewFunc)(const char* c_szFileName));
|
||||
void RegisterResourceNewFunctionByTypePointer(int iType, CResource* (*pNewFunc) (const char* c_szFileName));
|
||||
|
||||
void DumpFileListToTextFile(const char* c_szFileName);
|
||||
bool IsFileExist(const char * c_szFileName);
|
||||
|
||||
void Update();
|
||||
void ReserveDeletingResource(CResource * pResource);
|
||||
|
||||
public:
|
||||
void ProcessBackgroundLoading();
|
||||
void PushBackgroundLoadingSet(std::set<std::string> & LoadingSet);
|
||||
|
||||
protected:
|
||||
void __DestroyDeletingResourceMap();
|
||||
void __DestroyResourceMap();
|
||||
void __DestroyCacheMap();
|
||||
|
||||
DWORD __GetFileCRC(const char * c_szFileName, const char ** c_pszLowerFile = NULL);
|
||||
|
||||
protected:
|
||||
typedef std::map<DWORD, CResource *> TResourcePointerMap;
|
||||
typedef std::map<std::string, CResource* (*)(const char*)> TResourceNewFunctionPointerMap;
|
||||
typedef std::map<int, CResource* (*)(const char*)> TResourceNewFunctionByTypePointerMap;
|
||||
typedef std::map<CResource *, DWORD> TResourceDeletingMap;
|
||||
typedef std::map<DWORD, std::string> TResourceRequestMap;
|
||||
typedef std::map<long, CResource*> TResourceRefDecreaseWaitingMap;
|
||||
|
||||
protected:
|
||||
TResourcePointerMap m_pCacheMap;
|
||||
TResourcePointerMap m_pResMap;
|
||||
TResourceNewFunctionPointerMap m_pResNewFuncMap;
|
||||
TResourceNewFunctionByTypePointerMap m_pResNewFuncByTypeMap;
|
||||
TResourceDeletingMap m_ResourceDeletingMap;
|
||||
TResourceRequestMap m_RequestMap; // 쓰레드로 로딩 요청한 리스트
|
||||
TResourceRequestMap m_WaitingMap;
|
||||
TResourceRefDecreaseWaitingMap m_pResRefDecreaseWaitingMap;
|
||||
|
||||
static CFileLoaderThread ms_loadingThread;
|
||||
};
|
||||
|
||||
extern int g_iLoadingDelayTime;
|
||||
@@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include "GrpScreen.h"
|
||||
|
||||
class CScreenFilter : public CScreen
|
||||
{
|
||||
public:
|
||||
CScreenFilter();
|
||||
virtual ~CScreenFilter();
|
||||
|
||||
void SetEnable(BOOL bFlag);
|
||||
void SetBlendType(BYTE bySrcType, BYTE byDestType);
|
||||
void SetColor(const D3DXCOLOR & c_rColor);
|
||||
|
||||
void Render();
|
||||
|
||||
protected:
|
||||
BOOL m_bEnable;
|
||||
BYTE m_bySrcType;
|
||||
BYTE m_byDestType;
|
||||
D3DXCOLOR m_Color;
|
||||
};
|
||||
@@ -0,0 +1,341 @@
|
||||
/******************************************************************************
|
||||
|
||||
Copyright (C) 1999, 2000 NVIDIA Corporation
|
||||
|
||||
This file is provided without support, instruction, or implied warranty of any
|
||||
kind. NVIDIA makes no guarantee of its fitness for a particular purpose and is
|
||||
not liable under any circumstances for any damages or loss whatsoever arising
|
||||
from the use or inability to use this file or items derived from it.
|
||||
|
||||
Comments:
|
||||
|
||||
A simple class to manage rendering state. Created as a singleton.
|
||||
Create it as a static global, or with new. It doesn't matter as long as it is created
|
||||
before you use the CStateManager::GetSingleton() API to get a reference to it.
|
||||
|
||||
Call it with STATEMANAGER.SetRenderState(...)
|
||||
Call it with STATEMANAGER.SetTextureStageState(...), etc.
|
||||
|
||||
Call the 'Save' versions of the function if you want to deviate from the current state.
|
||||
Call the 'Restore' version to retrieve the last Save.
|
||||
|
||||
There are two levels of caching:
|
||||
- All Sets/Saves/Restores are tracked for redundancy. This reduces the size of the batch to
|
||||
be flushed
|
||||
- The flush function is called before rendering, and only copies state that is
|
||||
different from the current chip state.
|
||||
|
||||
If you get an assert it is probably because an API call failed.
|
||||
|
||||
See NVLink for a good example of how this class is used.
|
||||
|
||||
Don't be afraid of the vector being used to track the flush batch. It will grow as big as
|
||||
it needs to be and then stop, so it shouldn't be reallocated.
|
||||
|
||||
The state manager holds a reference to the d3d device.
|
||||
|
||||
- cmaughan@nvidia.com
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef __CSTATEMANAGER_H
|
||||
#define __CSTATEMANAGER_H
|
||||
|
||||
#include <d3d8.h>
|
||||
#include <d3dx8.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "../EterBase/Singleton.h"
|
||||
|
||||
#define CHECK_D3DAPI(a) \
|
||||
{ \
|
||||
HRESULT hr = (a); \
|
||||
\
|
||||
if (hr != S_OK) \
|
||||
assert(!#a); \
|
||||
}
|
||||
|
||||
static const DWORD STATEMANAGER_MAX_RENDERSTATES = 256;
|
||||
static const DWORD STATEMANAGER_MAX_TEXTURESTATES = 128;
|
||||
static const DWORD STATEMANAGER_MAX_STAGES = 8;
|
||||
static const DWORD STATEMANAGER_MAX_VCONSTANTS = 96;
|
||||
static const DWORD STATEMANAGER_MAX_PCONSTANTS = 8;
|
||||
static const DWORD STATEMANAGER_MAX_TRANSFORMSTATES = 300; // World1 lives way up there...
|
||||
static const DWORD STATEMANAGER_MAX_STREAMS = 16;
|
||||
|
||||
class CStreamData
|
||||
{
|
||||
public:
|
||||
CStreamData(LPDIRECT3DVERTEXBUFFER8 pStreamData = NULL, UINT Stride = 0) : m_lpStreamData(pStreamData), m_Stride(Stride)
|
||||
{
|
||||
}
|
||||
|
||||
bool operator == (const CStreamData& rhs) const
|
||||
{
|
||||
return ((m_lpStreamData == rhs.m_lpStreamData) && (m_Stride == rhs.m_Stride));
|
||||
}
|
||||
|
||||
LPDIRECT3DVERTEXBUFFER8 m_lpStreamData;
|
||||
UINT m_Stride;
|
||||
};
|
||||
|
||||
class CIndexData
|
||||
{
|
||||
public:
|
||||
CIndexData(LPDIRECT3DINDEXBUFFER8 pIndexData = NULL, UINT BaseVertexIndex = 0)
|
||||
: m_lpIndexData(pIndexData),
|
||||
m_BaseVertexIndex(BaseVertexIndex)
|
||||
{
|
||||
}
|
||||
|
||||
bool operator == (const CIndexData& rhs) const
|
||||
{
|
||||
return ((m_lpIndexData == rhs.m_lpIndexData) && (m_BaseVertexIndex == rhs.m_BaseVertexIndex));
|
||||
}
|
||||
|
||||
LPDIRECT3DINDEXBUFFER8 m_lpIndexData;
|
||||
UINT m_BaseVertexIndex;
|
||||
};
|
||||
|
||||
// State types managed by the class
|
||||
typedef enum eStateType
|
||||
{
|
||||
STATE_MATERIAL = 0,
|
||||
STATE_RENDER,
|
||||
STATE_TEXTURE,
|
||||
STATE_TEXTURESTAGE,
|
||||
STATE_VSHADER,
|
||||
STATE_PSHADER,
|
||||
STATE_TRANSFORM,
|
||||
STATE_VCONSTANT,
|
||||
STATE_PCONSTANT,
|
||||
STATE_STREAM,
|
||||
STATE_INDEX
|
||||
} eStateType;
|
||||
|
||||
class CStateID
|
||||
{
|
||||
public:
|
||||
CStateID(eStateType Type, DWORD dwValue0 = 0, DWORD dwValue1 = 0)
|
||||
: m_Type(Type),
|
||||
m_dwValue0(dwValue0),
|
||||
m_dwValue1(dwValue1)
|
||||
{
|
||||
}
|
||||
|
||||
CStateID(eStateType Type, DWORD dwStage, D3DTEXTURESTAGESTATETYPE StageType)
|
||||
: m_Type(Type),
|
||||
m_dwStage(dwStage),
|
||||
m_TextureStageStateType(StageType)
|
||||
{
|
||||
}
|
||||
|
||||
CStateID(eStateType Type, D3DRENDERSTATETYPE RenderType)
|
||||
: m_Type(Type),
|
||||
m_RenderStateType(RenderType)
|
||||
{
|
||||
}
|
||||
|
||||
eStateType m_Type;
|
||||
|
||||
union
|
||||
{
|
||||
DWORD m_dwValue0;
|
||||
DWORD m_dwStage;
|
||||
D3DRENDERSTATETYPE m_RenderStateType;
|
||||
D3DTRANSFORMSTATETYPE m_TransformStateType;
|
||||
};
|
||||
|
||||
union
|
||||
{
|
||||
DWORD m_dwValue1;
|
||||
D3DTEXTURESTAGESTATETYPE m_TextureStageStateType;
|
||||
};
|
||||
};
|
||||
|
||||
typedef std::vector<CStateID> TStateID;
|
||||
|
||||
class CStateManagerState
|
||||
{
|
||||
public:
|
||||
CStateManagerState()
|
||||
{
|
||||
}
|
||||
|
||||
void ResetState()
|
||||
{
|
||||
DWORD i, y;
|
||||
|
||||
for (i = 0; i < STATEMANAGER_MAX_RENDERSTATES; i++)
|
||||
m_RenderStates[i] = 0x7FFFFFFF;
|
||||
|
||||
for (i = 0; i < STATEMANAGER_MAX_STAGES; i++)
|
||||
for (y = 0; y < STATEMANAGER_MAX_TEXTURESTATES; y++)
|
||||
m_TextureStates[i][y] = 0x7FFFFFFF;
|
||||
|
||||
for (i = 0; i < STATEMANAGER_MAX_STREAMS; i++)
|
||||
m_StreamData[i] = CStreamData();
|
||||
|
||||
m_IndexData = CIndexData();
|
||||
|
||||
for (i = 0; i < STATEMANAGER_MAX_STAGES; i++)
|
||||
m_Textures[i] = NULL;
|
||||
|
||||
// Matrices and constants are not cached, just restored. It's silly to check all the
|
||||
// data elements (by which time the driver could have been sent them).
|
||||
for (i = 0; i < STATEMANAGER_MAX_TRANSFORMSTATES; i++)
|
||||
D3DXMatrixIdentity(&m_Matrices[i]);
|
||||
|
||||
for (i = 0; i < STATEMANAGER_MAX_VCONSTANTS; i++)
|
||||
m_VertexShaderConstants[i] = D3DXVECTOR4(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
|
||||
for (i = 0; i < STATEMANAGER_MAX_PCONSTANTS; i++)
|
||||
m_PixelShaderConstants[i] = D3DXVECTOR4(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
|
||||
m_dwPixelShader = 0;
|
||||
m_dwVertexShader = D3DFVF_XYZ;
|
||||
|
||||
ZeroMemory(&m_Matrices, sizeof(D3DXMATRIX) * STATEMANAGER_MAX_TRANSFORMSTATES);
|
||||
}
|
||||
|
||||
// Renderstates
|
||||
DWORD m_RenderStates[STATEMANAGER_MAX_RENDERSTATES];
|
||||
|
||||
// Texture stage states
|
||||
DWORD m_TextureStates[STATEMANAGER_MAX_STAGES][STATEMANAGER_MAX_TEXTURESTATES];
|
||||
|
||||
// Vertex shader constants
|
||||
D3DXVECTOR4 m_VertexShaderConstants[STATEMANAGER_MAX_VCONSTANTS];
|
||||
|
||||
// Pixel shader constants
|
||||
D3DXVECTOR4 m_PixelShaderConstants[STATEMANAGER_MAX_PCONSTANTS];
|
||||
|
||||
// Textures
|
||||
LPDIRECT3DBASETEXTURE8 m_Textures[STATEMANAGER_MAX_STAGES];
|
||||
|
||||
// Shaders
|
||||
DWORD m_dwPixelShader;
|
||||
DWORD m_dwVertexShader;
|
||||
|
||||
D3DXMATRIX m_Matrices[STATEMANAGER_MAX_TRANSFORMSTATES];
|
||||
|
||||
D3DMATERIAL8 m_D3DMaterial;
|
||||
|
||||
CStreamData m_StreamData[STATEMANAGER_MAX_STREAMS];
|
||||
CIndexData m_IndexData;
|
||||
};
|
||||
|
||||
class CStateManager : public CSingleton<CStateManager>
|
||||
{
|
||||
public:
|
||||
CStateManager(LPDIRECT3DDEVICE8 lpDevice);
|
||||
virtual ~CStateManager();
|
||||
|
||||
void SetDefaultState();
|
||||
void Restore();
|
||||
|
||||
bool BeginScene();
|
||||
void EndScene();
|
||||
|
||||
// Material
|
||||
void SaveMaterial();
|
||||
void SaveMaterial(const D3DMATERIAL8 * pMaterial);
|
||||
void RestoreMaterial();
|
||||
void SetMaterial(const D3DMATERIAL8 * pMaterial);
|
||||
void GetMaterial(D3DMATERIAL8 * pMaterial);
|
||||
|
||||
void SetLight(DWORD index, CONST D3DLIGHT8* pLight);
|
||||
void GetLight(DWORD index, D3DLIGHT8* pLight);
|
||||
|
||||
// Renderstates
|
||||
void SaveRenderState(D3DRENDERSTATETYPE Type, DWORD dwValue);
|
||||
void RestoreRenderState(D3DRENDERSTATETYPE Type);
|
||||
void SetRenderState(D3DRENDERSTATETYPE Type, DWORD Value);
|
||||
void GetRenderState(D3DRENDERSTATETYPE Type, DWORD * pdwValue);
|
||||
|
||||
// Textures
|
||||
void SaveTexture(DWORD dwStage, LPDIRECT3DBASETEXTURE8 pTexture);
|
||||
void RestoreTexture(DWORD dwStage);
|
||||
void SetTexture(DWORD dwStage, LPDIRECT3DBASETEXTURE8 pTexture);
|
||||
void GetTexture(DWORD dwStage, LPDIRECT3DBASETEXTURE8 * ppTexture);
|
||||
|
||||
// Texture stage states
|
||||
void SaveTextureStageState(DWORD dwStage, D3DTEXTURESTAGESTATETYPE Type, DWORD dwValue);
|
||||
void RestoreTextureStageState(DWORD dwStage, D3DTEXTURESTAGESTATETYPE Type);
|
||||
void SetTextureStageState(DWORD dwStage, D3DTEXTURESTAGESTATETYPE Type, DWORD dwValue);
|
||||
void GetTextureStageState(DWORD dwStage, D3DTEXTURESTAGESTATETYPE Type, DWORD * pdwValue);
|
||||
void SetBestFiltering(DWORD dwStage); // if possible set anisotropy filtering, or use trilinear
|
||||
|
||||
// Vertex Shader
|
||||
void SaveVertexShader(DWORD dwShader);
|
||||
void RestoreVertexShader();
|
||||
void SetVertexShader(DWORD dwShader);
|
||||
void GetVertexShader(DWORD * pdwShader);
|
||||
|
||||
// Pixel Shader
|
||||
void SavePixelShader(DWORD dwShader);
|
||||
void RestorePixelShader();
|
||||
void SetPixelShader(DWORD dwShader);
|
||||
void GetPixelShader(DWORD * pdwShader);
|
||||
|
||||
// *** These states are cached, but not protected from multiple sends of the same value.
|
||||
// Transform
|
||||
void SaveTransform(D3DTRANSFORMSTATETYPE Transform, const D3DMATRIX* pMatrix);
|
||||
void RestoreTransform(D3DTRANSFORMSTATETYPE Transform);
|
||||
|
||||
// Don't cache-check the transform. To much to do
|
||||
void SetTransform(D3DTRANSFORMSTATETYPE Type, const D3DMATRIX* pMatrix);
|
||||
void GetTransform(D3DTRANSFORMSTATETYPE Type, D3DMATRIX * pMatrix);
|
||||
|
||||
// SetVertexShaderConstant
|
||||
void SaveVertexShaderConstant(DWORD dwRegister, CONST void* pConstantData, DWORD dwConstantCount);
|
||||
void RestoreVertexShaderConstant(DWORD dwRegister, DWORD dwConstantCount);
|
||||
void SetVertexShaderConstant(DWORD dwRegister, CONST void* pConstantData, DWORD dwConstantCount);
|
||||
|
||||
// SetPixelShaderConstant
|
||||
void SavePixelShaderConstant(DWORD dwRegister, CONST void* pConstantData, DWORD dwConstantCount);
|
||||
void RestorePixelShaderConstant(DWORD dwRegister, DWORD dwConstantCount);
|
||||
void SetPixelShaderConstant(DWORD dwRegister, CONST void* pConstantData, DWORD dwConstantCount);
|
||||
|
||||
void SaveStreamSource(UINT StreamNumber, LPDIRECT3DVERTEXBUFFER8 pStreamData, UINT Stride);
|
||||
void RestoreStreamSource(UINT StreamNumber);
|
||||
void SetStreamSource(UINT StreamNumber, LPDIRECT3DVERTEXBUFFER8 pStreamData, UINT Stride);
|
||||
|
||||
void SaveIndices(LPDIRECT3DINDEXBUFFER8 pIndexData, UINT BaseVertexIndex);
|
||||
void RestoreIndices();
|
||||
void SetIndices(LPDIRECT3DINDEXBUFFER8 pIndexData,UINT BaseVertexIndex);
|
||||
|
||||
HRESULT DrawPrimitive(D3DPRIMITIVETYPE PrimitiveType, UINT StartVertex, UINT PrimitiveCount);
|
||||
HRESULT DrawPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount, const void* pVertexStreamZeroData, UINT VertexStreamZeroStride);
|
||||
HRESULT DrawIndexedPrimitive(D3DPRIMITIVETYPE PrimitiveType, UINT minIndex, UINT NumVertices, UINT startIndex, UINT primCount);
|
||||
HRESULT DrawIndexedPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType, UINT MinVertexIndex, UINT NumVertexIndices, UINT PrimitiveCount, CONST void * pIndexData, D3DFORMAT IndexDataFormat, CONST void * pVertexStreamZeroData, UINT VertexStreamZeroStride);
|
||||
|
||||
// Codes For Debug
|
||||
DWORD GetRenderState(D3DRENDERSTATETYPE Type);
|
||||
|
||||
private:
|
||||
void SetDevice(LPDIRECT3DDEVICE8 lpDevice);
|
||||
|
||||
private:
|
||||
CStateManagerState m_ChipState;
|
||||
CStateManagerState m_CurrentState;
|
||||
CStateManagerState m_CopyState;
|
||||
TStateID m_DirtyStates;
|
||||
bool m_bForce;
|
||||
bool m_bScene;
|
||||
DWORD m_dwBestMinFilter;
|
||||
DWORD m_dwBestMagFilter;
|
||||
LPDIRECT3DDEVICE8 m_lpD3DDev;
|
||||
|
||||
#ifdef _DEBUG
|
||||
// Saving Flag
|
||||
BOOL m_bRenderStateSavingFlag[STATEMANAGER_MAX_RENDERSTATES];
|
||||
BOOL m_bTextureStageStateSavingFlag[STATEMANAGER_MAX_STAGES][STATEMANAGER_MAX_TEXTURESTATES];
|
||||
BOOL m_bTransformSavingFlag[STATEMANAGER_MAX_TRANSFORMSTATES];
|
||||
#endif _DEBUG
|
||||
};
|
||||
|
||||
#define STATEMANAGER (CStateManager::Instance())
|
||||
|
||||
#endif __CSTATEMANAGER_H
|
||||
@@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include "DibBar.h"
|
||||
|
||||
class CTextBar : public CDibBar
|
||||
{
|
||||
public:
|
||||
CTextBar(int fontSize, bool isBold);
|
||||
virtual ~CTextBar();
|
||||
|
||||
void TextOut(int ix, int iy, const char * c_szText);
|
||||
void SetTextColor(int r, int g, int b);
|
||||
void GetTextExtent(const char * c_szText, SIZE* p_size);
|
||||
|
||||
protected:
|
||||
void __SetFont(int fontSize, bool isBold);
|
||||
|
||||
void OnCreate();
|
||||
|
||||
protected:
|
||||
HFONT m_hFont;
|
||||
HFONT m_hOldFont;
|
||||
|
||||
int m_fontSize;
|
||||
bool m_isBold;
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
#ifndef __INC_ETERLIB_THREAD_H__
|
||||
#define __INC_ETERLIB_THREAD_H__
|
||||
|
||||
class CThread
|
||||
{
|
||||
public:
|
||||
CThread();
|
||||
int Create(void * arg);
|
||||
|
||||
protected:
|
||||
static UINT CALLBACK EntryPoint(void * pThis);
|
||||
|
||||
virtual UINT Setup() = 0; // Execute이 불려지기 전에 불려진다.
|
||||
virtual UINT Execute(void * arg) = 0; // 실제 쓰레드가 하는 일이 들어가는 곳
|
||||
|
||||
UINT Run(void * arg);
|
||||
|
||||
void * Arg() const { return m_pArg; }
|
||||
void Arg(void * arg) { m_pArg = arg; }
|
||||
|
||||
HANDLE m_hThread;
|
||||
|
||||
private:
|
||||
void * m_pArg;
|
||||
unsigned m_uThreadID;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,248 @@
|
||||
#ifndef __INC_ETERPACKLIB_ETERPACK_H__
|
||||
#define __INC_ETERPACKLIB_ETERPACK_H__
|
||||
|
||||
#include <list>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "../EterBase/MappedFile.h"
|
||||
|
||||
#ifndef MAKEFOURCC
|
||||
#define MAKEFOURCC(ch0, ch1, ch2, ch3) \
|
||||
((DWORD)(BYTE) (ch0 ) | ((DWORD)(BYTE) (ch1) << 8) | \
|
||||
((DWORD)(BYTE) (ch2) << 16) | ((DWORD)(BYTE) (ch3) << 24))
|
||||
#endif
|
||||
|
||||
|
||||
//#define CHECKSUM_CHECK_MD5
|
||||
|
||||
#include "md5.h"
|
||||
|
||||
namespace eterpack
|
||||
{
|
||||
const DWORD c_PackCC = MAKEFOURCC('E', 'P', 'K', 'D');
|
||||
const DWORD c_IndexCC = MAKEFOURCC('E', 'P', 'K', 'D');
|
||||
const DWORD c_Version = 2;
|
||||
// FourCC + Version + m_indexCount
|
||||
const DWORD c_HeaderSize = sizeof(DWORD) + sizeof(DWORD) + sizeof(long);
|
||||
};
|
||||
|
||||
enum EEterPackTypes
|
||||
{
|
||||
DBNAME_MAX_LEN = 255,
|
||||
FILENAME_MAX_LEN = 160,
|
||||
FREE_INDEX_BLOCK_SIZE = 32768,
|
||||
FREE_INDEX_MAX_SIZE = 512,
|
||||
DATA_BLOCK_SIZE = 256,
|
||||
|
||||
COMPRESSED_TYPE_NONE = 0,
|
||||
COMPRESSED_TYPE_COMPRESS = 1,
|
||||
COMPRESSED_TYPE_SECURITY = 2,
|
||||
COMPRESSED_TYPE_PANAMA = 3,
|
||||
COMPRESSED_TYPE_HYBRIDCRYPT = 4,
|
||||
COMPRESSED_TYPE_HYBRIDCRYPT_WITHSDB = 5,
|
||||
COMPRESSED_TYPE_COUNT = 6,
|
||||
};
|
||||
|
||||
#pragma pack(push, 4)
|
||||
typedef struct SEterPackIndex
|
||||
{
|
||||
long id;
|
||||
char filename[FILENAME_MAX_LEN + 1];
|
||||
DWORD filename_crc;
|
||||
long real_data_size;
|
||||
long data_size;
|
||||
#ifdef CHECKSUM_CHECK_MD5
|
||||
BYTE MD5Digest[16];
|
||||
#else
|
||||
DWORD data_crc;
|
||||
#endif
|
||||
long data_position;
|
||||
char compressed_type;
|
||||
} TEterPackIndex;
|
||||
#pragma pack(pop)
|
||||
|
||||
typedef std::unordered_map<DWORD, TEterPackIndex *> TDataPositionMap;
|
||||
typedef std::list<TEterPackIndex *> TFreeIndexList;
|
||||
|
||||
|
||||
class CEterPack;
|
||||
|
||||
class CEterFileDict
|
||||
{
|
||||
public:
|
||||
struct Item
|
||||
{
|
||||
Item() : pkPack(NULL), pkInfo(NULL) {}
|
||||
|
||||
CEterPack* pkPack;
|
||||
TEterPackIndex* pkInfo;
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
BUCKET_SIZE = 16,
|
||||
};
|
||||
|
||||
typedef std::unordered_multimap<DWORD, Item> TDict;
|
||||
|
||||
public:
|
||||
void InsertItem(CEterPack* pkPack, TEterPackIndex* pkInfo);
|
||||
void UpdateItem(CEterPack* pkPack, TEterPackIndex* pkInfo);
|
||||
|
||||
Item* GetItem(DWORD dwFileNameHash, const char* c_pszFileName);
|
||||
|
||||
const TDict& GetDict() const
|
||||
{
|
||||
return m_dict;
|
||||
}
|
||||
|
||||
private:
|
||||
TDict m_dict;
|
||||
};
|
||||
|
||||
class EterPackPolicy_CSHybridCrypt;
|
||||
|
||||
class CEterPack
|
||||
{
|
||||
public:
|
||||
CEterPack();
|
||||
virtual ~CEterPack();
|
||||
|
||||
void Destroy();
|
||||
bool Create(CEterFileDict& rkFileDict, const char * dbname, const char * pathName, bool bReadOnly = true, const BYTE* iv = NULL);
|
||||
bool DecryptIV(DWORD dwPanamaKey);
|
||||
|
||||
const std::string& GetPathName();
|
||||
const char * GetDBName();
|
||||
|
||||
//THEMIDA
|
||||
bool Get(CMappedFile & mappedFile, const char * filename, LPCVOID * data);
|
||||
//THEMIDA
|
||||
bool Get2(CMappedFile & mappedFile, const char * filename, TEterPackIndex* index, LPCVOID * data);
|
||||
|
||||
|
||||
//THEMIDA
|
||||
bool Put(const char * filename, const char * sourceFilename, BYTE packType, const std::string& strRelateMapName);
|
||||
//THEMIDA
|
||||
bool Put(const char * filename, LPCVOID data, long len, BYTE packType);
|
||||
|
||||
bool Delete(const char * filename);
|
||||
|
||||
bool Extract();
|
||||
|
||||
long GetFragmentSize();
|
||||
|
||||
bool IsExist(const char * filename);
|
||||
|
||||
TDataPositionMap & GetIndexMap();
|
||||
|
||||
bool EncryptIndexFile();
|
||||
bool DecryptIndexFile();
|
||||
|
||||
DWORD DeleteUnreferencedData(); // 몇개가 삭제 되었는지 리턴 한다.
|
||||
|
||||
bool GetNames(std::vector<std::string>* retNames);
|
||||
|
||||
EterPackPolicy_CSHybridCrypt* GetPackPolicy_HybridCrypt() const;
|
||||
|
||||
private:
|
||||
bool __BuildIndex(CEterFileDict& rkFileDict, bool bOverwirte=false);
|
||||
|
||||
bool CreateIndexFile();
|
||||
TEterPackIndex * FindIndex(const char * filename);
|
||||
long GetNewIndexPosition(CFileBase& file);
|
||||
TEterPackIndex * NewIndex(CFileBase& file, const char * filename, long size);
|
||||
void WriteIndex(CFileBase& file, TEterPackIndex * index);
|
||||
int GetFreeBlockIndex(long size);
|
||||
void PushFreeIndex(TEterPackIndex * index);
|
||||
|
||||
bool CreateDataFile();
|
||||
long GetNewDataPosition(CFileBase& file);
|
||||
bool ReadData(CFileBase& file, TEterPackIndex * index, LPVOID data, long maxsize);
|
||||
bool WriteData(CFileBase& file, TEterPackIndex * index, LPCVOID data);
|
||||
bool WriteNewData(CFileBase& file, TEterPackIndex * index, LPCVOID data);
|
||||
|
||||
bool Delete(TEterPackIndex * pIndex);
|
||||
|
||||
protected:
|
||||
CMappedFile m_file;
|
||||
|
||||
char* m_file_data;
|
||||
unsigned m_file_size;
|
||||
|
||||
long m_indexCount;
|
||||
bool m_bEncrypted;
|
||||
|
||||
char m_dbName[DBNAME_MAX_LEN+1];
|
||||
char m_indexFileName[MAX_PATH+1];
|
||||
TEterPackIndex * m_indexData;
|
||||
long m_FragmentSize;
|
||||
bool m_bReadOnly;
|
||||
bool m_bDecrypedIV;
|
||||
|
||||
std::unordered_map<DWORD, DWORD> m_map_indexRefCount;
|
||||
TDataPositionMap m_DataPositionMap;
|
||||
TFreeIndexList m_FreeIndexList[FREE_INDEX_MAX_SIZE + 1]; // MAX 도 억세스 하므로 + 1 크기만큼 만든다.
|
||||
|
||||
std::string m_stDataFileName;
|
||||
std::string m_stPathName;
|
||||
|
||||
|
||||
EterPackPolicy_CSHybridCrypt* m_pCSHybridCryptPolicy;
|
||||
|
||||
private:
|
||||
void __CreateFileNameKey_Panama(const char * filename, BYTE * key, unsigned int keySize);
|
||||
bool __Decrypt_Panama(const char* filename, const BYTE* data, SIZE_T dataSize, CLZObject& zObj);
|
||||
bool __Encrypt_Panama(const char* filename, const BYTE* data, SIZE_T dataSize, CLZObject& zObj);
|
||||
std::string m_stIV_Panama;
|
||||
|
||||
//private:
|
||||
// bool m_bIsDataLoaded;
|
||||
// // 그냥 time_t를 쓰면, 32bit time_t를 사용하는 소스에서는,
|
||||
// // CEterPack의 size를 실제 size - 4로 인식하기 때문에 문제가 발생할 수 있다.
|
||||
// __time64_t m_tLastAccessTime;
|
||||
//public:
|
||||
// __time64_t GetLastAccessTime() { return m_tLastAccessTime; }
|
||||
// void UpdateLastAccessTime();
|
||||
// void ClearDataMemoryMap();
|
||||
|
||||
#ifdef CHECKSUM_CHECK_MD5
|
||||
void GenerateMD5Hash( BYTE* pData, int nLength, IN OUT MD5_CTX& context );
|
||||
#endif
|
||||
};
|
||||
|
||||
class CMakePackLog
|
||||
{
|
||||
public:
|
||||
static CMakePackLog& GetSingleton();
|
||||
|
||||
public:
|
||||
CMakePackLog();
|
||||
~CMakePackLog();
|
||||
|
||||
void SetFileName(const char* c_szFileName);
|
||||
|
||||
void Writef(const char* c_szFormat, ...);
|
||||
void Writenf(const char* c_szFormat, ...);
|
||||
void Write(const char* c_szBuf);
|
||||
|
||||
void WriteErrorf(const char* c_szFormat, ...);
|
||||
void WriteErrornf(const char* c_szFormat, ...);
|
||||
void WriteError(const char* c_szBuf);
|
||||
|
||||
void FlushError();
|
||||
|
||||
private:
|
||||
void __Write(const char* c_szBuf, int nBufLen);
|
||||
void __WriteError(const char* c_szBuf, int nBufLen);
|
||||
bool __IsLogMode();
|
||||
|
||||
private:
|
||||
FILE* m_fp;
|
||||
FILE* m_fp_err;
|
||||
|
||||
std::string m_stFileName;
|
||||
std::string m_stErrorFileName;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,96 @@
|
||||
#pragma once
|
||||
|
||||
#include <windows.h>
|
||||
#include <unordered_map>
|
||||
#include "../EterBase/Singleton.h"
|
||||
#include "../EterBase/Stl.h"
|
||||
|
||||
#include "EterPack.h"
|
||||
|
||||
class CEterPackManager : public CSingleton<CEterPackManager>
|
||||
{
|
||||
public:
|
||||
struct SCache
|
||||
{
|
||||
BYTE* m_abBufData;
|
||||
DWORD m_dwBufSize;
|
||||
};
|
||||
public:
|
||||
enum ESearchModes
|
||||
{
|
||||
SEARCH_FILE_FIRST,
|
||||
SEARCH_PACK_FIRST
|
||||
};
|
||||
|
||||
typedef std::list<CEterPack*> TEterPackList;
|
||||
typedef std::unordered_map<std::string, CEterPack*, stringhash> TEterPackMap;
|
||||
|
||||
public:
|
||||
CEterPackManager();
|
||||
virtual ~CEterPackManager();
|
||||
|
||||
void SetCacheMode();
|
||||
void SetRelativePathMode();
|
||||
|
||||
void LoadStaticCache(const char* c_szFileName);
|
||||
|
||||
void SetSearchMode(bool bPackFirst);
|
||||
int GetSearchMode();
|
||||
|
||||
//THEMIDA
|
||||
bool Get(CMappedFile & rMappedFile, const char * c_szFileName, LPCVOID * pData);
|
||||
|
||||
//THEMIDA
|
||||
bool GetFromPack(CMappedFile & rMappedFile, const char * c_szFileName, LPCVOID * pData);
|
||||
|
||||
//THEMIDA
|
||||
bool GetFromFile(CMappedFile & rMappedFile, const char * c_szFileName, LPCVOID * pData);
|
||||
bool isExist(const char * c_szFileName);
|
||||
bool isExistInPack(const char * c_szFileName);
|
||||
|
||||
bool RegisterPack(const char * c_szName, const char * c_szDirectory, const BYTE* c_pbIV = NULL);
|
||||
void RegisterRootPack(const char * c_szName);
|
||||
bool RegisterPackWhenPackMaking(const char * c_szName, const char * c_szDirectory, CEterPack* pPack);
|
||||
|
||||
|
||||
bool DecryptPackIV(DWORD key);
|
||||
|
||||
const char * GetRootPackFileName();
|
||||
|
||||
//for hybridcrypt
|
||||
//THEMIDA
|
||||
void WriteHybridCryptPackInfo(const char* pFileName);
|
||||
|
||||
//THEMIDA
|
||||
void RetrieveHybridCryptPackKeys( const BYTE* pStream );
|
||||
//THEMIDA
|
||||
void RetrieveHybridCryptPackSDB( const BYTE* pStream );
|
||||
|
||||
// 메모리에 매핑된 팩들 가운데, 정리해야할 것들 정리.
|
||||
public:
|
||||
void ArrangeMemoryMappedPack();
|
||||
|
||||
protected:
|
||||
int ConvertFileName(const char * c_szFileName, std::string & rstrFileName); // StringPath std::string 버전
|
||||
bool CompareName(const char * c_szDirectoryName, DWORD iLength, const char * c_szFileName);
|
||||
|
||||
CEterPack* FindPack(const char* c_szPathName);
|
||||
|
||||
SCache* __FindCache(DWORD dwFileNameHash);
|
||||
void __ClearCacheMap();
|
||||
|
||||
protected:
|
||||
bool m_bTryRelativePath;
|
||||
bool m_isCacheMode;
|
||||
int m_iSearchMode;
|
||||
|
||||
CEterFileDict m_FileDict;
|
||||
CEterPack m_RootPack;
|
||||
TEterPackList m_PackList;
|
||||
TEterPackMap m_PackMap;
|
||||
TEterPackMap m_DirPackMap;
|
||||
|
||||
std::unordered_map<DWORD, SCache> m_kMap_dwNameKey_kCache;
|
||||
|
||||
CRITICAL_SECTION m_csFinder;
|
||||
};
|
||||
@@ -0,0 +1,889 @@
|
||||
#pragma once
|
||||
|
||||
// class CActorInstance
|
||||
|
||||
// Note : 캐릭터의 Lighting, Local Point Light, Weapon Trace 등의 효과와 콤보 데이타, 사운드 데이타,
|
||||
// 모션 데이타 들을 추상적, 총체적으로 관리하는 개별 매니저가 될 것이다.
|
||||
|
||||
#include "FlyTarget.h"
|
||||
#include "RaceData.h"
|
||||
#include "RaceMotionData.h"
|
||||
#include "PhysicsObject.h"
|
||||
#include "ActorInstanceInterface.h"
|
||||
#include "Interface.h"
|
||||
//#include "../eterGrnLib/ThingInstance.h"
|
||||
|
||||
class CItemData;
|
||||
class CWeaponTrace;
|
||||
class IFlyEventHandler;
|
||||
class CSpeedTreeWrapper;
|
||||
|
||||
class IMobProto : public CSingleton<IMobProto>
|
||||
{
|
||||
public:
|
||||
IMobProto() {}
|
||||
virtual ~IMobProto() {}
|
||||
|
||||
virtual bool FindRaceType(UINT eRace, UINT* puType);
|
||||
};
|
||||
|
||||
class CActorInstance : public IActorInstance, public IFlyTargetableObject
|
||||
{
|
||||
public:
|
||||
class IEventHandler
|
||||
{
|
||||
public:
|
||||
static IEventHandler* GetEmptyPtr();
|
||||
|
||||
public:
|
||||
struct SState
|
||||
{
|
||||
TPixelPosition kPPosSelf;
|
||||
FLOAT fAdvRotSelf;
|
||||
};
|
||||
|
||||
public:
|
||||
IEventHandler() {}
|
||||
virtual ~IEventHandler() {}
|
||||
|
||||
virtual void OnSyncing(const SState& c_rkState) = 0;
|
||||
virtual void OnWaiting(const SState& c_rkState) = 0;
|
||||
virtual void OnMoving(const SState& c_rkState) = 0;
|
||||
virtual void OnMove(const SState& c_rkState) = 0;
|
||||
virtual void OnStop(const SState& c_rkState) = 0;
|
||||
virtual void OnWarp(const SState& c_rkState) = 0;
|
||||
virtual void OnSetAffect(UINT uAffect) = 0;
|
||||
virtual void OnResetAffect(UINT uAffect) = 0;
|
||||
virtual void OnClearAffects() = 0;
|
||||
|
||||
virtual void OnAttack(const SState& c_rkState, WORD wMotionIndex) = 0;
|
||||
virtual void OnUseSkill(const SState& c_rkState, UINT uMotSkill, UINT uMotLoopCount) = 0;
|
||||
|
||||
virtual void OnHit(UINT uSkill, CActorInstance& rkActorVictim, BOOL isSendPacket) = 0;
|
||||
|
||||
virtual void OnChangeShape() = 0;
|
||||
};
|
||||
|
||||
// 2004.07.05.myevan.궁신탄영 맵에 끼이는 문제해결
|
||||
private:
|
||||
static IBackground& GetBackground();
|
||||
|
||||
public:
|
||||
static bool IsDirLine();
|
||||
|
||||
public:
|
||||
|
||||
enum EType
|
||||
{
|
||||
TYPE_ENEMY,
|
||||
TYPE_NPC,
|
||||
TYPE_STONE,
|
||||
TYPE_WARP,
|
||||
TYPE_DOOR,
|
||||
TYPE_BUILDING,
|
||||
TYPE_PC,
|
||||
TYPE_POLY,
|
||||
TYPE_HORSE,
|
||||
TYPE_GOTO,
|
||||
|
||||
TYPE_OBJECT, // Only For Client
|
||||
};
|
||||
|
||||
enum ERenderMode
|
||||
{
|
||||
RENDER_MODE_NORMAL,
|
||||
RENDER_MODE_BLEND,
|
||||
RENDER_MODE_ADD,
|
||||
RENDER_MODE_MODULATE,
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
// Motion Queueing System
|
||||
enum EMotionPushType
|
||||
{
|
||||
MOTION_TYPE_NONE,
|
||||
MOTION_TYPE_ONCE,
|
||||
MOTION_TYPE_LOOP,
|
||||
};
|
||||
|
||||
typedef struct SReservingMotionNode
|
||||
{
|
||||
EMotionPushType iMotionType;
|
||||
|
||||
float fStartTime;
|
||||
float fBlendTime;
|
||||
float fDuration;
|
||||
float fSpeedRatio;
|
||||
|
||||
DWORD dwMotionKey;
|
||||
} TReservingMotionNode;
|
||||
|
||||
struct SCurrentMotionNode
|
||||
{
|
||||
EMotionPushType iMotionType;
|
||||
DWORD dwMotionKey;
|
||||
|
||||
DWORD dwcurFrame;
|
||||
DWORD dwFrameCount;
|
||||
|
||||
float fStartTime;
|
||||
float fEndTime;
|
||||
float fSpeedRatio;
|
||||
|
||||
int iLoopCount;
|
||||
UINT uSkill;
|
||||
};
|
||||
|
||||
typedef std::deque<TReservingMotionNode> TMotionDeque;
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
// Motion Event
|
||||
typedef struct SMotionEventInstance
|
||||
{
|
||||
int iType;
|
||||
int iMotionEventIndex;
|
||||
float fStartingTime;
|
||||
|
||||
const CRaceMotionData::TMotionEventData * c_pMotionData;
|
||||
} TMotionEventInstance;
|
||||
|
||||
typedef std::list<TMotionEventInstance> TMotionEventInstanceList;
|
||||
typedef TMotionEventInstanceList::iterator TMotionEventInstanceListIterator;
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
// For Collision Detection
|
||||
typedef struct SCollisionPointInstance
|
||||
{
|
||||
const NRaceData::TCollisionData * c_pCollisionData;
|
||||
BOOL isAttached;
|
||||
DWORD dwModelIndex;
|
||||
DWORD dwBoneIndex;
|
||||
CDynamicSphereInstanceVector SphereInstanceVector;
|
||||
} TCollisionPointInstance;
|
||||
typedef std::list<TCollisionPointInstance> TCollisionPointInstanceList;
|
||||
typedef TCollisionPointInstanceList::iterator TCollisionPointInstanceListIterator;
|
||||
|
||||
typedef std::map<CActorInstance*, float> THittedInstanceMap;
|
||||
typedef std::map<const NRaceData::THitData *, THittedInstanceMap> THitDataMap;
|
||||
struct SSplashArea
|
||||
{
|
||||
BOOL isEnableHitProcess;
|
||||
UINT uSkill;
|
||||
MOTION_KEY MotionKey;
|
||||
float fDisappearingTime;
|
||||
const CRaceMotionData::TMotionAttackingEventData * c_pAttackingEvent;
|
||||
CDynamicSphereInstanceVector SphereInstanceVector;
|
||||
|
||||
THittedInstanceMap HittedInstanceMap;
|
||||
};
|
||||
|
||||
typedef struct SHittingData
|
||||
{
|
||||
BYTE byAttackingType;
|
||||
DWORD dwMotionKey;
|
||||
BYTE byEventIndex;
|
||||
} THittingData;
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
// For Attaching
|
||||
enum EAttachEffect
|
||||
{
|
||||
EFFECT_LIFE_NORMAL,
|
||||
EFFECT_LIFE_INFINITE,
|
||||
EFFECT_LIFE_WITH_MOTION,
|
||||
};
|
||||
|
||||
struct TAttachingEffect
|
||||
{
|
||||
DWORD dwEffectIndex;
|
||||
int iBoneIndex;
|
||||
DWORD dwModelIndex;
|
||||
D3DXMATRIX matTranslation;
|
||||
BOOL isAttaching;
|
||||
|
||||
int iLifeType;
|
||||
DWORD dwEndTime;
|
||||
};
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public:
|
||||
static void ShowDirectionLine(bool isVisible);
|
||||
static void DestroySystem();
|
||||
|
||||
public:
|
||||
CActorInstance();
|
||||
virtual ~CActorInstance();
|
||||
|
||||
// 20041201.myevan.인스턴스베이스용 함수
|
||||
void INSTANCEBASE_Transform();
|
||||
void INSTANCEBASE_Deform();
|
||||
|
||||
void Destroy();
|
||||
|
||||
void Move();
|
||||
void Stop(float fBlendingTime=0.15f);
|
||||
|
||||
void SetMainInstance();
|
||||
|
||||
void SetParalysis(bool isParalysis);
|
||||
void SetFaint(bool isFaint);
|
||||
void SetSleep(bool isSleep);
|
||||
void SetResistFallen(bool isResistFallen);
|
||||
|
||||
void SetAttackSpeed(float fAtkSpd);
|
||||
void SetMoveSpeed(float fMovSpd);
|
||||
|
||||
void SetMaterialAlpha(DWORD dwAlpha);
|
||||
void SetMaterialColor(DWORD dwColor);
|
||||
|
||||
void SetEventHandler(IEventHandler* pkEventHandler);
|
||||
|
||||
bool SetRace(DWORD eRace);
|
||||
void SetHair(DWORD eHair);
|
||||
void SetVirtualID(DWORD dwVID);
|
||||
|
||||
void SetShape(DWORD eShape, float fSpecular=0.0f);
|
||||
void ChangeMaterial(const char * c_szFileName);
|
||||
|
||||
public:
|
||||
void SetComboType(WORD wComboType);
|
||||
|
||||
DWORD GetRace();
|
||||
DWORD GetVirtualID();
|
||||
|
||||
UINT GetActorType() const;
|
||||
void SetActorType(UINT eType);
|
||||
|
||||
bool CanAct();
|
||||
bool CanMove();
|
||||
bool CanAttack();
|
||||
bool CanUseSkill();
|
||||
|
||||
bool IsPC();
|
||||
bool IsNPC();
|
||||
bool IsEnemy();
|
||||
bool IsStone();
|
||||
bool IsWarp();
|
||||
bool IsGoto();
|
||||
bool IsObject();
|
||||
bool IsDoor();
|
||||
bool IsPoly();
|
||||
|
||||
bool IsBuilding();
|
||||
|
||||
bool IsHandMode();
|
||||
bool IsBowMode();
|
||||
bool IsTwoHandMode();
|
||||
|
||||
void AttachWeapon(DWORD dwItemIndex,DWORD dwParentPartIndex = CRaceData::PART_MAIN, DWORD dwPartIndex = CRaceData::PART_WEAPON);
|
||||
void AttachWeapon(DWORD dwParentPartIndex, DWORD dwPartIndex, CItemData * pItemData);
|
||||
|
||||
void RefreshActorInstance();
|
||||
DWORD GetPartItemID(DWORD dwPartIndex);
|
||||
|
||||
// Attach Effect
|
||||
BOOL GetAttachingBoneName(DWORD dwPartIndex, const char ** c_szBoneName);
|
||||
void UpdateAttachingInstances();
|
||||
void DettachEffect(DWORD dwEID);
|
||||
DWORD AttachEffectByName(DWORD dwParentPartIndex, const char * c_pszBoneName, const char * c_pszEffectFileName);
|
||||
DWORD AttachEffectByID(DWORD dwParentPartIndex, const char * c_pszBoneName, DWORD dwEffectID, const D3DXVECTOR3 * c_pv3Position = NULL);
|
||||
DWORD AttachSmokeEffect(DWORD eSmoke);
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
// Motion Queueing System
|
||||
void SetMotionMode(int iMotionMode); // FIXME : 모드의 시간차 적용이 가능하게끔 한다.
|
||||
int GetMotionMode();
|
||||
void SetLoopMotion(DWORD dwMotion, float fBlendTime = 0.1f, float fSpeedRatio=1.0f);
|
||||
bool InterceptOnceMotion(DWORD dwMotion, float fBlendTime = 0.1f, UINT uSkill=0, float fSpeedRatio=1.0f);
|
||||
bool InterceptLoopMotion(DWORD dwMotion, float fBlendTime = 0.1f);
|
||||
bool PushOnceMotion(DWORD dwMotion, float fBlendTime = 0.1f, float fSpeedRatio=1.0f); // FIXME : 모드의 시간차 적용이 가능하게끔 한다.
|
||||
bool PushLoopMotion(DWORD dwMotion, float fBlendTime = 0.1f, float fSpeedRatio=1.0f); // FIXME : 모드의 시간차 적용이 가능하게끔 한다.
|
||||
void SetMotionLoopCount(int iCount);
|
||||
|
||||
bool IsPushing();
|
||||
|
||||
BOOL isLock();
|
||||
BOOL IsUsingSkill();
|
||||
BOOL CanCheckAttacking();
|
||||
BOOL CanCancelSkill();
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
// Collison Detection
|
||||
bool CreateCollisionInstancePiece(DWORD dwAttachingModelIndex, const NRaceData::TAttachingData * c_pAttachingData, TCollisionPointInstance * pPointInstance);
|
||||
|
||||
void UpdatePointInstance();
|
||||
void UpdatePointInstance(TCollisionPointInstance * pPointInstance);
|
||||
bool CheckCollisionDetection(const CDynamicSphereInstanceVector * c_pAttackingSphereVector, D3DXVECTOR3 * pv3Position);
|
||||
|
||||
// Collision Detection Checking
|
||||
virtual bool TestCollisionWithDynamicSphere(const CDynamicSphereInstance & dsi);
|
||||
|
||||
void UpdateAdvancingPointInstance();
|
||||
|
||||
BOOL IsClickableDistanceDestInstance(CActorInstance & rkInstDst, float fDistance);
|
||||
|
||||
bool AvoidObject(const CGraphicObjectInstance& c_rkBGObj);
|
||||
bool IsBlockObject(const CGraphicObjectInstance& c_rkBGObj);
|
||||
void BlockMovement();
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
protected:
|
||||
BOOL __TestObjectCollision(const CGraphicObjectInstance * c_pObjectInstance);
|
||||
|
||||
public:
|
||||
BOOL TestActorCollision(CActorInstance & rVictim );
|
||||
BOOL TestPhysicsBlendingCollision(CActorInstance & rVictim);
|
||||
|
||||
BOOL AttackingProcess(CActorInstance & rVictim);
|
||||
|
||||
void PreAttack();
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
// Battle
|
||||
// Input
|
||||
// 하위로 옮길 가능성이 있는 코드들
|
||||
// 네트웍 연동시 전투 관련은 플레이어를 제외하곤 단순히 Showing Type이기 때문에
|
||||
// 조건 검사가 필요 없다.
|
||||
void InputNormalAttackCommand(float fDirRot); // Process input - Only used by player's character
|
||||
bool InputComboAttackCommand(float fDirRot); // Process input - Only used by player's character
|
||||
|
||||
// Command
|
||||
BOOL isAttacking();
|
||||
BOOL isNormalAttacking();
|
||||
BOOL isComboAttacking();
|
||||
BOOL IsSplashAttacking();
|
||||
BOOL IsUsingMovingSkill();
|
||||
BOOL IsActEmotion();
|
||||
DWORD GetComboIndex();
|
||||
float GetAttackingElapsedTime();
|
||||
void SetBlendingPosition(const TPixelPosition & c_rPosition, float fBlendingTime = 1.0f);
|
||||
void ResetBlendingPosition();
|
||||
void GetBlendingPosition(TPixelPosition * pPosition);
|
||||
|
||||
BOOL NormalAttack(float fDirRot, float fBlendTime = 0.1f);
|
||||
BOOL ComboAttack(DWORD wMotionIndex, float fDirRot, float fBlendTime = 0.1f);
|
||||
|
||||
void Revive();
|
||||
|
||||
BOOL IsSleep();
|
||||
BOOL IsParalysis();
|
||||
BOOL IsFaint();
|
||||
BOOL IsResistFallen();
|
||||
BOOL IsWaiting();
|
||||
BOOL IsMoving();
|
||||
BOOL IsDead();
|
||||
BOOL IsStun();
|
||||
BOOL IsAttacked();
|
||||
BOOL IsDamage();
|
||||
BOOL IsKnockDown();
|
||||
void SetWalkMode();
|
||||
void SetRunMode();
|
||||
void Stun();
|
||||
void Die();
|
||||
void DieEnd();
|
||||
|
||||
void SetBattleHitEffect(DWORD dwID);
|
||||
void SetBattleAttachEffect(DWORD dwID);
|
||||
|
||||
MOTION_KEY GetNormalAttackIndex();
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
// Position
|
||||
const D3DXVECTOR3& GetMovementVectorRef();
|
||||
const D3DXVECTOR3& GetPositionVectorRef();
|
||||
|
||||
void SetCurPixelPosition(const TPixelPosition& c_rkPPosCur);
|
||||
void NEW_SetAtkPixelPosition(const TPixelPosition& c_rkPPosAtk);
|
||||
void NEW_SetSrcPixelPosition(const TPixelPosition& c_rkPPosSrc);
|
||||
void NEW_SetDstPixelPosition(const TPixelPosition& c_rkPPosDst);
|
||||
void NEW_SetDstPixelPositionZ(float z);
|
||||
|
||||
const TPixelPosition& NEW_GetAtkPixelPositionRef();
|
||||
const TPixelPosition& NEW_GetCurPixelPositionRef();
|
||||
const TPixelPosition& NEW_GetSrcPixelPositionRef();
|
||||
const TPixelPosition& NEW_GetDstPixelPositionRef();
|
||||
|
||||
const TPixelPosition& NEW_GetLastPixelPositionRef();
|
||||
|
||||
void GetPixelPosition(TPixelPosition * pPixelPosition);
|
||||
void SetPixelPosition(const TPixelPosition& c_rPixelPos);
|
||||
|
||||
// Rotation Command
|
||||
void LookAt(float fDirRot);
|
||||
void LookAt(float fx, float fy);
|
||||
void LookAt(CActorInstance * pInstance);
|
||||
void LookWith(CActorInstance * pInstance);
|
||||
void LookAtFromXY(float x, float y, CActorInstance * pDestInstance);
|
||||
|
||||
|
||||
void SetReachScale(float fScale);
|
||||
void SetOwner(DWORD dwOwnerVID);
|
||||
|
||||
float GetRotation();
|
||||
float GetTargetRotation();
|
||||
|
||||
float GetAdvancingRotation();
|
||||
|
||||
float GetRotatingTime();
|
||||
void SetRotation(float fRot);
|
||||
void SetXYRotation(float fRotX, float fRotY);
|
||||
void BlendRotation(float fRot, float fBlendTime);
|
||||
void SetAdvancingRotation(float fRot);
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
void MotionEventProcess();
|
||||
void MotionEventProcess(DWORD dwcurTime, int iIndex, const CRaceMotionData::TMotionEventData * c_pData);
|
||||
void SoundEventProcess(BOOL bCheckFrequency);
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////
|
||||
// Rendering Functions - Temporary Place
|
||||
BOOL IsMovement();
|
||||
|
||||
void RestoreRenderMode();
|
||||
|
||||
void BeginDiffuseRender();
|
||||
void EndDiffuseRender();
|
||||
void BeginOpacityRender();
|
||||
void EndOpacityRender();
|
||||
|
||||
void BeginBlendRender();
|
||||
void EndBlendRender();
|
||||
void SetBlendRenderMode();
|
||||
void SetAlphaValue(float fAlpha);
|
||||
float GetAlphaValue();
|
||||
void BlendAlphaValue(float fDstAlpha, float fDuration);
|
||||
void SetSpecularInfo(BOOL bEnable, int iPart, float fAlpha);
|
||||
void SetSpecularInfoForce(BOOL bEnable, int iPart, float fAlpha);
|
||||
|
||||
void BeginAddRender();
|
||||
void EndAddRender();
|
||||
void SetAddRenderMode();
|
||||
void SetAddColor(const D3DXCOLOR & c_rColor);
|
||||
|
||||
void BeginModulateRender();
|
||||
void EndModulateRender();
|
||||
void SetModulateRenderMode();
|
||||
|
||||
void SetRenderMode(int iRenderMode);
|
||||
|
||||
void RenderTrace();
|
||||
void RenderCollisionData();
|
||||
void RenderToShadowMap();
|
||||
|
||||
|
||||
protected:
|
||||
void __AdjustCollisionMovement(const CGraphicObjectInstance * c_pGraphicObjectInstance);
|
||||
|
||||
public:
|
||||
void AdjustDynamicCollisionMovement(const CActorInstance * c_pActorInstance);
|
||||
|
||||
// Weapon Trace
|
||||
void SetWeaponTraceTexture(const char * szTextureName);
|
||||
void UseTextureWeaponTrace();
|
||||
void UseAlphaWeaponTrace();
|
||||
|
||||
// ETC
|
||||
void UpdateAttribute();
|
||||
bool IntersectDefendingSphere();
|
||||
float GetHeight();
|
||||
void ShowAllAttachingEffect();
|
||||
void HideAllAttachingEffect();
|
||||
void ClearAttachingEffect();
|
||||
|
||||
// Fishing
|
||||
bool CanFishing();
|
||||
BOOL IsFishing();
|
||||
void SetFishingPosition(D3DXVECTOR3 & rv3Position);
|
||||
|
||||
// Flying Methods
|
||||
// As a Flying Target
|
||||
public:
|
||||
virtual D3DXVECTOR3 OnGetFlyTargetPosition();
|
||||
|
||||
void OnShootDamage();
|
||||
|
||||
// As a Shooter
|
||||
// NOTE : target and target position are exclusive
|
||||
public:
|
||||
void ClearFlyTarget();
|
||||
bool IsFlyTargetObject();
|
||||
void AddFlyTarget(const CFlyTarget & cr_FlyTarget);
|
||||
void SetFlyTarget(const CFlyTarget & cr_FlyTarget);
|
||||
void LookAtFlyTarget();
|
||||
|
||||
float GetFlyTargetDistance();
|
||||
|
||||
void ClearFlyEventHandler();
|
||||
void SetFlyEventHandler(IFlyEventHandler * pHandler);
|
||||
|
||||
// 2004. 07. 07. [levites] - 스킬 사용중 타겟이 바뀌는 문제 해결을 위한 코드
|
||||
bool CanChangeTarget();
|
||||
|
||||
protected:
|
||||
IFlyEventHandler * m_pFlyEventHandler;
|
||||
|
||||
public:
|
||||
void MountHorse(CActorInstance * pkHorse);
|
||||
void HORSE_MotionProcess(BOOL isPC);
|
||||
void MotionProcess(BOOL isPC);
|
||||
void RotationProcess();
|
||||
void PhysicsProcess();
|
||||
void ComboProcess();
|
||||
void TransformProcess();
|
||||
void AccumulationMovement();
|
||||
void ShakeProcess();
|
||||
void TraceProcess();
|
||||
void __MotionEventProcess(BOOL isPC);
|
||||
void __AccumulationMovement(float fRot);
|
||||
BOOL __SplashAttackProcess(CActorInstance & rVictim);
|
||||
BOOL __NormalAttackProcess(CActorInstance & rVictim);
|
||||
bool __CanInputNormalAttackCommand();
|
||||
|
||||
private:
|
||||
void __Shake(DWORD dwDuration);
|
||||
|
||||
protected:
|
||||
CFlyTarget m_kFlyTarget;
|
||||
CFlyTarget m_kBackupFlyTarget;
|
||||
std::deque<CFlyTarget> m_kQue_kFlyTarget;
|
||||
|
||||
protected:
|
||||
bool __IsInSplashTime();
|
||||
|
||||
void OnUpdate();
|
||||
void OnRender();
|
||||
|
||||
BOOL isValidAttacking();
|
||||
|
||||
void ReservingMotionProcess();
|
||||
void CurrentMotionProcess();
|
||||
MOTION_KEY GetRandomMotionKey(MOTION_KEY dwMotionKey);
|
||||
|
||||
float GetLastMotionTime(float fBlendTime); // NOTE : 자동으로 BlendTime만큼을 앞당긴 시간을 리턴
|
||||
float GetMotionDuration(DWORD dwMotionKey);
|
||||
|
||||
bool InterceptMotion(EMotionPushType iMotionType, WORD wMotion, float fBlendTime = 0.1f, UINT uSkill=0, float fSpeedRatio=1.0f);
|
||||
void PushMotion(EMotionPushType iMotionType, DWORD dwMotionKey, float fBlendTime, float fSpeedRatio=1.0f);
|
||||
void ProcessMotionEventEffectEvent(const CRaceMotionData::TMotionEventData * c_pData);
|
||||
void ProcessMotionEventEffectToTargetEvent(const CRaceMotionData::TMotionEventData * c_pData);
|
||||
void ProcessMotionEventSpecialAttacking(int iMotionEventIndex, const CRaceMotionData::TMotionEventData * c_pData);
|
||||
void ProcessMotionEventSound(const CRaceMotionData::TMotionEventData * c_pData);
|
||||
void ProcessMotionEventFly(const CRaceMotionData::TMotionEventData * c_pData);
|
||||
void ProcessMotionEventWarp(const CRaceMotionData::TMotionEventData * c_pData);
|
||||
|
||||
void AddMovement(float fx, float fy, float fz);
|
||||
|
||||
bool __IsLeftHandWeapon(DWORD type);
|
||||
bool __IsRightHandWeapon(DWORD type);
|
||||
bool __IsWeaponTrace(DWORD weaponType);
|
||||
|
||||
protected:
|
||||
void __InitializeMovement();
|
||||
|
||||
protected:
|
||||
void __Initialize();
|
||||
|
||||
void __ClearAttachingEffect();
|
||||
|
||||
float __GetOwnerTime();
|
||||
DWORD __GetOwnerVID();
|
||||
bool __CanPushDestActor(CActorInstance& rkActorDst);
|
||||
|
||||
protected:
|
||||
void __RunNextCombo();
|
||||
void __ClearCombo();
|
||||
void __OnEndCombo();
|
||||
|
||||
void __ProcessDataAttackSuccess(const NRaceData::TAttackData & c_rAttackData, CActorInstance & rVictim, const D3DXVECTOR3 & c_rv3Position, UINT uiSkill = 0, BOOL isSendPacket = TRUE);
|
||||
void __ProcessMotionEventAttackSuccess(DWORD dwMotionKey, BYTE byEventIndex, CActorInstance & rVictim);
|
||||
void __ProcessMotionAttackSuccess(DWORD dwMotionKey, CActorInstance & rVictim);
|
||||
|
||||
|
||||
void __HitStone(CActorInstance& rVictim);
|
||||
void __HitGood(CActorInstance& rVictim);
|
||||
void __HitGreate(CActorInstance& rVictim);
|
||||
|
||||
void __PushDirect(CActorInstance & rVictim);
|
||||
void __PushCircle(CActorInstance & rVictim);
|
||||
bool __isInvisible();
|
||||
void __SetFallingDirection(float fx, float fy);
|
||||
|
||||
protected:
|
||||
struct SSetMotionData
|
||||
{
|
||||
MOTION_KEY dwMotKey;
|
||||
float fSpeedRatio;
|
||||
float fBlendTime;
|
||||
int iLoopCount;
|
||||
UINT uSkill;
|
||||
|
||||
SSetMotionData()
|
||||
{
|
||||
iLoopCount=0;
|
||||
dwMotKey=0;
|
||||
fSpeedRatio=1.0f;
|
||||
fBlendTime=0.0f;
|
||||
uSkill=0;
|
||||
}
|
||||
};
|
||||
|
||||
protected:
|
||||
float __GetAttackSpeed();
|
||||
DWORD __SetMotion(const SSetMotionData& c_rkSetMotData, DWORD dwRandMotKey=0); // 모션 데이터 설정
|
||||
void __ClearMotion();
|
||||
|
||||
bool __BindMotionData(DWORD dwMotionKey); // 모션 데이터를 바인딩
|
||||
void __ClearHittedActorInstanceMap(); // 때려진 액터 인스턴스 맵을 지운다
|
||||
|
||||
UINT __GetMotionType(); // 모션 타입 얻기
|
||||
|
||||
bool __IsNeedFlyTargetMotion(); // FlyTarget 이 필요한 모션인가?
|
||||
bool __HasMotionFlyEvent(); // 무언가를 쏘는가?
|
||||
bool __IsWaitMotion(); // 대기 모션 인가?
|
||||
bool __IsMoveMotion(); // 이동 모션 인가?
|
||||
bool __IsAttackMotion(); // 공격 모션 인가?
|
||||
bool __IsComboAttackMotion(); // 콤보 공격 모션 인가?
|
||||
bool __IsDamageMotion(); // 데미지 모션인가?
|
||||
bool __IsKnockDownMotion(); // 넉다운 모션인가?
|
||||
bool __IsDieMotion(); // 사망 모션 인가?
|
||||
bool __IsStandUpMotion(); // 일어서기 모션인가?
|
||||
bool __IsMountingHorse();
|
||||
|
||||
bool __CanAttack(); // 공격 할수 있는가?
|
||||
bool __CanNextComboAttack(); // 다음 콤보 어택이 가능한가?
|
||||
|
||||
bool __IsComboAttacking(); // 콤보 공격중인가?
|
||||
void __CancelComboAttack(); // 콤보 공격 취소
|
||||
|
||||
WORD __GetCurrentMotionIndex();
|
||||
DWORD __GetCurrentMotionKey();
|
||||
|
||||
int __GetLoopCount();
|
||||
WORD __GetCurrentComboType();
|
||||
|
||||
void __ShowEvent();
|
||||
void __HideEvent();
|
||||
BOOL __IsHiding();
|
||||
BOOL __IsMovingSkill(WORD wSkillNumber);
|
||||
|
||||
float __GetReachScale();
|
||||
|
||||
void __CreateAttributeInstance(CAttributeData * pData);
|
||||
|
||||
bool __IsFlyTargetPC();
|
||||
bool __IsSameFlyTarget(CActorInstance * pInstance);
|
||||
D3DXVECTOR3 __GetFlyTargetPosition();
|
||||
|
||||
protected:
|
||||
void __DestroyWeaponTrace(); // 무기 잔상을 제거한다
|
||||
void __ShowWeaponTrace(); // 무기 잔상을 보인다
|
||||
void __HideWeaponTrace(); // 무기 잔상을 감춘다
|
||||
|
||||
protected:
|
||||
// collision data
|
||||
void OnUpdateCollisionData(const CStaticCollisionDataVector * pscdVector);
|
||||
void OnUpdateHeighInstance(CAttributeInstance * pAttributeInstance);
|
||||
bool OnGetObjectHeight(float fX, float fY, float * pfHeight);
|
||||
|
||||
protected:
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
// Motion Queueing System
|
||||
TMotionDeque m_MotionDeque;
|
||||
SCurrentMotionNode m_kCurMotNode;
|
||||
WORD m_wcurMotionMode;
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
// For Collision Detection
|
||||
TCollisionPointInstanceList m_BodyPointInstanceList;
|
||||
TCollisionPointInstanceList m_DefendingPointInstanceList;
|
||||
SSplashArea m_kSplashArea; // TODO : 복수에 대한 고려를 해야한다 - [levites]
|
||||
CAttributeInstance * m_pAttributeInstance;
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
// For Battle System
|
||||
std::vector<CWeaponTrace*> m_WeaponTraceVector;
|
||||
CPhysicsObject m_PhysicsObject;
|
||||
|
||||
DWORD m_dwcurComboIndex;
|
||||
|
||||
DWORD m_eActorType;
|
||||
|
||||
DWORD m_eRace;
|
||||
DWORD m_eShape;
|
||||
DWORD m_eHair;
|
||||
BOOL m_isPreInput;
|
||||
BOOL m_isNextPreInput;
|
||||
DWORD m_dwcurComboBackMotionIndex;
|
||||
|
||||
WORD m_wcurComboType;
|
||||
|
||||
float m_fAtkDirRot;
|
||||
|
||||
CRaceData* m_pkCurRaceData;
|
||||
CRaceMotionData* m_pkCurRaceMotionData;
|
||||
|
||||
// Defender
|
||||
float m_fInvisibleTime;
|
||||
BOOL m_isHiding;
|
||||
|
||||
// TODO : State로 통합 시킬 수 있는지 고려해 볼것
|
||||
BOOL m_isResistFallen;
|
||||
BOOL m_isSleep;
|
||||
BOOL m_isFaint;
|
||||
BOOL m_isParalysis;
|
||||
BOOL m_isStun;
|
||||
BOOL m_isRealDead;
|
||||
BOOL m_isWalking;
|
||||
BOOL m_isMain;
|
||||
|
||||
// Effect
|
||||
DWORD m_dwBattleHitEffectID;
|
||||
DWORD m_dwBattleAttachEffectID;
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Fishing
|
||||
D3DXVECTOR3 m_v3FishingPosition;
|
||||
int m_iFishingEffectID;
|
||||
|
||||
// Position
|
||||
float m_x;
|
||||
float m_y;
|
||||
float m_z;
|
||||
D3DXVECTOR3 m_v3Pos;
|
||||
D3DXVECTOR3 m_v3Movement;
|
||||
BOOL m_bNeedUpdateCollision;
|
||||
|
||||
DWORD m_dwShakeTime;
|
||||
|
||||
float m_fReachScale;
|
||||
float m_fMovSpd;
|
||||
float m_fAtkSpd;
|
||||
|
||||
// Rotation
|
||||
float m_fcurRotation;
|
||||
float m_rotBegin;
|
||||
float m_rotEnd;
|
||||
float m_rotEndTime;
|
||||
float m_rotBeginTime;
|
||||
float m_rotBlendTime;
|
||||
float m_fAdvancingRotation;
|
||||
float m_rotX;
|
||||
float m_rotY;
|
||||
|
||||
float m_fOwnerBaseTime;
|
||||
|
||||
// Rendering
|
||||
int m_iRenderMode;
|
||||
D3DXCOLOR m_AddColor;
|
||||
float m_fAlphaValue;
|
||||
|
||||
// Part
|
||||
DWORD m_adwPartItemID[CRaceData::PART_MAX_NUM];
|
||||
|
||||
// Attached Effect
|
||||
std::list<TAttachingEffect> m_AttachingEffectList;
|
||||
bool m_bEffectInitialized;
|
||||
|
||||
// material color
|
||||
DWORD m_dwMtrlColor;
|
||||
DWORD m_dwMtrlAlpha;
|
||||
|
||||
TPixelPosition m_kPPosCur;
|
||||
TPixelPosition m_kPPosSrc;
|
||||
TPixelPosition m_kPPosDst;
|
||||
TPixelPosition m_kPPosAtk;
|
||||
|
||||
TPixelPosition m_kPPosLast;
|
||||
|
||||
THitDataMap m_HitDataMap;
|
||||
|
||||
CActorInstance * m_pkHorse;
|
||||
CSpeedTreeWrapper * m_pkTree;
|
||||
|
||||
|
||||
protected:
|
||||
DWORD m_dwSelfVID;
|
||||
DWORD m_dwOwnerVID;
|
||||
|
||||
|
||||
protected:
|
||||
void __InitializeStateData();
|
||||
void __InitializeMotionData();
|
||||
void __InitializeRotationData();
|
||||
void __InitializePositionData();
|
||||
|
||||
public: // InstanceBase 통합전 임시로 public
|
||||
IEventHandler* __GetEventHandlerPtr();
|
||||
IEventHandler& __GetEventHandlerRef();
|
||||
|
||||
void __OnSyncing();
|
||||
void __OnWaiting();
|
||||
void __OnMoving();
|
||||
void __OnMove();
|
||||
void __OnStop();
|
||||
void __OnWarp();
|
||||
void __OnClearAffects();
|
||||
void __OnSetAffect(UINT uAffect);
|
||||
void __OnResetAffect(UINT uAffect);
|
||||
void __OnAttack(WORD wMotionIndex);
|
||||
void __OnUseSkill(UINT uMotSkill, UINT uLoopCount, bool isMoving);
|
||||
|
||||
protected:
|
||||
void __OnHit(UINT uSkill, CActorInstance& rkInstVictm, BOOL isSendPacket);
|
||||
|
||||
public:
|
||||
void EnableSkipCollision();
|
||||
void DisableSkipCollision();
|
||||
bool CanSkipCollision();
|
||||
|
||||
protected:
|
||||
void __InitializeCollisionData();
|
||||
|
||||
bool m_canSkipCollision;
|
||||
|
||||
protected:
|
||||
struct SBlendAlpha
|
||||
{
|
||||
float m_fBaseTime;
|
||||
float m_fBaseAlpha;
|
||||
float m_fDuration;
|
||||
float m_fDstAlpha;
|
||||
|
||||
DWORD m_iOldRenderMode;
|
||||
bool m_isBlending;
|
||||
} m_kBlendAlpha;
|
||||
|
||||
void __BlendAlpha_Initialize();
|
||||
void __BlendAlpha_Apply(float fDstAlpha, float fDuration);
|
||||
void __BlendAlpha_Update();
|
||||
void __BlendAlpha_UpdateFadeIn();
|
||||
void __BlendAlpha_UpdateFadeOut();
|
||||
void __BlendAlpha_UpdateComplete();
|
||||
float __BlendAlpha_GetElapsedTime();
|
||||
|
||||
void __Push(int x, int y);
|
||||
|
||||
public:
|
||||
void TEMP_Push(int x, int y);
|
||||
bool __IsSyncing();
|
||||
|
||||
void __CreateTree(const char * c_szFileName);
|
||||
void __DestroyTree();
|
||||
void __SetTreePosition(float fx, float fy, float fz);
|
||||
|
||||
protected:
|
||||
IEventHandler* m_pkEventHandler;
|
||||
|
||||
protected:
|
||||
static bool ms_isDirLine;
|
||||
};
|
||||
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include "../EterGrnLib/ThingInstance.h"
|
||||
|
||||
class IActorInstance : public CGraphicThingInstance
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
ID = ACTOR_OBJECT
|
||||
};
|
||||
int GetType() const { return ID; }
|
||||
|
||||
IActorInstance() {}
|
||||
virtual ~IActorInstance() {}
|
||||
virtual bool TestCollisionWithDynamicSphere(const CDynamicSphereInstance & dsi) = 0;
|
||||
virtual DWORD GetVirtualID() = 0;
|
||||
};
|
||||
@@ -0,0 +1,310 @@
|
||||
#pragma once
|
||||
|
||||
#include "../SpeedTreeLib/SpeedTreeWrapper.h"
|
||||
#include "../EterGrnLib/ThingInstance.h"
|
||||
#include "MapType.h"
|
||||
#include "DungeonBlock.h"
|
||||
|
||||
class CMapOutdoor;
|
||||
class CEffectInstance;
|
||||
|
||||
class CArea
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
ROTATION_STEP_COUNT = 24,
|
||||
ROTATION_STEP_AMOUNT = 360 / ROTATION_STEP_COUNT,
|
||||
YAW_STEP_COUNT = 24,
|
||||
YAW_STEP_AMOUNT = 360 / YAW_STEP_COUNT,
|
||||
PITCH_STEP_COUNT = YAW_STEP_COUNT,
|
||||
PITCH_STEP_AMOUNT = YAW_STEP_AMOUNT,
|
||||
};
|
||||
|
||||
typedef D3DXVECTOR3 TObjectPosition;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Object Static Data
|
||||
typedef struct SObjectData
|
||||
{
|
||||
TObjectPosition Position;
|
||||
DWORD dwCRC;
|
||||
BYTE abyPortalID[PORTAL_ID_MAX_NUM];
|
||||
|
||||
// For Tree
|
||||
// - Nothing
|
||||
|
||||
// For Granny Thing
|
||||
float m_fYaw;
|
||||
float m_fPitch;
|
||||
float m_fRoll;
|
||||
float m_fHeightBias;
|
||||
|
||||
// For Effect
|
||||
// - Nothing
|
||||
|
||||
// For Ambience
|
||||
DWORD dwRange;
|
||||
float fMaxVolumeAreaPercentage;
|
||||
|
||||
void InitializeRotation();
|
||||
} TObjectData;
|
||||
|
||||
struct ObjectDataComp
|
||||
{
|
||||
bool operator () (TObjectData & lhs, TObjectData & rhs) const
|
||||
{
|
||||
return lhs.dwCRC < rhs.dwCRC;
|
||||
}
|
||||
};
|
||||
|
||||
typedef std::vector<TObjectData> TObjectDataVector;
|
||||
typedef TObjectDataVector::iterator TObjectDataIterator;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Object Dynamic Data
|
||||
typedef struct SAmbienceInstance : public CScreen
|
||||
{
|
||||
float fx, fy, fz;
|
||||
DWORD dwRange;
|
||||
float fMaxVolumeAreaPercentage;
|
||||
int iPlaySoundIndex;
|
||||
float fNextPlayTime;
|
||||
prt::TPropertyAmbience AmbienceData;
|
||||
|
||||
SAmbienceInstance();
|
||||
virtual ~SAmbienceInstance() {}
|
||||
void __Update(float fxCenter, float fyCenter, float fzCenter);
|
||||
void (SAmbienceInstance::*Update)(float fxCenter, float fyCenter, float fzCenter);
|
||||
void UpdateOnceSound(float fxCenter, float fyCenter, float fzCenter);
|
||||
void UpdateStepSound(float fxCenter, float fyCenter, float fzCenter);
|
||||
void UpdateLoopSound(float fxCenter, float fyCenter, float fzCenter);
|
||||
void Render();
|
||||
bool Picking();
|
||||
float __GetVolumeFromDistance(float fDistance);
|
||||
} TAmbienceInstance;
|
||||
|
||||
typedef struct SObjectInstance
|
||||
{
|
||||
DWORD dwType;
|
||||
CAttributeInstance * pAttributeInstance;
|
||||
|
||||
// Data For Tree
|
||||
CSpeedTreeWrapper * pTree;
|
||||
|
||||
// Data For Normal Object or Building
|
||||
BOOL isShadowFlag;
|
||||
CGraphicThingInstance * pThingInstance;
|
||||
|
||||
// Data for Effect
|
||||
DWORD dwEffectID;
|
||||
DWORD dwEffectInstanceIndex;
|
||||
|
||||
// Data For Ambience
|
||||
TAmbienceInstance * pAmbienceInstance;
|
||||
|
||||
// Dungeon
|
||||
CDungeonBlock * pDungeonBlock;
|
||||
|
||||
void Clear()
|
||||
{
|
||||
if (pTree)
|
||||
pTree->Clear();
|
||||
|
||||
if (pThingInstance)
|
||||
pThingInstance->Clear();
|
||||
|
||||
if (pAttributeInstance)
|
||||
pAttributeInstance->Clear();
|
||||
|
||||
if (pAmbienceInstance)
|
||||
pAmbienceInstance->Clear();
|
||||
|
||||
if (pDungeonBlock)
|
||||
pDungeonBlock->Clear();
|
||||
|
||||
__Initialize();
|
||||
}
|
||||
|
||||
void SetTree(float x, float y, float z, DWORD dwTreeCRC, const char* c_szTreeName);
|
||||
|
||||
void __Initialize()
|
||||
{
|
||||
dwType = prt::PROPERTY_TYPE_NONE;
|
||||
|
||||
dwEffectID = 0xffffffff;
|
||||
dwEffectInstanceIndex = 0xffffffff;
|
||||
isShadowFlag = false;
|
||||
|
||||
pTree=NULL;
|
||||
pThingInstance=NULL;
|
||||
pAttributeInstance=NULL;
|
||||
pAmbienceInstance=NULL;
|
||||
pDungeonBlock=NULL;
|
||||
}
|
||||
|
||||
SObjectInstance()
|
||||
{
|
||||
__Initialize();
|
||||
}
|
||||
virtual ~SObjectInstance()
|
||||
{
|
||||
}
|
||||
} TObjectInstance;
|
||||
|
||||
typedef std::vector<CSpeedTreeWrapper *> TTreeInstanceVector;
|
||||
typedef std::vector<CGraphicThingInstance *> TThingInstanceVector;
|
||||
typedef std::vector<CDungeonBlock *> TDungeonBlockInstanceVector;
|
||||
typedef std::vector<TObjectInstance *> TObjectInstanceVector;
|
||||
typedef std::vector<TAmbienceInstance *> TAmbienceInstanceVector;
|
||||
typedef std::map<CGraphicThingInstance *, DWORD> TGraphicThingInstanceCRCMap; // 최적화용 by 동현
|
||||
typedef std::set<int> TShowingPortalIDSet;
|
||||
|
||||
typedef struct SCRCWithNumber
|
||||
{
|
||||
DWORD dwCRC;
|
||||
DWORD dwNumber;
|
||||
} TCRCWithNumber;
|
||||
|
||||
typedef std::vector<TCRCWithNumber> TCRCWithNumberVector;
|
||||
|
||||
struct FFindIfCRC
|
||||
{
|
||||
|
||||
FFindIfCRC(DWORD dwCRC) { m_dwCRC = dwCRC; }
|
||||
|
||||
bool operator() (TCRCWithNumber & rCRCWithNumber)
|
||||
{
|
||||
if (rCRCWithNumber.dwCRC == m_dwCRC)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
DWORD m_dwCRC;
|
||||
};
|
||||
|
||||
struct CRCNumComp
|
||||
{
|
||||
bool operator () (TCRCWithNumber & lhs, TCRCWithNumber & rhs) const
|
||||
{
|
||||
return lhs.dwNumber > rhs.dwNumber;
|
||||
}
|
||||
};
|
||||
|
||||
public:
|
||||
CArea();
|
||||
virtual ~CArea();
|
||||
|
||||
void CollectRenderingObject(std::vector<CGraphicThingInstance*>& rkVct_pkOpaqueThingInst);
|
||||
void CollectBlendRenderingObject(std::vector<CGraphicThingInstance*>& rkVct_pkBlendThingInst);
|
||||
|
||||
void SetMapOutDoor(CMapOutdoor * pOwnerOutdoorMap);
|
||||
void Clear();
|
||||
|
||||
bool Load(const char * c_szPathName);
|
||||
|
||||
DWORD GetObjectDataCount();
|
||||
bool GetObjectDataPointer(DWORD dwIndex, const TObjectData ** ppObjectData) const;
|
||||
|
||||
const DWORD GetObjectInstanceCount() const;
|
||||
const bool GetObjectInstancePointer(const DWORD & dwIndex, const TObjectInstance ** ppObjectInstance) const;
|
||||
|
||||
void EnablePortal(BOOL bFlag=TRUE);
|
||||
void ClearPortal();
|
||||
void AddShowingPortalID(int iNum);
|
||||
void RefreshPortal();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void Update();
|
||||
void UpdateAroundAmbience(float fX, float fY, float fZ);
|
||||
|
||||
void Render();
|
||||
void RenderEffect();
|
||||
void RenderCollision();
|
||||
void RenderAmbience();
|
||||
void RenderDungeon();
|
||||
void Refresh();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void SetCoordinate(const WORD & c_usCoordX, const WORD & c_usCoordY);
|
||||
void GetCoordinate(WORD * usCoordX, WORD * usCoordY);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
DWORD DEBUG_GetRenderedCRCNum();
|
||||
TCRCWithNumberVector & DEBUG_GetRenderedCRCWithNumVector();
|
||||
DWORD DEBUG_GetRenderedGrapphicThingInstanceNum();
|
||||
|
||||
CMapOutdoor * GetOwner() { return m_pOwnerOutdoorMap; }
|
||||
|
||||
protected:
|
||||
|
||||
bool CheckObjectIndex(DWORD dwIndex) const;
|
||||
|
||||
bool __Load_LoadObject(const char * c_szFileName);
|
||||
bool __Load_LoadAmbience(const char * c_szFileName);
|
||||
void __Load_BuildObjectInstances();
|
||||
|
||||
void __UpdateAniThingList();
|
||||
void __UpdateEffectList();
|
||||
|
||||
void __LoadAttribute(TObjectInstance * pObjectInstance, const char * c_szAttributeFileName);
|
||||
|
||||
protected:
|
||||
void __Clear_DestroyObjectInstance(TObjectInstance * pObjectInstance);
|
||||
|
||||
void __SetObjectInstance(TObjectInstance * pObjectInstance, const TObjectData * c_pData);
|
||||
void __SetObjectInstance_SetTree(TObjectInstance * pObjectInstance, const TObjectData * c_pData, CProperty * pProperty);
|
||||
void __SetObjectInstance_SetBuilding(TObjectInstance * pObjectInstance, const TObjectData * c_pData, CProperty * pProperty);
|
||||
void __SetObjectInstance_SetEffect(TObjectInstance * pObjectInstance, const TObjectData * c_pData, CProperty * pProperty);
|
||||
void __SetObjectInstance_SetAmbience(TObjectInstance * pObjectInstance, const TObjectData * c_pData, CProperty * pProperty);
|
||||
void __SetObjectInstance_SetDungeonBlock(TObjectInstance * pObjectInstance, const TObjectData * c_pData, CProperty * pProperty);
|
||||
|
||||
protected:
|
||||
// Static Data
|
||||
TObjectDataVector m_ObjectDataVector; // Area 상에 있는 오브젝트들
|
||||
|
||||
// Rendering Instances
|
||||
TObjectInstanceVector m_ObjectInstanceVector;
|
||||
|
||||
// Clone Instance Vector
|
||||
TTreeInstanceVector m_TreeCloneInstaceVector;
|
||||
TThingInstanceVector m_ThingCloneInstaceVector;
|
||||
TDungeonBlockInstanceVector m_DungeonBlockCloneInstanceVector;
|
||||
TThingInstanceVector m_AniThingCloneInstanceVector;
|
||||
TThingInstanceVector m_ShadowThingCloneInstaceVector;
|
||||
TAmbienceInstanceVector m_AmbienceCloneInstanceVector;
|
||||
TGraphicThingInstanceCRCMap m_GraphicThingInstanceCRCMap;
|
||||
TCRCWithNumberVector m_kRenderedThingInstanceCRCWithNumberVector;
|
||||
TThingInstanceVector m_kRenderedGrapphicThingInstanceVector;
|
||||
|
||||
// 좌표 : 심리스 맵 전체 중에서의 좌표... 둘다 0~999
|
||||
WORD m_wX;
|
||||
WORD m_wY;
|
||||
|
||||
// Owner COutdoorMap poineter
|
||||
CMapOutdoor * m_pOwnerOutdoorMap;
|
||||
|
||||
protected:
|
||||
static CDynamicPool<TObjectInstance> ms_ObjectInstancePool;
|
||||
static CDynamicPool<CAttributeInstance> ms_AttributeInstancePool;
|
||||
static CDynamicPool<TAmbienceInstance> ms_AmbienceInstancePool;
|
||||
static CDynamicPool<CDungeonBlock> ms_DungeonBlockInstancePool;
|
||||
|
||||
typedef std::map<DWORD, CEffectInstance*> TEffectInstanceMap;
|
||||
typedef TEffectInstanceMap::iterator TEffectInstanceIterator;
|
||||
TEffectInstanceMap m_EffectInstanceMap;
|
||||
|
||||
BOOL m_bPortalEnable;
|
||||
TShowingPortalIDSet m_kSet_ShowingPortalID;
|
||||
|
||||
public:
|
||||
static void DestroySystem();
|
||||
|
||||
static CArea* New();
|
||||
static void Delete(CArea* pkArea);
|
||||
|
||||
static CDynamicPool<CArea> ms_kPool;
|
||||
};
|
||||
@@ -0,0 +1,160 @@
|
||||
#pragma once
|
||||
|
||||
class CMapOutdoor;
|
||||
|
||||
#include "../PRTerrainLib/Terrain.h"
|
||||
#include "TerrainPatch.h"
|
||||
|
||||
class CTerrain : public CTerrainImpl, public CGraphicBase
|
||||
{
|
||||
public:
|
||||
|
||||
enum EBoundaryLoadPart
|
||||
{
|
||||
LOAD_INVALID,
|
||||
LOAD_NOBOUNDARY,
|
||||
LOAD_TOPLEFT,
|
||||
LOAD_TOP,
|
||||
LOAD_TOPRIGHT,
|
||||
LOAD_LEFT,
|
||||
LOAD_RIGHT,
|
||||
LOAD_BOTTOMLEFT,
|
||||
LOAD_BOTTOM,
|
||||
LOAD_BOTTOMRIGHT,
|
||||
LOAD_ALLBOUNDARY,
|
||||
};
|
||||
|
||||
CTerrain();
|
||||
virtual ~CTerrain();
|
||||
|
||||
virtual void Clear();
|
||||
|
||||
void SetMapOutDoor(CMapOutdoor * pOwnerOutdoorMap);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Loading
|
||||
bool RAW_LoadTileMap(const char * c_pszFileName, bool bBGLoading = false);
|
||||
|
||||
bool LoadHeightMap(const char * c_pszFileName);
|
||||
|
||||
void CalculateTerrainPatch();
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void CopySettingFromGlobalSetting();
|
||||
|
||||
WORD WE_GetHeightMapValue(short sX, short sY);
|
||||
|
||||
bool IsReady() { return m_bReady; }
|
||||
void SetReady(bool bReady = true) { m_bReady = bReady; }
|
||||
|
||||
// Height Map
|
||||
WORD * GetHeightMap() { return m_awRawHeightMap; }
|
||||
float GetHeight(int x, int y);
|
||||
|
||||
// Normal Map
|
||||
bool GetNormal(int ix, int iy, D3DXVECTOR3 * pv3Normal);
|
||||
|
||||
// TileMap
|
||||
BYTE * RAW_GetTileMap() { return m_abyTileMap; }
|
||||
char * GetNormalMap() { return m_acNormalMap; }
|
||||
|
||||
// Attr
|
||||
bool LoadAttrMap(const char * c_pszFileName);
|
||||
BYTE * GetAttrMap() { return m_abyAttrMap; }
|
||||
BYTE GetAttr(WORD wCoordX, WORD wCoordY);
|
||||
bool isAttrOn(WORD wCoordX, WORD wCoordY, BYTE byAttrFlag);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Water
|
||||
BYTE * GetWaterMap() { return m_abyWaterMap; }
|
||||
void GetWaterHeight(BYTE byWaterNum, long * plWaterHeight);
|
||||
bool GetWaterHeight(WORD wCoordX, WORD wCoordY, long * plWaterHeight);
|
||||
|
||||
// Shadow Texture
|
||||
void LoadShadowTexture(const char * c_pszFileName);
|
||||
|
||||
// Shadow Map
|
||||
bool LoadShadowMap(const char * c_pszFileName);
|
||||
|
||||
// MiniMap
|
||||
void LoadMiniMapTexture(const char * c_pszFileName);
|
||||
inline LPDIRECT3DTEXTURE8 GetMiniMapTexture() { return m_lpMiniMapTexture; }
|
||||
|
||||
// Marked Area
|
||||
BOOL IsMarked() { return m_bMarked; }
|
||||
void AllocateMarkedSplats(BYTE * pbyAlphaMap);
|
||||
void DeallocateMarkedSplats();
|
||||
TTerrainSplatPatch & GetMarkedSplatPatch() { return m_MarkedSplatPatch; }
|
||||
|
||||
// Coordinate
|
||||
void GetCoordinate(WORD * usCoordX, WORD * usCoordY)
|
||||
{
|
||||
*usCoordX = m_wX;
|
||||
*usCoordY = m_wY;
|
||||
}
|
||||
|
||||
void SetCoordinate(WORD wCoordX, WORD wCoordY);
|
||||
|
||||
std::string & GetName() { return m_strName; }
|
||||
void SetName(const std::string c_strName) { m_strName = c_strName; }
|
||||
|
||||
CMapOutdoor * GetOwner() { return m_pOwnerOutdoorMap; }
|
||||
void RAW_GenerateSplat(bool bBGLoading = false);
|
||||
|
||||
protected:
|
||||
bool Initialize();
|
||||
void RAW_AllocateSplats(bool bBGLoading = false);
|
||||
void RAW_DeallocateSplats(bool bBGLoading = false);
|
||||
virtual void RAW_CountTiles();
|
||||
|
||||
LPDIRECT3DTEXTURE8 AddTexture32(BYTE byImageNum, BYTE * pbyImage, long lTextureWidth, long lTextureHeight);
|
||||
void PutImage32(BYTE * pbySrc, BYTE * pbyDst, long src_pitch, long dst_pitch, long lTextureWidth, long lTextureHeight, bool bResize = false);
|
||||
void PutImage16(BYTE * pbySrc, BYTE * pbyDst, long src_pitch, long dst_pitch, long lTextureWidth, long lTextureHeight, bool bResize = false);
|
||||
|
||||
protected:
|
||||
void CalculateNormal(long x, long y);
|
||||
|
||||
protected:
|
||||
std::string m_strName;
|
||||
WORD m_wX;
|
||||
WORD m_wY;
|
||||
|
||||
protected:
|
||||
bool m_bReady;
|
||||
|
||||
CGraphicImageInstance m_ShadowGraphicImageInstance;
|
||||
|
||||
//MiniMap
|
||||
CGraphicImageInstance m_MiniMapGraphicImageInstance;
|
||||
LPDIRECT3DTEXTURE8 m_lpMiniMapTexture;
|
||||
|
||||
|
||||
// Owner COutdoorMap poineter
|
||||
CMapOutdoor * m_pOwnerOutdoorMap;
|
||||
|
||||
// Picking
|
||||
D3DXVECTOR3 m_v3Pick;
|
||||
|
||||
DWORD m_dwNumTexturesShow;
|
||||
std::vector<DWORD> m_VectorNumShowTexture;
|
||||
|
||||
CTerrainPatch m_TerrainPatchList[PATCH_XCOUNT * PATCH_YCOUNT];
|
||||
|
||||
BOOL m_bMarked;
|
||||
TTerrainSplatPatch m_MarkedSplatPatch;
|
||||
LPDIRECT3DTEXTURE8 m_lpMarkedTexture;
|
||||
|
||||
public:
|
||||
CTerrainPatch * GetTerrainPatchPtr(BYTE byPatchNumX, BYTE byPatchNumY);
|
||||
|
||||
protected:
|
||||
void _CalculateTerrainPatch(BYTE byPatchNumX, BYTE byPatchNumY);
|
||||
|
||||
public:
|
||||
static void DestroySystem();
|
||||
|
||||
static CTerrain* New();
|
||||
static void Delete(CTerrain* pkTerrain);
|
||||
|
||||
static CDynamicPool<CTerrain> ms_kPool;
|
||||
};
|
||||
@@ -0,0 +1,56 @@
|
||||
#pragma once
|
||||
|
||||
#include "../EterLib/ResourceManager.h"
|
||||
#include "../EterLib/GrpObjectInstance.h"
|
||||
#include "../EterGrnLib/ModelInstance.h"
|
||||
#include "../EterGrnLib/Thing.h"
|
||||
|
||||
class CDungeonModelInstance;
|
||||
|
||||
class CDungeonBlock : public CGraphicObjectInstance
|
||||
{
|
||||
public:
|
||||
typedef std::vector<CDungeonModelInstance *> TModelInstanceContainer;
|
||||
enum
|
||||
{
|
||||
ID = THING_OBJECT
|
||||
};
|
||||
int GetType() const { return ID; }
|
||||
|
||||
public:
|
||||
CDungeonBlock();
|
||||
virtual ~CDungeonBlock();
|
||||
|
||||
void Destroy();
|
||||
|
||||
void BuildBoundingSphere();
|
||||
bool Load(const char * c_szFileName);
|
||||
|
||||
bool Intersect(float * pfu, float * pfv, float * pft);
|
||||
void GetBoundBox(D3DXVECTOR3 * pv3Min, D3DXVECTOR3 * pv3Max);
|
||||
|
||||
void Update();
|
||||
void Render();
|
||||
|
||||
bool GetBoundingSphere(D3DXVECTOR3 & v3Center, float & fRadius);
|
||||
void OnUpdateCollisionData(const CStaticCollisionDataVector * pscdVector);
|
||||
void OnUpdateHeighInstance(CAttributeInstance * pAttributeInstance);
|
||||
bool OnGetObjectHeight(float fX, float fY, float * pfHeight);
|
||||
|
||||
void OnRender() {}
|
||||
void OnBlendRender() {}
|
||||
void OnRenderToShadowMap() {}
|
||||
void OnRenderShadow();
|
||||
void OnRenderPCBlocker() {}
|
||||
|
||||
protected:
|
||||
void __Initialize();
|
||||
|
||||
protected:
|
||||
D3DXVECTOR3 m_v3Center;
|
||||
float m_fRadius;
|
||||
|
||||
CGraphicThing * m_pThing;
|
||||
TModelInstanceContainer m_ModelInstanceContainer;
|
||||
CGraphicVertexBuffer m_kDeformableVertexBuffer;
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
#include "ActorInstance.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CGameEventManager
|
||||
//
|
||||
// Note : Game상에서 일어나는 폭발, 화면 흔들림, Range 무기들의 움직임과 타격 등의 Event
|
||||
// 를 종합적으로 관리하는 클래스. - [levites]
|
||||
//
|
||||
// Note : 게임상의 Cinematic Event 를 컨트롤하는 매니져로 사용한다. 2004.07.19 - [levites]
|
||||
//
|
||||
|
||||
class CGameEventManager : public CSingleton<CGameEventManager>, public CScreen
|
||||
{
|
||||
public:
|
||||
CGameEventManager();
|
||||
virtual ~CGameEventManager();
|
||||
|
||||
void SetCenterPosition(float fx, float fy, float fz);
|
||||
void Update();
|
||||
|
||||
void ProcessEventScreenWaving(CActorInstance * pActorInstance, const CRaceMotionData::TScreenWavingEventData * c_pData);
|
||||
|
||||
protected:
|
||||
TPixelPosition m_CenterPosition;
|
||||
};
|
||||
@@ -0,0 +1,524 @@
|
||||
#pragma once
|
||||
|
||||
// NOTE : Item의 통합 관리 클래스다.
|
||||
// Icon, Model (droped on ground), Game Data
|
||||
|
||||
#include "../EterLib/GrpSubImage.h"
|
||||
#include "../EterGrnLib/Thing.h"
|
||||
|
||||
class CItemData
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
ITEM_NAME_MAX_LEN = 24,
|
||||
ITEM_LIMIT_MAX_NUM = 2,
|
||||
ITEM_VALUES_MAX_NUM = 6,
|
||||
ITEM_SMALL_DESCR_MAX_LEN = 256,
|
||||
ITEM_APPLY_MAX_NUM = 3,
|
||||
ITEM_SOCKET_MAX_NUM = 3,
|
||||
};
|
||||
|
||||
enum EItemType
|
||||
{
|
||||
ITEM_TYPE_NONE, //0
|
||||
ITEM_TYPE_WEAPON, //1//무기
|
||||
ITEM_TYPE_ARMOR, //2//갑옷
|
||||
ITEM_TYPE_USE, //3//아이템 사용
|
||||
ITEM_TYPE_AUTOUSE, //4
|
||||
ITEM_TYPE_MATERIAL, //5
|
||||
ITEM_TYPE_SPECIAL, //6 //스페셜 아이템
|
||||
ITEM_TYPE_TOOL, //7
|
||||
ITEM_TYPE_LOTTERY, //8//복권
|
||||
ITEM_TYPE_ELK, //9//돈
|
||||
ITEM_TYPE_METIN, //10
|
||||
ITEM_TYPE_CONTAINER, //11
|
||||
ITEM_TYPE_FISH, //12//낚시
|
||||
ITEM_TYPE_ROD, //13
|
||||
ITEM_TYPE_RESOURCE, //14
|
||||
ITEM_TYPE_CAMPFIRE, //15
|
||||
ITEM_TYPE_UNIQUE, //16
|
||||
ITEM_TYPE_SKILLBOOK, //17
|
||||
ITEM_TYPE_QUEST, //18
|
||||
ITEM_TYPE_POLYMORPH, //19
|
||||
ITEM_TYPE_TREASURE_BOX, //20//보물상자
|
||||
ITEM_TYPE_TREASURE_KEY, //21//보물상자 열쇠
|
||||
ITEM_TYPE_SKILLFORGET, //22
|
||||
ITEM_TYPE_GIFTBOX, //23
|
||||
ITEM_TYPE_PICK, //24
|
||||
ITEM_TYPE_HAIR, //25//머리
|
||||
ITEM_TYPE_TOTEM, //26//토템
|
||||
ITEM_TYPE_BLEND, //27//생성될때 랜덤하게 속성이 붙는 약물
|
||||
ITEM_TYPE_COSTUME, //28//코스츔 아이템 (2011년 8월 추가된 코스츔 시스템용 아이템)
|
||||
ITEM_TYPE_DS, //29 //용혼석
|
||||
ITEM_TYPE_SPECIAL_DS, //30 // 특수한 용혼석 (DS_SLOT에 착용하는 UNIQUE 아이템이라 생각하면 됨)
|
||||
ITEM_TYPE_EXTRACT, //31 추출도구.
|
||||
ITEM_TYPE_SECONDARY_COIN, //32 명도전.
|
||||
ITEM_TYPE_RING, //33 반지 (유니크 슬롯이 아닌 순수 반지 슬롯)
|
||||
ITEM_TYPE_BELT, //34 벨트
|
||||
|
||||
ITEM_TYPE_MAX_NUM,
|
||||
};
|
||||
|
||||
enum EWeaponSubTypes
|
||||
{
|
||||
WEAPON_SWORD,
|
||||
WEAPON_DAGGER, //이도류
|
||||
WEAPON_BOW,
|
||||
WEAPON_TWO_HANDED,
|
||||
WEAPON_BELL,
|
||||
WEAPON_FAN,
|
||||
WEAPON_ARROW,
|
||||
WEAPON_NUM_TYPES,
|
||||
|
||||
WEAPON_NONE = WEAPON_NUM_TYPES+1,
|
||||
};
|
||||
|
||||
enum EMaterialSubTypes
|
||||
{
|
||||
MATERIAL_LEATHER,
|
||||
MATERIAL_BLOOD,
|
||||
MATERIAL_ROOT,
|
||||
MATERIAL_NEEDLE,
|
||||
MATERIAL_JEWEL,
|
||||
MATERIAL_DS_REFINE_NORMAL,
|
||||
MATERIAL_DS_REFINE_BLESSED,
|
||||
MATERIAL_DS_REFINE_HOLLY,
|
||||
};
|
||||
|
||||
enum EArmorSubTypes
|
||||
{
|
||||
ARMOR_BODY,
|
||||
ARMOR_HEAD,
|
||||
ARMOR_SHIELD,
|
||||
ARMOR_WRIST,
|
||||
ARMOR_FOOTS,
|
||||
ARMOR_NECK,
|
||||
ARMOR_EAR,
|
||||
ARMOR_NUM_TYPES
|
||||
};
|
||||
|
||||
enum ECostumeSubTypes
|
||||
{
|
||||
COSTUME_BODY, //0 갑옷(main look)
|
||||
COSTUME_HAIR, //1 헤어(탈착가능)
|
||||
COSTUME_NUM_TYPES,
|
||||
};
|
||||
|
||||
enum EUseSubTypes
|
||||
{
|
||||
USE_POTION, // 0
|
||||
USE_TALISMAN,
|
||||
USE_TUNING,
|
||||
USE_MOVE,
|
||||
USE_TREASURE_BOX,
|
||||
USE_MONEYBAG,
|
||||
USE_BAIT,
|
||||
USE_ABILITY_UP,
|
||||
USE_AFFECT,
|
||||
USE_CREATE_STONE,
|
||||
USE_SPECIAL, // 10
|
||||
USE_POTION_NODELAY,
|
||||
USE_CLEAR,
|
||||
USE_INVISIBILITY,
|
||||
USE_DETACHMENT,
|
||||
USE_BUCKET,
|
||||
USE_POTION_CONTINUE,
|
||||
USE_CLEAN_SOCKET,
|
||||
USE_CHANGE_ATTRIBUTE,
|
||||
USE_ADD_ATTRIBUTE,
|
||||
USE_ADD_ACCESSORY_SOCKET, // 20
|
||||
USE_PUT_INTO_ACCESSORY_SOCKET,
|
||||
USE_ADD_ATTRIBUTE2,
|
||||
USE_RECIPE,
|
||||
USE_CHANGE_ATTRIBUTE2,
|
||||
USE_BIND,
|
||||
USE_UNBIND,
|
||||
USE_TIME_CHARGE_PER,
|
||||
USE_TIME_CHARGE_FIX, // 28
|
||||
USE_PUT_INTO_BELT_SOCKET, // 29 벨트 소켓에 사용할 수 있는 아이템
|
||||
USE_PUT_INTO_RING_SOCKET, // 30 반지 소켓에 사용할 수 있는 아이템 (유니크 반지 말고, 새로 추가된 반지 슬롯)
|
||||
};
|
||||
|
||||
enum EDragonSoulSubType
|
||||
{
|
||||
DS_SLOT1,
|
||||
DS_SLOT2,
|
||||
DS_SLOT3,
|
||||
DS_SLOT4,
|
||||
DS_SLOT5,
|
||||
DS_SLOT6,
|
||||
DS_SLOT_NUM_TYPES = 6,
|
||||
};
|
||||
|
||||
enum EMetinSubTypes
|
||||
{
|
||||
METIN_NORMAL,
|
||||
METIN_GOLD,
|
||||
};
|
||||
|
||||
enum ELimitTypes
|
||||
{
|
||||
LIMIT_NONE,
|
||||
|
||||
LIMIT_LEVEL,
|
||||
LIMIT_STR,
|
||||
LIMIT_DEX,
|
||||
LIMIT_INT,
|
||||
LIMIT_CON,
|
||||
LIMIT_PCBANG,
|
||||
|
||||
/// 착용 여부와 상관 없이 실시간으로 시간 차감 (socket0에 소멸 시간이 박힘: unix_timestamp 타입)
|
||||
LIMIT_REAL_TIME,
|
||||
|
||||
/// 아이템을 맨 처음 사용(혹은 착용) 한 순간부터 리얼타임 타이머 시작
|
||||
/// 최초 사용 전에는 socket0에 사용가능시간(초단위, 0이면 프로토의 limit value값 사용) 값이 쓰여있다가
|
||||
/// 아이템 사용시 socket1에 사용 횟수가 박히고 socket0에 unix_timestamp 타입의 소멸시간이 박힘.
|
||||
LIMIT_REAL_TIME_START_FIRST_USE,
|
||||
|
||||
/// 아이템을 착용 중일 때만 사용 시간이 차감되는 아이템
|
||||
/// socket0에 남은 시간이 초단위로 박힘. (아이템 최초 사용시 해당 값이 0이면 프로토의 limit value값을 socket0에 복사)
|
||||
LIMIT_TIMER_BASED_ON_WEAR,
|
||||
|
||||
LIMIT_MAX_NUM
|
||||
};
|
||||
|
||||
enum EItemAntiFlag
|
||||
{
|
||||
ITEM_ANTIFLAG_FEMALE = (1 << 0), // 여성 사용 불가
|
||||
ITEM_ANTIFLAG_MALE = (1 << 1), // 남성 사용 불가
|
||||
ITEM_ANTIFLAG_WARRIOR = (1 << 2), // 무사 사용 불가
|
||||
ITEM_ANTIFLAG_ASSASSIN = (1 << 3), // 자객 사용 불가
|
||||
ITEM_ANTIFLAG_SURA = (1 << 4), // 수라 사용 불가
|
||||
ITEM_ANTIFLAG_SHAMAN = (1 << 5), // 무당 사용 불가
|
||||
ITEM_ANTIFLAG_GET = (1 << 6), // 집을 수 없음
|
||||
ITEM_ANTIFLAG_DROP = (1 << 7), // 버릴 수 없음
|
||||
ITEM_ANTIFLAG_SELL = (1 << 8), // 팔 수 없음
|
||||
ITEM_ANTIFLAG_EMPIRE_A = (1 << 9), // A 제국 사용 불가
|
||||
ITEM_ANTIFLAG_EMPIRE_B = (1 << 10), // B 제국 사용 불가
|
||||
ITEM_ANTIFLAG_EMPIRE_R = (1 << 11), // C 제국 사용 불가
|
||||
ITEM_ANTIFLAG_SAVE = (1 << 12), // 저장되지 않음
|
||||
ITEM_ANTIFLAG_GIVE = (1 << 13), // 거래 불가
|
||||
ITEM_ANTIFLAG_PKDROP = (1 << 14), // PK시 떨어지지 않음
|
||||
ITEM_ANTIFLAG_STACK = (1 << 15), // 합칠 수 없음
|
||||
ITEM_ANTIFLAG_MYSHOP = (1 << 16), // 개인 상점에 올릴 수 없음
|
||||
};
|
||||
|
||||
enum EItemFlag
|
||||
{
|
||||
ITEM_FLAG_REFINEABLE = (1 << 0), // 개량 가능
|
||||
ITEM_FLAG_SAVE = (1 << 1),
|
||||
ITEM_FLAG_STACKABLE = (1 << 2), // 여러개 합칠 수 있음
|
||||
ITEM_FLAG_COUNT_PER_1GOLD = (1 << 3), // 가격이 개수 / 가격으로 변함
|
||||
ITEM_FLAG_SLOW_QUERY = (1 << 4), // 게임 종료시에만 SQL에 쿼리함
|
||||
ITEM_FLAG_RARE = (1 << 5),
|
||||
ITEM_FLAG_UNIQUE = (1 << 6),
|
||||
ITEM_FLAG_MAKECOUNT = (1 << 7),
|
||||
ITEM_FLAG_IRREMOVABLE = (1 << 8),
|
||||
ITEM_FLAG_CONFIRM_WHEN_USE = (1 << 9),
|
||||
ITEM_FLAG_QUEST_USE = (1 << 10), // 퀘스트 스크립트 돌리는지?
|
||||
ITEM_FLAG_QUEST_USE_MULTIPLE= (1 << 11), // 퀘스트 스크립트 돌리는지?
|
||||
ITEM_FLAG_UNUSED03 = (1 << 12), // UNUSED03
|
||||
ITEM_FLAG_LOG = (1 << 13), // 사용시 로그를 남기는 아이템인가?
|
||||
ITEM_FLAG_APPLICABLE = (1 << 14),
|
||||
};
|
||||
|
||||
enum EWearPositions
|
||||
{
|
||||
WEAR_BODY, // 0
|
||||
WEAR_HEAD, // 1
|
||||
WEAR_FOOTS, // 2
|
||||
WEAR_WRIST, // 3
|
||||
WEAR_WEAPON, // 4
|
||||
WEAR_NECK, // 5
|
||||
WEAR_EAR, // 6
|
||||
WEAR_UNIQUE1, // 7
|
||||
WEAR_UNIQUE2, // 8
|
||||
WEAR_ARROW, // 9
|
||||
WEAR_SHIELD, // 10
|
||||
WEAR_MAX_NUM,
|
||||
};
|
||||
|
||||
enum EItemWearableFlag
|
||||
{
|
||||
WEARABLE_BODY = (1 << 0),
|
||||
WEARABLE_HEAD = (1 << 1),
|
||||
WEARABLE_FOOTS = (1 << 2),
|
||||
WEARABLE_WRIST = (1 << 3),
|
||||
WEARABLE_WEAPON = (1 << 4),
|
||||
WEARABLE_NECK = (1 << 5),
|
||||
WEARABLE_EAR = (1 << 6),
|
||||
WEARABLE_UNIQUE = (1 << 7),
|
||||
WEARABLE_SHIELD = (1 << 8),
|
||||
WEARABLE_ARROW = (1 << 9),
|
||||
};
|
||||
|
||||
enum EApplyTypes
|
||||
{
|
||||
APPLY_NONE, // 0
|
||||
APPLY_MAX_HP, // 1
|
||||
APPLY_MAX_SP, // 2
|
||||
APPLY_CON, // 3
|
||||
APPLY_INT, // 4
|
||||
APPLY_STR, // 5
|
||||
APPLY_DEX, // 6
|
||||
APPLY_ATT_SPEED, // 7
|
||||
APPLY_MOV_SPEED, // 8
|
||||
APPLY_CAST_SPEED, // 9
|
||||
APPLY_HP_REGEN, // 10
|
||||
APPLY_SP_REGEN, // 11
|
||||
APPLY_POISON_PCT, // 12
|
||||
APPLY_STUN_PCT, // 13
|
||||
APPLY_SLOW_PCT, // 14
|
||||
APPLY_CRITICAL_PCT, // 15
|
||||
APPLY_PENETRATE_PCT, // 16
|
||||
APPLY_ATTBONUS_HUMAN, // 17
|
||||
APPLY_ATTBONUS_ANIMAL, // 18
|
||||
APPLY_ATTBONUS_ORC, // 19
|
||||
APPLY_ATTBONUS_MILGYO, // 20
|
||||
APPLY_ATTBONUS_UNDEAD, // 21
|
||||
APPLY_ATTBONUS_DEVIL, // 22
|
||||
APPLY_STEAL_HP, // 23
|
||||
APPLY_STEAL_SP, // 24
|
||||
APPLY_MANA_BURN_PCT, // 25
|
||||
APPLY_DAMAGE_SP_RECOVER, // 26
|
||||
APPLY_BLOCK, // 27
|
||||
APPLY_DODGE, // 28
|
||||
APPLY_RESIST_SWORD, // 29
|
||||
APPLY_RESIST_TWOHAND, // 30
|
||||
APPLY_RESIST_DAGGER, // 31
|
||||
APPLY_RESIST_BELL, // 32
|
||||
APPLY_RESIST_FAN, // 33
|
||||
APPLY_RESIST_BOW, // 34
|
||||
APPLY_RESIST_FIRE, // 35
|
||||
APPLY_RESIST_ELEC, // 36
|
||||
APPLY_RESIST_MAGIC, // 37
|
||||
APPLY_RESIST_WIND, // 38
|
||||
APPLY_REFLECT_MELEE, // 39
|
||||
APPLY_REFLECT_CURSE, // 40
|
||||
APPLY_POISON_REDUCE, // 41
|
||||
APPLY_KILL_SP_RECOVER, // 42
|
||||
APPLY_EXP_DOUBLE_BONUS, // 43
|
||||
APPLY_GOLD_DOUBLE_BONUS, // 44
|
||||
APPLY_ITEM_DROP_BONUS, // 45
|
||||
APPLY_POTION_BONUS, // 46
|
||||
APPLY_KILL_HP_RECOVER, // 47
|
||||
APPLY_IMMUNE_STUN, // 48
|
||||
APPLY_IMMUNE_SLOW, // 49
|
||||
APPLY_IMMUNE_FALL, // 50
|
||||
APPLY_SKILL, // 51
|
||||
APPLY_BOW_DISTANCE, // 52
|
||||
APPLY_ATT_GRADE_BONUS, // 53
|
||||
APPLY_DEF_GRADE_BONUS, // 54
|
||||
APPLY_MAGIC_ATT_GRADE, // 55
|
||||
APPLY_MAGIC_DEF_GRADE, // 56
|
||||
APPLY_CURSE_PCT, // 57
|
||||
APPLY_MAX_STAMINA, // 58
|
||||
APPLY_ATT_BONUS_TO_WARRIOR, // 59
|
||||
APPLY_ATT_BONUS_TO_ASSASSIN,// 60
|
||||
APPLY_ATT_BONUS_TO_SURA, // 61
|
||||
APPLY_ATT_BONUS_TO_SHAMAN, // 62
|
||||
APPLY_ATT_BONUS_TO_MONSTER, // 63
|
||||
APPLY_MALL_ATTBONUS, // 64 공격력 +x%
|
||||
APPLY_MALL_DEFBONUS, // 65 방어력 +x%
|
||||
APPLY_MALL_EXPBONUS, // 66 경험치 +x%
|
||||
APPLY_MALL_ITEMBONUS, // 67 아이템 드롭율 x/10배
|
||||
APPLY_MALL_GOLDBONUS, // 68 돈 드롭율 x/10배
|
||||
APPLY_MAX_HP_PCT, // 69 최대 생명력 +x%
|
||||
APPLY_MAX_SP_PCT, // 70 최대 정신력 +x%
|
||||
APPLY_SKILL_DAMAGE_BONUS, // 71 스킬 데미지 * (100+x)%
|
||||
APPLY_NORMAL_HIT_DAMAGE_BONUS, // 72 평타 데미지 * (100+x)%
|
||||
APPLY_SKILL_DEFEND_BONUS, // 73 스킬 데미지 방어 * (100-x)%
|
||||
APPLY_NORMAL_HIT_DEFEND_BONUS, // 74 평타 데미지 방어 * (100-x)%
|
||||
APPLY_EXTRACT_HP_PCT, //75
|
||||
APPLY_PC_BANG_EXP_BONUS, //76
|
||||
APPLY_PC_BANG_DROP_BONUS, //77
|
||||
APPLY_RESIST_WARRIOR, //78
|
||||
APPLY_RESIST_ASSASSIN , //79
|
||||
APPLY_RESIST_SURA, //80
|
||||
APPLY_RESIST_SHAMAN, //81
|
||||
APPLY_ENERGY, //82
|
||||
APPLY_DEF_GRADE, // 83 방어력. DEF_GRADE_BONUS는 클라에서 두배로 보여지는 의도된 버그(...)가 있다.
|
||||
APPLY_COSTUME_ATTR_BONUS, // 84 코스튬 아이템에 붙은 속성치 보너스
|
||||
APPLY_MAGIC_ATTBONUS_PER, // 85 마법 공격력 +x%
|
||||
APPLY_MELEE_MAGIC_ATTBONUS_PER, // 86 마법 + 밀리 공격력 +x%
|
||||
|
||||
APPLY_RESIST_ICE, // 87 냉기 저항
|
||||
APPLY_RESIST_EARTH, // 88 대지 저항
|
||||
APPLY_RESIST_DARK, // 89 어둠 저항
|
||||
|
||||
APPLY_ANTI_CRITICAL_PCT, //90 크리티컬 저항
|
||||
APPLY_ANTI_PENETRATE_PCT, //91 관통타격 저항
|
||||
|
||||
MAX_APPLY_NUM, //
|
||||
};
|
||||
|
||||
enum EImmuneFlags
|
||||
{
|
||||
IMMUNE_PARA = (1 << 0),
|
||||
IMMUNE_CURSE = (1 << 1),
|
||||
IMMUNE_STUN = (1 << 2),
|
||||
IMMUNE_SLEEP = (1 << 3),
|
||||
IMMUNE_SLOW = (1 << 4),
|
||||
IMMUNE_POISON = (1 << 5),
|
||||
IMMUNE_TERROR = (1 << 6),
|
||||
};
|
||||
|
||||
#pragma pack(push)
|
||||
#pragma pack(1)
|
||||
typedef struct SItemLimit
|
||||
{
|
||||
BYTE bType;
|
||||
long lValue;
|
||||
} TItemLimit;
|
||||
|
||||
typedef struct SItemApply
|
||||
{
|
||||
BYTE bType;
|
||||
long lValue;
|
||||
} TItemApply;
|
||||
|
||||
typedef struct SItemTable
|
||||
{
|
||||
DWORD dwVnum;
|
||||
DWORD dwVnumRange;
|
||||
char szName[ITEM_NAME_MAX_LEN + 1];
|
||||
char szLocaleName[ITEM_NAME_MAX_LEN + 1];
|
||||
BYTE bType;
|
||||
BYTE bSubType;
|
||||
|
||||
BYTE bWeight;
|
||||
BYTE bSize;
|
||||
|
||||
DWORD dwAntiFlags;
|
||||
DWORD dwFlags;
|
||||
DWORD dwWearFlags;
|
||||
DWORD dwImmuneFlag;
|
||||
|
||||
DWORD dwIBuyItemPrice;
|
||||
DWORD dwISellItemPrice;
|
||||
|
||||
TItemLimit aLimits[ITEM_LIMIT_MAX_NUM];
|
||||
TItemApply aApplies[ITEM_APPLY_MAX_NUM];
|
||||
long alValues[ITEM_VALUES_MAX_NUM];
|
||||
long alSockets[ITEM_SOCKET_MAX_NUM];
|
||||
DWORD dwRefinedVnum;
|
||||
WORD wRefineSet;
|
||||
BYTE bAlterToMagicItemPct;
|
||||
BYTE bSpecular;
|
||||
BYTE bGainSocketPct;
|
||||
} TItemTable;
|
||||
|
||||
// typedef struct SItemTable
|
||||
// {
|
||||
// DWORD dwVnum;
|
||||
// char szItemName[ITEM_NAME_MAX_LEN + 1];
|
||||
// BYTE bType;
|
||||
// BYTE bSubType;
|
||||
// BYTE bSize;
|
||||
// DWORD dwAntiFlags;
|
||||
// DWORD dwFlags;
|
||||
// DWORD dwWearFlags;
|
||||
// DWORD dwIBuyItemPrice;
|
||||
// DWORD dwISellItemPrice;
|
||||
// TItemLimit aLimits[ITEM_LIMIT_MAX_NUM];
|
||||
// TItemApply aApplies[ITEM_APPLY_MAX_NUM];
|
||||
// long alValues[ITEM_VALUES_MAX_NUM];
|
||||
// long alSockets[ITEM_SOCKET_MAX_NUM];
|
||||
// DWORD dwRefinedVnum;
|
||||
// BYTE bSpecular;
|
||||
// DWORD dwIconNumber;
|
||||
// } TItemTable;
|
||||
#pragma pack(pop)
|
||||
|
||||
public:
|
||||
CItemData();
|
||||
virtual ~CItemData();
|
||||
|
||||
void Clear();
|
||||
void SetSummary(const std::string& c_rstSumm);
|
||||
void SetDescription(const std::string& c_rstDesc);
|
||||
|
||||
CGraphicThing * GetModelThing();
|
||||
CGraphicThing * GetSubModelThing();
|
||||
CGraphicThing * GetDropModelThing();
|
||||
CGraphicSubImage * GetIconImage();
|
||||
|
||||
DWORD GetLODModelThingCount();
|
||||
BOOL GetLODModelThingPointer(DWORD dwIndex, CGraphicThing ** ppModelThing);
|
||||
|
||||
DWORD GetAttachingDataCount();
|
||||
BOOL GetCollisionDataPointer(DWORD dwIndex, const NRaceData::TAttachingData ** c_ppAttachingData);
|
||||
BOOL GetAttachingDataPointer(DWORD dwIndex, const NRaceData::TAttachingData ** c_ppAttachingData);
|
||||
|
||||
/////
|
||||
const TItemTable* GetTable() const;
|
||||
DWORD GetIndex() const;
|
||||
const char * GetName() const;
|
||||
const char * GetDescription() const;
|
||||
const char * GetSummary() const;
|
||||
BYTE GetType() const;
|
||||
BYTE GetSubType() const;
|
||||
UINT GetRefine() const;
|
||||
const char* GetUseTypeString() const;
|
||||
DWORD GetWeaponType() const;
|
||||
BYTE GetSize() const;
|
||||
BOOL IsAntiFlag(DWORD dwFlag) const;
|
||||
BOOL IsFlag(DWORD dwFlag) const;
|
||||
BOOL IsWearableFlag(DWORD dwFlag) const;
|
||||
BOOL HasNextGrade() const;
|
||||
DWORD GetWearFlags() const;
|
||||
DWORD GetIBuyItemPrice() const;
|
||||
DWORD GetISellItemPrice() const;
|
||||
BOOL GetLimit(BYTE byIndex, TItemLimit * pItemLimit) const;
|
||||
BOOL GetApply(BYTE byIndex, TItemApply * pItemApply) const;
|
||||
long GetValue(BYTE byIndex) const;
|
||||
long GetSocket(BYTE byIndex) const;
|
||||
long SetSocket(BYTE byIndex,DWORD value);
|
||||
int GetSocketCount() const;
|
||||
DWORD GetIconNumber() const;
|
||||
|
||||
UINT GetSpecularPoweru() const;
|
||||
float GetSpecularPowerf() const;
|
||||
|
||||
/////
|
||||
|
||||
BOOL IsEquipment() const;
|
||||
|
||||
/////
|
||||
|
||||
//BOOL LoadItemData(const char * c_szFileName);
|
||||
void SetDefaultItemData(const char * c_szIconFileName, const char * c_szModelFileName = NULL);
|
||||
void SetItemTableData(TItemTable * pItemTable);
|
||||
|
||||
protected:
|
||||
void __LoadFiles();
|
||||
void __SetIconImage(const char * c_szFileName);
|
||||
|
||||
protected:
|
||||
std::string m_strModelFileName;
|
||||
std::string m_strSubModelFileName;
|
||||
std::string m_strDropModelFileName;
|
||||
std::string m_strIconFileName;
|
||||
std::string m_strDescription;
|
||||
std::string m_strSummary;
|
||||
std::vector<std::string> m_strLODModelFileNameVector;
|
||||
|
||||
CGraphicThing * m_pModelThing;
|
||||
CGraphicThing * m_pSubModelThing;
|
||||
CGraphicThing * m_pDropModelThing;
|
||||
CGraphicSubImage * m_pIconImage;
|
||||
std::vector<CGraphicThing *> m_pLODModelThingVector;
|
||||
|
||||
NRaceData::TAttachingDataVector m_AttachingDataVector;
|
||||
DWORD m_dwVnum;
|
||||
TItemTable m_ItemTable;
|
||||
|
||||
public:
|
||||
static void DestroySystem();
|
||||
|
||||
static CItemData* New();
|
||||
static void Delete(CItemData* pkItemData);
|
||||
|
||||
static CDynamicPool<CItemData> ms_kPool;
|
||||
};
|
||||
@@ -0,0 +1,42 @@
|
||||
#pragma once
|
||||
|
||||
#include "ItemData.h"
|
||||
|
||||
class CItemManager : public CSingleton<CItemManager>
|
||||
{
|
||||
public:
|
||||
enum EItemDescCol
|
||||
{
|
||||
ITEMDESC_COL_VNUM,
|
||||
ITEMDESC_COL_NAME,
|
||||
ITEMDESC_COL_DESC,
|
||||
ITEMDESC_COL_SUMM,
|
||||
ITEMDESC_COL_NUM,
|
||||
};
|
||||
|
||||
public:
|
||||
typedef std::map<DWORD, CItemData*> TItemMap;
|
||||
typedef std::map<std::string, CItemData*> TItemNameMap;
|
||||
|
||||
public:
|
||||
CItemManager();
|
||||
virtual ~CItemManager();
|
||||
|
||||
void Destroy();
|
||||
|
||||
BOOL SelectItemData(DWORD dwIndex);
|
||||
CItemData * GetSelectedItemDataPointer();
|
||||
|
||||
BOOL GetItemDataPointer(DWORD dwItemID, CItemData ** ppItemData);
|
||||
|
||||
/////
|
||||
bool LoadItemDesc(const char* c_szFileName);
|
||||
bool LoadItemList(const char* c_szFileName);
|
||||
bool LoadItemTable(const char* c_szFileName);
|
||||
CItemData * MakeItemData(DWORD dwIndex);
|
||||
|
||||
protected:
|
||||
TItemMap m_ItemMap;
|
||||
std::vector<CItemData*> m_vec_ItemRange;
|
||||
CItemData * m_pSelectedItemData;
|
||||
};
|
||||
@@ -0,0 +1,64 @@
|
||||
#pragma once
|
||||
|
||||
class CMapBase : public CScreen
|
||||
{
|
||||
public:
|
||||
enum EMAPTYPE
|
||||
{
|
||||
MAPTYPE_INVALID,
|
||||
MAPTYPE_INDOOR,
|
||||
MAPTYPE_OUTDOOR,
|
||||
};
|
||||
|
||||
public:
|
||||
CMapBase();
|
||||
virtual ~CMapBase();
|
||||
|
||||
virtual void Clear();
|
||||
virtual bool Initialize() = 0;
|
||||
virtual bool Destroy() = 0;
|
||||
virtual bool Load(float x, float y, float z) = 0;
|
||||
|
||||
virtual bool Update(float fX, float fY, float fZ) = 0;
|
||||
virtual void UpdateAroundAmbience(float fX, float fY, float fZ) = 0;
|
||||
virtual float GetHeight(float fx, float fy) = 0;
|
||||
virtual void OnBeginEnvironment() = 0; // 렌더링 할 때 불려지며 여기서 Environment에 관련 있는 것들을 셋팅 한다.
|
||||
|
||||
virtual void ApplyLight(DWORD dwVersion, const D3DLIGHT8& c_rkLight) = 0;
|
||||
|
||||
protected:
|
||||
virtual void OnRender() = 0;
|
||||
virtual void OnSetEnvironmentDataPtr() = 0; // Environment 데이터가 설정될 때 불려진다.
|
||||
virtual void OnResetEnvironmentDataPtr() = 0;
|
||||
|
||||
public:
|
||||
void Render();
|
||||
void SetEnvironmentDataPtr(const TEnvironmentData * c_pEnvironmentData);
|
||||
void ResetEnvironmentDataPtr(const TEnvironmentData * c_pEnvironmentData);
|
||||
bool Enter();
|
||||
bool Leave();
|
||||
bool IsReady() { return m_bReady; }
|
||||
|
||||
bool LoadProperty();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Setting
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
EMAPTYPE GetType() const { return m_eType; }
|
||||
void SetType(EMAPTYPE eType) { m_eType = eType; }
|
||||
|
||||
const std::string & GetName() const { return m_strName; }
|
||||
void SetName(const std::string & cr_strName) { m_strName = cr_strName; }
|
||||
|
||||
bool IsCopiedMap() const { return m_strParentMapName.length() > 0; } // "원본 데이터는 따로 있는" 복사 맵인가?
|
||||
const std::string& GetParentMapName() const { return m_strParentMapName; } // 원본 데이터를 갖고있는 맵의 이름을 리턴 (복사맵의 경우 필수로 세팅되어야 함)
|
||||
const std::string& GetMapDataDirectory() const { return IsCopiedMap() ? m_strParentMapName : m_strName; }
|
||||
|
||||
protected:
|
||||
EMAPTYPE m_eType; // 맵 종류... 현재는 Indoor와 Ourdoor가 있다.
|
||||
std::string m_strName; // 맵 이름. 맵 이름이 맵 식별자가 될 수 있을까?
|
||||
std::string m_strParentMapName; // 원본 맵의 이름. 이 값이 세팅되어 있다면 실제 모든 맵 데이터는 ParentMap/* 경로에서 읽어온다. 맵의 일부만 읽어오는 기능은 필요없대서 패스.
|
||||
bool m_bReady;
|
||||
|
||||
const TEnvironmentData * mc_pEnvironmentData;
|
||||
};
|
||||
@@ -0,0 +1,169 @@
|
||||
#pragma once
|
||||
|
||||
class CMapBase;
|
||||
#include "MapOutdoor.h"
|
||||
#include "PropertyManager.h"
|
||||
|
||||
// VICTIM_COLLISION_TEST
|
||||
#include "PhysicsObject.h"
|
||||
// VICTIM_COLLISION_TEST_END
|
||||
|
||||
// Map Manager
|
||||
class CMapManager : public CScreen, public IPhysicsWorld
|
||||
{
|
||||
public:
|
||||
CMapManager();
|
||||
virtual ~CMapManager();
|
||||
|
||||
bool IsMapOutdoor();
|
||||
CMapOutdoor& GetMapOutdoorRef();
|
||||
|
||||
bool IsSoftwareTilingEnable();
|
||||
void ReserveSoftwareTilingEnable(bool isEnable);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Contructor / Destructor
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void Initialize();
|
||||
void Destroy();
|
||||
|
||||
void Create(); // AllocMap 호출 해서 m_pMap 을 만듬
|
||||
|
||||
virtual void Clear();
|
||||
virtual CMapBase * AllocMap();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Map 관리 함수
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool IsMapReady();
|
||||
|
||||
virtual bool LoadMap(const std::string & c_rstrMapName, float x, float y, float z);
|
||||
bool UnloadMap(const std::string c_strMapName);
|
||||
|
||||
bool UpdateMap(float fx, float fy, float fz);
|
||||
void UpdateAroundAmbience(float fx, float fy, float fz);
|
||||
float GetHeight(float fx, float fy);
|
||||
float GetTerrainHeight(float fx, float fy);
|
||||
bool GetWaterHeight(int iX, int iY, long * plWaterHeight);
|
||||
|
||||
bool GetNormal(int ix, int iy, D3DXVECTOR3 * pv3Normal);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Environment
|
||||
///
|
||||
// NOTE : 다음 Environment로 서서히 블렌딩 시킨다
|
||||
// 아직 세부 구현은 되어있지 않음. 이 함수들은 Protected로 넣고,
|
||||
// MapManager에 TimeControl 부분을 구현하도록 한다. - [levites]
|
||||
void SetEnvironmentDataPtr(const TEnvironmentData * c_pEnvironmentData);
|
||||
void ResetEnvironmentDataPtr(const TEnvironmentData * c_pEnvironmentData);
|
||||
void SetEnvironmentData(int nEnvDataIndex);
|
||||
|
||||
void BeginEnvironment();
|
||||
void EndEnvironment();
|
||||
|
||||
void BlendEnvironmentData(const TEnvironmentData * c_pEnvironmentData, int iTransitionTime);
|
||||
|
||||
void GetCurrentEnvironmentData(const TEnvironmentData ** c_ppEnvironmentData);
|
||||
bool RegisterEnvironmentData(DWORD dwIndex, const char * c_szFileName);
|
||||
bool GetEnvironmentData(DWORD dwIndex, const TEnvironmentData ** c_ppEnvironmentData);
|
||||
|
||||
// Portal
|
||||
void RefreshPortal();
|
||||
void ClearPortal();
|
||||
void AddShowingPortalID(int iID);
|
||||
|
||||
// External interface
|
||||
void LoadProperty();
|
||||
|
||||
DWORD GetShadowMapColor(float fx, float fy);
|
||||
|
||||
// VICITM_COLLISION_TEST
|
||||
virtual bool isPhysicalCollision(const D3DXVECTOR3 & c_rvCheckPosition);
|
||||
// VICITM_COLLISION_TEST_END
|
||||
|
||||
bool isAttrOn(float fX, float fY, BYTE byAttr);
|
||||
bool GetAttr(float fX, float fY, BYTE * pbyAttr);
|
||||
bool isAttrOn(int iX, int iY, BYTE byAttr);
|
||||
bool GetAttr(int iX, int iY, BYTE * pbyAttr);
|
||||
|
||||
std::vector<int> & GetRenderedSplatNum(int * piPatch, int * piSplat, float * pfSplatRatio);
|
||||
CArea::TCRCWithNumberVector & GetRenderedGraphicThingInstanceNum(DWORD * pdwGraphicThingInstanceNum, DWORD * pdwCRCNum);
|
||||
|
||||
protected:
|
||||
TEnvironmentData * AllocEnvironmentData();
|
||||
void DeleteEnvironmentData(TEnvironmentData * pEnvironmentData);
|
||||
BOOL LoadEnvironmentData(const char * c_szFileName, TEnvironmentData * pEnvironmentData);
|
||||
|
||||
protected:
|
||||
CPropertyManager m_PropertyManager;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Environment
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
TEnvironmentDataMap m_EnvironmentDataMap;
|
||||
const TEnvironmentData * mc_pcurEnvironmentData;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Map
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
CMapOutdoor * m_pkMap;
|
||||
CSpeedTreeForestDirectX8 m_Forest;
|
||||
|
||||
public:
|
||||
// 2004.10.14.myevan.TEMP_CAreaLoaderThread
|
||||
//bool BGLoadingEnable();
|
||||
//void BGLoadingEnable(bool bBGLoadingEnable);
|
||||
void SetTerrainRenderSort(CMapOutdoor::ETerrainRenderSort eTerrainRenderSort);
|
||||
CMapOutdoor::ETerrainRenderSort GetTerrainRenderSort();
|
||||
|
||||
void GetBaseXY(DWORD * pdwBaseX, DWORD * pdwBaseY);
|
||||
|
||||
public:
|
||||
void SetTransparentTree(bool bTransparenTree);
|
||||
|
||||
public:
|
||||
typedef struct
|
||||
{
|
||||
std::string m_strName;
|
||||
DWORD m_dwBaseX;
|
||||
DWORD m_dwBaseY;
|
||||
DWORD m_dwSizeX;
|
||||
DWORD m_dwSizeY;
|
||||
DWORD m_dwEndX;
|
||||
DWORD m_dwEndY;
|
||||
} TMapInfo;
|
||||
typedef std::vector<TMapInfo> TMapInfoVector;
|
||||
typedef TMapInfoVector::iterator TMapInfoVectorIterator;
|
||||
|
||||
protected:
|
||||
TMapInfoVector m_kVct_kMapInfo;
|
||||
|
||||
bool m_isSoftwareTilingEnableReserved;
|
||||
|
||||
protected:
|
||||
void __LoadMapInfoVector();
|
||||
|
||||
protected:
|
||||
struct FFindMapName
|
||||
{
|
||||
std::string strNametoFind;
|
||||
FFindMapName(const std::string & c_rMapName)
|
||||
{
|
||||
strNametoFind = c_rMapName;
|
||||
stl_lowers(strNametoFind);
|
||||
}
|
||||
bool operator() (TMapInfo & rMapInfo)
|
||||
{
|
||||
if (rMapInfo.m_strName == strNametoFind)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
};
|
||||
public:
|
||||
void SetAtlasInfoFileName(const char* filename)
|
||||
{
|
||||
m_stAtlasInfoFileName = filename;
|
||||
}
|
||||
private:
|
||||
std::string m_stAtlasInfoFileName;
|
||||
};
|
||||
@@ -0,0 +1,779 @@
|
||||
#pragma once
|
||||
|
||||
#include "../EterLib/SkyBox.h"
|
||||
#include "../EterLib/LensFlare.h"
|
||||
#include "../EterLib/ScreenFilter.h"
|
||||
|
||||
#include "../PRTerrainLib/TerrainType.h"
|
||||
#include "../PRTerrainLib/TextureSet.h"
|
||||
|
||||
#include "../SpeedTreeLib/SpeedTreeForestDirectX8.h"
|
||||
|
||||
#include "MapBase.h"
|
||||
#include "Area.h"
|
||||
#include "AreaTerrain.h"
|
||||
#include "AreaLoaderThread.h"
|
||||
|
||||
#include "MonsterAreaInfo.h"
|
||||
|
||||
|
||||
#define LOAD_SIZE_WIDTH 1
|
||||
|
||||
#define AROUND_AREA_NUM 1+(LOAD_SIZE_WIDTH*2)*(LOAD_SIZE_WIDTH*2)*2
|
||||
#define MAX_PREPARE_SIZE 9
|
||||
#define MAX_MAPSIZE 256 // 0 ~ 255, cellsize 200 = 64km
|
||||
|
||||
#define TERRAINPATCH_LODMAX 3
|
||||
|
||||
typedef struct SOutdoorMapCoordinate
|
||||
{
|
||||
short m_sTerrainCoordX; // Terrain 좌표
|
||||
short m_sTerrainCoordY;
|
||||
} TOutdoorMapCoordinate;
|
||||
|
||||
typedef std::map<const std::string, TOutdoorMapCoordinate> TOutdoorMapCoordinateMap;
|
||||
|
||||
class CTerrainPatchProxy;
|
||||
class CTerrainQuadtreeNode;
|
||||
|
||||
class CMapOutdoor : public CMapBase
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
VIEW_NONE = 0,
|
||||
VIEW_PART,
|
||||
VIEW_ALL,
|
||||
};
|
||||
|
||||
enum EPart
|
||||
{
|
||||
PART_TERRAIN,
|
||||
PART_OBJECT,
|
||||
PART_CLOUD,
|
||||
PART_WATER,
|
||||
PART_TREE,
|
||||
PART_SKY,
|
||||
PART_NUM,
|
||||
};
|
||||
|
||||
enum ETerrainRenderSort
|
||||
{
|
||||
DISTANCE_SORT,
|
||||
TEXTURE_SORT,
|
||||
};
|
||||
|
||||
public:
|
||||
CMapOutdoor();
|
||||
virtual ~CMapOutdoor();
|
||||
|
||||
virtual void OnBeginEnvironment();
|
||||
|
||||
protected:
|
||||
bool Initialize();
|
||||
void InitializeFog();
|
||||
|
||||
virtual bool Destroy();
|
||||
virtual void OnSetEnvironmentDataPtr();
|
||||
virtual void OnResetEnvironmentDataPtr();
|
||||
|
||||
virtual void OnRender();
|
||||
|
||||
virtual void OnPreAssignTerrainPtr() {};
|
||||
|
||||
public:
|
||||
void SetInverseViewAndDynamicShaodwMatrices();
|
||||
virtual bool Load(float x, float y, float z);
|
||||
virtual float GetHeight(float x, float y);
|
||||
virtual float GetCacheHeight(float x, float y);
|
||||
|
||||
virtual bool Update(float fX, float fY, float fZ);
|
||||
virtual void UpdateAroundAmbience(float fX, float fY, float fZ);
|
||||
|
||||
public:
|
||||
void Clear();
|
||||
|
||||
void SetVisiblePart(int ePart, bool isVisible);
|
||||
void SetSplatLimit(int iSplatNum);
|
||||
std::vector<int> & GetRenderedSplatNum(int * piPatch, int * piSplat, float * pfSplatRatio);
|
||||
CArea::TCRCWithNumberVector & GetRenderedGraphicThingInstanceNum(DWORD * pdwGraphicThingInstanceNum, DWORD * pdwCRCNum);
|
||||
|
||||
bool LoadSetting(const char * c_szFileName);
|
||||
|
||||
void ApplyLight(DWORD dwVersion, const D3DLIGHT8& c_rkLight);
|
||||
void SetEnvironmentScreenFilter();
|
||||
void SetEnvironmentSkyBox();
|
||||
void SetEnvironmentLensFlare();
|
||||
|
||||
void CreateCharacterShadowTexture();
|
||||
void ReleaseCharacterShadowTexture();
|
||||
void SetShadowTextureSize(WORD size);
|
||||
|
||||
bool BeginRenderCharacterShadowToTexture();
|
||||
void EndRenderCharacterShadowToTexture();
|
||||
void RenderWater();
|
||||
void RenderMarkedArea();
|
||||
void RecurseRenderAttr(CTerrainQuadtreeNode *Node, bool bCullEnable=TRUE);
|
||||
void DrawPatchAttr(long patchnum);
|
||||
void ClearGuildArea();
|
||||
void RegisterGuildArea(int isx, int isy, int iex, int iey);
|
||||
|
||||
void VisibleMarkedArea();
|
||||
void DisableMarkedArea();
|
||||
|
||||
void UpdateSky();
|
||||
void RenderCollision();
|
||||
void RenderSky();
|
||||
void RenderCloud();
|
||||
void RenderBeforeLensFlare();
|
||||
void RenderAfterLensFlare();
|
||||
void RenderScreenFiltering();
|
||||
|
||||
void SetWireframe(bool bWireFrame);
|
||||
bool IsWireframe();
|
||||
|
||||
bool GetPickingPointWithRay(const CRay & rRay, D3DXVECTOR3 * v3IntersectPt);
|
||||
bool GetPickingPointWithRayOnlyTerrain(const CRay & rRay, D3DXVECTOR3 * v3IntersectPt);
|
||||
bool GetPickingPoint(D3DXVECTOR3 * v3IntersectPt);
|
||||
void GetTerrainCount(short * psTerrainCountX, short * psTerrainCountY)
|
||||
{
|
||||
*psTerrainCountX = m_sTerrainCountX;
|
||||
*psTerrainCountY = m_sTerrainCountY;
|
||||
}
|
||||
|
||||
bool SetTerrainCount(short sTerrainCountX, short sTerrainCountY);
|
||||
|
||||
// Shadow
|
||||
void SetDrawShadow(bool bDrawShadow);
|
||||
void SetDrawCharacterShadow(bool bDrawChrShadow);
|
||||
|
||||
DWORD GetShadowMapColor(float fx, float fy);
|
||||
|
||||
protected:
|
||||
bool __PickTerrainHeight(float& fPos, const D3DXVECTOR3& v3Start, const D3DXVECTOR3& v3End, float fStep, float fRayRange, float fLimitRange, D3DXVECTOR3* pv3Pick);
|
||||
|
||||
virtual void __ClearGarvage();
|
||||
virtual void __UpdateGarvage();
|
||||
|
||||
virtual bool LoadTerrain(WORD wTerrainCoordX, WORD wTerrainCoordY, WORD wCellCoordX, WORD wCellCoordY);
|
||||
virtual bool LoadArea(WORD wAreaCoordX, WORD wAreaCoordY, WORD wCellCoordX, WORD wCellCoordY);
|
||||
virtual void UpdateAreaList(long lCenterX, long lCenterY);
|
||||
bool isTerrainLoaded(WORD wX, WORD wY);
|
||||
bool isAreaLoaded(WORD wX, WORD wY);
|
||||
|
||||
void AssignTerrainPtr(); // 현재 좌표에서 주위(ex. 3x3)에 있는 것들의 포인터를 연결한다. (업데이트 시 불려짐)
|
||||
|
||||
void SaveAlphaFogOperation();
|
||||
void RestoreAlphaFogOperation();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// New
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// 여러가지 맵들을 얻는다.
|
||||
void GetHeightMap(const BYTE & c_rucTerrainNum, WORD ** pwHeightMap);
|
||||
void GetNormalMap(const BYTE & c_rucTerrainNum, char ** pucNormalMap);
|
||||
|
||||
// Water
|
||||
void GetWaterMap(const BYTE & c_rucTerrainNum, BYTE ** pucWaterMap);
|
||||
void GetWaterHeight(BYTE byTerrainNum, BYTE byWaterNum, long * plWaterHeight);
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Terrain
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
protected:
|
||||
// 데이터
|
||||
CTerrain * m_pTerrain[AROUND_AREA_NUM]; // Terrain
|
||||
CTerrainPatchProxy * m_pTerrainPatchProxyList; // CTerrain을 랜더링 할때 실제로 랜더링하는 폴리곤 패치들... Seamless Map 을 위해 CTerrain으로부터 독립...
|
||||
|
||||
long m_lViewRadius; // 시야 거리.. 셀단위임..
|
||||
float m_fHeightScale; // 높이 스케일... 1.0일때 0~655.35미터까지 표현 가능.
|
||||
|
||||
short m_sTerrainCountX, m_sTerrainCountY; // seamless map 안에 들어가는 Terrain개수
|
||||
|
||||
TOutdoorMapCoordinate m_CurCoordinate; // 현재의 좌표
|
||||
|
||||
long m_lCurCoordStartX, m_lCurCoordStartY;
|
||||
TOutdoorMapCoordinate m_PrevCoordinate; // 현재의 좌표
|
||||
TOutdoorMapCoordinateMap m_EntryPointMap;
|
||||
|
||||
WORD m_wPatchCount;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Index Buffer
|
||||
#ifdef WORLD_EDITOR
|
||||
WORD * m_pwIndices; /* temp Index buffer */
|
||||
|
||||
CGraphicIndexBuffer m_IndexBuffer;
|
||||
WORD m_wNumIndices;
|
||||
#else
|
||||
WORD * m_pwaIndices[TERRAINPATCH_LODMAX];
|
||||
|
||||
CGraphicIndexBuffer m_IndexBuffer[TERRAINPATCH_LODMAX];
|
||||
WORD m_wNumIndices[TERRAINPATCH_LODMAX];
|
||||
#endif
|
||||
virtual void DestroyTerrain();
|
||||
|
||||
void CreateTerrainPatchProxyList();
|
||||
void DestroyTerrainPatchProxyList();
|
||||
|
||||
void UpdateTerrain(float fX, float fY);
|
||||
|
||||
void ConvertTerrainToTnL(long lx, long ly);
|
||||
|
||||
void AssignPatch(long lPatchNum, long lx0, long ly0, long lx1, long ly1);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Index Buffer
|
||||
void ADDLvl1TL(WORD * pIndices, WORD & rwCount, const WORD & c_rwCurCount, const BYTE & c_rucNumLineWarp);
|
||||
void ADDLvl1T(WORD * pIndices, WORD & rwCount, const WORD & c_rwCurCount, const BYTE & c_rucNumLineWarp);
|
||||
void ADDLvl1TR(WORD * pIndices, WORD & rwCount, const WORD & c_rwCurCount, const BYTE & c_rucNumLineWarp);
|
||||
void ADDLvl1L(WORD * pIndices, WORD & rwCount, const WORD & c_rwCurCount, const BYTE & c_rucNumLineWarp);
|
||||
void ADDLvl1R(WORD * pIndices, WORD & rwCount, const WORD & c_rwCurCount, const BYTE & c_rucNumLineWarp);
|
||||
void ADDLvl1BL(WORD * pIndices, WORD & rwCount, const WORD & c_rwCurCount, const BYTE & c_rucNumLineWarp);
|
||||
void ADDLvl1B(WORD * pIndices, WORD & rwCount, const WORD & c_rwCurCount, const BYTE & c_rucNumLineWarp);
|
||||
void ADDLvl1BR(WORD * pIndices, WORD & rwCount, const WORD & c_rwCurCount, const BYTE & c_rucNumLineWarp);
|
||||
void ADDLvl1M(WORD * pIndices, WORD & rwCount, const WORD & c_rwCurCount, const BYTE & c_rucNumLineWarp);
|
||||
void ADDLvl2TL(WORD * pIndices, WORD & rwCount, const WORD & c_rwCurCount, const BYTE & c_rucNumLineWarp);
|
||||
void ADDLvl2T(WORD * pIndices, WORD & rwCount, const WORD & c_rwCurCount, const BYTE & c_rucNumLineWarp);
|
||||
void ADDLvl2TR(WORD * pIndices, WORD & rwCount, const WORD & c_rwCurCount, const BYTE & c_rucNumLineWarp);
|
||||
void ADDLvl2L(WORD * pIndices, WORD & rwCount, const WORD & c_rwCurCount, const BYTE & c_rucNumLineWarp);
|
||||
void ADDLvl2R(WORD * pIndices, WORD & rwCount, const WORD & c_rwCurCount, const BYTE & c_rucNumLineWarp);
|
||||
void ADDLvl2BL(WORD * pIndices, WORD & rwCount, const WORD & c_rwCurCount, const BYTE & c_rucNumLineWarp);
|
||||
void ADDLvl2B(WORD * pIndices, WORD & rwCount, const WORD & c_rwCurCount, const BYTE & c_rucNumLineWarp);
|
||||
void ADDLvl2BR(WORD * pIndices, WORD & rwCount, const WORD & c_rwCurCount, const BYTE & c_rucNumLineWarp);
|
||||
void ADDLvl2M(WORD * pIndices, WORD & rwCount, const WORD & c_rwCurCount, const BYTE & c_rucNumLineWarp);
|
||||
|
||||
public:
|
||||
BOOL GetTerrainPointer(BYTE c_ucTerrainNum, CTerrain ** ppTerrain);
|
||||
float GetTerrainHeight(float fx, float fy);
|
||||
bool GetWaterHeight(int iX, int iY, long * plWaterHeight);
|
||||
bool GetNormal(int ix, int iy, D3DXVECTOR3 * pv3Normal);
|
||||
|
||||
void RenderTerrain();
|
||||
|
||||
const long GetViewRadius() { return m_lViewRadius; }
|
||||
const float GetHeightScale() { return m_fHeightScale; }
|
||||
|
||||
const TOutdoorMapCoordinate & GetEntryPoint(const std::string & c_rstrEntryPointName) const;
|
||||
void SetEntryPoint(const std::string & c_rstrEntryPointName, const TOutdoorMapCoordinate & c_rOutdoorMapCoordinate);
|
||||
const TOutdoorMapCoordinate & GetCurCoordinate() { return m_CurCoordinate; }
|
||||
const TOutdoorMapCoordinate & GetPrevCoordinate() { return m_PrevCoordinate; }
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Area
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
protected:
|
||||
CArea * m_pArea[AROUND_AREA_NUM]; // Data
|
||||
|
||||
virtual void DestroyArea();
|
||||
|
||||
void __UpdateArea(D3DXVECTOR3& v3Player);
|
||||
#ifdef WORLD_EDITOR
|
||||
void __NEW_WorldEditor_UpdateArea();
|
||||
#endif
|
||||
void __Game_UpdateArea(D3DXVECTOR3& v3Player);
|
||||
|
||||
void __BuildDynamicSphereInstanceVector();
|
||||
|
||||
void __CollectShadowReceiver(D3DXVECTOR3& v3Target, D3DXVECTOR3& v3Light);
|
||||
void __CollectCollisionPCBlocker(D3DXVECTOR3& v3Eye, D3DXVECTOR3& v3Target, float fDistance);
|
||||
void __CollectCollisionShadowReceiver(D3DXVECTOR3& v3Target, D3DXVECTOR3& v3Light);
|
||||
void __UpdateAroundAreaList();
|
||||
bool __IsInShadowReceiverList(CGraphicObjectInstance* pkObjInstTest);
|
||||
bool __IsInPCBlockerList(CGraphicObjectInstance* pkObjInstTest);
|
||||
|
||||
void ConvertToMapCoords(float fx, float fy, int *iCellX, int *iCellY, BYTE * pucSubCellX, BYTE * pucSubCellY, WORD * pwTerrainNumX, WORD * pwTerrainNumY);
|
||||
|
||||
public:
|
||||
BOOL GetAreaPointer(const BYTE c_ucAreaNum, CArea ** ppArea);
|
||||
void RenderArea(bool bRenderAmbience = true);
|
||||
void RenderBlendArea();
|
||||
void RenderDungeon();
|
||||
void RenderEffect();
|
||||
void RenderPCBlocker();
|
||||
void RenderTree();
|
||||
|
||||
public:
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// For Grass
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
float GetHeight(float* pPos);
|
||||
bool GetBrushColor(float fX, float fY, float* pLowColor, float* pHighColor);
|
||||
bool isAttrOn(float fX, float fY, BYTE byAttr);
|
||||
bool GetAttr(float fX, float fY, BYTE * pbyAttr);
|
||||
bool isAttrOn(int iX, int iY, BYTE byAttr);
|
||||
bool GetAttr(int iX, int iY, BYTE * pbyAttr);
|
||||
|
||||
void SetMaterialDiffuse(float fr, float fg, float fb);
|
||||
void SetMaterialAmbient(float fr, float fg, float fb);
|
||||
void SetTerrainMaterial(const PR_MATERIAL * pMaterial);
|
||||
|
||||
bool GetTerrainNum(float fx, float fy, BYTE * pbyTerrainNum);
|
||||
bool GetTerrainNumFromCoord(WORD wCoordX, WORD wCoordY, BYTE * pbyTerrainNum);
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// New
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
long m_lCenterX, m_lCenterY; // Terrain 좌표 내의 셀 좌표...
|
||||
long m_lOldReadX, m_lOldReadY; /* Last center */
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Octree
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
CTerrainQuadtreeNode * m_pRootNode;
|
||||
|
||||
void BuildQuadTree();
|
||||
CTerrainQuadtreeNode * AllocQuadTreeNode(long x0, long y0, long x1, long y1);
|
||||
void SubDivideNode(CTerrainQuadtreeNode * Node);
|
||||
void UpdateQuadTreeHeights(CTerrainQuadtreeNode *Node);
|
||||
|
||||
|
||||
void FreeQuadTree();
|
||||
|
||||
struct TPatchDrawStruct
|
||||
{
|
||||
float fDistance;
|
||||
BYTE byTerrainNum;
|
||||
long lPatchNum;
|
||||
CTerrainPatchProxy * pTerrainPatchProxy;
|
||||
|
||||
bool operator<( const TPatchDrawStruct & rhs) const
|
||||
{
|
||||
return fDistance < rhs.fDistance;
|
||||
}
|
||||
};
|
||||
|
||||
public:
|
||||
typedef std::vector<BYTE> TTerrainNumVector;
|
||||
struct FSortPatchDrawStructWithTerrainNum
|
||||
{
|
||||
static TTerrainNumVector m_TerrainNumVector;
|
||||
FSortPatchDrawStructWithTerrainNum()
|
||||
{
|
||||
m_TerrainNumVector.clear();
|
||||
}
|
||||
|
||||
bool operator () (const TPatchDrawStruct & lhs, const TPatchDrawStruct & rhs)
|
||||
{
|
||||
DWORD lhsTerrainNumOrder = 0, rhsTerrainNumOrder = 0;
|
||||
bool blhsOrderFound = false;
|
||||
bool brhsOrderFound = false;
|
||||
|
||||
TTerrainNumVector::iterator lhsIterator = std::find(m_TerrainNumVector.begin(), m_TerrainNumVector.end(), lhs.byTerrainNum);
|
||||
TTerrainNumVector::iterator rhsIterator = std::find(m_TerrainNumVector.begin(), m_TerrainNumVector.end(), rhs.byTerrainNum);
|
||||
|
||||
if (lhsIterator != m_TerrainNumVector.end())
|
||||
{
|
||||
blhsOrderFound = true;
|
||||
lhsTerrainNumOrder = lhsIterator - m_TerrainNumVector.begin();
|
||||
}
|
||||
if (rhsIterator != m_TerrainNumVector.end())
|
||||
{
|
||||
brhsOrderFound = true;
|
||||
rhsTerrainNumOrder = rhsIterator - m_TerrainNumVector.begin();
|
||||
}
|
||||
if (!brhsOrderFound)
|
||||
{
|
||||
m_TerrainNumVector.push_back(rhs.byTerrainNum);
|
||||
rhsTerrainNumOrder = m_TerrainNumVector.size() -1;
|
||||
}
|
||||
if (!blhsOrderFound)
|
||||
{
|
||||
lhsIterator = std::find(m_TerrainNumVector.begin(), m_TerrainNumVector.end(), lhs.byTerrainNum);
|
||||
if (lhsIterator != m_TerrainNumVector.end())
|
||||
{
|
||||
blhsOrderFound = true;
|
||||
lhsTerrainNumOrder = lhsIterator - m_TerrainNumVector.begin();
|
||||
}
|
||||
if (!blhsOrderFound)
|
||||
{
|
||||
m_TerrainNumVector.push_back(lhs.byTerrainNum);
|
||||
lhsTerrainNumOrder = m_TerrainNumVector.size() -1;
|
||||
}
|
||||
}
|
||||
|
||||
return lhsTerrainNumOrder < rhsTerrainNumOrder;
|
||||
}
|
||||
};
|
||||
|
||||
protected:
|
||||
|
||||
std::vector<std::pair<float, long> > m_PatchVector;
|
||||
std::vector<TPatchDrawStruct> m_PatchDrawStructVector;
|
||||
|
||||
void SetPatchDrawVector();
|
||||
|
||||
void NEW_DrawWireFrame(CTerrainPatchProxy * pTerrainPatchProxy, WORD wPrimitiveCount, D3DPRIMITIVETYPE ePrimitiveType);
|
||||
|
||||
void DrawWireFrame(long patchnum, WORD wPrimitiveCount, D3DPRIMITIVETYPE ePrimitiveType);
|
||||
void DrawWater(long patchnum);
|
||||
|
||||
bool m_bDrawWireFrame;
|
||||
bool m_bDrawShadow;
|
||||
bool m_bDrawChrShadow;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Water
|
||||
D3DXMATRIX m_matBump;
|
||||
void LoadWaterTexture();
|
||||
void UnloadWaterTexture();
|
||||
//Water
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Alpha Fog
|
||||
CGraphicImageInstance m_AlphaFogImageInstance;
|
||||
D3DXMATRIX m_matAlphaFogTexture;
|
||||
// Alpha Fog
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Character Shadow
|
||||
LPDIRECT3DTEXTURE8 m_lpCharacterShadowMapTexture;
|
||||
LPDIRECT3DSURFACE8 m_lpCharacterShadowMapRenderTargetSurface;
|
||||
LPDIRECT3DSURFACE8 m_lpCharacterShadowMapDepthSurface;
|
||||
D3DVIEWPORT8 m_ShadowMapViewport;
|
||||
WORD m_wShadowMapSize;
|
||||
|
||||
// Backup Device Context
|
||||
LPDIRECT3DSURFACE8 m_lpBackupRenderTargetSurface;
|
||||
LPDIRECT3DSURFACE8 m_lpBackupDepthSurface;
|
||||
D3DVIEWPORT8 m_BackupViewport;
|
||||
|
||||
// Character Shadow
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// View Frustum Culling
|
||||
D3DXPLANE m_plane[6];
|
||||
|
||||
void BuildViewFrustum(D3DXMATRIX & mat);
|
||||
|
||||
CTextureSet m_TextureSet;
|
||||
|
||||
protected:
|
||||
CSkyBox m_SkyBox;
|
||||
CLensFlare m_LensFlare;
|
||||
CScreenFilter m_ScreenFilter;
|
||||
|
||||
protected:
|
||||
void SetIndexBuffer();
|
||||
void SelectIndexBuffer(BYTE byLODLevel, WORD * pwPrimitiveCount, D3DPRIMITIVETYPE * pePrimitiveType);
|
||||
|
||||
D3DXMATRIX m_matWorldForCommonUse;
|
||||
D3DXMATRIX m_matViewInverse;
|
||||
|
||||
D3DXMATRIX m_matSplatAlpha;
|
||||
D3DXMATRIX m_matStaticShadow;
|
||||
D3DXMATRIX m_matDynamicShadow;
|
||||
D3DXMATRIX m_matDynamicShadowScale;
|
||||
D3DXMATRIX m_matLightView;
|
||||
|
||||
float m_fTerrainTexCoordBase;
|
||||
float m_fWaterTexCoordBase;
|
||||
|
||||
float m_fXforDistanceCaculation, m_fYforDistanceCaculation;
|
||||
|
||||
protected:
|
||||
typedef std::vector<CTerrain *> TTerrainPtrVector;
|
||||
typedef TTerrainPtrVector::iterator TTerrainPtrVectorIterator;
|
||||
typedef std::vector<CArea *> TAreaPtrVector;
|
||||
typedef TAreaPtrVector::iterator TAreaPtrVectorIterator;
|
||||
|
||||
TTerrainPtrVector m_TerrainVector;
|
||||
TTerrainPtrVector m_TerrainDeleteVector;
|
||||
TTerrainPtrVector m_TerrainLoadRequestVector;
|
||||
TTerrainPtrVector m_TerrainLoadWaitVector;
|
||||
TTerrainPtrVectorIterator m_TerrainPtrVectorIterator;
|
||||
|
||||
TAreaPtrVector m_AreaVector;
|
||||
TAreaPtrVector m_AreaDeleteVector;
|
||||
TAreaPtrVector m_AreaLoadRequestVector;
|
||||
TAreaPtrVector m_AreaLoadWaitVector;
|
||||
TAreaPtrVectorIterator m_AreaPtrVectorIterator;
|
||||
|
||||
struct FPushToDeleteVector
|
||||
{
|
||||
enum EDeleteDir
|
||||
{
|
||||
DELETE_LEFT,
|
||||
DELETE_RIGHT,
|
||||
DELETE_TOP,
|
||||
DELETE_BOTTOM,
|
||||
};
|
||||
|
||||
EDeleteDir m_eLRDeleteDir;
|
||||
EDeleteDir m_eTBDeleteDir;
|
||||
TOutdoorMapCoordinate m_CurCoordinate;
|
||||
|
||||
FPushToDeleteVector(EDeleteDir eLRDeleteDir, EDeleteDir eTBDeleteDir, TOutdoorMapCoordinate CurCoord)
|
||||
{
|
||||
m_eLRDeleteDir = eLRDeleteDir;
|
||||
m_eTBDeleteDir = eTBDeleteDir;
|
||||
m_CurCoordinate = CurCoord;
|
||||
}
|
||||
};
|
||||
|
||||
struct FPushTerrainToDeleteVector : public FPushToDeleteVector
|
||||
{
|
||||
TTerrainPtrVector m_ReturnTerrainVector;
|
||||
|
||||
FPushTerrainToDeleteVector(EDeleteDir eLRDeleteDir, EDeleteDir eTBDeleteDir, TOutdoorMapCoordinate CurCoord)
|
||||
: FPushToDeleteVector(eLRDeleteDir, eTBDeleteDir, CurCoord)
|
||||
{
|
||||
m_ReturnTerrainVector.clear();
|
||||
}
|
||||
|
||||
void operator() (CTerrain * pTerrain);
|
||||
};
|
||||
|
||||
struct FPushAreaToDeleteVector : public FPushToDeleteVector
|
||||
{
|
||||
TAreaPtrVector m_ReturnAreaVector;
|
||||
|
||||
FPushAreaToDeleteVector(EDeleteDir eLRDeleteDir, EDeleteDir eTBDeleteDir, TOutdoorMapCoordinate CurCoord)
|
||||
: FPushToDeleteVector(eLRDeleteDir, eTBDeleteDir, CurCoord)
|
||||
{
|
||||
m_ReturnAreaVector.clear();
|
||||
}
|
||||
|
||||
void operator() (CArea * pArea);
|
||||
};
|
||||
|
||||
protected:
|
||||
void InitializeVisibleParts();
|
||||
bool IsVisiblePart(int ePart);
|
||||
|
||||
float __GetNoFogDistance();
|
||||
float __GetFogDistance();
|
||||
|
||||
|
||||
protected:
|
||||
DWORD m_dwVisiblePartFlags;
|
||||
|
||||
int m_iRenderedSplatNumSqSum;
|
||||
int m_iRenderedSplatNum;
|
||||
int m_iRenderedPatchNum;
|
||||
std::vector<int> m_RenderedTextureNumVector;
|
||||
int m_iSplatLimit;
|
||||
|
||||
protected:
|
||||
int m_iPatchTerrainVertexCount;
|
||||
int m_iPatchWaterVertexCount;
|
||||
|
||||
int m_iPatchTerrainVertexSize;
|
||||
int m_iPatchWaterVertexSize;
|
||||
|
||||
DWORD m_dwRenderedCRCNum;
|
||||
DWORD m_dwRenderedGraphicThingInstanceNum;
|
||||
|
||||
std::list<RECT> m_rkList_kGuildArea;
|
||||
|
||||
protected:
|
||||
void __RenderTerrain_RecurseRenderQuadTree(CTerrainQuadtreeNode *Node, bool bCullCheckNeed = true);
|
||||
int __RenderTerrain_RecurseRenderQuadTree_CheckBoundingCircle(const D3DXVECTOR3 & c_v3Center, const float & c_fRadius);
|
||||
|
||||
void __RenderTerrain_AppendPatch(const D3DXVECTOR3& c_rv3Center, float fDistance, long lPatchNum);
|
||||
|
||||
void __RenderTerrain_RenderSoftwareTransformPatch();
|
||||
void __RenderTerrain_RenderHardwareTransformPatch();
|
||||
|
||||
protected:
|
||||
void __HardwareTransformPatch_RenderPatchSplat(long patchnum, WORD wPrimitiveCount, D3DPRIMITIVETYPE ePrimitiveType);
|
||||
void __HardwareTransformPatch_RenderPatchNone(long patchnum, WORD wPrimitiveCount, D3DPRIMITIVETYPE ePrimitiveType);
|
||||
|
||||
|
||||
protected:
|
||||
struct SoftwareTransformPatch_SData
|
||||
{
|
||||
enum
|
||||
{
|
||||
SPLAT_VB_NUM = 8,
|
||||
NONE_VB_NUM = 8,
|
||||
};
|
||||
|
||||
IDirect3DVertexBuffer8* m_pkVBSplat[SPLAT_VB_NUM];
|
||||
IDirect3DVertexBuffer8* m_pkVBNone[NONE_VB_NUM];
|
||||
DWORD m_dwSplatPos;
|
||||
DWORD m_dwNonePos;
|
||||
DWORD m_dwLightVersion;
|
||||
} m_kSTPD;
|
||||
|
||||
struct SoftwareTransformPatch_SRenderState {
|
||||
D3DXMATRIX m_m4Proj;
|
||||
D3DXMATRIX m_m4Frustum;
|
||||
D3DXMATRIX m_m4DynamicShadow;
|
||||
D3DLIGHT8 m_kLight;
|
||||
D3DMATERIAL8 m_kMtrl;
|
||||
D3DXVECTOR3 m_v3Player;
|
||||
DWORD m_dwFogColor;
|
||||
float m_fScreenHalfWidth;
|
||||
float m_fScreenHalfHeight;
|
||||
|
||||
float m_fFogNearDistance;
|
||||
float m_fFogFarDistance;
|
||||
float m_fFogNearTransZ;
|
||||
float m_fFogFarTransZ;
|
||||
float m_fFogLenInv;
|
||||
};
|
||||
|
||||
struct SoftwareTransformPatch_STVertex
|
||||
{
|
||||
D3DXVECTOR4 kPosition;
|
||||
};
|
||||
|
||||
struct SoftwareTransformPatch_STLVertex
|
||||
{
|
||||
D3DXVECTOR4 kPosition;
|
||||
DWORD dwDiffuse;
|
||||
DWORD dwFog;
|
||||
D3DXVECTOR2 kTexTile;
|
||||
D3DXVECTOR2 kTexAlpha;
|
||||
D3DXVECTOR2 kTexStaticShadow;
|
||||
D3DXVECTOR2 kTexDynamicShadow;
|
||||
};
|
||||
|
||||
|
||||
void __SoftwareTransformPatch_ApplyRenderState();
|
||||
void __SoftwareTransformPatch_RestoreRenderState(DWORD dwFogEnable);
|
||||
|
||||
void __SoftwareTransformPatch_Initialize();
|
||||
bool __SoftwareTransformPatch_Create();
|
||||
void __SoftwareTransformPatch_Destroy();
|
||||
void __SoftwareTransformPatch_BuildPipeline(SoftwareTransformPatch_SRenderState& rkTPRS);
|
||||
void __SoftwareTransformPatch_BuildPipeline_BuildFogFuncTable(SoftwareTransformPatch_SRenderState& rkTPRS);
|
||||
bool __SoftwareTransformPatch_SetTransform(SoftwareTransformPatch_SRenderState& rkTPRS, SoftwareTransformPatch_STLVertex* akTransVertex, CTerrainPatchProxy& rkTerrainPatchProxy, UINT uTerrainX, UINT uTerrainY, bool isFogEnable, bool isDynamicShadow);
|
||||
|
||||
bool __SoftwareTransformPatch_SetSplatStream(SoftwareTransformPatch_STLVertex* akTransVertex);
|
||||
bool __SoftwareTransformPatch_SetShadowStream(SoftwareTransformPatch_STLVertex* akTransVertex);
|
||||
|
||||
void __SoftwareTransformPatch_ApplyStaticShadowRenderState();
|
||||
void __SoftwareTransformPatch_RestoreStaticShadowRenderState();
|
||||
|
||||
void __SoftwareTransformPatch_ApplyFogShadowRenderState();
|
||||
void __SoftwareTransformPatch_RestoreFogShadowRenderState();
|
||||
void __SoftwareTransformPatch_ApplyDynamicShadowRenderState();
|
||||
void __SoftwareTransformPatch_RestoreDynamicShadowRenderState();
|
||||
void __SoftwareTransformPatch_RenderPatchSplat(SoftwareTransformPatch_SRenderState& rkTPRS, long patchnum, WORD wPrimitiveCount, D3DPRIMITIVETYPE ePrimitiveType, bool isFogEnable);
|
||||
void __SoftwareTransformPatch_RenderPatchNone(SoftwareTransformPatch_SRenderState& rkTPRS, long patchnum, WORD wPrimitiveCount, D3DPRIMITIVETYPE ePrimitiveType);
|
||||
|
||||
|
||||
protected:
|
||||
std::vector<CGraphicObjectInstance *> m_ShadowReceiverVector;
|
||||
std::vector<CGraphicObjectInstance *> m_PCBlockerVector;
|
||||
|
||||
protected:
|
||||
float m_fOpaqueWaterDepth;
|
||||
CGraphicImageInstance m_WaterInstances[30];
|
||||
|
||||
public:
|
||||
float GetOpaqueWaterDepth() { return m_fOpaqueWaterDepth; }
|
||||
void SetOpaqueWaterDepth(float fOpaqueWaterDepth) { m_fOpaqueWaterDepth = fOpaqueWaterDepth; }
|
||||
void SetTerrainRenderSort(ETerrainRenderSort eTerrainRenderSort) { m_eTerrainRenderSort = eTerrainRenderSort;}
|
||||
ETerrainRenderSort GetTerrainRenderSort() { return m_eTerrainRenderSort; }
|
||||
|
||||
protected:
|
||||
ETerrainRenderSort m_eTerrainRenderSort;
|
||||
|
||||
protected:
|
||||
CGraphicImageInstance m_attrImageInstance;
|
||||
CGraphicImageInstance m_BuildingTransparentImageInstance;
|
||||
D3DXMATRIX m_matBuildingTransparent;
|
||||
|
||||
protected:
|
||||
CDynamicPool<CMonsterAreaInfo> m_kPool_kMonsterAreaInfo;
|
||||
TMonsterAreaInfoPtrVector m_MonsterAreaInfoPtrVector;
|
||||
TMonsterAreaInfoPtrVectorIterator m_MonsterAreaInfoPtrVectorIterator;
|
||||
|
||||
public:
|
||||
bool LoadMonsterAreaInfo();
|
||||
|
||||
CMonsterAreaInfo * AddMonsterAreaInfo(long lOriginX, long lOriginY, long lSizeX, long lSizeY);
|
||||
void RemoveAllMonsterAreaInfo();
|
||||
|
||||
DWORD GetMonsterAreaInfoCount() { return m_MonsterAreaInfoPtrVector.size(); }
|
||||
bool GetMonsterAreaInfoFromVectorIndex(DWORD dwMonsterAreaInfoVectorIndex, CMonsterAreaInfo ** ppMonsterAreaInfo);
|
||||
|
||||
CMonsterAreaInfo * AddNewMonsterAreaInfo(long lOriginX, long lOriginY, long lSizeX, long lSizeY,
|
||||
CMonsterAreaInfo::EMonsterAreaInfoType eMonsterAreaInfoType,
|
||||
DWORD dwVID, DWORD dwCount, CMonsterAreaInfo::EMonsterDir eMonsterDir);
|
||||
|
||||
public:
|
||||
void GetBaseXY(DWORD * pdwBaseX, DWORD * pdwBaseY);
|
||||
void SetBaseXY(DWORD dwBaseX, DWORD dwBaseY);
|
||||
|
||||
void SetTransparentTree(bool bTransparentTree) { m_bTransparentTree = bTransparentTree;}
|
||||
void EnableTerrainOnlyForHeight(bool bFlag) { m_bEnableTerrainOnlyForHeight = bFlag; }
|
||||
void EnablePortal(bool bFlag);
|
||||
bool IsEnablePortal() { return m_bEnablePortal; }
|
||||
|
||||
protected:
|
||||
DWORD m_dwBaseX;
|
||||
DWORD m_dwBaseY;
|
||||
|
||||
D3DXVECTOR3 m_v3Player;
|
||||
|
||||
bool m_bShowEntirePatchTextureCount;
|
||||
bool m_bTransparentTree;
|
||||
bool m_bEnableTerrainOnlyForHeight;
|
||||
bool m_bEnablePortal;
|
||||
|
||||
// XMas
|
||||
private:
|
||||
struct SXMasTree
|
||||
{
|
||||
CSpeedTreeWrapper* m_pkTree;
|
||||
int m_iEffectID;
|
||||
} m_kXMas;
|
||||
|
||||
void __XMasTree_Initialize();
|
||||
void __XMasTree_Create(float x, float y, float z, const char* c_szTreeName, const char* c_szEffName);
|
||||
|
||||
public:
|
||||
void XMasTree_Destroy();
|
||||
void XMasTree_Set(float x, float y, float z, const char* c_szTreeName, const char* c_szEffName);
|
||||
|
||||
// Special Effect
|
||||
private:
|
||||
typedef std::map<DWORD, int> TSpecialEffectMap;
|
||||
TSpecialEffectMap m_kMap_dwID_iEffectID;
|
||||
|
||||
public:
|
||||
void SpecialEffect_Create(DWORD dwID, float x, float y, float z, const char* c_szEffName);
|
||||
void SpecialEffect_Delete(DWORD dwID);
|
||||
void SpecialEffect_Destroy();
|
||||
|
||||
private:
|
||||
struct SHeightCache
|
||||
{
|
||||
struct SItem
|
||||
{
|
||||
DWORD m_dwKey;
|
||||
float m_fHeight;
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
HASH_SIZE = 100,
|
||||
};
|
||||
|
||||
std::vector<SItem> m_akVct_kItem[HASH_SIZE];
|
||||
|
||||
bool m_isUpdated;
|
||||
} m_kHeightCache;
|
||||
|
||||
void __HeightCache_Init();
|
||||
void __HeightCache_Update();
|
||||
|
||||
public:
|
||||
void SetEnvironmentDataName(const std::string& strEnvironmentDataName);
|
||||
std::string& GetEnvironmentDataName();
|
||||
|
||||
protected:
|
||||
std::string m_settings_envDataName;
|
||||
std::string m_envDataName;
|
||||
|
||||
private:
|
||||
bool m_bSettingTerrainVisible;
|
||||
};
|
||||
@@ -0,0 +1,99 @@
|
||||
#pragma once
|
||||
|
||||
#include "MapUtil.h"
|
||||
|
||||
class IPhysicsWorld
|
||||
{
|
||||
public:
|
||||
IPhysicsWorld()
|
||||
{
|
||||
assert(ms_pWorld == NULL);
|
||||
ms_pWorld = this;
|
||||
}
|
||||
|
||||
virtual ~IPhysicsWorld()
|
||||
{
|
||||
if (this == ms_pWorld)
|
||||
ms_pWorld = NULL;
|
||||
}
|
||||
|
||||
static IPhysicsWorld* GetPhysicsWorld()
|
||||
{
|
||||
return ms_pWorld;
|
||||
}
|
||||
|
||||
virtual bool isPhysicalCollision(const D3DXVECTOR3 & c_rvCheckPosition) = 0;
|
||||
|
||||
private:
|
||||
static IPhysicsWorld* ms_pWorld;
|
||||
};
|
||||
|
||||
class CActorInstance;
|
||||
//NOTE : 맘에 안들지만 Dependency Inversion을 막고 이전과 동일한 interface를 유지하기 위해서 이방식대로 간다
|
||||
//하지만 제대로 설계를 한다면 world와 live object들의 관리는 조금더 base project에서 (gamelib이나 더 base project에서 해야 한다 )
|
||||
class IObjectManager
|
||||
{
|
||||
public:
|
||||
IObjectManager()
|
||||
{
|
||||
assert(ms_ObjManager == NULL);
|
||||
ms_ObjManager = this;
|
||||
}
|
||||
|
||||
virtual ~IObjectManager()
|
||||
{
|
||||
if (this == ms_ObjManager)
|
||||
ms_ObjManager = NULL;
|
||||
}
|
||||
|
||||
static IObjectManager* GetObjectManager()
|
||||
{
|
||||
return ms_ObjManager;
|
||||
}
|
||||
|
||||
virtual void AdjustCollisionWithOtherObjects(CActorInstance* pInst ) = 0;
|
||||
|
||||
private:
|
||||
static IObjectManager* ms_ObjManager;
|
||||
};
|
||||
|
||||
class CPhysicsObject
|
||||
{
|
||||
public:
|
||||
CPhysicsObject();
|
||||
virtual ~CPhysicsObject();
|
||||
|
||||
void Initialize();
|
||||
|
||||
void Update(float fElapsedTime);
|
||||
|
||||
bool isBlending();
|
||||
|
||||
void SetDirection(const D3DXVECTOR3 & c_rv3Direction);
|
||||
void IncreaseExternalForce(const D3DXVECTOR3 & c_rvBasePosition, float fForce);
|
||||
void SetLastPosition(const TPixelPosition & c_rPosition, float fBlendingTime);
|
||||
void GetLastPosition(TPixelPosition * pPosition);
|
||||
|
||||
float GetXMovement();
|
||||
float GetYMovement();
|
||||
void ClearSavingMovement();
|
||||
|
||||
void SetActorInstance( CActorInstance* pInst ) { m_pActorInstance = pInst; }
|
||||
CActorInstance* GetActorInstance() { return m_pActorInstance; }
|
||||
|
||||
protected:
|
||||
void Accumulate(D3DXVECTOR3 * pv3Position);
|
||||
|
||||
protected:
|
||||
float m_fMass;
|
||||
float m_fFriction;
|
||||
D3DXVECTOR3 m_v3Direction;
|
||||
D3DXVECTOR3 m_v3Acceleration;
|
||||
D3DXVECTOR3 m_v3Velocity;
|
||||
|
||||
D3DXVECTOR3 m_v3LastPosition;
|
||||
CEaseOutInterpolation m_xPushingPosition;
|
||||
CEaseOutInterpolation m_yPushingPosition;
|
||||
|
||||
CActorInstance* m_pActorInstance;
|
||||
};
|
||||
@@ -0,0 +1,43 @@
|
||||
#pragma once
|
||||
|
||||
#include "../EterPack/EterPack.h"
|
||||
|
||||
class CPropertyManager : public CSingleton<CPropertyManager>
|
||||
{
|
||||
public:
|
||||
CPropertyManager();
|
||||
virtual ~CPropertyManager();
|
||||
|
||||
void Clear();
|
||||
|
||||
void SetPack(CEterPack * pPack);
|
||||
bool BuildPack();
|
||||
|
||||
bool LoadReservedCRC(const char * c_pszFileName);
|
||||
void ReserveCRC(DWORD dwCRC);
|
||||
DWORD GetUniqueCRC(const char * c_szSeed);
|
||||
|
||||
bool Initialize(const char * c_pszPackFileName = NULL);
|
||||
bool Register(const char * c_pszFileName, CProperty ** ppProperty = NULL);
|
||||
|
||||
bool Get(DWORD dwCRC, CProperty ** ppProperty);
|
||||
bool Get(const char * c_pszFileName, CProperty ** ppProperty);
|
||||
|
||||
// bool Add(const char * c_pszFileName);
|
||||
// bool Remove(DWORD dwCRC);
|
||||
|
||||
bool Put(const char * c_pszFileName, const char * c_pszSourceFileName);
|
||||
|
||||
bool Erase(DWORD dwCRC);
|
||||
bool Erase(const char * c_pszFileName);
|
||||
|
||||
protected:
|
||||
typedef std::map<DWORD, CProperty *> TPropertyCRCMap;
|
||||
typedef std::set<DWORD> TCRCSet;
|
||||
|
||||
bool m_isFileMode;
|
||||
TPropertyCRCMap m_PropertyByCRCMap;
|
||||
TCRCSet m_ReservedCRCSet;
|
||||
CEterPack m_pack;
|
||||
CEterFileDict m_fileDict;
|
||||
};
|
||||
@@ -0,0 +1,238 @@
|
||||
#pragma once
|
||||
|
||||
#include "../EterGrnLib/Thing.h"
|
||||
|
||||
class CRaceMotionData;
|
||||
class CAttributeData;
|
||||
|
||||
#define COMBO_KEY DWORD
|
||||
#define MAKE_COMBO_KEY(motion_mode, combo_type) ( (DWORD(motion_mode) << 16) | (DWORD(combo_type)) )
|
||||
#define COMBO_KEY_GET_MOTION_MODE(key) ( WORD(DWORD(key) >> 16 & 0xFFFF) )
|
||||
#define COMBO_KEY_GET_COMBO_TYPE(key) ( WORD(DWORD(key) & 0xFFFF) )
|
||||
|
||||
class CRaceData
|
||||
{
|
||||
public:
|
||||
enum EParts
|
||||
{
|
||||
// Share index with server
|
||||
// ECharacterEquipmentPart도 수정해주세요.
|
||||
//패킷 크기가 변합니다 서버와 상의후 추가해주세요.
|
||||
PART_MAIN,
|
||||
PART_WEAPON,
|
||||
PART_HEAD,
|
||||
PART_WEAPON_LEFT,
|
||||
PART_HAIR,
|
||||
|
||||
PART_MAX_NUM,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
SMOKE_NUM = 4,
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
// Graphic Resource
|
||||
|
||||
// Model
|
||||
typedef std::map<WORD, CGraphicThing*> TGraphicThingMap;
|
||||
typedef std::map<DWORD, std::string> TAttachingBoneNameMap;
|
||||
|
||||
// Motion
|
||||
typedef struct SMotion
|
||||
{
|
||||
BYTE byPercentage;
|
||||
CGraphicThing * pMotion;
|
||||
CRaceMotionData * pMotionData;
|
||||
} TMotion;
|
||||
typedef std::vector<TMotion> TMotionVector;
|
||||
typedef std::map<WORD, TMotionVector> TMotionVectorMap;
|
||||
|
||||
typedef struct SMotionModeData
|
||||
{
|
||||
WORD wMotionModeIndex;
|
||||
|
||||
TMotionVectorMap MotionVectorMap;
|
||||
|
||||
SMotionModeData() {}
|
||||
virtual ~SMotionModeData() {}
|
||||
} TMotionModeData;
|
||||
typedef std::map<WORD, TMotionModeData*> TMotionModeDataMap;
|
||||
typedef TMotionModeDataMap::iterator TMotionModeDataIterator;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
// Model Data
|
||||
typedef struct SModelData
|
||||
{
|
||||
NRaceData::TAttachingDataVector AttachingDataVector;
|
||||
} TModelData;
|
||||
typedef std::map<DWORD, TModelData> TModelDataMap;
|
||||
typedef TModelDataMap::iterator TModelDataMapIterator;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
// Motion Data
|
||||
typedef std::map<DWORD, CRaceMotionData*> TMotionDataMap;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
// Combo Data
|
||||
typedef std::vector<DWORD> TComboIndexVector;
|
||||
typedef struct SComboAttackData
|
||||
{
|
||||
TComboIndexVector ComboIndexVector;
|
||||
} TComboData;
|
||||
typedef std::map<DWORD, DWORD> TNormalAttackIndexMap;
|
||||
typedef std::map<COMBO_KEY, TComboData> TComboAttackDataMap;
|
||||
typedef TComboAttackDataMap::iterator TComboAttackDataIterator;
|
||||
|
||||
struct SSkin
|
||||
{
|
||||
int m_ePart;
|
||||
|
||||
std::string m_stSrcFileName;
|
||||
std::string m_stDstFileName;
|
||||
|
||||
SSkin()
|
||||
{
|
||||
m_ePart=0;
|
||||
}
|
||||
SSkin(const SSkin& c_rkSkin)
|
||||
{
|
||||
Copy(c_rkSkin);
|
||||
}
|
||||
void operator=(const SSkin& c_rkSkin)
|
||||
{
|
||||
Copy(c_rkSkin);
|
||||
}
|
||||
void Copy(const SSkin& c_rkSkin)
|
||||
{
|
||||
m_ePart=c_rkSkin.m_ePart;
|
||||
m_stSrcFileName=c_rkSkin.m_stSrcFileName;
|
||||
m_stDstFileName=c_rkSkin.m_stDstFileName;
|
||||
}
|
||||
};
|
||||
|
||||
struct SHair
|
||||
{
|
||||
std::string m_stModelFileName;
|
||||
std::vector<SSkin> m_kVct_kSkin;
|
||||
};
|
||||
|
||||
struct SShape
|
||||
{
|
||||
std::string m_stModelFileName;
|
||||
std::vector<SSkin> m_kVct_kSkin;
|
||||
};
|
||||
|
||||
public:
|
||||
static CRaceData* New();
|
||||
static void Delete(CRaceData* pkRaceData);
|
||||
static void CreateSystem(UINT uCapacity, UINT uMotModeCapacity);
|
||||
static void DestroySystem();
|
||||
|
||||
public:
|
||||
CRaceData();
|
||||
virtual ~CRaceData();
|
||||
|
||||
void Destroy();
|
||||
|
||||
// Codes For Client
|
||||
const char* GetBaseModelFileName() const;
|
||||
const char* GetAttributeFileName() const;
|
||||
const char* GetMotionListFileName() const;
|
||||
CGraphicThing * GetBaseModelThing();
|
||||
CGraphicThing * GetLODModelThing();
|
||||
CAttributeData * GetAttributeDataPtr();
|
||||
BOOL GetAttachingBoneName(DWORD dwPartIndex, const char ** c_pszBoneName);
|
||||
BOOL CreateMotionModeIterator(TMotionModeDataIterator & itor);
|
||||
BOOL NextMotionModeIterator(TMotionModeDataIterator & itor);
|
||||
|
||||
BOOL GetMotionKey(WORD wMotionModeIndex, WORD wMotionIndex, MOTION_KEY * pMotionKey);
|
||||
|
||||
BOOL GetMotionModeDataPointer(WORD wMotionMode, TMotionModeData ** ppMotionModeData);
|
||||
BOOL GetModelDataPointer(DWORD dwModelIndex, const TModelData ** c_ppModelData);
|
||||
BOOL GetMotionVectorPointer(WORD wMotionMode, WORD wMotionIndex, const TMotionVector ** c_ppMotionVector);
|
||||
BOOL GetMotionDataPointer(WORD wMotionMode, WORD wMotionIndex, WORD wMotionSubIndex, CRaceMotionData** ppMotionData);
|
||||
BOOL GetMotionDataPointer(DWORD dwMotionKey, CRaceMotionData ** ppMotionData);
|
||||
|
||||
DWORD GetAttachingDataCount();
|
||||
BOOL GetAttachingDataPointer(DWORD dwIndex, const NRaceData::TAttachingData ** c_ppAttachingData);
|
||||
BOOL GetCollisionDataPointer(DWORD dwIndex, const NRaceData::TAttachingData ** c_ppAttachingData);
|
||||
BOOL GetBodyCollisionDataPointer(const NRaceData::TAttachingData ** c_ppAttachingData);
|
||||
|
||||
BOOL IsTree();
|
||||
const char * GetTreeFileName();
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
// Setup by Script
|
||||
BOOL LoadRaceData(const char * c_szFileName);
|
||||
|
||||
CGraphicThing* RegisterMotionData(WORD wMotionMode, WORD wMotionIndex, const char * c_szFileName, BYTE byPercentage = 100);
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
// Setup by Python
|
||||
void SetRace(DWORD dwRaceIndex);
|
||||
void RegisterAttachingBoneName(DWORD dwPartIndex, const char * c_szBoneName);
|
||||
|
||||
void RegisterMotionMode(WORD wMotionModeIndex);
|
||||
void SetMotionModeParent(WORD wParentMotionModeIndex, WORD wMotionModeIndex);
|
||||
void OLD_RegisterMotion(WORD wMotionModeIndex, WORD wMotionIndex, const char * c_szFileName, BYTE byPercentage = 100);
|
||||
CGraphicThing* NEW_RegisterMotion(CRaceMotionData* pkMotionData, WORD wMotionModeIndex, WORD wMotionIndex, const char * c_szFileName, BYTE byPercentage = 100);
|
||||
bool SetMotionRandomWeight(WORD wMotionModeIndex, WORD wMotionIndex, WORD wMotionSubIndex, BYTE byPercentage);
|
||||
|
||||
void RegisterNormalAttack(WORD wMotionModeIndex, WORD wMotionIndex);
|
||||
BOOL GetNormalAttackIndex(WORD wMotionModeIndex, WORD * pwMotionIndex);
|
||||
|
||||
void ReserveComboAttack(WORD wMotionModeIndex, WORD wComboType, DWORD dwComboCount);
|
||||
void RegisterComboAttack(WORD wMotionModeIndex, WORD wComboType, DWORD dwComboIndex, WORD wMotionIndex);
|
||||
BOOL GetComboDataPointer(WORD wMotionModeIndex, WORD wComboType, TComboData ** ppComboData);
|
||||
|
||||
void SetShapeModel(UINT eShape, const char* c_szModelFileName);
|
||||
void AppendShapeSkin(UINT eShape, UINT ePart, const char* c_szSrcFileName, const char* c_szDstFileName);
|
||||
|
||||
void SetHairSkin(UINT eHair, UINT ePart, const char* c_szModelFileName, const char* c_szSrcFileName, const char* c_szDstFileName);
|
||||
|
||||
/////
|
||||
|
||||
DWORD GetSmokeEffectID(UINT eSmoke);
|
||||
|
||||
const std::string& GetSmokeBone();
|
||||
|
||||
SHair* FindHair(UINT eHair);
|
||||
SShape* FindShape(UINT eShape);
|
||||
|
||||
protected:
|
||||
void __Initialize();
|
||||
|
||||
void __OLD_RegisterMotion(WORD wMotionMode, WORD wMotionIndex, const TMotion & rMotion);
|
||||
|
||||
BOOL GetMotionVectorPointer(WORD wMotionMode, WORD wMotionIndex, TMotionVector ** ppMotionVector);
|
||||
|
||||
protected:
|
||||
DWORD m_dwRaceIndex;
|
||||
DWORD m_adwSmokeEffectID[SMOKE_NUM];
|
||||
|
||||
CGraphicThing * m_pBaseModelThing;
|
||||
CGraphicThing * m_pLODModelThing;
|
||||
|
||||
std::string m_strBaseModelFileName;
|
||||
std::string m_strTreeFileName;
|
||||
std::string m_strAttributeFileName;
|
||||
std::string m_strMotionListFileName;
|
||||
std::string m_strSmokeBoneName;
|
||||
|
||||
TModelDataMap m_ModelDataMap;
|
||||
TMotionModeDataMap m_pMotionModeDataMap;
|
||||
TAttachingBoneNameMap m_AttachingBoneNameMap;
|
||||
TComboAttackDataMap m_ComboAttackDataMap;
|
||||
TNormalAttackIndexMap m_NormalAttackIndexMap;
|
||||
|
||||
std::map<DWORD, SHair> m_kMap_dwHairKey_kHair;
|
||||
std::map<DWORD, SShape> m_kMap_dwShapeKey_kShape;
|
||||
|
||||
NRaceData::TAttachingDataVector m_AttachingDataVector;
|
||||
|
||||
protected:
|
||||
static CDynamicPool<TMotionModeData> ms_MotionModeDataPool;
|
||||
static CDynamicPool<CRaceData> ms_kPool;
|
||||
};
|
||||
@@ -0,0 +1,49 @@
|
||||
#pragma once
|
||||
|
||||
#include "RaceData.h"
|
||||
|
||||
class CRaceManager : public CSingleton<CRaceManager>
|
||||
{
|
||||
public:
|
||||
typedef std::map<DWORD, CRaceData *> TRaceDataMap;
|
||||
typedef TRaceDataMap::iterator TRaceDataIterator;
|
||||
|
||||
public:
|
||||
CRaceManager();
|
||||
virtual ~CRaceManager();
|
||||
|
||||
void Create();
|
||||
void Destroy();
|
||||
|
||||
void RegisterRaceName(DWORD dwRaceIndex, const char * c_szName);
|
||||
void RegisterRaceSrcName(const char * c_szName, const char * c_szSrcName);
|
||||
|
||||
void SetPathName(const char * c_szPathName);
|
||||
const char * GetFullPathFileName(const char* c_szFileName);
|
||||
|
||||
// Handling
|
||||
void CreateRace(DWORD dwRaceIndex);
|
||||
void SelectRace(DWORD dwRaceIndex);
|
||||
CRaceData * GetSelectedRaceDataPointer();
|
||||
// Handling
|
||||
|
||||
BOOL GetRaceDataPointer(DWORD dwRaceIndex, CRaceData ** ppRaceData);
|
||||
|
||||
|
||||
protected:
|
||||
CRaceData* __LoadRaceData(DWORD dwRaceIndex);
|
||||
bool __LoadRaceMotionList(CRaceData& rkRaceData, const char* pathName, const char* motionListFileName);
|
||||
|
||||
void __Initialize();
|
||||
void __DestroyRaceDataMap();
|
||||
|
||||
protected:
|
||||
TRaceDataMap m_RaceDataMap;
|
||||
|
||||
std::map<std::string, std::string> m_kMap_stRaceName_stSrcName;
|
||||
std::map<DWORD, std::string> m_kMap_dwRaceKey_stRaceName;
|
||||
|
||||
private:
|
||||
std::string m_strPathName;
|
||||
CRaceData * m_pSelectedRaceData;
|
||||
};
|
||||
@@ -0,0 +1,301 @@
|
||||
#pragma once
|
||||
|
||||
#include "../MilesLib/Type.h"
|
||||
#include "RaceMotionDataEvent.h"
|
||||
|
||||
class CRaceMotionData
|
||||
{
|
||||
public:
|
||||
enum EType
|
||||
{
|
||||
TYPE_NONE,
|
||||
TYPE_WAIT,
|
||||
TYPE_MOVE,
|
||||
TYPE_ATTACK,
|
||||
TYPE_COMBO,
|
||||
TYPE_DAMAGE,
|
||||
TYPE_KNOCKDOWN,
|
||||
TYPE_DIE,
|
||||
TYPE_SKILL,
|
||||
TYPE_STANDUP,
|
||||
TYPE_EVENT,
|
||||
TYPE_FISHING,
|
||||
TYPE_NUM,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
SKILL_NUM = 255,
|
||||
};
|
||||
|
||||
enum EMode
|
||||
{
|
||||
MODE_RESERVED,
|
||||
MODE_GENERAL,
|
||||
|
||||
MODE_ONEHAND_SWORD,
|
||||
MODE_TWOHAND_SWORD,
|
||||
MODE_DUALHAND_SWORD,
|
||||
MODE_BOW,
|
||||
MODE_FAN,
|
||||
MODE_BELL,
|
||||
MODE_FISHING,
|
||||
|
||||
MODE_HORSE,
|
||||
MODE_HORSE_ONEHAND_SWORD,
|
||||
MODE_HORSE_TWOHAND_SWORD,
|
||||
MODE_HORSE_DUALHAND_SWORD,
|
||||
MODE_HORSE_BOW,
|
||||
MODE_HORSE_FAN,
|
||||
MODE_HORSE_BELL,
|
||||
|
||||
MODE_WEDDING_DRESS,
|
||||
|
||||
MODE_MAX_NUM,
|
||||
};
|
||||
|
||||
enum EName
|
||||
{
|
||||
NAME_NONE, // 0 없음
|
||||
NAME_WAIT, // 1 대기 (00.msa)
|
||||
NAME_WALK, // 2 걷기 (02.msa)
|
||||
NAME_RUN, // 3 뛰기 (03.msa)
|
||||
NAME_CHANGE_WEAPON, // 4 무기바꾸기
|
||||
NAME_DAMAGE, // 5 정면맞기 (30.msa)
|
||||
NAME_DAMAGE_FLYING, // 6 정면날아가기 (32.msa)
|
||||
NAME_STAND_UP, // 7 정면일어나기 (33.msa)
|
||||
NAME_DAMAGE_BACK, // 8 후면맞기 (34.msa)
|
||||
NAME_DAMAGE_FLYING_BACK, // 9 후면날아가기 (35.msa)
|
||||
NAME_STAND_UP_BACK, // 10 후면일어나기 (36.msa)
|
||||
NAME_DEAD, // 11 죽기 (31.msa)
|
||||
NAME_DEAD_BACK, // 12 후면죽기 (37.msa)
|
||||
NAME_NORMAL_ATTACK, // 13 공격 (20.msa)
|
||||
NAME_COMBO_ATTACK_1, // 14 콤보 공격
|
||||
NAME_COMBO_ATTACK_2, // 15 콤보 공격
|
||||
NAME_COMBO_ATTACK_3, // 16 콤보 공격
|
||||
NAME_COMBO_ATTACK_4, // 17 콤보 공격
|
||||
NAME_COMBO_ATTACK_5, // 18 콤보 공격
|
||||
NAME_COMBO_ATTACK_6, // 19 콤보 공격
|
||||
NAME_COMBO_ATTACK_7, // 20 콤보 공격
|
||||
NAME_COMBO_ATTACK_8, // 21 콤보 공격
|
||||
NAME_INTRO_WAIT, // 22 선택화면 대기
|
||||
NAME_INTRO_SELECTED, // 23 선택화면 선택
|
||||
NAME_INTRO_NOT_SELECTED, // 24 선택화면 비선택
|
||||
NAME_SPAWN, // 25 소환
|
||||
NAME_FISHING_THROW, // 26 낚시 던지기
|
||||
NAME_FISHING_WAIT, // 27 낚시 대기
|
||||
NAME_FISHING_STOP, // 28 낚시 그만두기
|
||||
NAME_FISHING_REACT, // 29 낚시 반응
|
||||
NAME_FISHING_CATCH, // 30 낚시 잡기
|
||||
NAME_FISHING_FAIL, // 31 낚시 실패
|
||||
NAME_STOP, // 32 말 멈추기
|
||||
NAME_SPECIAL_1, // 33 몬스터/NPC 특수 동작 (24.msa)
|
||||
NAME_SPECIAL_2, // 34 몬스터/NPC 특수 동작 (25.msa)
|
||||
NAME_SPECIAL_3,
|
||||
NAME_SPECIAL_4,
|
||||
NAME_SPECIAL_5,
|
||||
NAME_SPECIAL_6,
|
||||
NAME_SKILL = 50,
|
||||
NAME_SKILL_END = NAME_SKILL+SKILL_NUM,
|
||||
|
||||
// CLAP
|
||||
NAME_CLAP,
|
||||
|
||||
// CHEERS
|
||||
NAME_CHEERS_1,
|
||||
NAME_CHEERS_2,
|
||||
|
||||
// KISS
|
||||
NAME_KISS_START,
|
||||
NAME_KISS_WITH_WARRIOR = NAME_KISS_START + 0,
|
||||
NAME_KISS_WITH_ASSASSIN = NAME_KISS_START + 1,
|
||||
NAME_KISS_WITH_SURA = NAME_KISS_START + 2,
|
||||
NAME_KISS_WITH_SHAMAN = NAME_KISS_START + 3,
|
||||
|
||||
// FRENCH_KISS
|
||||
NAME_FRENCH_KISS_START,
|
||||
NAME_FRENCH_KISS_WITH_WARRIOR = NAME_FRENCH_KISS_START + 0,
|
||||
NAME_FRENCH_KISS_WITH_ASSASSIN = NAME_FRENCH_KISS_START + 1,
|
||||
NAME_FRENCH_KISS_WITH_SURA = NAME_FRENCH_KISS_START + 2,
|
||||
NAME_FRENCH_KISS_WITH_SHAMAN = NAME_FRENCH_KISS_START + 3,
|
||||
|
||||
// SLAP
|
||||
NAME_SLAP_HIT_START,
|
||||
NAME_SLAP_HIT_WITH_WARRIOR = NAME_SLAP_HIT_START + 0,
|
||||
NAME_SLAP_HIT_WITH_ASSASSIN = NAME_SLAP_HIT_START + 1,
|
||||
NAME_SLAP_HIT_WITH_SURA = NAME_SLAP_HIT_START + 2,
|
||||
NAME_SLAP_HIT_WITH_SHAMAN = NAME_SLAP_HIT_START + 3,
|
||||
|
||||
NAME_SLAP_HURT_START,
|
||||
NAME_SLAP_HURT_WITH_WARRIOR = NAME_SLAP_HURT_START + 0,
|
||||
NAME_SLAP_HURT_WITH_ASSASSIN = NAME_SLAP_HURT_START + 1,
|
||||
NAME_SLAP_HURT_WITH_SURA = NAME_SLAP_HURT_START + 2,
|
||||
NAME_SLAP_HURT_WITH_SHAMAN = NAME_SLAP_HURT_START + 3,
|
||||
|
||||
NAME_DIG,
|
||||
|
||||
NAME_DANCE_1,
|
||||
NAME_DANCE_2,
|
||||
NAME_DANCE_3,
|
||||
NAME_DANCE_4,
|
||||
NAME_DANCE_5,
|
||||
NAME_DANCE_6, // 강남스타일
|
||||
|
||||
NAME_DANCE_END = NAME_DANCE_1 + 16,
|
||||
|
||||
NAME_CONGRATULATION,
|
||||
NAME_FORGIVE,
|
||||
NAME_ANGRY,
|
||||
NAME_ATTRACTIVE,
|
||||
NAME_SAD,
|
||||
NAME_SHY,
|
||||
NAME_CHEERUP,
|
||||
NAME_BANTER,
|
||||
NAME_JOY,
|
||||
|
||||
NAME_MAX_NUM,
|
||||
};
|
||||
|
||||
enum EMotionEventType
|
||||
{
|
||||
MOTION_EVENT_TYPE_NONE,
|
||||
|
||||
MOTION_EVENT_TYPE_EFFECT,
|
||||
MOTION_EVENT_TYPE_SCREEN_WAVING,
|
||||
MOTION_EVENT_TYPE_SCREEN_FLASHING,
|
||||
MOTION_EVENT_TYPE_SPECIAL_ATTACKING,
|
||||
MOTION_EVENT_TYPE_SOUND,
|
||||
MOTION_EVENT_TYPE_FLY,
|
||||
MOTION_EVENT_TYPE_CHARACTER_SHOW,
|
||||
MOTION_EVENT_TYPE_CHARACTER_HIDE,
|
||||
MOTION_EVENT_TYPE_WARP,
|
||||
MOTION_EVENT_TYPE_EFFECT_TO_TARGET,
|
||||
|
||||
MOTION_EVENT_TYPE_MAX_NUM,
|
||||
};
|
||||
|
||||
typedef struct SComboInputData
|
||||
{
|
||||
float fInputStartTime;
|
||||
float fNextComboTime;
|
||||
float fInputEndTime;
|
||||
} TComboInputData;
|
||||
|
||||
typedef struct NMotionEvent::SMotionEventData TMotionEventData;
|
||||
typedef struct NMotionEvent::SMotionEventDataScreenWaving TScreenWavingEventData;
|
||||
typedef struct NMotionEvent::SMotionEventDataScreenFlashing TScreenFlashingEventData;
|
||||
typedef struct NMotionEvent::SMotionEventDataEffect TMotionEffectEventData;
|
||||
typedef struct NMotionEvent::SMotionEventDataFly TMotionFlyEventData;
|
||||
typedef struct NMotionEvent::SMotionEventDataAttack TMotionAttackingEventData;
|
||||
typedef struct NMotionEvent::SMotionEventDataSound TMotionSoundEventData;
|
||||
typedef struct NMotionEvent::SMotionEventDataCharacterShow TMotionCharacterShowEventData;
|
||||
typedef struct NMotionEvent::SMotionEventDataCharacterHide TMotionCharacterHideEventData;
|
||||
typedef struct NMotionEvent::SMotionEventDataWarp TMotionWarpEventData;
|
||||
typedef struct NMotionEvent::SMotionEventDataEffectToTarget TMotionEffectToTargetEventData;
|
||||
typedef std::vector<TMotionEventData*> TMotionEventDataVector;
|
||||
|
||||
public:
|
||||
static CRaceMotionData* New();
|
||||
static void Delete(CRaceMotionData* pkData);
|
||||
|
||||
static void CreateSystem(UINT uCapacity);
|
||||
static void DestroySystem();
|
||||
|
||||
public:
|
||||
CRaceMotionData();
|
||||
virtual ~CRaceMotionData();
|
||||
|
||||
void Initialize();
|
||||
void Destroy();
|
||||
|
||||
void SetName(UINT eName);
|
||||
|
||||
UINT GetType() const; // 모션 타입 얻기
|
||||
bool IsLock() const; // 락된 모션 인가? (다른 모션에 캔슬되지 않음)
|
||||
|
||||
int GetLoopCount() const;
|
||||
|
||||
const char * GetMotionFileName() const;
|
||||
const char * GetSoundScriptFileName() const;
|
||||
|
||||
void SetMotionDuration(float fDur);
|
||||
float GetMotionDuration();
|
||||
|
||||
bool IsAccumulationMotion();
|
||||
void SetAccumulationPosition(const TPixelPosition & c_rPos);
|
||||
const TPixelPosition & GetAccumulationPosition() { return m_accumulationPosition; }
|
||||
|
||||
BOOL IsComboInputTimeData() const; // 콤보 입력 타이밍 데이터가 있는가?
|
||||
|
||||
float GetComboInputStartTime() const;
|
||||
float GetNextComboTime() const;
|
||||
float GetComboInputEndTime() const;
|
||||
|
||||
// Attacking
|
||||
BOOL isAttackingMotion() const;
|
||||
const NRaceData::TMotionAttackData * GetMotionAttackDataPointer() const;
|
||||
const NRaceData::TMotionAttackData & GetMotionAttackDataReference() const;
|
||||
BOOL HasSplashMotionEvent() const;
|
||||
|
||||
// Skill
|
||||
BOOL IsCancelEnableSkill() const;
|
||||
|
||||
// Loop
|
||||
BOOL IsLoopMotion() const;
|
||||
float GetLoopStartTime() const;
|
||||
float GetLoopEndTime() const;
|
||||
|
||||
// Motion Event Data
|
||||
DWORD GetMotionEventDataCount() const;
|
||||
BOOL GetMotionEventDataPointer(BYTE byIndex, const CRaceMotionData::TMotionEventData ** c_ppData) const;
|
||||
BOOL GetMotionAttackingEventDataPointer(BYTE byIndex, const CRaceMotionData::TMotionAttackingEventData ** c_ppMotionEventData) const;
|
||||
int GetEventType(DWORD dwIndex) const;
|
||||
float GetEventStartTime(DWORD dwIndex) const;
|
||||
|
||||
// Sound Data
|
||||
const NSound::TSoundInstanceVector * GetSoundInstanceVectorPointer() const;
|
||||
|
||||
// File
|
||||
#ifdef WORLD_EDITOR
|
||||
bool SaveMotionData(const char * c_szFileName);
|
||||
#endif
|
||||
bool LoadMotionData(const char * c_szFileName);
|
||||
bool LoadSoundScriptData(const char * c_szFileName);
|
||||
|
||||
protected:
|
||||
void SetType(UINT eType);
|
||||
|
||||
protected:
|
||||
UINT m_eType;
|
||||
UINT m_eName;
|
||||
BOOL m_isLock;
|
||||
int m_iLoopCount;
|
||||
|
||||
std::string m_strMotionFileName;
|
||||
std::string m_strSoundScriptDataFileName;
|
||||
float m_fMotionDuration;
|
||||
|
||||
BOOL m_isAccumulationMotion;
|
||||
TPixelPosition m_accumulationPosition;
|
||||
|
||||
BOOL m_isComboMotion;
|
||||
TComboInputData m_ComboInputData;
|
||||
|
||||
BOOL m_isLoopMotion;
|
||||
float m_fLoopStartTime;
|
||||
float m_fLoopEndTime;
|
||||
|
||||
BOOL m_isAttackingMotion;
|
||||
NRaceData::TMotionAttackData m_MotionAttackData;
|
||||
|
||||
BOOL m_bCancelEnableSkill;
|
||||
|
||||
TMotionEventDataVector m_MotionEventDataVector;
|
||||
NSound::TSoundInstanceVector m_SoundInstanceVector;
|
||||
|
||||
private:
|
||||
BOOL m_hasSplashEvent;
|
||||
|
||||
protected:
|
||||
static CDynamicPool<CRaceMotionData> ms_kPool;
|
||||
};
|
||||
@@ -0,0 +1,290 @@
|
||||
#pragma once
|
||||
|
||||
#include "../EffectLib/EffectManager.h"
|
||||
#include "FlyingObjectManager.h"
|
||||
|
||||
namespace NMotionEvent
|
||||
{
|
||||
typedef struct SMotionEventData
|
||||
{
|
||||
int iType;
|
||||
DWORD dwFrame;
|
||||
float fStartingTime;
|
||||
float fDurationTime;
|
||||
|
||||
SMotionEventData() : dwFrame(0), fStartingTime(0.0f), fDurationTime(0.0f) {}
|
||||
virtual ~SMotionEventData() {}
|
||||
|
||||
virtual void Save(FILE * File, int iTabs) = 0;
|
||||
virtual bool Load(CTextFileLoader & rTextFileLoader) { return true; }
|
||||
} TMotionEventData;
|
||||
|
||||
// Screen Waving
|
||||
typedef struct SMotionEventDataScreenWaving : public SMotionEventData
|
||||
{
|
||||
int iPower;
|
||||
int iAffectingRange;
|
||||
|
||||
SMotionEventDataScreenWaving() {}
|
||||
virtual ~SMotionEventDataScreenWaving() {}
|
||||
|
||||
void Save(FILE * File, int iTabs)
|
||||
{
|
||||
PrintfTabs(File, iTabs, "\n");
|
||||
PrintfTabs(File, iTabs, "DuringTime %f\n", fDurationTime);
|
||||
PrintfTabs(File, iTabs, "Power %d\n", iPower);
|
||||
PrintfTabs(File, iTabs, "AffectingRange %d\n", iAffectingRange);
|
||||
}
|
||||
bool Load(CTextFileLoader & rTextFileLoader)
|
||||
{
|
||||
if (!rTextFileLoader.GetTokenFloat("duringtime", &fDurationTime))
|
||||
return false;
|
||||
if (!rTextFileLoader.GetTokenInteger("power", &iPower))
|
||||
return false;
|
||||
if (!rTextFileLoader.GetTokenInteger("affectingrange", &iAffectingRange))
|
||||
iAffectingRange = 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
} TMotionEventDataScreenWaving;
|
||||
|
||||
// Screen Flashing
|
||||
typedef struct SMotionEventDataScreenFlashing : public SMotionEventData
|
||||
{
|
||||
D3DXCOLOR FlashingColor;
|
||||
|
||||
SMotionEventDataScreenFlashing() {}
|
||||
virtual ~SMotionEventDataScreenFlashing() {}
|
||||
|
||||
void Save(FILE * File, int iTabs) {}
|
||||
bool Load(CTextFileLoader & rTextFileLoader)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
} TMotionEventDataScreenFlashing;
|
||||
|
||||
// Effect
|
||||
typedef struct SMotionEventDataEffect : public SMotionEventData
|
||||
{
|
||||
BOOL isAttaching;
|
||||
BOOL isFollowing;
|
||||
BOOL isIndependent;
|
||||
std::string strAttachingBoneName;
|
||||
D3DXVECTOR3 v3EffectPosition;
|
||||
|
||||
DWORD dwEffectIndex;
|
||||
std::string strEffectFileName;
|
||||
|
||||
SMotionEventDataEffect() {}
|
||||
virtual ~SMotionEventDataEffect() {}
|
||||
|
||||
void Save(FILE * File, int iTabs)
|
||||
{
|
||||
PrintfTabs(File, iTabs, "\n");
|
||||
PrintfTabs(File, iTabs, "IndependentFlag %d\n", isIndependent);
|
||||
PrintfTabs(File, iTabs, "AttachingEnable %d\n", isAttaching);
|
||||
PrintfTabs(File, iTabs, "AttachingBoneName \"%s\"\n", strAttachingBoneName.c_str());
|
||||
PrintfTabs(File, iTabs, "FollowingEnable %d\n", isFollowing);
|
||||
PrintfTabs(File, iTabs, "EffectFileName \"%s\"\n", strEffectFileName.c_str());
|
||||
PrintfTabs(File, iTabs, "EffectPosition %f %f %f\n", v3EffectPosition.x, v3EffectPosition.y, v3EffectPosition.z);
|
||||
}
|
||||
virtual bool Load(CTextFileLoader & rTextFileLoader)
|
||||
{
|
||||
if (!rTextFileLoader.GetTokenBoolean("independentflag", &isIndependent))
|
||||
isIndependent = FALSE;
|
||||
if (!rTextFileLoader.GetTokenBoolean("attachingenable", &isAttaching))
|
||||
return false;
|
||||
if (!rTextFileLoader.GetTokenString("attachingbonename", &strAttachingBoneName))
|
||||
return false;
|
||||
if (!rTextFileLoader.GetTokenString("effectfilename", &strEffectFileName))
|
||||
return false;
|
||||
if (!rTextFileLoader.GetTokenPosition("effectposition", &v3EffectPosition))
|
||||
return false;
|
||||
if (!rTextFileLoader.GetTokenBoolean("followingenable", &isFollowing))
|
||||
{
|
||||
isFollowing = FALSE;
|
||||
}
|
||||
dwEffectIndex = GetCaseCRC32(strEffectFileName.c_str(), strEffectFileName.length());
|
||||
CEffectManager::Instance().RegisterEffect(strEffectFileName.c_str());
|
||||
|
||||
return true;
|
||||
}
|
||||
} TMotionEventDataEffect;
|
||||
|
||||
// Effect To Target
|
||||
typedef struct SMotionEventDataEffectToTarget : public SMotionEventData
|
||||
{
|
||||
DWORD dwEffectIndex;
|
||||
|
||||
std::string strEffectFileName;
|
||||
D3DXVECTOR3 v3EffectPosition;
|
||||
BOOL isFollowing;
|
||||
BOOL isFishingEffect;
|
||||
|
||||
SMotionEventDataEffectToTarget() {}
|
||||
virtual ~SMotionEventDataEffectToTarget() {}
|
||||
|
||||
void Save(FILE * File, int iTabs)
|
||||
{
|
||||
PrintfTabs(File, iTabs, "\n");
|
||||
PrintfTabs(File, iTabs, "EffectFileName \"%s\"\n", strEffectFileName.c_str());
|
||||
PrintfTabs(File, iTabs, "EffectPosition %f %f %f\n", v3EffectPosition.x, v3EffectPosition.y, v3EffectPosition.z);
|
||||
PrintfTabs(File, iTabs, "FollowingEnable %d\n", isFollowing);
|
||||
PrintfTabs(File, iTabs, "FishingEffectFlag %d\n", isFishingEffect);
|
||||
}
|
||||
virtual bool Load(CTextFileLoader & rTextFileLoader)
|
||||
{
|
||||
if (!rTextFileLoader.GetTokenString("effectfilename", &strEffectFileName))
|
||||
return false;
|
||||
if (!rTextFileLoader.GetTokenPosition("effectposition", &v3EffectPosition))
|
||||
return false;
|
||||
if (!rTextFileLoader.GetTokenBoolean("followingenable", &isFollowing))
|
||||
{
|
||||
isFollowing = FALSE;
|
||||
}
|
||||
if (!rTextFileLoader.GetTokenBoolean("fishingeffectflag", &isFishingEffect))
|
||||
{
|
||||
isFishingEffect = FALSE;
|
||||
}
|
||||
dwEffectIndex = GetCaseCRC32(strEffectFileName.c_str(), strEffectFileName.length());
|
||||
#ifndef _DEBUG
|
||||
CEffectManager::Instance().RegisterEffect(strEffectFileName.c_str());
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
} TMotionEventDataEffectToTarget;
|
||||
|
||||
// Fly
|
||||
typedef struct SMotionEventDataFly : public SMotionEventData
|
||||
{
|
||||
BOOL isAttaching;
|
||||
std::string strAttachingBoneName;
|
||||
D3DXVECTOR3 v3FlyPosition;
|
||||
|
||||
DWORD dwFlyIndex;
|
||||
std::string strFlyFileName;
|
||||
|
||||
SMotionEventDataFly() {}
|
||||
virtual ~SMotionEventDataFly() {}
|
||||
|
||||
void Save(FILE * File, int iTabs)
|
||||
{
|
||||
PrintfTabs(File, iTabs, "\n");
|
||||
PrintfTabs(File, iTabs, "AttachingEnable %d\n", isAttaching);
|
||||
PrintfTabs(File, iTabs, "AttachingBoneName \"%s\"\n", strAttachingBoneName.c_str());
|
||||
PrintfTabs(File, iTabs, "FlyFileName \"%s\"\n", strFlyFileName.c_str());
|
||||
PrintfTabs(File, iTabs, "FlyPosition %f %f %f\n", v3FlyPosition.x, v3FlyPosition.y, v3FlyPosition.z);
|
||||
}
|
||||
bool Load(CTextFileLoader & rTextFileLoader)
|
||||
{
|
||||
if (!rTextFileLoader.GetTokenBoolean("attachingenable", &isAttaching))
|
||||
return false;
|
||||
if (!rTextFileLoader.GetTokenString("attachingbonename", &strAttachingBoneName))
|
||||
return false;
|
||||
if (!rTextFileLoader.GetTokenString("flyfilename", &strFlyFileName))
|
||||
return false;
|
||||
if (!rTextFileLoader.GetTokenPosition("flyposition", &v3FlyPosition))
|
||||
return false;
|
||||
dwFlyIndex = GetCaseCRC32(strFlyFileName.c_str(), strFlyFileName.length());
|
||||
|
||||
#ifndef _DEBUG
|
||||
// Register Fly
|
||||
CFlyingManager::Instance().RegisterFlyingData(strFlyFileName.c_str());
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
} TMotionEventDataFly;
|
||||
|
||||
// Attacking
|
||||
typedef struct SMotionEventDataAttack : public SMotionEventData
|
||||
{
|
||||
NRaceData::TCollisionData CollisionData;
|
||||
NRaceData::TAttackData AttackData;
|
||||
BOOL isEnableHitProcess;
|
||||
|
||||
SMotionEventDataAttack() {}
|
||||
virtual ~SMotionEventDataAttack() {}
|
||||
|
||||
void Save(FILE * File, int iTabs)
|
||||
{
|
||||
PrintfTabs(File, iTabs, "DuringTime %f\n", fDurationTime);
|
||||
PrintfTabs(File, iTabs, "EnableHitProcess %d\n", isEnableHitProcess);
|
||||
PrintfTabs(File, iTabs, "\n");
|
||||
|
||||
NRaceData::SaveAttackData(File, iTabs, AttackData);
|
||||
NRaceData::SaveCollisionData(File, iTabs, CollisionData);
|
||||
}
|
||||
bool Load(CTextFileLoader & rTextFileLoader)
|
||||
{
|
||||
if (!rTextFileLoader.GetTokenFloat("duringtime", &fDurationTime))
|
||||
return false;
|
||||
|
||||
if (!rTextFileLoader.GetTokenBoolean("enablehitprocess", &isEnableHitProcess))
|
||||
{
|
||||
isEnableHitProcess = TRUE;
|
||||
}
|
||||
|
||||
if (!NRaceData::LoadAttackData(rTextFileLoader, &AttackData))
|
||||
return false;
|
||||
|
||||
if (!NRaceData::LoadCollisionData(rTextFileLoader, &CollisionData))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
} TMotionEventDataAttacking;
|
||||
|
||||
// Sound
|
||||
typedef struct SMotionEventDataSound : public SMotionEventData
|
||||
{
|
||||
std::string strSoundFileName; // Direct Sound Node
|
||||
|
||||
SMotionEventDataSound() {}
|
||||
virtual ~SMotionEventDataSound() {}
|
||||
|
||||
void Save(FILE * File, int iTabs)
|
||||
{
|
||||
PrintfTabs(File, iTabs, "\n");
|
||||
PrintfTabs(File, iTabs, "SoundFileName \"%s\"\n", strSoundFileName.c_str());
|
||||
}
|
||||
bool Load(CTextFileLoader & rTextFileLoader)
|
||||
{
|
||||
if (!rTextFileLoader.GetTokenString("soundfilename", &strSoundFileName))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
} TMotionEventDataSound;
|
||||
|
||||
// Character Show
|
||||
typedef struct SMotionEventDataCharacterShow : public SMotionEventData
|
||||
{
|
||||
SMotionEventDataCharacterShow() {}
|
||||
virtual ~SMotionEventDataCharacterShow() {}
|
||||
|
||||
void Save(FILE * File, int iTabs) {}
|
||||
void Load() {}
|
||||
} TMotionEventDataCharacterShow;
|
||||
|
||||
// Character Hide
|
||||
typedef struct SMotionEventDataCharacterHide : public SMotionEventData
|
||||
{
|
||||
SMotionEventDataCharacterHide() {}
|
||||
virtual ~SMotionEventDataCharacterHide() {}
|
||||
|
||||
void Save(FILE * File, int iTabs) {}
|
||||
void Load() {}
|
||||
} TMotionEventDataCharacterHide;
|
||||
|
||||
// Warp
|
||||
typedef struct SMotionEventDataWarp : public SMotionEventData
|
||||
{
|
||||
SMotionEventDataWarp() {}
|
||||
virtual ~SMotionEventDataWarp() {}
|
||||
|
||||
void Save(FILE * File, int iTabs) {}
|
||||
void Load() {}
|
||||
} TMotionWarpEventData;
|
||||
};
|
||||
@@ -0,0 +1,55 @@
|
||||
#pragma once
|
||||
|
||||
#include "../EterLib/GrpScreen.h"
|
||||
|
||||
class CSnowParticle;
|
||||
|
||||
class CSnowEnvironment : public CScreen
|
||||
{
|
||||
public:
|
||||
CSnowEnvironment();
|
||||
virtual ~CSnowEnvironment();
|
||||
|
||||
bool Create();
|
||||
void Destroy();
|
||||
|
||||
void Enable();
|
||||
void Disable();
|
||||
|
||||
void Update(const D3DXVECTOR3 & c_rv3Pos);
|
||||
void Deform();
|
||||
void Render();
|
||||
|
||||
protected:
|
||||
void __Initialize();
|
||||
bool __CreateBlurTexture();
|
||||
bool __CreateGeometry();
|
||||
void __BeginBlur();
|
||||
void __ApplyBlur();
|
||||
|
||||
protected:
|
||||
LPDIRECT3DSURFACE8 m_lpOldSurface;
|
||||
LPDIRECT3DSURFACE8 m_lpOldDepthStencilSurface;
|
||||
|
||||
LPDIRECT3DTEXTURE8 m_lpSnowTexture;
|
||||
LPDIRECT3DSURFACE8 m_lpSnowRenderTargetSurface;
|
||||
LPDIRECT3DSURFACE8 m_lpSnowDepthSurface;
|
||||
|
||||
LPDIRECT3DTEXTURE8 m_lpAccumTexture;
|
||||
LPDIRECT3DSURFACE8 m_lpAccumRenderTargetSurface;
|
||||
LPDIRECT3DSURFACE8 m_lpAccumDepthSurface;
|
||||
|
||||
LPDIRECT3DVERTEXBUFFER8 m_pVB;
|
||||
LPDIRECT3DINDEXBUFFER8 m_pIB;
|
||||
|
||||
D3DXVECTOR3 m_v3Center;
|
||||
|
||||
WORD m_wBlurTextureSize;
|
||||
CGraphicImageInstance * m_pImageInstance;
|
||||
std::vector<CSnowParticle*> m_kVct_pkParticleSnow;
|
||||
|
||||
DWORD m_dwParticleMaxNum;
|
||||
BOOL m_bBlurEnable;
|
||||
|
||||
BOOL m_bSnowEnable;
|
||||
};
|
||||
@@ -0,0 +1,46 @@
|
||||
// TerrainDecal.h: interface for the CTerrainDecal class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_TERRAINDECAL_H__8E387316_FCCF_446F_AB82_82721F7AC08C__INCLUDED_)
|
||||
#define AFX_TERRAINDECAL_H__8E387316_FCCF_446F_AB82_82721F7AC08C__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include "../EterLib/Decal.h"
|
||||
|
||||
class CMapOutdoor;
|
||||
|
||||
class CTerrainDecal : public CDecal
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
MAX_SEARCH_VERTICES = 1024,
|
||||
};
|
||||
|
||||
CTerrainDecal(CMapOutdoor * pMapOutdoor = NULL);
|
||||
virtual ~CTerrainDecal();
|
||||
|
||||
virtual void Make(D3DXVECTOR3 v3Center, D3DXVECTOR3 v3Normal, D3DXVECTOR3 v3Tangent, float fWidth, float fHeight, float fDepth);
|
||||
// virtual void Update();
|
||||
virtual void Render();
|
||||
|
||||
void SetMapOutdoor(CMapOutdoor * pMapOutdoor) { m_pMapOutdoor = pMapOutdoor; }
|
||||
|
||||
protected:
|
||||
|
||||
void SearchAffectedTerrainMesh(float fMinX,
|
||||
float fMaxX,
|
||||
float fMinY,
|
||||
float fMaxY,
|
||||
DWORD * pdwAffectedPrimitiveCount,
|
||||
D3DXVECTOR3 * pv3AffectedVertex,
|
||||
D3DXVECTOR3 * pv3AffectedNormal);
|
||||
|
||||
CMapOutdoor * m_pMapOutdoor;
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_TERRAINDECAL_H__8E387316_FCCF_446F_AB82_82721F7AC08C__INCLUDED_)
|
||||
@@ -0,0 +1,250 @@
|
||||
// TerrainPatch.h: interface for the CTerrainPatch class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_TERRAINPATCH_H__CDD52438_D542_433C_8748_3A15C910A65E__INCLUDED_)
|
||||
#define AFX_TERRAINPATCH_H__CDD52438_D542_433C_8748_3A15C910A65E__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include "../EterLib/GrpVertexBuffer.h"
|
||||
#include "../PRTerrainLib/Terrain.h"
|
||||
|
||||
#pragma pack(push)
|
||||
#pragma pack(1)
|
||||
|
||||
struct HardwareTransformPatch_SSourceVertex
|
||||
{
|
||||
D3DXVECTOR3 kPosition;
|
||||
D3DXVECTOR3 kNormal;
|
||||
};
|
||||
|
||||
struct SoftwareTransformPatch_SSourceVertex
|
||||
{
|
||||
D3DXVECTOR3 kPosition;
|
||||
D3DXVECTOR3 kNormal;
|
||||
DWORD dwDiffuse;
|
||||
};
|
||||
|
||||
struct SWaterVertex
|
||||
{
|
||||
float x, y, z; // position
|
||||
DWORD dwDiffuse;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
class CTerrainPatch
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
PATCH_TYPE_PLAIN = 0,
|
||||
PATCH_TYPE_HILL,
|
||||
PATCH_TYPE_CLIFF,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
TERRAIN_VERTEX_COUNT = (CTerrainImpl::PATCH_XSIZE+1)*(CTerrainImpl::PATCH_YSIZE+1)
|
||||
};
|
||||
|
||||
static bool SOFTWARE_TRANSFORM_PATCH_ENABLE;
|
||||
|
||||
public:
|
||||
CTerrainPatch() { Clear(); }
|
||||
~CTerrainPatch() { Clear(); }
|
||||
|
||||
void Clear();
|
||||
|
||||
void ClearID() { SetID(0xFFFFFFFF); }
|
||||
|
||||
void SetMinX(float fMinX) { m_fMinX = fMinX; }
|
||||
float GetMinX() { return m_fMinX; }
|
||||
|
||||
void SetMaxX(float fMaxX) { m_fMaxX = fMaxX; }
|
||||
float GetMaxX() { return m_fMaxX; }
|
||||
|
||||
void SetMinY(float fMinY) { m_fMinY = fMinY; }
|
||||
float GetMinY() { return m_fMinY; }
|
||||
|
||||
void SetMaxY(float fMaxY) { m_fMaxY = fMaxY; }
|
||||
float GetMaxY() { return m_fMaxY; }
|
||||
|
||||
void SetMinZ(float fMinZ) { m_fMinZ = fMinZ; }
|
||||
float GetMinZ() { return m_fMinZ; }
|
||||
|
||||
void SetMaxZ(float fMaxZ) { m_fMaxZ = fMaxZ; }
|
||||
float GetMaxZ() { return m_fMaxZ; }
|
||||
|
||||
bool IsUse() { return m_bUse; }
|
||||
void SetUse(bool bUse) { m_bUse = bUse; }
|
||||
|
||||
bool IsWaterExist() { return m_bWaterExist; }
|
||||
void SetWaterExist(bool bWaterExist) { m_bWaterExist = bWaterExist; }
|
||||
|
||||
DWORD GetID() { return m_dwID; }
|
||||
void SetID(DWORD dwID) { m_dwID = dwID; }
|
||||
|
||||
void SetType(BYTE byType) { m_byType = byType; }
|
||||
BYTE GetType() { return m_byType; }
|
||||
|
||||
void NeedUpdate(bool bNeedUpdate) { m_bNeedUpdate = bNeedUpdate;}
|
||||
bool NeedUpdate() { return m_bNeedUpdate; }
|
||||
|
||||
UINT GetWaterFaceCount();
|
||||
|
||||
void SoftwareTransformPatch_UpdateTerrainLighting(DWORD dwVersion, const D3DLIGHT8& c_rkLight, const D3DMATERIAL8& c_rkMtrl);
|
||||
|
||||
void BuildTerrainVertexBuffer(HardwareTransformPatch_SSourceVertex* akSrcVertex);
|
||||
void BuildWaterVertexBuffer(SWaterVertex* akSrcVertex, UINT uWaterVertexCount);
|
||||
|
||||
protected:
|
||||
void __BuildHardwareTerrainVertexBuffer(HardwareTransformPatch_SSourceVertex* akSrcVertex);
|
||||
void __BuildSoftwareTerrainVertexBuffer(HardwareTransformPatch_SSourceVertex* akSrcVertex);
|
||||
|
||||
private:
|
||||
float m_fMinX;
|
||||
float m_fMaxX;
|
||||
float m_fMinY;
|
||||
float m_fMaxY;
|
||||
float m_fMinZ;
|
||||
float m_fMaxZ;
|
||||
bool m_bUse;
|
||||
bool m_bWaterExist;
|
||||
DWORD m_dwID;
|
||||
DWORD m_dwWaterPriCount;
|
||||
|
||||
CGraphicVertexBuffer m_WaterVertexBuffer;
|
||||
BYTE m_byType;
|
||||
|
||||
bool m_bNeedUpdate;
|
||||
DWORD m_dwVersion;
|
||||
|
||||
public:
|
||||
CGraphicVertexBuffer* GetWaterVertexBufferPointer() { return &m_WaterVertexBuffer;}
|
||||
|
||||
public:
|
||||
CGraphicVertexBuffer* HardwareTransformPatch_GetVertexBufferPtr() {return &m_kHT.m_kVB;}
|
||||
|
||||
protected:
|
||||
struct SHardwareTransformPatch
|
||||
{
|
||||
CGraphicVertexBuffer m_kVB;
|
||||
} m_kHT;
|
||||
|
||||
|
||||
public:
|
||||
SoftwareTransformPatch_SSourceVertex* SoftwareTransformPatch_GetTerrainVertexDataPtr()
|
||||
{return m_kST.m_akTerrainVertex;}
|
||||
|
||||
protected:
|
||||
struct SSoftwareTransformPatch
|
||||
{
|
||||
SoftwareTransformPatch_SSourceVertex* m_akTerrainVertex;
|
||||
|
||||
SSoftwareTransformPatch();
|
||||
~SSoftwareTransformPatch();
|
||||
|
||||
void Create();
|
||||
void Destroy();
|
||||
|
||||
void __Initialize();
|
||||
} m_kST;
|
||||
|
||||
};
|
||||
|
||||
class CTerrainPatchProxy
|
||||
{
|
||||
public:
|
||||
CTerrainPatchProxy();
|
||||
virtual ~CTerrainPatchProxy();
|
||||
|
||||
void Clear();
|
||||
|
||||
void SetCenterPosition(const D3DXVECTOR3& c_rv3Center);
|
||||
|
||||
bool IsIn(const D3DXVECTOR3& c_rv3Target, float fRadius);
|
||||
|
||||
bool isUsed() { return m_bUsed; }
|
||||
void SetUsed(bool bUsed) { m_bUsed = bUsed; }
|
||||
|
||||
short GetPatchNum() { return m_sPatchNum; }
|
||||
void SetPatchNum(short sPatchNum) { m_sPatchNum = sPatchNum; }
|
||||
|
||||
BYTE GetTerrainNum() { return m_byTerrainNum; }
|
||||
void SetTerrainNum(BYTE byTerrainNum) { m_byTerrainNum = byTerrainNum; }
|
||||
|
||||
void SetTerrainPatch(CTerrainPatch * pTerrainPatch) { m_pTerrainPatch = pTerrainPatch;}
|
||||
|
||||
bool isWaterExists();
|
||||
|
||||
UINT GetWaterFaceCount();
|
||||
|
||||
float GetMinX();
|
||||
float GetMaxX();
|
||||
float GetMinY();
|
||||
float GetMaxY();
|
||||
float GetMinZ();
|
||||
float GetMaxZ();
|
||||
|
||||
// Vertex Buffer
|
||||
CGraphicVertexBuffer * GetWaterVertexBufferPointer();
|
||||
SoftwareTransformPatch_SSourceVertex* SoftwareTransformPatch_GetTerrainVertexDataPtr();
|
||||
CGraphicVertexBuffer* HardwareTransformPatch_GetVertexBufferPtr();
|
||||
|
||||
void SoftwareTransformPatch_UpdateTerrainLighting(DWORD dwVersion, const D3DLIGHT8& c_rkLight, const D3DMATERIAL8& c_rkMtrl);
|
||||
|
||||
protected:
|
||||
bool m_bUsed;
|
||||
short m_sPatchNum; // Patch Number
|
||||
|
||||
BYTE m_byTerrainNum;
|
||||
|
||||
CTerrainPatch * m_pTerrainPatch;
|
||||
|
||||
D3DXVECTOR3 m_v3Center;
|
||||
};
|
||||
|
||||
inline bool CTerrainPatchProxy::isWaterExists()
|
||||
{
|
||||
return m_pTerrainPatch->IsWaterExist();
|
||||
}
|
||||
|
||||
inline float CTerrainPatchProxy::GetMinX()
|
||||
{
|
||||
return m_pTerrainPatch->GetMinX();
|
||||
}
|
||||
|
||||
inline float CTerrainPatchProxy::GetMaxX()
|
||||
{
|
||||
return m_pTerrainPatch->GetMaxX();
|
||||
}
|
||||
|
||||
inline float CTerrainPatchProxy::GetMinY()
|
||||
{
|
||||
return m_pTerrainPatch->GetMinY();
|
||||
}
|
||||
|
||||
inline float CTerrainPatchProxy::GetMaxY()
|
||||
{
|
||||
return m_pTerrainPatch->GetMaxY();
|
||||
}
|
||||
|
||||
inline float CTerrainPatchProxy::GetMinZ()
|
||||
{
|
||||
return m_pTerrainPatch->GetMinZ();
|
||||
}
|
||||
|
||||
inline float CTerrainPatchProxy::GetMaxZ()
|
||||
{
|
||||
return m_pTerrainPatch->GetMaxZ();
|
||||
}
|
||||
|
||||
inline CGraphicVertexBuffer * CTerrainPatchProxy::GetWaterVertexBufferPointer()
|
||||
{
|
||||
return m_pTerrainPatch->GetWaterVertexBufferPointer();
|
||||
}
|
||||
|
||||
#endif // !defined(AFX_TERRAINPATCH_H__CDD52438_D542_433C_8748_3A15C910A65E__INCLUDED_)
|
||||
@@ -0,0 +1,32 @@
|
||||
// stdafx.h : include file for standard system include files,
|
||||
// or project specific include files that are used frequently, but
|
||||
// are changed infrequently
|
||||
//
|
||||
|
||||
#if !defined(AFX_STDAFX_H__EECC0C4D_07A5_4D9E_B40F_767A80FD6DE6__INCLUDED_)
|
||||
#define AFX_STDAFX_H__EECC0C4D_07A5_4D9E_B40F_767A80FD6DE6__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||
|
||||
// TODO: reference additional headers your program requires here
|
||||
#pragma warning(disable:4702)
|
||||
|
||||
//#include <crtdbg.h>
|
||||
|
||||
#include "../EterLib/StdAfx.h"
|
||||
#include "../EterGrnLib/StdAfx.h"
|
||||
// PORT: dropped #include "../ScriptLib/StdAfx.h": no PRTerrainLib file uses Python, and it would pull
|
||||
// CPython headers into every terrain translation unit.
|
||||
|
||||
/* Fast Float<->Integer conversion */
|
||||
extern float PR_FCNV;
|
||||
extern long PR_ICNV;
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_STDAFX_H__EECC0C4D_07A5_4D9E_B40F_767A80FD6DE6__INCLUDED_)
|
||||
@@ -0,0 +1,156 @@
|
||||
// Terrain.h: interface for the CTerrainImpl class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_TERRAIN_H__1C9108E1_69A7_4392_9B68_0E6CD4E1BFBA__INCLUDED_)
|
||||
#define AFX_TERRAIN_H__1C9108E1_69A7_4392_9B68_0E6CD4E1BFBA__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include "../EterImageLib/TGAImage.h"
|
||||
|
||||
#include "TextureSet.h"
|
||||
#include "TerrainType.h"
|
||||
|
||||
class CTerrainImpl
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
XSIZE = TERRAIN_SIZE,
|
||||
YSIZE = TERRAIN_SIZE,
|
||||
HEIGHTMAP_XSIZE = XSIZE+1,
|
||||
HEIGHTMAP_YSIZE = YSIZE+1,
|
||||
HEIGHTMAP_RAW_XSIZE = XSIZE+3,
|
||||
HEIGHTMAP_RAW_YSIZE = YSIZE+3,
|
||||
ATTRMAP_XSIZE = XSIZE*2,
|
||||
ATTRMAP_YSIZE = YSIZE*2,
|
||||
ATTRMAP_ZCOUNT = 8,
|
||||
TILEMAP_XSIZE = XSIZE*2,
|
||||
TILEMAP_YSIZE = YSIZE*2,
|
||||
TILEMAP_RAW_XSIZE = XSIZE*2+2,
|
||||
TILEMAP_RAW_YSIZE = YSIZE*2+2,
|
||||
WATERMAP_XSIZE = XSIZE,
|
||||
WATERMAP_YSIZE = YSIZE,
|
||||
NORMALMAP_XSIZE = XSIZE+1,
|
||||
NORMALMAP_YSIZE = YSIZE+1,
|
||||
SHADOWMAP_XSIZE = XSIZE*2,
|
||||
SHADOWMAP_YSIZE = YSIZE*2,
|
||||
SPLATALPHA_RAW_XSIZE = XSIZE*2+2,
|
||||
SPLATALPHA_RAW_YSIZE = YSIZE*2+2,
|
||||
SPLATALPHA_ZCOUNT = 7,
|
||||
HEIGHT_TILE_XRATIO = TILEMAP_XSIZE / XSIZE,
|
||||
HEIGHT_TILE_YRATIO = TILEMAP_XSIZE / XSIZE,
|
||||
|
||||
PATCH_XSIZE = TERRAIN_PATCHSIZE,
|
||||
PATCH_YSIZE = TERRAIN_PATCHSIZE,
|
||||
PATCH_TILE_XSIZE = PATCH_XSIZE * HEIGHT_TILE_XRATIO,
|
||||
PATCH_TILE_YSIZE = PATCH_YSIZE * HEIGHT_TILE_YRATIO,
|
||||
PATCH_XCOUNT = TERRAIN_PATCHCOUNT,
|
||||
PATCH_YCOUNT = TERRAIN_PATCHCOUNT,
|
||||
|
||||
CELLSCALE = 200,
|
||||
CELLSCALE_IN_METER = CELLSCALE / 100,
|
||||
HALF_CELLSCALE = CELLSCALE / 2,
|
||||
HALF_CELLSCALE_IN_METER = HALF_CELLSCALE / 100,
|
||||
TERRAIN_XSIZE = XSIZE * CELLSCALE,
|
||||
TERRAIN_YSIZE = YSIZE * CELLSCALE,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
MAX_ATTRIBUTE_NUM = 8,
|
||||
MAX_WATER_NUM = 255,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
ATTRIBUTE_BLOCK = (1 << 0),
|
||||
ATTRIBUTE_WATER = (1 << 1),
|
||||
ATTRIBUTE_BANPK = (1 << 2),
|
||||
};
|
||||
|
||||
public:
|
||||
static void SetTextureSet(CTextureSet * pTextureSet);
|
||||
static CTextureSet * GetTextureSet(); // 무조건 성공해야 함
|
||||
|
||||
protected:
|
||||
static CTextureSet * ms_pTextureSet;
|
||||
|
||||
public:
|
||||
CTerrainImpl();
|
||||
virtual ~CTerrainImpl();
|
||||
|
||||
TTerrainSplatPatch & GetTerrainSplatPatch() {return m_TerrainSplatPatch;}
|
||||
DWORD GetNumTextures() { return ms_pTextureSet->GetTextureCount(); }
|
||||
TTerrainTexture & GetTexture(const long & c_rlTextureNum) { return ms_pTextureSet->GetTexture(c_rlTextureNum); }
|
||||
// int GetHeightTileMapRatio() { return m_iHeightTileRatio; }
|
||||
|
||||
bool LoadWaterMap(const char * c_szWaterMapName);
|
||||
bool LoadWaterMapFile(const char * c_szWaterMapName);
|
||||
|
||||
LPDIRECT3DTEXTURE8 GetShadowTexture() { return m_lpShadowTexture; }
|
||||
|
||||
DWORD GetShadowMapColor(float fx, float fy);
|
||||
|
||||
protected:
|
||||
void Initialize();
|
||||
virtual void Clear();
|
||||
|
||||
void LoadTextures();
|
||||
bool LoadHeightMap(const char *c_szFileName);
|
||||
bool RAW_LoadTileMap(const char * c_szFileName);
|
||||
bool LoadAttrMap(const char *c_pszFileName);
|
||||
#ifdef WORLD_EDITOR
|
||||
public:
|
||||
#endif
|
||||
__forceinline WORD GetHeightMapValue(short sx, short sy);
|
||||
|
||||
protected:
|
||||
LPDIRECT3DTEXTURE8 m_lpAlphaTexture[MAXTERRAINTEXTURES];
|
||||
WORD m_awRawHeightMap[HEIGHTMAP_RAW_YSIZE*HEIGHTMAP_RAW_XSIZE];
|
||||
|
||||
BYTE m_abyTileMap[TILEMAP_RAW_YSIZE*TILEMAP_RAW_XSIZE];
|
||||
BYTE m_abyAttrMap[ATTRMAP_YSIZE*ATTRMAP_XSIZE];
|
||||
BYTE m_abyWaterMap[WATERMAP_YSIZE*WATERMAP_XSIZE];
|
||||
CHAR m_acNormalMap[NORMALMAP_YSIZE*NORMALMAP_XSIZE*3];
|
||||
|
||||
TGA_HEADER m_HeightMapHeader;
|
||||
|
||||
WORD m_wTileMapVersion;
|
||||
|
||||
long m_lViewRadius;
|
||||
float m_fHeightScale;
|
||||
|
||||
TTerrainSplatPatch m_TerrainSplatPatch;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//Water Map
|
||||
BYTE m_byNumWater;
|
||||
long m_lWaterHeight[MAX_WATER_NUM + 1];
|
||||
//Water Map
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// TileMap과 HeightMap 비율
|
||||
// int m_iHeightTileRatio;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Shadow Map
|
||||
LPDIRECT3DTEXTURE8 m_lpShadowTexture;
|
||||
WORD m_awShadowMap[SHADOWMAP_YSIZE*SHADOWMAP_XSIZE]; // 16bit R5 G6 B5
|
||||
|
||||
protected:
|
||||
long m_lSplatTilesX;
|
||||
long m_lSplatTilesY;
|
||||
};
|
||||
|
||||
|
||||
__forceinline WORD CTerrainImpl::GetHeightMapValue(short sx, short sy)
|
||||
{
|
||||
return m_awRawHeightMap[(sy+1) * HEIGHTMAP_RAW_XSIZE + sx+1];
|
||||
}
|
||||
|
||||
#endif // !defined(AFX_TERRAIN_H__1C9108E1_69A7_4392_9B68_0E6CD4E1BFBA__INCLUDED_)
|
||||
@@ -0,0 +1,95 @@
|
||||
#ifndef __TERRAIn_TYPES__
|
||||
#define __TERRAIn_TYPES__
|
||||
|
||||
#include "../EterLib/GrpVertexBuffer.h"
|
||||
#include "../EterLib/GrpIndexBuffer.h"
|
||||
|
||||
#define TERRAIN_PATCHSIZE 16
|
||||
#define TERRAIN_SIZE 128
|
||||
#define TERRAIN_PATCHCOUNT TERRAIN_SIZE/TERRAIN_PATCHSIZE
|
||||
#define MAXTERRAINTEXTURES 256
|
||||
|
||||
typedef struct
|
||||
{
|
||||
long Active;
|
||||
long NeedsUpdate;
|
||||
LPDIRECT3DTEXTURE8 pd3dTexture;
|
||||
} TTerainSplat;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
DWORD TileCount[MAXTERRAINTEXTURES];
|
||||
DWORD PatchTileCount[TERRAIN_PATCHCOUNT*TERRAIN_PATCHCOUNT][MAXTERRAINTEXTURES];
|
||||
TTerainSplat Splats[MAXTERRAINTEXTURES];
|
||||
bool m_bNeedsUpdate;
|
||||
} TTerrainSplatPatch;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char used;
|
||||
short mat;
|
||||
|
||||
CGraphicVertexBuffer vb;
|
||||
CGraphicIndexBuffer ib;
|
||||
long VertexSize;
|
||||
|
||||
short NumIndices;
|
||||
|
||||
float minx, maxx;
|
||||
float miny, maxy;
|
||||
float minz, maxz;
|
||||
} TERRAIN_VBUFFER;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char name[19];
|
||||
float ambi_r, ambi_g, ambi_b, ambi_a; /* Ambient Color */
|
||||
float diff_r, diff_g, diff_b, diff_a; /* Diffuse Color */
|
||||
float spec_r, spec_g, spec_b, spec_a; /* Specular Color */
|
||||
float spec_power; /* Specular power */
|
||||
} PR_MATERIAL;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
/* Public Settings */
|
||||
float PageUVLength;
|
||||
long SquaresPerTexture; /* Heightfield squares per texture (128 texels) */
|
||||
long SplatTilesX; /* Number of splat textures across map */
|
||||
long SplatTilesY; /* Number of splat textures down map */
|
||||
long DisableWrapping;
|
||||
long DisableShadow;
|
||||
long ShadowMode;
|
||||
long OutsideVisible;
|
||||
D3DXVECTOR3 SunLocation;
|
||||
} TTerrainGlobals;
|
||||
|
||||
/* Converts a floating point number to an integer by truncation, using
|
||||
the FISTP instruction */
|
||||
#define PR_FLOAT_TO_INTASM __asm \
|
||||
{ \
|
||||
__asm fld PR_FCNV \
|
||||
__asm fistp PR_ICNV \
|
||||
}
|
||||
|
||||
#define PR_FLOAT_TO_FIXED(inreal, outint) \
|
||||
{ \
|
||||
PR_FCNV = (inreal) * 65536.0f; \
|
||||
PR_FLOAT_TO_INTASM; \
|
||||
(outint) = PR_ICNV; \
|
||||
}
|
||||
|
||||
#define PR_FLOAT_TO_INT(inreal, outint) \
|
||||
{ \
|
||||
PR_FCNV = (inreal); \
|
||||
PR_FLOAT_TO_INTASM; \
|
||||
(outint) = PR_ICNV > PR_FCNV ? PR_ICNV - 1 : PR_ICNV; \
|
||||
}
|
||||
|
||||
#define PR_FLOAT_ADD_TO_INT(inreal, outint) \
|
||||
{ \
|
||||
PR_FCNV = (inreal); \
|
||||
PR_FLOAT_TO_INTASM; \
|
||||
(outint) += PR_ICNV; \
|
||||
}
|
||||
|
||||
#endif //__TERRAIn_TYPES__
|
||||
@@ -0,0 +1,90 @@
|
||||
#ifndef __INC_TERRAINLIB_TEXTURESET_H__
|
||||
#define __INC_TERRAINLIB_TEXTURESET_H__
|
||||
|
||||
#include "../EterLib/GrpImageInstance.h"
|
||||
|
||||
typedef struct STerrainTexture
|
||||
{
|
||||
STerrainTexture() : pd3dTexture(NULL),
|
||||
UScale(4.0f),
|
||||
VScale(4.0f),
|
||||
UOffset(0.0f),
|
||||
VOffset(0.0f),
|
||||
bSplat(true),
|
||||
Begin(0),
|
||||
End(0)
|
||||
{
|
||||
}
|
||||
|
||||
~STerrainTexture()
|
||||
{
|
||||
}
|
||||
|
||||
std::string stFilename;
|
||||
LPDIRECT3DTEXTURE8 pd3dTexture;
|
||||
CGraphicImageInstance ImageInstance;
|
||||
float UScale;
|
||||
float VScale;
|
||||
float UOffset;
|
||||
float VOffset;
|
||||
bool bSplat;
|
||||
unsigned short Begin, End; // 0 ~ 65535 의 16bit heightfield 높이값.
|
||||
D3DXMATRIX m_matTransform;
|
||||
} TTerrainTexture;
|
||||
|
||||
class CTextureSet
|
||||
{
|
||||
public:
|
||||
typedef std::vector<TTerrainTexture> TTextureVector;
|
||||
|
||||
CTextureSet();
|
||||
virtual ~CTextureSet();
|
||||
|
||||
void Initialize();
|
||||
void Clear();
|
||||
|
||||
void Create();
|
||||
|
||||
bool Load(const char * c_pszFileName, float fTerrainTexCoordBase);
|
||||
bool Save(const char * c_pszFileName);
|
||||
|
||||
unsigned long GetTextureCount();
|
||||
|
||||
TTerrainTexture & GetTexture(unsigned long ulIndex);
|
||||
bool RemoveTexture(unsigned long ulIndex);
|
||||
|
||||
bool SetTexture(unsigned long ulIndex,
|
||||
const char * c_szFileName,
|
||||
float fuScale,
|
||||
float fvScale,
|
||||
float fuOffset,
|
||||
float fvOffset,
|
||||
bool bSplat,
|
||||
unsigned short usBegin,
|
||||
unsigned short usEnd,
|
||||
float fTerrainTexCoordBase);
|
||||
|
||||
void Reload(float fTerrainTexCoordBase);
|
||||
|
||||
bool AddTexture(const char * c_szFileName,
|
||||
float fuScale,
|
||||
float fvScale,
|
||||
float fuOffset,
|
||||
float fvOffset,
|
||||
bool bSplat,
|
||||
unsigned short usBegin,
|
||||
unsigned short usEnd,
|
||||
float fTerrainTexCoordBase);
|
||||
|
||||
const char * GetFileName() { return m_stFileName.c_str(); }
|
||||
|
||||
protected:
|
||||
void AddEmptyTexture();
|
||||
|
||||
protected:
|
||||
TTextureVector m_Textures;
|
||||
TTerrainTexture m_ErrorTexture;
|
||||
std::string m_stFileName;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,108 @@
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// CSpeedTreeForest Class
|
||||
//
|
||||
// (c) 2003 IDV, Inc.
|
||||
//
|
||||
// This class is provided to illustrate one way to incorporate
|
||||
// SpeedTreeRT into an OpenGL application. All of the SpeedTreeRT
|
||||
// calls that must be made on a per tree basis are done by this class.
|
||||
// Calls that apply to all trees (i.e. static SpeedTreeRT functions)
|
||||
// are made in the functions in main.cpp.
|
||||
//
|
||||
//
|
||||
// *** INTERACTIVE DATA VISUALIZATION (IDV) PROPRIETARY INFORMATION ***
|
||||
//
|
||||
// This software is supplied under the terms of a license agreement or
|
||||
// nondisclosure agreement with Interactive Data Visualization and may
|
||||
// not be copied or disclosed except in accordance with the terms of
|
||||
// that agreement.
|
||||
//
|
||||
// Copyright (c) 2001-2003 IDV, Inc.
|
||||
// All Rights Reserved.
|
||||
//
|
||||
// IDV, Inc.
|
||||
// 1233 Washington St. Suite 610
|
||||
// Columbia, SC 29201
|
||||
// Voice: (803) 799-1699
|
||||
// Fax: (803) 931-0320
|
||||
// Web: http://www.idvinc.com
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// Include Files
|
||||
#include <SpeedTreeRT.h>
|
||||
#include "SpeedTreeWrapper.h"
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// Render bit vector
|
||||
|
||||
#define Forest_RenderBranches (1 << 0)
|
||||
#define Forest_RenderLeaves (1 << 1)
|
||||
#define Forest_RenderFronds (1 << 2)
|
||||
#define Forest_RenderBillboards (1 << 3)
|
||||
#define Forest_RenderAll ((1 << 4) - 1)
|
||||
#define Forest_RenderToShadow (1 << 5)
|
||||
#define Forest_RenderToMiniMap (1 << 6)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// class CSpeedTreeForest declaration
|
||||
|
||||
class CSpeedTreeForest
|
||||
{
|
||||
public:
|
||||
typedef std::map<DWORD, CSpeedTreeWrapper *> TTreeMap;
|
||||
|
||||
public:
|
||||
CSpeedTreeForest();
|
||||
virtual ~CSpeedTreeForest();
|
||||
|
||||
void ClearMainTree();
|
||||
|
||||
|
||||
BOOL GetMainTree(DWORD dwCRC, CSpeedTreeWrapper ** ppMainTree, const char * c_pszFileName);
|
||||
CSpeedTreeWrapper * GetMainTree(DWORD dwCRC);
|
||||
void DeleteMainTree(DWORD dwCRC);
|
||||
|
||||
CSpeedTreeWrapper * CreateInstance(float x, float y, float z, DWORD dwTreeCRC, const char * c_pszTreeName);
|
||||
void DeleteInstance(CSpeedTreeWrapper * pTree);
|
||||
|
||||
//void SetLodLimits(void);
|
||||
|
||||
void UpdateSystem(float fCurrentTime);
|
||||
|
||||
void Clear();
|
||||
|
||||
void SetLight(const float * afDirection, const float * afAmbient, const float * afDiffuse);
|
||||
void SetFog(float fFogNear, float fFogFar);
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
const float * GetExtents(void) const { return m_afForestExtents; }
|
||||
|
||||
// wind management
|
||||
float GetWindStrength(void) const { return m_fWindStrength; }
|
||||
void SetWindStrength(float fStrength);
|
||||
void SetupWindMatrices(float fTimeInSecs);
|
||||
|
||||
// overridden by specific graphics API
|
||||
virtual void UploadWindMatrix(unsigned int uiLocation, const float* pMatrix) const = 0;
|
||||
virtual void Render(unsigned long ulRenderBitVector) = 0;
|
||||
|
||||
protected:
|
||||
TTreeMap m_pMainTreeMap;
|
||||
|
||||
float m_afLighting[12];
|
||||
float m_afFog[4];
|
||||
|
||||
private:
|
||||
void AdjustExtents(float x, float y, float z);
|
||||
|
||||
float m_afForestExtents[6]; // [0] = min x, [1] = min y..., [3] = max x, [4] = max y...
|
||||
float m_fWindStrength; // 0.0 = no wind, 1.0 = full strength
|
||||
|
||||
float m_fAccumTime;
|
||||
};
|
||||
@@ -0,0 +1,64 @@
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// CSpeedTreeForestOpenGL Class
|
||||
//
|
||||
// (c) 2003 IDV, Inc.
|
||||
//
|
||||
// This class is provided to illustrate one way to incorporate
|
||||
// SpeedTreeRT into an OpenGL application. All of the SpeedTreeRT
|
||||
// calls that must be made on a per tree basis are done by this class.
|
||||
// Calls that apply to all trees (i.e. static SpeedTreeRT functions)
|
||||
// are made in the functions in main.cpp.
|
||||
//
|
||||
//
|
||||
// *** INTERACTIVE DATA VISUALIZATION (IDV) PROPRIETARY INFORMATION ***
|
||||
//
|
||||
// This software is supplied under the terms of a license agreement or
|
||||
// nondisclosure agreement with Interactive Data Visualization and may
|
||||
// not be copied or disclosed except in accordance with the terms of
|
||||
// that agreement.
|
||||
//
|
||||
// Copyright (c) 2001-2003 IDV, Inc.
|
||||
// All Rights Reserved.
|
||||
//
|
||||
// IDV, Inc.
|
||||
// 1233 Washington St. Suite 610
|
||||
// Columbia, SC 29201
|
||||
// Voice: (803) 799-1699
|
||||
// Fax: (803) 931-0320
|
||||
// Web: http://www.idvinc.com
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// Include Files
|
||||
|
||||
//#include <map>
|
||||
#define SPEEDTREE_DATA_FORMAT_DIRECTX
|
||||
|
||||
#include "SpeedTreeForest.h"
|
||||
#include "SpeedTreeMaterial.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// class CSpeedTreeForestDirectX8 declaration
|
||||
class CSpeedTreeForestDirectX8 : public CSpeedTreeForest, public CGraphicBase, public CSingleton<CSpeedTreeForestDirectX8>
|
||||
{
|
||||
public:
|
||||
CSpeedTreeForestDirectX8();
|
||||
virtual ~CSpeedTreeForestDirectX8();
|
||||
|
||||
void UploadWindMatrix(unsigned int uiLocation, const float* pMatrix) const;
|
||||
void UpdateCompundMatrix(const D3DXVECTOR3 & c_rEyeVec, const D3DXMATRIX & c_rmatView, const D3DXMATRIX & c_rmatProj);
|
||||
|
||||
void Render(unsigned long ulRenderBitVector = Forest_RenderAll);
|
||||
bool SetRenderingDevice(LPDIRECT3DDEVICE8 pDevice);
|
||||
|
||||
private:
|
||||
bool InitVertexShaders();
|
||||
|
||||
private:
|
||||
LPDIRECT3DDEVICE8 m_pDx; // the rendering context
|
||||
|
||||
DWORD m_dwBranchVertexShader; // branch/frond vertex shaders
|
||||
DWORD m_dwLeafVertexShader; // leaf vertex shader
|
||||
};
|
||||
@@ -0,0 +1,79 @@
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// CSpeedTreeMaterial Class
|
||||
//
|
||||
// (c) 2003 IDV, Inc.
|
||||
//
|
||||
// This class is provided to illustrate one way to incorporate
|
||||
// SpeedTreeRT into an OpenGL application. All of the SpeedTreeRT
|
||||
// calls that must be made on a per tree basis are done by this class.
|
||||
// Calls that apply to all trees (i.e. static SpeedTreeRT functions)
|
||||
// are made in the functions in main.cpp.
|
||||
//
|
||||
//
|
||||
// *** INTERACTIVE DATA VISUALIZATION (IDV) PROPRIETARY INFORMATION ***
|
||||
//
|
||||
// This software is supplied under the terms of a license agreement or
|
||||
// nondisclosure agreement with Interactive Data Visualization and may
|
||||
// not be copied or disclosed except in accordance with the terms of
|
||||
// that agreement.
|
||||
//
|
||||
// Copyright (c) 2001-2003 IDV, Inc.
|
||||
// All Rights Reserved.
|
||||
//
|
||||
// IDV, Inc.
|
||||
// 1233 Washington St. Suite 610
|
||||
// Columbia, SC 29201
|
||||
// Voice: (803) 799-1699
|
||||
// Fax: (803) 931-0320
|
||||
// Web: http://www.idvinc.com
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// Include Files
|
||||
|
||||
#include <d3d8.h>
|
||||
#include <d3d8types.h>
|
||||
#include <d3dx8.h>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// class CSpeedTreeMaterial declaration/definiton
|
||||
|
||||
class CSpeedTreeMaterial
|
||||
{
|
||||
public:
|
||||
CSpeedTreeMaterial()
|
||||
{
|
||||
m_cMaterial.Ambient.r = m_cMaterial.Diffuse.r = m_cMaterial.Specular.r = m_cMaterial.Emissive.r = 1.0f;
|
||||
m_cMaterial.Ambient.g = m_cMaterial.Diffuse.g = m_cMaterial.Specular.g = m_cMaterial.Emissive.g = 1.0f;
|
||||
m_cMaterial.Ambient.b = m_cMaterial.Diffuse.b = m_cMaterial.Specular.b = m_cMaterial.Emissive.b = 1.0f;
|
||||
m_cMaterial.Ambient.a = m_cMaterial.Diffuse.a = m_cMaterial.Specular.a = m_cMaterial.Emissive.a = 1.0f;
|
||||
m_cMaterial.Power = 5.0f;
|
||||
}
|
||||
|
||||
void Set(const float * pMaterialArray)
|
||||
{
|
||||
memcpy(&m_cMaterial.Diffuse, pMaterialArray, 3 * sizeof(float));
|
||||
m_cMaterial.Diffuse.a = 1.0f;
|
||||
|
||||
memcpy(&m_cMaterial.Ambient, pMaterialArray + 3, 3 * sizeof(float));
|
||||
m_cMaterial.Ambient.a = 1.0f;
|
||||
|
||||
memcpy(&m_cMaterial.Specular, pMaterialArray + 6, 3 * sizeof(float));
|
||||
m_cMaterial.Specular.a = 1.0f;
|
||||
|
||||
memcpy(&m_cMaterial.Emissive, pMaterialArray + 9, 3 * sizeof(float));
|
||||
m_cMaterial.Emissive.a = 1.0f;
|
||||
|
||||
m_cMaterial.Power = pMaterialArray[12];
|
||||
}
|
||||
|
||||
D3DMATERIAL8 * Get()
|
||||
{
|
||||
return &m_cMaterial;
|
||||
}
|
||||
|
||||
private:
|
||||
D3DMATERIAL8 m_cMaterial; // the material object
|
||||
};
|
||||
@@ -0,0 +1,203 @@
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// SpeedTreeRTExample Class
|
||||
//
|
||||
// (c) 2003 IDV, Inc.
|
||||
//
|
||||
// This class is provided to illustrate one way to incorporate
|
||||
// SpeedTreeRT into an OpenGL application. All of the SpeedTreeRT
|
||||
// calls that must be made on a per tree basis are done by this class.
|
||||
// Calls that apply to all trees (i.e. static SpeedTreeRT functions)
|
||||
// are made in the functions in main.cpp.
|
||||
//
|
||||
//
|
||||
// *** INTERACTIVE DATA VISUALIZATION (IDV) PROPRIETARY INFORMATION ***
|
||||
//
|
||||
// This software is supplied under the terms of a license agreement or
|
||||
// nondisclosure agreement with Interactive Data Visualization and may
|
||||
// not be copied or disclosed except in accordance with the terms of
|
||||
// that agreement.
|
||||
//
|
||||
// Copyright (c) 2001-2003 IDV, Inc.
|
||||
// All Rights Reserved.
|
||||
//
|
||||
// IDV, Inc.
|
||||
// 1233 Washington St. Suite 610
|
||||
// Columbia, SC 29201
|
||||
// Voice: (803) 799-1699
|
||||
// Fax: (803) 931-0320
|
||||
// Web: http://www.idvinc.com
|
||||
//
|
||||
|
||||
#pragma once
|
||||
#pragma warning (disable : 4786)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// Include files
|
||||
|
||||
#include "SpeedTreeMaterial.h"
|
||||
#include <SpeedTreeRT.h>
|
||||
|
||||
#include <d3d8.h>
|
||||
#include <d3d8types.h>
|
||||
#include <d3dx8.h>
|
||||
#include <vector>
|
||||
|
||||
#include "../EterLib/GrpObjectInstance.h"
|
||||
#include "../EterLib/GrpImageInstance.h"
|
||||
|
||||
#ifndef SAFE_DELETE
|
||||
#define SAFE_DELETE(p) { if (p) { delete (p); (p) = NULL; } }
|
||||
#endif
|
||||
|
||||
#ifndef SAFE_DELETE_ARRAY
|
||||
#define SAFE_DELETE_ARRAY(p) { if (p) { delete[] (p); (p) = NULL; } }
|
||||
#endif
|
||||
|
||||
#ifndef SAFE_RELEASE
|
||||
#define SAFE_RELEASE(p) { if (p) { (p)->Release(); (p) = NULL; } }
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// class CSpeedTreeWrapper declaration
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4100)
|
||||
|
||||
class CSpeedTreeWrapper : public CGraphicObjectInstance
|
||||
{
|
||||
enum
|
||||
{
|
||||
ID = TREE_OBJECT
|
||||
};
|
||||
int GetType() const { return ID; }
|
||||
|
||||
// Collision Data
|
||||
protected:
|
||||
virtual void OnUpdateCollisionData(const CStaticCollisionDataVector * pscdVector);
|
||||
virtual void OnUpdateHeighInstance(CAttributeInstance * pAttributeInstance) {}
|
||||
virtual bool OnGetObjectHeight(float fX, float fY, float * pfHeight) { return false; }
|
||||
// Bounding Sphere
|
||||
public:
|
||||
virtual bool GetBoundingSphere(D3DXVECTOR3 & v3Center, float & fRadius);
|
||||
|
||||
public:
|
||||
static bool ms_bSelfShadowOn;
|
||||
|
||||
public:
|
||||
// methods from CGraphicObjectInstance
|
||||
virtual void SetPosition(float x, float y, float z);
|
||||
virtual void CalculateBBox();
|
||||
|
||||
virtual void OnRender(); // Render 시에 메소드, 그러나 프리뷰나 특수한 경우에만 직접 Render 콜을 부르며
|
||||
// 그 이외에는 RenderBranches, RenderFronds 등의 메소드를 CSpeedTreeForest에서 호출한다.
|
||||
virtual void OnBlendRender() {}
|
||||
virtual void OnRenderToShadowMap() {}
|
||||
virtual void OnRenderShadow() {}
|
||||
virtual void OnRenderPCBlocker();
|
||||
|
||||
public:
|
||||
CSpeedTreeWrapper();
|
||||
virtual ~CSpeedTreeWrapper();
|
||||
|
||||
const float * GetPosition();
|
||||
static void SetVertexShaders(DWORD dwBranchVertexShader, DWORD dwLeafVertexShader);
|
||||
|
||||
// geometry
|
||||
bool LoadTree(const char * pszSptFile, const BYTE * c_pbBlock = NULL, unsigned int uiBlockSize = 0, unsigned int nSeed = 1, float fSize = -1.0f, float fSizeVariance = -1.0f);
|
||||
const float * GetBoundingBox(void) const { return m_afBoundingBox; }
|
||||
void GetTreeSize(float & r_fSize, float & r_fVariance);
|
||||
UINT GetCollisionObjectCount();
|
||||
void GetCollisionObject(unsigned int nIndex, CSpeedTreeRT::ECollisionObjectType& eType, float* pPosition, float* pDimensions);
|
||||
|
||||
// rendering
|
||||
void SetupBranchForTreeType(void) const;
|
||||
void SetupFrondForTreeType(void) const;
|
||||
void SetupLeafForTreeType(void) const;
|
||||
void EndLeafForTreeType(void);
|
||||
|
||||
#ifdef WRAPPER_USE_GPU_LEAF_PLACEMENT
|
||||
void UploadLeafTables(unsigned int uiLocation) const;
|
||||
#endif
|
||||
|
||||
void RenderBranches(void) const;
|
||||
void RenderFronds(void) const;
|
||||
void RenderLeaves(void) const;
|
||||
void RenderBillboards(void) const;
|
||||
|
||||
// instancing
|
||||
CSpeedTreeWrapper ** GetInstances(unsigned int& nCount);
|
||||
CSpeedTreeWrapper * InstanceOf(void) const { return m_pInstanceOf; }
|
||||
CSpeedTreeWrapper * MakeInstance();
|
||||
void DeleteInstance(CSpeedTreeWrapper * pInstance);
|
||||
CSpeedTreeRT * GetSpeedTree(void) const { return m_pSpeedTree; }
|
||||
|
||||
// lighting
|
||||
const CSpeedTreeMaterial & GetBranchMaterial(void) const { return m_cBranchMaterial; }
|
||||
const CSpeedTreeMaterial & GetFrondMaterial(void) const { return m_cFrondMaterial; }
|
||||
const CSpeedTreeMaterial & GetLeafMaterial(void) const { return m_cLeafMaterial; }
|
||||
float GetLeafLightingAdjustment(void) const { return m_pSpeedTree->GetLeafLightingAdjustment( ); }
|
||||
|
||||
// wind
|
||||
void SetWindStrength(float fStrength) { m_pSpeedTree->SetWindStrength(fStrength); }
|
||||
void Advance(void);
|
||||
|
||||
// utility
|
||||
LPDIRECT3DTEXTURE8 GetBranchTexture(void) const;
|
||||
void CleanUpMemory(void);
|
||||
|
||||
private:
|
||||
void SetupBuffers(void);
|
||||
void SetupBranchBuffers(void);
|
||||
void SetupFrondBuffers(void);
|
||||
void SetupLeafBuffers(void);
|
||||
void PositionTree(void) const;
|
||||
static bool LoadTexture(const char* pFilename, CGraphicImageInstance & rImage);
|
||||
void SetShaderConstants(const float* pMaterial) const;
|
||||
|
||||
|
||||
private:
|
||||
// SpeedTreeRT data
|
||||
CSpeedTreeRT* m_pSpeedTree; // the SpeedTree object
|
||||
CSpeedTreeRT::STextures* m_pTextureInfo; // texture info cache
|
||||
bool m_bIsInstance; // is this an instance?
|
||||
std::vector<CSpeedTreeWrapper*> m_vInstances; // what is an instance of us
|
||||
CSpeedTreeWrapper* m_pInstanceOf; // which tree is this an instance of
|
||||
|
||||
// geometry cache
|
||||
CSpeedTreeRT::SGeometry* m_pGeometryCache; // cache for pulling geometry from SpeedTree avoids lots of reallocation
|
||||
|
||||
// branch buffers
|
||||
LPDIRECT3DVERTEXBUFFER8 m_pBranchVertexBuffer; // branch vertex buffer
|
||||
unsigned int m_unBranchVertexCount; // number of vertices in branches
|
||||
LPDIRECT3DINDEXBUFFER8 m_pBranchIndexBuffer; // branch index buffer
|
||||
unsigned short* m_pBranchIndexCounts; // number of indexes per branch LOD level
|
||||
|
||||
// frond buffers
|
||||
LPDIRECT3DVERTEXBUFFER8 m_pFrondVertexBuffer; // frond vertex buffer
|
||||
unsigned int m_unFrondVertexCount; // number of vertices in frond
|
||||
LPDIRECT3DINDEXBUFFER8 m_pFrondIndexBuffer; // frond index buffer
|
||||
unsigned short* m_pFrondIndexCounts; // number of indexes per frond LOD level
|
||||
|
||||
// leaf buffers
|
||||
unsigned short m_usNumLeafLods; // the number of leaf LODs
|
||||
LPDIRECT3DVERTEXBUFFER8* m_pLeafVertexBuffer; // leaf vertex buffer
|
||||
bool* m_pLeavesUpdatedByCpu; // stores which LOD's have been updated already per frame
|
||||
|
||||
// tree properties
|
||||
float m_afPos[3]; // tree position
|
||||
float m_afBoundingBox[6]; // tree bounding box
|
||||
|
||||
// materials
|
||||
CSpeedTreeMaterial m_cBranchMaterial; // branch material
|
||||
CSpeedTreeMaterial m_cLeafMaterial; // leaf material
|
||||
CSpeedTreeMaterial m_cFrondMaterial; // frond material
|
||||
|
||||
// branch texture
|
||||
CGraphicImageInstance m_BranchImageInstance;
|
||||
CGraphicImageInstance m_ShadowImageInstance; // shadow texture object (used if shadows are enabled)
|
||||
CGraphicImageInstance m_CompositeImageInstance;
|
||||
|
||||
static DWORD ms_dwBranchVertexShader;
|
||||
static DWORD ms_dwLeafVertexShader;
|
||||
};
|
||||
|
||||
#pragma warning(pop)
|
||||
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||
|
||||
#include <assert.h>
|
||||
//#include <crtdbg.h>
|
||||
|
||||
//#include "Forest.h"
|
||||
#include "SpeedTreeForestDirectX8.h"
|
||||
|
||||
// Armadillo nanomite protection
|
||||
#ifndef NANOBEGIN
|
||||
#ifdef __BORLANDC__
|
||||
#define NANOBEGIN __emit__ (0xEB,0x03,0xD6,0xD7,0x01)
|
||||
#define NANOEND __emit__ (0xEB,0x03,0xD6,0xD7,0x00)
|
||||
#else
|
||||
#define NANOBEGIN __asm _emit 0xEB __asm _emit 0x03 __asm _emit 0xD6 __asm _emit 0xD7 __asm _emit 0x01
|
||||
#define NANOEND __asm _emit 0xEB __asm _emit 0x03 __asm _emit 0xD6 __asm _emit 0xD7 __asm _emit 0x00
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,247 @@
|
||||
/* Copyright (C) John W. Ratcliff, 2001.
|
||||
* All rights reserved worldwide.
|
||||
*
|
||||
* This software is provided "as is" without express or implied
|
||||
* warranties. You may freely copy and compile this source into
|
||||
* applications you distribute provided that the copyright text
|
||||
* below is included in the resulting source code, for example:
|
||||
* "Portions Copyright (C) John W. Ratcliff, 2001"
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
/***********************************************************************/
|
||||
/** POOL : Template class to manage a fixed pool of items for */
|
||||
/** extremely fast allocation and deallocation. */
|
||||
/** */
|
||||
/** Written by John W. Ratcliff jratcliff@att.net */
|
||||
/***********************************************************************/
|
||||
|
||||
template <class Type> class Pool
|
||||
{
|
||||
public:
|
||||
Pool(void)
|
||||
{
|
||||
mHead = 0;
|
||||
mFree = 0;
|
||||
mData = 0;
|
||||
mCurrent = 0;
|
||||
mFreeCount = 0;
|
||||
mUsedCount = 0;
|
||||
};
|
||||
|
||||
~Pool(void)
|
||||
{
|
||||
if (mData)
|
||||
delete [] mData;
|
||||
};
|
||||
|
||||
|
||||
void Release(void)
|
||||
{
|
||||
if (mData)
|
||||
delete [] mData;
|
||||
|
||||
mHead = 0;
|
||||
mFree = 0;
|
||||
|
||||
mData = 0;
|
||||
mCurrent = 0;
|
||||
mFreeCount = 0;
|
||||
mUsedCount = 0;
|
||||
};
|
||||
|
||||
void Set(int maxitems)
|
||||
{
|
||||
if (mData)
|
||||
delete [] mData; // delete any previous incarnation.
|
||||
mMaxItems = maxitems;
|
||||
mData = new Type[mMaxItems];
|
||||
mFree = mData;
|
||||
mHead = 0;
|
||||
int loopValue = (mMaxItems-1);
|
||||
for (int i=0; i<loopValue; i++)
|
||||
{
|
||||
mData[i].SetNext( &mData[i+1] );
|
||||
if ( i == 0 )
|
||||
mData[i].SetPrevious( 0 );
|
||||
else
|
||||
mData[i].SetPrevious( &mData[i-1] );
|
||||
}
|
||||
|
||||
mData[loopValue].SetNext(0);
|
||||
mData[loopValue].SetPrevious( &mData[loopValue-1] );
|
||||
mCurrent = 0; // there is no current, currently. <g>
|
||||
mFreeCount = maxitems;
|
||||
mUsedCount = 0;
|
||||
};
|
||||
|
||||
|
||||
Type * GetNext(bool &looped)
|
||||
{
|
||||
|
||||
looped = false; //default value
|
||||
|
||||
if ( !mHead ) return 0; // there is no data to process.
|
||||
Type *ret;
|
||||
|
||||
if ( !mCurrent )
|
||||
{
|
||||
ret = mHead;
|
||||
looped = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = mCurrent;
|
||||
}
|
||||
|
||||
if ( ret ) mCurrent = ret->GetNext();
|
||||
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
bool IsEmpty(void) const
|
||||
{
|
||||
if ( !mHead ) return true;
|
||||
return false;
|
||||
};
|
||||
|
||||
int Begin(void)
|
||||
{
|
||||
mCurrent = mHead;
|
||||
return mUsedCount;
|
||||
};
|
||||
|
||||
int GetUsedCount(void) const { return mUsedCount; };
|
||||
int GetFreeCount(void) const { return mFreeCount; };
|
||||
|
||||
Type * GetNext(void)
|
||||
{
|
||||
if ( !mHead ) return 0; // there is no data to process.
|
||||
|
||||
Type *ret;
|
||||
|
||||
if ( !mCurrent )
|
||||
{
|
||||
ret = mHead;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = mCurrent;
|
||||
}
|
||||
|
||||
if ( ret ) mCurrent = ret->GetNext();
|
||||
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
void Release(Type *t)
|
||||
{
|
||||
|
||||
if ( t == mCurrent ) mCurrent = t->GetNext();
|
||||
|
||||
// first patch old linked list.. his previous now points to his next
|
||||
Type *prev = t->GetPrevious();
|
||||
|
||||
if ( prev )
|
||||
{
|
||||
Type *next = t->GetNext();
|
||||
prev->SetNext( next ); // my previous now points to my next
|
||||
if ( next ) next->SetPrevious(prev);
|
||||
// list is patched!
|
||||
}
|
||||
else
|
||||
{
|
||||
Type *next = t->GetNext();
|
||||
mHead = next;
|
||||
if ( mHead ) mHead->SetPrevious(0);
|
||||
}
|
||||
|
||||
Type *temp = mFree; // old head of free list.
|
||||
mFree = t; // new head of linked list.
|
||||
t->SetPrevious(0);
|
||||
t->SetNext(temp);
|
||||
|
||||
mUsedCount--;
|
||||
mFreeCount++;
|
||||
};
|
||||
|
||||
Type * GetFreeNoLink(void) // get free, but don't link it to the used list!!
|
||||
{
|
||||
// Free allocated items are always added to the head of the list
|
||||
if ( !mFree ) return 0;
|
||||
Type *ret = mFree;
|
||||
mFree = ret->GetNext(); // new head of free list
|
||||
mUsedCount++;
|
||||
mFreeCount--;
|
||||
ret->SetNext(0);
|
||||
ret->SetPrevious(0);
|
||||
return ret;
|
||||
};
|
||||
|
||||
Type * GetFreeLink(void)
|
||||
{
|
||||
// Free allocated items are always added to the head of the list
|
||||
if ( !mFree ) return 0;
|
||||
Type *ret = mFree;
|
||||
mFree = ret->GetNext(); // new head of free list
|
||||
Type *temp = mHead; // current head of list
|
||||
mHead = ret; // new head of list is this free one
|
||||
if ( temp ) temp->SetPrevious(ret);
|
||||
mHead->SetNext(temp);
|
||||
mHead->SetPrevious(0);
|
||||
mUsedCount++;
|
||||
mFreeCount--;
|
||||
return ret;
|
||||
};
|
||||
|
||||
void AddAfter(Type *e,Type *item)
|
||||
{
|
||||
// Add 'item' after 'e'
|
||||
if ( e )
|
||||
{
|
||||
Type *eprev = e->GetPrevious();
|
||||
Type *enext = e->GetNext();
|
||||
e->SetNext(item);
|
||||
item->SetNext(enext);
|
||||
item->SetPrevious(e);
|
||||
if ( enext ) enext->SetPrevious(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
mHead = item;
|
||||
item->SetPrevious(0);
|
||||
item->SetNext(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void AddBefore(Type *e,Type *item)
|
||||
{
|
||||
// Add 'item' before 'e'
|
||||
Type *eprev = e->GetPrevious();
|
||||
Type *enext = e->GetNext();
|
||||
|
||||
if ( !eprev )
|
||||
mHead = item;
|
||||
else
|
||||
eprev->SetNext(item);
|
||||
|
||||
item->SetPrevious(eprev);
|
||||
item->SetNext(e);
|
||||
|
||||
e->SetPrevious(item);
|
||||
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
int mMaxItems;
|
||||
Type *mCurrent; // current iteration location.
|
||||
Type *mData;
|
||||
Type *mHead; // head of used list.
|
||||
Type *mFree; // head of free list.
|
||||
int mUsedCount;
|
||||
int mFreeCount;
|
||||
};
|
||||
@@ -0,0 +1,106 @@
|
||||
/* Copyright (C) John W. Ratcliff, 2001.
|
||||
* All rights reserved worldwide.
|
||||
*
|
||||
* This software is provided "as is" without express or implied
|
||||
* warranties. You may freely copy and compile this source into
|
||||
* applications you distribute provided that the copyright text
|
||||
* below is included in the resulting source code, for example:
|
||||
* "Portions Copyright (C) John W. Ratcliff, 2001"
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "vector.h"
|
||||
|
||||
|
||||
/***********************************************************************/
|
||||
/** SPHERE.H : Base class to represent a Sphere in 3 space. */
|
||||
/** */
|
||||
/** Written by John W. Ratcliff jratcliff@att.net */
|
||||
/***********************************************************************/
|
||||
|
||||
class SphereInterface
|
||||
{
|
||||
public:
|
||||
SphereInterface();
|
||||
virtual ~SphereInterface();
|
||||
virtual int GetVertexCount(void) const = 0;
|
||||
virtual bool GetVertex(int i,Vector3d &vect) const = 0;
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
|
||||
class Sphere
|
||||
{
|
||||
public:
|
||||
Sphere();
|
||||
Sphere(const Vector3d ¢er, float radius);
|
||||
|
||||
virtual ~Sphere() {}
|
||||
|
||||
void Set(const Vector3d ¢er, float radius);
|
||||
|
||||
void Compute(const SphereInterface &source);
|
||||
|
||||
float GetRadius(void) const { return mRadius; };
|
||||
float GetRadius2(void) const { return mRadius2; };
|
||||
const Vector3d& GetCenter(void) const { return mCenter; };
|
||||
|
||||
bool RayIntersection(const Vector3d &rayOrigin,
|
||||
const Vector3d &V,
|
||||
float distance,
|
||||
Vector3d *intersect);
|
||||
|
||||
|
||||
bool RayIntersection(const Vector3d &rayOrigin,
|
||||
const Vector3d &rayDirection,
|
||||
Vector3d *intersect);
|
||||
|
||||
bool RayIntersectionInFront(const Vector3d &rayOrigin,
|
||||
const Vector3d &rayDirection,
|
||||
Vector3d *intersect);
|
||||
|
||||
void Report(void);
|
||||
|
||||
void SetRadius(float radius)
|
||||
{
|
||||
mRadius = radius;
|
||||
mRadius2 = radius*radius;
|
||||
}
|
||||
|
||||
|
||||
bool InSphereXY(const Vector3d &pos,float distance) const
|
||||
{
|
||||
float dx = pos.x - mCenter.x;
|
||||
float dy = pos.y - mCenter.y;
|
||||
float dist = sqrtf( dx*dx + dy*dy );
|
||||
if ( dist < (mRadius+distance) ) return true;
|
||||
return false;
|
||||
};
|
||||
|
||||
bool InSphere(const Vector3d &pos,float distance) const
|
||||
{
|
||||
float dx = pos.x - mCenter.x;
|
||||
float dy = pos.y - mCenter.y;
|
||||
float dz = pos.z - mCenter.z;
|
||||
|
||||
float dist = sqrtf( dx*dx + dy*dy + dz*dz );
|
||||
if ( dist < (mRadius+distance) ) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
Vector3d mCenter;
|
||||
private:
|
||||
float mRadius;
|
||||
float mRadius2; // radius squared.
|
||||
};
|
||||
|
||||
|
||||
inline Sphere::Sphere()
|
||||
: mCenter(Vector3d(0.0f, 0.0f, 0.0f)), mRadius(0.0f), mRadius2(0.0f) { };
|
||||
|
||||
inline Sphere::Sphere(const Vector3d ¢er, float radius)
|
||||
: mCenter(center), mRadius(radius), mRadius2(radius*radius) { };
|
||||
@@ -0,0 +1,492 @@
|
||||
/* Copyright (C) John W. Ratcliff, 2001.
|
||||
* All rights reserved worldwide.
|
||||
*
|
||||
* This software is provided "as is" without express or implied
|
||||
* warranties. You may freely copy and compile this source into
|
||||
* applications you distribute provided that the copyright text
|
||||
* below is included in the resulting source code, for example:
|
||||
* "Portions Copyright (C) John W. Ratcliff, 2001"
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
/***********************************************************************/
|
||||
/** SPHEREPACK.H: Contains all of the support code for Sphere Trees. */
|
||||
/** */
|
||||
/** Written by John W. Ratcliff jratcliff@att.net */
|
||||
/***********************************************************************/
|
||||
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "vector.h" // need 3d vector support.
|
||||
#include "pool.h" // need memory pool template class.
|
||||
#include "sphere.h" // Need sphere base class.
|
||||
#include "frustum.h" // Need to know what a frustum is.
|
||||
|
||||
#define DEMO 0// true if running in windows test app
|
||||
|
||||
enum SpherePackFlag
|
||||
{
|
||||
|
||||
SPF_SUPERSPHERE =(1<<0), // this is a supersphere, allocated and deleted by us
|
||||
SPF_ROOT_TREE =(1<<1), // member of the root tree
|
||||
SPF_LEAF_TREE =(1<<2), // member of the leaf node tree
|
||||
SPF_ROOTNODE =(1<<3), // this is the root node
|
||||
SPF_RECOMPUTE =(1<<4), // needs recomputed bounding sphere
|
||||
SPF_INTEGRATE =(1<<5), // needs to be reintegrated into tree
|
||||
// Frame-to-frame view frustum status. Only does callbacks when a
|
||||
// state change occurs.
|
||||
SPF_HIDDEN =(1<<6), // outside of view frustum
|
||||
SPF_PARTIAL =(1<<7), // partially inside view frustum
|
||||
SPF_INSIDE =(1<<8) // completely inside view frustum
|
||||
};
|
||||
|
||||
class SpherePackFactory; // forward reference the factory.
|
||||
class SpherePack; // forward reference the sphere package
|
||||
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4100)
|
||||
|
||||
// Virtual base class, used to implement callbacks for RayTracing,
|
||||
// range testing, and frustum culling.
|
||||
class SpherePackCallback
|
||||
{
|
||||
public:
|
||||
SpherePackCallback() {}
|
||||
virtual ~SpherePackCallback() {}
|
||||
|
||||
virtual void VisibilityCallback(const Frustum &f, // frustum clipped against
|
||||
SpherePack *sphere, // leaf node sphere in question
|
||||
ViewState state) // new state it is in.
|
||||
{};
|
||||
|
||||
virtual void RayTraceCallback(const Vector3d &p1, // source pos of ray
|
||||
const Vector3d &dir, // direction of ray
|
||||
float distance, // distance of ray
|
||||
const Vector3d §, // intersection location
|
||||
SpherePack *sphere) // sphere ray hit
|
||||
{};
|
||||
|
||||
virtual void RangeTestCallback(const Vector3d &searchpos, // position we are performing range test against.
|
||||
float distance, // squared distance we are range searching against.
|
||||
SpherePack *sphere,
|
||||
ViewState state) // sphere within range, VS_PARTIAL if sphere straddles range test
|
||||
{};
|
||||
|
||||
virtual void PointTest2dCallback(const Vector3d &searchpos, // position we are performing range test against.
|
||||
SpherePack *sphere,
|
||||
ViewState state) // sphere within range, VS_PARTIAL if sphere straddles range test
|
||||
{};
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
#pragma warning(pop)
|
||||
|
||||
class SpherePack : public Sphere
|
||||
{
|
||||
public:
|
||||
SpherePack(void)
|
||||
{
|
||||
mUserData = 0; // default user data is null
|
||||
mFactory = 0; // factory we are a member of
|
||||
mNext = 0; // linked list pointers
|
||||
mPrevious = 0;
|
||||
mParent = 0;
|
||||
mNextSibling = 0; // our brothers and sisters at this level.
|
||||
mPrevSibling = 0;
|
||||
mChildren = 0; // our children.
|
||||
mChildCount = 0; // number of children we have.
|
||||
mFifo1 = 0; // our FIFO1 location if we have one.
|
||||
mFifo2 = 0; // our FIFO2 location if we have one.
|
||||
SetRadius(0); // default radius
|
||||
mCenter.Set(0,0,0); // default center position.
|
||||
IS_SPHERE = false;
|
||||
};
|
||||
virtual ~SpherePack()
|
||||
{
|
||||
}
|
||||
|
||||
void Init(SpherePackFactory *factory, // factory we belong to
|
||||
const Vector3d &pos, // center of sphere
|
||||
float radius, // radius of sphere
|
||||
void *userdata, bool isSphere) // user data
|
||||
{
|
||||
IS_SPHERE = isSphere;
|
||||
mUserData = userdata;
|
||||
mParent = 0;
|
||||
mNextSibling = 0;
|
||||
mPrevSibling = 0;
|
||||
mFlags = 0;
|
||||
mFifo1 = 0;
|
||||
mFifo2 = 0;
|
||||
mFactory = factory;
|
||||
mCenter = pos;
|
||||
SetRadius(radius);
|
||||
};
|
||||
|
||||
// Access to SpherePack bit flags.
|
||||
void SetSpherePackFlag(SpherePackFlag flag) { mFlags|=flag; };
|
||||
void ClearSpherePackFlag(SpherePackFlag flag) { mFlags&=~flag; };
|
||||
bool HasSpherePackFlag(SpherePackFlag flag) const
|
||||
{
|
||||
if ( mFlags & flag ) return true;
|
||||
return false;
|
||||
};
|
||||
|
||||
|
||||
void SetParent(SpherePack *pack) { mParent = pack; };
|
||||
SpherePack * GetParent(void) const { return mParent; };
|
||||
|
||||
// Sphere has a new position.
|
||||
inline void NewPos(const Vector3d &pos);
|
||||
// Sphere has a new position and radius
|
||||
inline void NewPosRadius(const Vector3d &pos,float radius);
|
||||
|
||||
void Unlink(void)
|
||||
{
|
||||
if ( mFifo1 ) // if we belong to fifo1, null us out
|
||||
{
|
||||
*mFifo1 = 0;
|
||||
mFifo1 = 0;
|
||||
}
|
||||
|
||||
if ( mFifo2 ) // if we belong to fifo2, null us out
|
||||
{
|
||||
*mFifo2 = 0;
|
||||
mFifo2 = 0;
|
||||
}
|
||||
|
||||
if ( mParent ) mParent->LostChild(this);
|
||||
|
||||
assert( !mChildren ); // can't unlink guys with children!
|
||||
|
||||
mParent = 0; // got no father anymore
|
||||
}
|
||||
|
||||
|
||||
void AddChild(SpherePack *pack)
|
||||
{
|
||||
|
||||
SpherePack *my_child = mChildren;
|
||||
mChildren = pack; // new head of list
|
||||
|
||||
pack->SetNextSibling(my_child); // his next is my old next
|
||||
pack->SetPrevSibling(0); // at head of list, no previous
|
||||
pack->SetParent(this);
|
||||
|
||||
if ( my_child ) my_child->SetPrevSibling(pack); // previous now this..
|
||||
|
||||
mChildCount++;
|
||||
|
||||
#if defined(_DEBUG)
|
||||
float dist = DistanceSquared(pack);
|
||||
float radius = sqrtf(dist) + pack->GetRadius();
|
||||
|
||||
assert( radius <= GetRadius()+0.0001f );
|
||||
#endif
|
||||
}
|
||||
|
||||
void SetNextSibling(SpherePack *child) { mNextSibling = child; }
|
||||
void SetPrevSibling(SpherePack *child) { mPrevSibling = child; }
|
||||
|
||||
SpherePack * _GetNextSibling(void) const
|
||||
{
|
||||
return mNextSibling;
|
||||
}
|
||||
SpherePack * _GetPrevSibling(void) const
|
||||
{
|
||||
return mPrevSibling;
|
||||
}
|
||||
SpherePack * GetChildren(void) const { return mChildren; }
|
||||
|
||||
SpherePack * GetNext(void) const { return mNext; };
|
||||
SpherePack * GetPrevious(void) const { return mPrevious; };
|
||||
|
||||
void SetNext(SpherePack *pack) { mNext = pack; };
|
||||
void SetPrevious(SpherePack *pack) { mPrevious = pack; };
|
||||
|
||||
void * GetUserData(void) const { return mUserData; };
|
||||
void SetUserData(void *data, bool isSphere) { mUserData = data; IS_SPHERE=isSphere;};
|
||||
|
||||
float DistanceSquared(const SpherePack *pack) const { return mCenter.DistanceSq( pack->mCenter ); };
|
||||
|
||||
void LostChild(SpherePack *pack);
|
||||
|
||||
const Vector3d& GetPos(void) const { return mCenter; };
|
||||
|
||||
inline void Render(unsigned int color);
|
||||
|
||||
inline bool Recompute(float gravy);
|
||||
|
||||
int GetChildCount(void) const { return mChildCount; };
|
||||
|
||||
#if DEMO
|
||||
void SetColor(unsigned int color) { mColor = color; };
|
||||
unsigned int GetColor(void) const { return mColor; };
|
||||
#endif
|
||||
|
||||
void SetFifo1(SpherePack **fifo)
|
||||
{
|
||||
mFifo1 = fifo;
|
||||
};
|
||||
|
||||
void SetFifo2(SpherePack **fifo)
|
||||
{
|
||||
mFifo2 = fifo;
|
||||
};
|
||||
|
||||
void ComputeBindingDistance(SpherePack *parent)
|
||||
{
|
||||
mBindingDistance = parent->GetRadius() - GetRadius();
|
||||
if ( mBindingDistance <= 0 )
|
||||
mBindingDistance = 0;
|
||||
else
|
||||
mBindingDistance*=mBindingDistance;
|
||||
}
|
||||
|
||||
void VisibilityTest(const Frustum &f,
|
||||
SpherePackCallback *callback,
|
||||
ViewState state);
|
||||
|
||||
void RayTrace(const Vector3d &p1, // origin of Ray
|
||||
const Vector3d &dir, // direction of Ray
|
||||
float distance, // length of ray.
|
||||
SpherePackCallback *callback);
|
||||
|
||||
|
||||
void RangeTest(const Vector3d &p,
|
||||
float distance,
|
||||
SpherePackCallback *callback,
|
||||
ViewState state);
|
||||
|
||||
void PointTest2d(const Vector3d &p,
|
||||
SpherePackCallback *callback,
|
||||
ViewState state);
|
||||
|
||||
void Reset(void);
|
||||
|
||||
private:
|
||||
SpherePack *mNext;
|
||||
SpherePack *mPrevious; // used by pool memory management linked list code
|
||||
|
||||
SpherePack *mParent;
|
||||
SpherePack *mChildren; // *my* children
|
||||
|
||||
SpherePack *mNextSibling; // doubly linked list of my brothers
|
||||
SpherePack *mPrevSibling; // and sisters
|
||||
|
||||
SpherePack **mFifo1; // address of location inside of fifo1
|
||||
SpherePack **mFifo2; // address of location inside of fifo2
|
||||
|
||||
long mFlags; // my bit flags.
|
||||
long mChildCount; // number of children
|
||||
|
||||
float mBindingDistance;
|
||||
|
||||
void *mUserData;
|
||||
|
||||
SpherePackFactory *mFactory; // the factory we are a member of.
|
||||
#if DEMO
|
||||
unsigned long mColor;
|
||||
#endif
|
||||
|
||||
public:
|
||||
bool IS_SPHERE;
|
||||
};
|
||||
|
||||
class SpherePackFifo
|
||||
{
|
||||
public:
|
||||
SpherePackFifo(int fifosize)
|
||||
{
|
||||
mCount = 0;
|
||||
mSP = 0;
|
||||
mBottom = 0;
|
||||
mFifoSize = fifosize;
|
||||
mFifo = new SpherePack *[mFifoSize];
|
||||
};
|
||||
|
||||
virtual ~SpherePackFifo(void)
|
||||
{
|
||||
delete [] mFifo;
|
||||
};
|
||||
|
||||
SpherePack ** Push(SpherePack *sphere)
|
||||
{
|
||||
mCount++;
|
||||
SpherePack **ret = &mFifo[mSP];
|
||||
mFifo[mSP] = sphere;
|
||||
mSP++;
|
||||
if ( mSP == mFifoSize ) mSP = 0;
|
||||
return ret;
|
||||
};
|
||||
|
||||
SpherePack * Pop(void)
|
||||
{
|
||||
while ( mSP != mBottom )
|
||||
{
|
||||
mCount--;
|
||||
SpherePack *ret = mFifo[mBottom];
|
||||
mBottom++;
|
||||
if ( mBottom == mFifoSize ) mBottom = 0;
|
||||
if ( ret ) return ret;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool Flush(SpherePack *pack)
|
||||
{
|
||||
if ( mSP == mBottom ) return false;
|
||||
int i = mBottom;
|
||||
while ( i != mSP )
|
||||
{
|
||||
if ( mFifo[i] == pack )
|
||||
{
|
||||
mFifo[i] = 0;
|
||||
return true;
|
||||
}
|
||||
i++;
|
||||
if ( i == mFifoSize ) i = 0;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
int GetCount(void) const { return mCount; };
|
||||
|
||||
private:
|
||||
int mCount;
|
||||
int mSP; // stack pointer
|
||||
int mBottom;
|
||||
int mFifoSize;
|
||||
SpherePack **mFifo;
|
||||
};
|
||||
|
||||
|
||||
class SpherePackFactory : public SpherePackCallback
|
||||
{
|
||||
public:
|
||||
|
||||
SpherePackFactory(int maxspheres,
|
||||
float rootsize,
|
||||
float leafsize,
|
||||
float gravy);
|
||||
|
||||
|
||||
virtual ~SpherePackFactory(void);
|
||||
|
||||
void Process(void);
|
||||
|
||||
SpherePack *AddSphere_(const Vector3d &pos,
|
||||
float radius,
|
||||
void *userdata,
|
||||
bool isSphere,
|
||||
int flags=SPF_LEAF_TREE);
|
||||
|
||||
void AddIntegrate(SpherePack *pack); // add to the integration FIFO
|
||||
void AddRecompute(SpherePack *recompute); // add to the recomputation (balancing) FIFO.
|
||||
|
||||
void Integrate(SpherePack *pack,SpherePack *supersphere,float node_size);
|
||||
|
||||
void Render(void);
|
||||
|
||||
void Remove(SpherePack *pack);
|
||||
// see if any other spheres are contained within this one, if so
|
||||
// collapse them and inherit their children.
|
||||
#if DEMO
|
||||
unsigned int GetColor(void);
|
||||
#endif
|
||||
|
||||
void FrustumTest(const Frustum &f,SpherePackCallback *callback);
|
||||
|
||||
void RayTrace(const Vector3d &p1, // source
|
||||
const Vector3d &p2, // dest
|
||||
SpherePackCallback *callback);
|
||||
|
||||
void RangeTest(const Vector3d ¢er,float radius,SpherePackCallback *callback);
|
||||
void PointTest2d(const Vector3d ¢er, SpherePackCallback *callback);
|
||||
|
||||
virtual void RayTraceCallback(const Vector3d &p1, // source pos of ray
|
||||
const Vector3d &dir, // direction of ray
|
||||
float distance, // distance of ray
|
||||
const Vector3d §, // intersection location
|
||||
SpherePack *sphere);
|
||||
|
||||
virtual void RangeTestCallback(const Vector3d &p,float distance,SpherePack *sphere,ViewState state);
|
||||
virtual void PointTest2dCallback(const Vector3d &p, SpherePack *sphere,ViewState state);
|
||||
|
||||
virtual void VisibilityCallback(const Frustum &f,SpherePack *sphere,ViewState state);
|
||||
|
||||
|
||||
void Reset(void);
|
||||
|
||||
private:
|
||||
|
||||
|
||||
SpherePack *mRoot; // 1024x1024 root node of all active spheres.
|
||||
SpherePack *mLeaf; // 1024x1024 root node of all active spheres.
|
||||
SpherePackCallback *mCallback;
|
||||
|
||||
Pool< SpherePack > mSpheres; // all spheres possibly represented.
|
||||
|
||||
SpherePackFifo *mIntegrate; // integration fifo
|
||||
SpherePackFifo *mRecompute; // recomputation fifo
|
||||
|
||||
#if DEMO
|
||||
#define MAXCOLORS 12
|
||||
int mColorCount;
|
||||
unsigned int mColors[MAXCOLORS];
|
||||
#endif
|
||||
|
||||
float mMaxRootSize; // maximum size of a root node supersphere
|
||||
float mMaxLeafSize; // maximum size of the leaf node supersphere
|
||||
float mSuperSphereGravy; // binding distance gravy.
|
||||
};
|
||||
|
||||
//*** Source code placed in header file so that it will be inlined!
|
||||
void SpherePack::NewPos(const Vector3d &pos)
|
||||
{
|
||||
mCenter = pos; // set our new center position.
|
||||
|
||||
// is we have a parent (meaning we are a valid leaf node) and we have not already been flagged for re-integration, then.....
|
||||
if (mParent && !HasSpherePackFlag(SPF_INTEGRATE))
|
||||
{
|
||||
float dist = DistanceSquared(mParent); // compute squared distance to our parent.
|
||||
|
||||
if (dist >= mBindingDistance) // if that exceeds our binding distance...
|
||||
{
|
||||
// If our parent, is not already marked to be recomputed (rebalance the sphere), then add him to the recomputation fifo.
|
||||
mFactory->AddRecompute(mParent);
|
||||
|
||||
// Unlink ourselves from the parent sphere and place ourselves into the root node.
|
||||
Unlink();
|
||||
mFactory->AddIntegrate(this); // add ourselves to the re-integration fifo.
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void SpherePack::NewPosRadius(const Vector3d &pos,float radius)
|
||||
{
|
||||
// New position and, possibly, a new radius.
|
||||
mCenter = pos;
|
||||
|
||||
if (mParent && !HasSpherePackFlag(SPF_INTEGRATE))
|
||||
{
|
||||
if (radius != GetRadius())
|
||||
{
|
||||
SetRadius(radius);
|
||||
ComputeBindingDistance(mParent);
|
||||
}
|
||||
|
||||
mFactory->AddRecompute(mParent);
|
||||
|
||||
float dist = DistanceSquared(mParent);
|
||||
|
||||
if (dist >= mBindingDistance)
|
||||
{
|
||||
Unlink();
|
||||
mFactory->AddIntegrate(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -162,6 +162,186 @@ typedef enum _D3DLIGHTTYPE
|
||||
D3DLIGHT_FORCE_DWORD = 0x7fffffff
|
||||
} D3DLIGHTTYPE;
|
||||
|
||||
// Render-state enums and FVF/transform macros, generated from the SDK d3d8types.h.
|
||||
typedef enum _D3DPRIMITIVETYPE
|
||||
{
|
||||
D3DPT_POINTLIST = 1,
|
||||
D3DPT_LINELIST = 2,
|
||||
D3DPT_LINESTRIP = 3,
|
||||
D3DPT_TRIANGLELIST = 4,
|
||||
D3DPT_TRIANGLESTRIP = 5,
|
||||
D3DPT_TRIANGLEFAN = 6,
|
||||
D3DPT_FORCE_DWORD = 0x7fffffff,
|
||||
} D3DPRIMITIVETYPE;
|
||||
|
||||
typedef enum _D3DTRANSFORMSTATETYPE
|
||||
{
|
||||
D3DTS_VIEW = 2,
|
||||
D3DTS_PROJECTION = 3,
|
||||
D3DTS_TEXTURE0 = 16,
|
||||
D3DTS_TEXTURE1 = 17,
|
||||
D3DTS_TEXTURE2 = 18,
|
||||
D3DTS_TEXTURE3 = 19,
|
||||
D3DTS_TEXTURE4 = 20,
|
||||
D3DTS_TEXTURE5 = 21,
|
||||
D3DTS_TEXTURE6 = 22,
|
||||
D3DTS_TEXTURE7 = 23,
|
||||
D3DTS_FORCE_DWORD = 0x7fffffff,
|
||||
} D3DTRANSFORMSTATETYPE;
|
||||
|
||||
typedef enum _D3DRENDERSTATETYPE
|
||||
{
|
||||
D3DRS_ZENABLE = 7,
|
||||
D3DRS_FILLMODE = 8,
|
||||
D3DRS_SHADEMODE = 9,
|
||||
D3DRS_LINEPATTERN = 10,
|
||||
D3DRS_ZWRITEENABLE = 14,
|
||||
D3DRS_ALPHATESTENABLE = 15,
|
||||
D3DRS_LASTPIXEL = 16,
|
||||
D3DRS_SRCBLEND = 19,
|
||||
D3DRS_DESTBLEND = 20,
|
||||
D3DRS_CULLMODE = 22,
|
||||
D3DRS_ZFUNC = 23,
|
||||
D3DRS_ALPHAREF = 24,
|
||||
D3DRS_ALPHAFUNC = 25,
|
||||
D3DRS_DITHERENABLE = 26,
|
||||
D3DRS_ALPHABLENDENABLE = 27,
|
||||
D3DRS_FOGENABLE = 28,
|
||||
D3DRS_SPECULARENABLE = 29,
|
||||
D3DRS_ZVISIBLE = 30,
|
||||
D3DRS_FOGCOLOR = 34,
|
||||
D3DRS_FOGTABLEMODE = 35,
|
||||
D3DRS_FOGSTART = 36,
|
||||
D3DRS_FOGEND = 37,
|
||||
D3DRS_FOGDENSITY = 38,
|
||||
D3DRS_EDGEANTIALIAS = 40,
|
||||
D3DRS_ZBIAS = 47,
|
||||
D3DRS_RANGEFOGENABLE = 48,
|
||||
D3DRS_STENCILENABLE = 52,
|
||||
D3DRS_STENCILFAIL = 53,
|
||||
D3DRS_STENCILZFAIL = 54,
|
||||
D3DRS_STENCILPASS = 55,
|
||||
D3DRS_STENCILFUNC = 56,
|
||||
D3DRS_STENCILREF = 57,
|
||||
D3DRS_STENCILMASK = 58,
|
||||
D3DRS_STENCILWRITEMASK = 59,
|
||||
D3DRS_TEXTUREFACTOR = 60,
|
||||
D3DRS_WRAP0 = 128,
|
||||
D3DRS_WRAP1 = 129,
|
||||
D3DRS_WRAP2 = 130,
|
||||
D3DRS_WRAP3 = 131,
|
||||
D3DRS_WRAP4 = 132,
|
||||
D3DRS_WRAP5 = 133,
|
||||
D3DRS_WRAP6 = 134,
|
||||
D3DRS_WRAP7 = 135,
|
||||
D3DRS_CLIPPING = 136,
|
||||
D3DRS_LIGHTING = 137,
|
||||
D3DRS_AMBIENT = 139,
|
||||
D3DRS_FOGVERTEXMODE = 140,
|
||||
D3DRS_COLORVERTEX = 141,
|
||||
D3DRS_LOCALVIEWER = 142,
|
||||
D3DRS_NORMALIZENORMALS = 143,
|
||||
D3DRS_DIFFUSEMATERIALSOURCE = 145,
|
||||
D3DRS_SPECULARMATERIALSOURCE = 146,
|
||||
D3DRS_AMBIENTMATERIALSOURCE = 147,
|
||||
D3DRS_EMISSIVEMATERIALSOURCE = 148,
|
||||
D3DRS_VERTEXBLEND = 151,
|
||||
D3DRS_CLIPPLANEENABLE = 152,
|
||||
D3DRS_SOFTWAREVERTEXPROCESSING = 153,
|
||||
D3DRS_POINTSIZE = 154,
|
||||
D3DRS_POINTSIZE_MIN = 155,
|
||||
D3DRS_POINTSPRITEENABLE = 156,
|
||||
D3DRS_POINTSCALEENABLE = 157,
|
||||
D3DRS_POINTSCALE_A = 158,
|
||||
D3DRS_POINTSCALE_B = 159,
|
||||
D3DRS_POINTSCALE_C = 160,
|
||||
D3DRS_MULTISAMPLEANTIALIAS = 161,
|
||||
D3DRS_MULTISAMPLEMASK = 162,
|
||||
D3DRS_PATCHEDGESTYLE = 163,
|
||||
D3DRS_PATCHSEGMENTS = 164,
|
||||
D3DRS_DEBUGMONITORTOKEN = 165,
|
||||
D3DRS_POINTSIZE_MAX = 166,
|
||||
D3DRS_INDEXEDVERTEXBLENDENABLE = 167,
|
||||
D3DRS_COLORWRITEENABLE = 168,
|
||||
D3DRS_TWEENFACTOR = 170,
|
||||
D3DRS_BLENDOP = 171,
|
||||
D3DRS_POSITIONORDER = 172,
|
||||
D3DRS_NORMALORDER = 173,
|
||||
D3DRS_FORCE_DWORD = 0x7fffffff,
|
||||
} D3DRENDERSTATETYPE;
|
||||
|
||||
typedef enum _D3DTEXTURESTAGESTATETYPE
|
||||
{
|
||||
D3DTSS_COLOROP = 1,
|
||||
D3DTSS_COLORARG1 = 2,
|
||||
D3DTSS_COLORARG2 = 3,
|
||||
D3DTSS_ALPHAOP = 4,
|
||||
D3DTSS_ALPHAARG1 = 5,
|
||||
D3DTSS_ALPHAARG2 = 6,
|
||||
D3DTSS_BUMPENVMAT00 = 7,
|
||||
D3DTSS_BUMPENVMAT01 = 8,
|
||||
D3DTSS_BUMPENVMAT10 = 9,
|
||||
D3DTSS_BUMPENVMAT11 = 10,
|
||||
D3DTSS_TEXCOORDINDEX = 11,
|
||||
D3DTSS_ADDRESSU = 13,
|
||||
D3DTSS_ADDRESSV = 14,
|
||||
D3DTSS_BORDERCOLOR = 15,
|
||||
D3DTSS_MAGFILTER = 16,
|
||||
D3DTSS_MINFILTER = 17,
|
||||
D3DTSS_MIPFILTER = 18,
|
||||
D3DTSS_MIPMAPLODBIAS = 19,
|
||||
D3DTSS_MAXMIPLEVEL = 20,
|
||||
D3DTSS_MAXANISOTROPY = 21,
|
||||
D3DTSS_BUMPENVLSCALE = 22,
|
||||
D3DTSS_BUMPENVLOFFSET = 23,
|
||||
D3DTSS_TEXTURETRANSFORMFLAGS = 24,
|
||||
D3DTSS_ADDRESSW = 25,
|
||||
D3DTSS_COLORARG0 = 26,
|
||||
D3DTSS_ALPHAARG0 = 27,
|
||||
D3DTSS_RESULTARG = 28,
|
||||
D3DTSS_FORCE_DWORD = 0x7fffffff,
|
||||
} D3DTEXTURESTAGESTATETYPE;
|
||||
|
||||
#define D3DTS_WORLDMATRIX(index) (D3DTRANSFORMSTATETYPE)(index + 256)
|
||||
#define D3DTS_WORLD D3DTS_WORLDMATRIX(0)
|
||||
#define D3DTS_WORLD1 D3DTS_WORLDMATRIX(1)
|
||||
#define D3DTS_WORLD2 D3DTS_WORLDMATRIX(2)
|
||||
#define D3DTS_WORLD3 D3DTS_WORLDMATRIX(3)
|
||||
#define D3DFVF_RESERVED0 0x001
|
||||
#define D3DFVF_POSITION_MASK 0x00E
|
||||
#define D3DFVF_XYZ 0x002
|
||||
#define D3DFVF_XYZRHW 0x004
|
||||
#define D3DFVF_XYZB1 0x006
|
||||
#define D3DFVF_XYZB2 0x008
|
||||
#define D3DFVF_XYZB3 0x00a
|
||||
#define D3DFVF_XYZB4 0x00c
|
||||
#define D3DFVF_XYZB5 0x00e
|
||||
#define D3DFVF_NORMAL 0x010
|
||||
#define D3DFVF_PSIZE 0x020
|
||||
#define D3DFVF_DIFFUSE 0x040
|
||||
#define D3DFVF_SPECULAR 0x080
|
||||
#define D3DFVF_TEXCOUNT_MASK 0xf00
|
||||
#define D3DFVF_TEXCOUNT_SHIFT 8
|
||||
#define D3DFVF_TEX0 0x000
|
||||
#define D3DFVF_TEX1 0x100
|
||||
#define D3DFVF_TEX2 0x200
|
||||
#define D3DFVF_TEX3 0x300
|
||||
#define D3DFVF_TEX4 0x400
|
||||
#define D3DFVF_TEX5 0x500
|
||||
#define D3DFVF_TEX6 0x600
|
||||
#define D3DFVF_TEX7 0x700
|
||||
#define D3DFVF_TEX8 0x800
|
||||
#define D3DFVF_LASTBETA_UBYTE4 0x1000
|
||||
#define D3DFVF_RESERVED2 0xE000
|
||||
#define D3DFVF_TEXTUREFORMAT2 0
|
||||
#define D3DFVF_TEXTUREFORMAT1 3
|
||||
#define D3DFVF_TEXTUREFORMAT3 1
|
||||
#define D3DFVF_TEXTUREFORMAT4 2
|
||||
#define D3DFVF_TEXCOORDSIZE3(CoordIndex) (D3DFVF_TEXTUREFORMAT3 << (CoordIndex*2 + 16))
|
||||
#define D3DFVF_TEXCOORDSIZE2(CoordIndex) (D3DFVF_TEXTUREFORMAT2)
|
||||
#define D3DFVF_TEXCOORDSIZE4(CoordIndex) (D3DFVF_TEXTUREFORMAT4 << (CoordIndex*2 + 16))
|
||||
#define D3DFVF_TEXCOORDSIZE1(CoordIndex) (D3DFVF_TEXTUREFORMAT1 << (CoordIndex*2 + 16))
|
||||
|
||||
typedef struct _D3DDISPLAYMODE
|
||||
{
|
||||
UINT Width;
|
||||
@@ -293,16 +473,19 @@ typedef struct _D3DCAPS8
|
||||
float MaxPixelShaderValue;
|
||||
} D3DCAPS8;
|
||||
|
||||
// COM interfaces: opaque here; platform/ owns every instance.
|
||||
// COM interfaces: no methods here; platform/ owns every instance. The resource hierarchy is kept
|
||||
// so the implicit upcasts 40250 relies on (texture -> base texture) compile.
|
||||
struct IDirect3D8;
|
||||
struct IDirect3DDevice8;
|
||||
struct IDirect3DBaseTexture8;
|
||||
struct IDirect3DTexture8;
|
||||
struct IDirect3DSurface8;
|
||||
struct IDirect3DVertexBuffer8;
|
||||
struct IDirect3DIndexBuffer8;
|
||||
struct IDirect3DResource8 {};
|
||||
struct IDirect3DBaseTexture8 : IDirect3DResource8 {};
|
||||
struct IDirect3DTexture8 : IDirect3DBaseTexture8 {};
|
||||
struct IDirect3DSurface8 : IDirect3DResource8 {};
|
||||
struct IDirect3DVertexBuffer8 : IDirect3DResource8 {};
|
||||
struct IDirect3DIndexBuffer8 : IDirect3DResource8 {};
|
||||
typedef IDirect3D8* LPDIRECT3D8;
|
||||
typedef IDirect3DDevice8* LPDIRECT3DDEVICE8;
|
||||
typedef IDirect3DResource8* LPDIRECT3DRESOURCE8;
|
||||
typedef IDirect3DBaseTexture8* LPDIRECT3DBASETEXTURE8;
|
||||
typedef IDirect3DTexture8* LPDIRECT3DTEXTURE8;
|
||||
typedef IDirect3DSurface8* LPDIRECT3DSURFACE8;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user