IN CAZ CA VRETI SA MODIFICATI MAI PUTIN FOLOSITI TUTORIALUL POSTAT PE FORUM + ARE SI FIX
directx9-metin2-full-testat-t98.html
Acum sa revenim la postare...
https://postimg.cc/S2dQh1bR
ordinea tutorialului este facut in functie de numarul folderului (1.,2.,3.)
o sa fac update-uri la post, daca o sa faceti tutorialul si aveti probleme lasati in comentarii si o sa fixez sau postati cu fix in caz ca rezolvati
toate resursele vor fii distruse cu o functie ce o sa fie apelata o singura data in cod(nu vor mai fii functii destroy in toate clasele)
functie recreateResource (recreaza toate resursele cu o functie apelata o singura data)
o sa arate ceva de genul :
https://postimg.cc/gallery/Sp8YDdc
UPDATE1:
https://postimg.cc/dZZ8ZF03/b]
O poza cu 2 cliente si cat consuma din procesor!
https://postimg.cc/WDfFGyCs
UPDATE2
https://postimg.cc/gallery/FcxStNT
UPDATE STATEMANAGER (o schimbare mica dar pentru viitoarele tutoriale o sa folosesc/elimin functii din clasa asta)
in Citeste.txt aveti toate functiile ce trebuiesc modificate si cum trebuiesc modificate! aveti mai jos poza cu tot ce trebuie sa faceti (nu trebuie sa cautati nimic manual ,doar replace all)
https://postimg.cc/gallery/RJhg9Dy
UPDATE CLASA TEXTURE : MUTATA PE GPU
In link aveti minumul ce trebuie modificat pentru a putea sa folositi noua clasa, este in lucru sa mut tot ce tine de texturi pe gpu(font,dib,sub,etc)
Fix texturi pixelate: Din greseala am folosit mipmap ceea ce in metin nu prea e folosit...
Fix:
GrpTextureN.cpp -> cauta si inlocuie x2 m_desc.Levels ? m_desc.Levels : D3DX_DEFAULT
inlocuie cu 0
fisiere pentru comparare cod (pana la tutorialul numarul 8)
Link tutoriale:
Adaugat TextureN.cpp si .h(in ultimul tutorial avea niste lipsuri),finalizare tutorial texturi gpu
UPDATE 09.01.2026 , fix vertexbuffer dungeon(nu mai puteai intra in dungeon pentru ca nu suporta meshul cu size TPNT2) multumesc @devlimit pentru gasirea bugului
ESTE UN MARE BUG LA TEXTURI,DECI RECOMAND MOMENTAN SA SE FACA TUTORIALELE FARA TEXTURI!
FIXUL LA VERTEXBUFFER TREBUIE FACUT NEAPARAT!
EXEMPLU CUM PUTETI FACE CACHE PENTRU GRANNY (ideea lui @Nermin)
EterGrnLib/Thing.cpp
#include "StdAfx.h"
#include "../eterbase/Debug.h"
#include "Thing.h"
#include "ThingInstance.h"
struct SThingModelCache
{
CGrannyModel* models;
int modelCount;
int refCount;
bool deviceObjectsCreated;
};
static std::unordered_map<std::string, SThingModelCache> g_ThingModelCache;
bool LoadThingModelsCached(const std::string& fileName, granny_file_info* pInfo, CGrannyModel*& outModels)
{
auto it = g_ThingModelCache.find(fileName);
if (it != g_ThingModelCache.end())
{
it->second.refCount++;
outModels = it->second.models;
return true;
}
int modelCount = pInfo->ModelCount;
CGrannyModel* models = new CGrannyModel[modelCount];
for (int m = 0; m < modelCount; ++m)
{
if (!models[m].CreateFromGrannyModelPointer(pInfo->Models[m]))
{
delete[] models;
return false;
}
}
g_ThingModelCache[fileName] = { models, modelCount, 1, false };
outModels = models;
return true;
}
void ReleaseThingModelsCached(const std::string& fileName)
{
auto it = g_ThingModelCache.find(fileName);
if (it == g_ThingModelCache.end())
return;
it->second.refCount--;
if (it->second.refCount <= 0)
{
if (it->second.deviceObjectsCreated)
{
for (int m = 0; m < it->second.modelCount; ++m)
it->second.models[m].DestroyDeviceObjects();
}
delete[] it->second.models;
g_ThingModelCache.erase(it);
}
}
struct SThingMotionCache
{
CGrannyMotion* motions;
int motionCount;
int refCount;
};
static std::unordered_map<std::string, SThingMotionCache> g_ThingMotionCache;
bool LoadThingMotionsCached(const std::string& fileName, granny_file_info* pInfo, CGrannyMotion*& outMotions)
{
auto it = g_ThingMotionCache.find(fileName);
if (it != g_ThingMotionCache.end())
{
it->second.refCount++;
outMotions = it->second.motions;
return true;
}
int motionCount = pInfo->AnimationCount;
CGrannyMotion* motions = new CGrannyMotion[motionCount];
for (int m = 0; m < motionCount; ++m)
{
if (!motions[m].BindGrannyAnimation(pInfo->Animations[m]))
{
delete[] motions;
return false;
}
}
g_ThingMotionCache[fileName] = { motions, motionCount, 1 };
outMotions = motions;
return true;
}
void ReleaseThingMotionsCached(const std::string& fileName)
{
auto it = g_ThingMotionCache.find(fileName);
if (it == g_ThingMotionCache.end())
return;
it->second.refCount--;
if (it->second.refCount <= 0)
{
delete[] it->second.motions;
g_ThingMotionCache.erase(it);
}
}
CGraphicThing::CGraphicThing(const char* c_szFileName) : CResource(c_szFileName)
{
Initialize();
}
CGraphicThing::~CGraphicThing()
{
Clear();
}
void CGraphicThing::Initialize()
{
m_pgrnFile = NULL;
m_pgrnFileInfo = NULL;
m_pgrnAni = NULL;
m_models = NULL;
m_motions = NULL;
}
void CGraphicThing::OnClear()
{
if (m_motions)
{
ReleaseThingMotionsCached(GetFileNameString());
m_motions = nullptr;
}
if (m_models)
{
ReleaseThingModelsCached(GetFileNameString());
m_models = nullptr;
}
if (m_pgrnFile)
{
GrannyFreeFile(m_pgrnFile);
m_pgrnFile = nullptr;
}
m_pgrnFileInfo = nullptr;
m_pgrnAni = nullptr;
}
CGraphicThing::TType CGraphicThing::Type()
{
static TType s_type = StringToType("CGraphicThing");
return s_type;
}
bool CGraphicThing::OnIsEmpty() const
{
return m_pgrnFile ? false : true;
}
bool CGraphicThing::OnIsType(TType type)
{
if (CGraphicThing::Type() == type)
return true;
return CResource::OnIsType(type);
}
bool CGraphicThing::CreateDeviceObjects()
{
if (!m_pgrnFileInfo || !m_models)
return true;
auto it = g_ThingModelCache.find(GetFileNameString());
if (it == g_ThingModelCache.end())
return true;
if (it->second.deviceObjectsCreated)
return true;
for (int m = 0; m < it->second.modelCount; ++m)
it->second.models[m].CreateDeviceObjects();
it->second.deviceObjectsCreated = true;
return true;
}
void CGraphicThing::DestroyDeviceObjects()
{
//if (!m_pgrnFileInfo)
// return;
//for (int m = 0; m < m_pgrnFileInfo->ModelCount; ++m)
//{
// CGrannyModel& rModel = m_models[m];
// rModel.DestroyDeviceObjects();
//}
}
bool CGraphicThing::CheckModelIndex(int iModel) const
{
if (!m_pgrnFileInfo)
{
Tracef("m_pgrnFileInfo == NULL: %s\n", GetFileName());
return false;
}
assert(m_pgrnFileInfo != NULL);
if (iModel < 0)
return false;
if (iModel >= m_pgrnFileInfo->ModelCount)
return false;
return true;
}
bool CGraphicThing::CheckMotionIndex(int iMotion) const
{
// Temporary
if (!m_pgrnFileInfo)
return false;
// Temporary
assert(m_pgrnFileInfo != NULL);
if (iMotion < 0)
return false;
if (iMotion >= m_pgrnFileInfo->AnimationCount)
return false;
return true;
}
CGrannyModel* CGraphicThing::GetModelPointer(int iModel)
{
assert(CheckModelIndex(iModel));
assert(m_models != NULL);
return m_models + iModel;
}
CGrannyMotion* CGraphicThing::GetMotionPointer(int iMotion)
{
assert(CheckMotionIndex(iMotion));
if (iMotion >= m_pgrnFileInfo->AnimationCount)
return NULL;
assert(m_motions != NULL);
return (m_motions + iMotion);
}
int CGraphicThing::GetModelCount() const
{
if (!m_pgrnFileInfo)
return 0;
return (m_pgrnFileInfo->ModelCount);
}
int CGraphicThing::GetMotionCount() const
{
if (!m_pgrnFileInfo)
return 0;
return (m_pgrnFileInfo->AnimationCount);
}
bool CGraphicThing::OnLoad(int iSize, const void* c_pvBuf)
{
if (!c_pvBuf)
return false;
m_pgrnFile = GrannyReadEntireFileFromMemory(iSize, (void*)c_pvBuf);
if (!m_pgrnFile)
return false;
m_pgrnFileInfo = GrannyGetFileInfo(m_pgrnFile);
if (!m_pgrnFileInfo)
return false;
LoadModels();
LoadMotions();
return true;
}
// SUPPORT_LOCAL_TEXTURE
static std::string gs_modelLocalPath;
const std::string& GetModelLocalPath()
{
return gs_modelLocalPath;
}
// END_OF_SUPPORT_LOCAL_TEXTURE
bool CGraphicThing::LoadModels()
{
assert(m_pgrnFile != NULL);
assert(m_models == NULL);
if (m_pgrnFileInfo->ModelCount <= 0)
return false;
const std::string& fileName = GetFileNameString();
if (!LoadThingModelsCached(fileName, m_pgrnFileInfo, m_models))
return false;
GrannyFreeFileSection(m_pgrnFile, GrannyStandardRigidVertexSection);
GrannyFreeFileSection(m_pgrnFile, GrannyStandardRigidIndexSection);
GrannyFreeFileSection(m_pgrnFile, GrannyStandardDeformableIndexSection);
GrannyFreeFileSection(m_pgrnFile, GrannyStandardTextureSection);
return true;
}
bool CGraphicThing::LoadMotions()
{
assert(m_pgrnFile != NULL);
assert(m_motions == NULL);
if (m_pgrnFileInfo->AnimationCount <= 0)
return false;
const std::string& fileName = GetFileNameString();
if (!LoadThingMotionsCached(fileName, m_pgrnFileInfo, m_motions))
return false;
return true;
}

la acest mesaj și conținutul se va afișa automat.



