mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-21 13:39:18 +02:00
removed dependencies on the old parser. The code can now be compiled outside of Borland C++
This commit is contained in:
45
MdlMngr.cpp
45
MdlMngr.cpp
@@ -13,23 +13,19 @@ http://mozilla.org/MPL/2.0/.
|
||||
|
||||
*/
|
||||
|
||||
#include "system.hpp"
|
||||
#include "classes.hpp"
|
||||
#include "Texture.h"
|
||||
#pragma hdrstop
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "MdlMngr.h"
|
||||
|
||||
#include "Globals.h"
|
||||
#include <string>
|
||||
#include "Logs.h"
|
||||
#include "McZapkie/mctools.h"
|
||||
|
||||
#define SeekFiles AnsiString("*.t3d")
|
||||
//#define SeekFiles std::string("*.t3d")
|
||||
|
||||
TModel3d * TMdlContainer::LoadModel(char *newName, bool dynamic)
|
||||
TModel3d * TMdlContainer::LoadModel(std::string const &NewName, bool dynamic)
|
||||
{ // wczytanie modelu do kontenerka
|
||||
SafeDeleteArray(Name);
|
||||
SafeDelete(Model);
|
||||
Name = new char[strlen(newName) + 1];
|
||||
strcpy(Name, newName);
|
||||
Name = NewName;
|
||||
Model = new TModel3d();
|
||||
if (!Model->LoadFromFile(Name, dynamic)) // np. "models\\pkp/head1-y.t3d"
|
||||
SafeDelete(Model);
|
||||
@@ -38,7 +34,7 @@ TModel3d * TMdlContainer::LoadModel(char *newName, bool dynamic)
|
||||
|
||||
TMdlContainer *TModelsManager::Models;
|
||||
int TModelsManager::Count;
|
||||
const MAX_MODELS = 1000;
|
||||
int const MAX_MODELS = 1000;
|
||||
|
||||
void TModelsManager::Init()
|
||||
{
|
||||
@@ -63,7 +59,7 @@ void TModelsManager::Free()
|
||||
SafeDeleteArray(Models);
|
||||
}
|
||||
|
||||
TModel3d * TModelsManager::LoadModel(char *Name, bool dynamic)
|
||||
TModel3d * TModelsManager::LoadModel(std::string const &Name, bool dynamic)
|
||||
{ // wczytanie modelu do tablicy
|
||||
TModel3d *mdl = NULL;
|
||||
if (Count >= MAX_MODELS)
|
||||
@@ -77,7 +73,7 @@ TModel3d * TModelsManager::LoadModel(char *Name, bool dynamic)
|
||||
return mdl;
|
||||
}
|
||||
|
||||
TModel3d * TModelsManager::GetModel(const char *Name, bool dynamic)
|
||||
TModel3d * TModelsManager::GetModel(std::string const &Name, bool dynamic)
|
||||
{ // model może być we wpisie "node...model" albo "node...dynamic", a także być dodatkowym w dynamic
|
||||
// (kabina, wnętrze, ładunek)
|
||||
// dla "node...dynamic" mamy podaną ścieżkę w "\dynamic\" i musi być co najmniej 1 poziom, zwkle
|
||||
@@ -99,7 +95,7 @@ TModel3d * TModelsManager::GetModel(const char *Name, bool dynamic)
|
||||
// - wczytanie uproszczonego wnętrza, ścieżka dokładna, tekstury z katalogu modelu
|
||||
// - niebo animowane, ścieżka brana ze wpisu, tekstury nieokreślone
|
||||
// - wczytanie modelu animowanego - Init() - sprawdzić
|
||||
char buf[255];
|
||||
std::string buf;
|
||||
std::string buftp = Global::asCurrentTexturePath; // zapamiętanie aktualnej ścieżki do tekstur,
|
||||
// bo będzie tyczmasowo zmieniana
|
||||
/*
|
||||
@@ -143,11 +139,11 @@ TModel3d * TModelsManager::GetModel(const char *Name, bool dynamic)
|
||||
}
|
||||
};
|
||||
*/
|
||||
if (strchr(Name, '\\') == NULL)
|
||||
if( Name.find('\\') == std::string::npos )
|
||||
{
|
||||
strcpy(buf, "models\\"); // Ra: by³o by lepiej katalog dodaæ w parserze
|
||||
strcat(buf, Name);
|
||||
if (strchr(Name, '/') != NULL)
|
||||
buf = "models\\"; // Ra: było by lepiej katalog dodać w parserze
|
||||
buf.append( Name );
|
||||
if( Name.find( '/') != std::string::npos)
|
||||
{
|
||||
Global::asCurrentTexturePath = Global::asCurrentTexturePath + Name;
|
||||
Global::asCurrentTexturePath.erase(Global::asCurrentTexturePath.find("/") + 1,
|
||||
@@ -156,19 +152,19 @@ TModel3d * TModelsManager::GetModel(const char *Name, bool dynamic)
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy(buf, Name);
|
||||
buf = Name;
|
||||
if (dynamic) // na razie tak, bo nie wiadomo, jaki może mieć wpływ na pozostałe modele
|
||||
if (strchr(Name, '/') != NULL)
|
||||
if (Name.find( '/') != std::string::npos)
|
||||
{ // pobieranie tekstur z katalogu, w którym jest model
|
||||
Global::asCurrentTexturePath = Global::asCurrentTexturePath + Name;
|
||||
Global::asCurrentTexturePath.erase(Global::asCurrentTexturePath.find("/") + 1,
|
||||
Global::asCurrentTexturePath.length() - 1);
|
||||
}
|
||||
}
|
||||
StrLower(buf);
|
||||
for (int i = 0; i < Count; i++)
|
||||
buf = ToLower( buf );
|
||||
for (int i = 0; i < Count; ++i)
|
||||
{
|
||||
if (strcmp(buf, Models[i].Name) == 0)
|
||||
if ( buf == Models[i].Name )
|
||||
{
|
||||
Global::asCurrentTexturePath = buftp;
|
||||
return (Models[i].Model);
|
||||
@@ -197,4 +193,3 @@ TModel3d TModelsManager::GetModel(char *Name, AnsiString asReplacableTexture)
|
||||
*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma package(smart_init)
|
||||
|
||||
Reference in New Issue
Block a user