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:
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user