port 2V2-d.2: Granny runtime on libgr2, main character model animates
Implement the Granny SDK 2.11 API the client uses on top of libgr2 (platform/EterGrnLib/GrannyRuntime.cpp, shim granny.h declared from the SDK header): file sections, type-definition vertex conversion, material textures by Usage, mesh/bone bindings, deformer, control clock/loop/ease and weighted SRT sampling. Port EterGrnLib (LODController, Material, Mesh, Model, ModelInstance*, Motion, Thing, ThingInstance, Util) plus EterLib GrpObjectInstance/GrpCollisionObject/CollisionData verbatim and drop their platform skeletons and pending stand-ins; register the gr2 resource factory; vertex/index buffers are CPU-side until the 2V2-e render adapter. app.UpdateGame/RenderGame now run 40250's bodies, reaching the CPythonApplication members through their singletons (the platform has no app object); CPythonGraphic joins GameSingletons in member order, and GetMousePosition reads the host cursor. port.login_flow asserts the main instance's PART_MAIN model has meshes, its diffuse image loaded and the WAIT motion moves the bones between frames; offline and live pass, port_gate macos PASS. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
5266b00c6e
commit
668f48d6ec
@@ -0,0 +1,140 @@
|
||||
#include "StdAfx.h"
|
||||
#include "ModelInstance.h"
|
||||
#include "Model.h"
|
||||
#include "../EterLib/ResourceManager.h"
|
||||
|
||||
|
||||
CGrannyModel* CGrannyModelInstance::GetModel()
|
||||
{
|
||||
return m_pModel;
|
||||
}
|
||||
|
||||
void CGrannyModelInstance::SetMaterialImagePointer(const char* c_szImageName, CGraphicImage* pImage)
|
||||
{
|
||||
m_kMtrlPal.SetMaterialImagePointer(c_szImageName, pImage);
|
||||
}
|
||||
|
||||
void CGrannyModelInstance::SetMaterialData(const char* c_szImageName, const SMaterialData& c_rkMaterialData)
|
||||
{
|
||||
m_kMtrlPal.SetMaterialData(c_szImageName, c_rkMaterialData);
|
||||
}
|
||||
|
||||
void CGrannyModelInstance::SetSpecularInfo(const char* c_szMtrlName, BOOL bEnable, float fPower)
|
||||
{
|
||||
m_kMtrlPal.SetSpecularInfo(c_szMtrlName, bEnable, fPower);
|
||||
}
|
||||
|
||||
void CGrannyModelInstance::SetLocalTime(float fLocalTime)
|
||||
{
|
||||
m_fLocalTime = fLocalTime;
|
||||
}
|
||||
|
||||
int CGrannyModelInstance::ResetLocalTime()
|
||||
{
|
||||
m_fLocalTime = 0.0f;
|
||||
return 0;
|
||||
}
|
||||
|
||||
float CGrannyModelInstance::GetLocalTime()
|
||||
{
|
||||
return m_fLocalTime;
|
||||
}
|
||||
|
||||
void CGrannyModelInstance::SetParentModelInstance(const CGrannyModelInstance* c_pParentModelInstance, const char * c_szBoneName)
|
||||
{
|
||||
int iBoneIndex;
|
||||
if (!c_pParentModelInstance->GetBoneIndexByName(c_szBoneName, &iBoneIndex))
|
||||
return;
|
||||
|
||||
SetParentModelInstance(c_pParentModelInstance, iBoneIndex);
|
||||
}
|
||||
|
||||
void CGrannyModelInstance::SetParentModelInstance(const CGrannyModelInstance* c_pParentModelInstance, int iBone)
|
||||
{
|
||||
mc_pParentInstance = c_pParentModelInstance;
|
||||
m_iParentBoneIndex = iBone;
|
||||
}
|
||||
|
||||
bool CGrannyModelInstance::IsEmpty()
|
||||
{
|
||||
if (m_pModel)
|
||||
{
|
||||
// NO_MESH_BUG_FIX
|
||||
if (!m_meshMatrices)
|
||||
return true;
|
||||
// END_OF_NO_MESH_BUG_FIX
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CGrannyModelInstance::CreateDeviceObjects()
|
||||
{
|
||||
__CreateDynamicVertexBuffer();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CGrannyModelInstance::DestroyDeviceObjects()
|
||||
{
|
||||
__DestroyDynamicVertexBuffer();
|
||||
}
|
||||
|
||||
void CGrannyModelInstance::__Initialize()
|
||||
{
|
||||
if (m_pModel)
|
||||
{
|
||||
m_pModel->Release();
|
||||
}
|
||||
m_pModel = NULL;
|
||||
mc_pParentInstance = NULL;
|
||||
m_iParentBoneIndex = 0;
|
||||
|
||||
m_pgrnModelInstance = NULL;
|
||||
|
||||
// WORK
|
||||
m_pgrnWorldPoseReal = NULL;
|
||||
// END_OF_WORK
|
||||
|
||||
// TEST
|
||||
// m_pgrnWorldPose = NULL;
|
||||
m_ppkSkeletonInst = NULL;
|
||||
// END_OF_TEST
|
||||
|
||||
m_meshMatrices = NULL;
|
||||
m_pgrnCtrl = NULL;
|
||||
m_pgrnAni = NULL;
|
||||
|
||||
m_dwOldUpdateFrame=0;
|
||||
|
||||
}
|
||||
|
||||
CGrannyModelInstance::CGrannyModelInstance()
|
||||
{
|
||||
m_pModel = NULL;
|
||||
__Initialize();
|
||||
}
|
||||
|
||||
CGrannyModelInstance::~CGrannyModelInstance()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
CDynamicPool<CGrannyModelInstance> CGrannyModelInstance::ms_kPool;
|
||||
|
||||
CGrannyModelInstance* CGrannyModelInstance::New()
|
||||
{
|
||||
return ms_kPool.Alloc();
|
||||
}
|
||||
|
||||
void CGrannyModelInstance::Delete(CGrannyModelInstance* pkInst)
|
||||
{
|
||||
pkInst->Clear();
|
||||
ms_kPool.Free(pkInst);
|
||||
}
|
||||
|
||||
void CGrannyModelInstance::DestroySystem()
|
||||
{
|
||||
ms_kPool.Destroy();
|
||||
}
|
||||
Reference in New Issue
Block a user