Moved all kart specific files into separate subdirs.

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@1629 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2008-03-05 02:09:50 +00:00
parent 1bcfab771a
commit 6c5efc2bc2
18 changed files with 59 additions and 176126 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -47,7 +47,7 @@ KartProperties::KartProperties() : m_icon_material(0), m_model(0)
//-----------------------------------------------------------------------------
void KartProperties::load(const std::string filename, const std::string node,
bool dont_load_models)
bool dont_load_models, bool dont_load_materials)
{
init_defaults();
@ -78,14 +78,28 @@ void KartProperties::load(const std::string filename, const std::string node,
}
delete root;
// Load material
m_icon_material = material_manager->getMaterial(m_icon_file);
if(!dont_load_materials)
{
// Load material
std::string materials_file = file_manager->getKartFile("materials.dat",getIdent());
file_manager->pushModelSearchPath(file_manager->getKartFile("", getIdent()));
file_manager->pushTextureSearchPath(file_manager->getKartFile("", getIdent()));
// addShared makes sure that these textures/material infos stay in memory
material_manager->addSharedMaterial(materials_file);
m_icon_material = material_manager->getMaterial(m_icon_file);
}
// Load model, except when called as part of --list-karts
if(m_model_file.length()>0 && !dont_load_models)
{
m_model = loader->load(m_model_file, CB_KART, false);
if(!m_model)
{
fprintf(stderr, "Can't find kart model '%s'.\n",m_model_file);
file_manager->popTextureSearchPath();
file_manager->popModelSearchPath();
return;
}
ssgStripify(m_model);
float x_min, x_max, y_min, y_max, z_min, z_max;
MinMax(m_model, &x_min, &x_max, &y_min, &y_max, &z_min, &z_max);
@ -93,6 +107,11 @@ void KartProperties::load(const std::string filename, const std::string node,
m_kart_length = y_max-y_min;
m_model->ref();
} // if
if(!dont_load_materials)
{
file_manager->popTextureSearchPath();
file_manager->popModelSearchPath();
}
} // load

View File

@ -108,7 +108,8 @@ public:
virtual void getAllData (const lisp::Lisp* lisp);
virtual void load (const std::string filename,
const std::string node="tuxkart-kart",
bool dont_load_models=false);
bool dont_load_models=false,
bool dont_load_materials=false);
Material* getIconMaterial () const {return m_icon_material; }
ssgEntity* getModel () const {return m_model; }

View File

@ -74,18 +74,7 @@ void MaterialManager::loadMaterial()
// material index later, so that these materials are not popped
const std::string fname = "materials.dat";
std::string full_name = file_manager->getTextureFile(fname);
if(full_name=="")
{
char msg[MAX_ERROR_MESSAGE_LENGTH];
snprintf(msg, sizeof(msg), "FATAL: File '%s' not found\n", fname.c_str());
throw std::runtime_error(msg);
}
if(!pushTempMaterial(full_name))
{
char msg[MAX_ERROR_MESSAGE_LENGTH];
snprintf(msg, sizeof(msg), "FATAL: Parsing error in '%s'\n", full_name.c_str());
throw std::runtime_error(msg);
}
addSharedMaterial(full_name);
ssgSetAppStateCallback(getAppState);
fuzzy_gst = getMaterial("fuzzy.rgb")->getState();
@ -93,6 +82,26 @@ void MaterialManager::loadMaterial()
m_shared_material_index = (int)m_materials.size();
} // MaterialManager
//-----------------------------------------------------------------------------
void MaterialManager::addSharedMaterial(const std::string& filename)
{
// Use temp material for reading, but then set the shared
// material index later, so that these materials are not popped
if(filename=="")
{
char msg[MAX_ERROR_MESSAGE_LENGTH];
snprintf(msg, sizeof(msg), "FATAL: File '%s' not found\n", filename.c_str());
throw std::runtime_error(msg);
}
if(!pushTempMaterial(filename))
{
char msg[MAX_ERROR_MESSAGE_LENGTH];
snprintf(msg, sizeof(msg), "FATAL: Parsing error in '%s'\n", filename.c_str());
throw std::runtime_error(msg);
}
m_shared_material_index = (int)m_materials.size();
} // addSharedMaterial
//-----------------------------------------------------------------------------
bool MaterialManager::pushTempMaterial(const std::string& filename)
{

View File

@ -38,14 +38,14 @@ private:
std::vector<Material*> m_materials;
public:
MaterialManager();
void loadMaterial ();
void reInit ();
int addEntity (Material *m);
Material *getMaterial (ssgLeaf *lf);
// Material *getMaterial (const char *texname);
Material *getMaterial (const std::string& t, bool is_full_path=false);
bool pushTempMaterial(const std::string& filename);
void popTempMaterial ();
void loadMaterial ();
void reInit ();
int addEntity (Material *m);
Material *getMaterial (ssgLeaf *lf);
Material *getMaterial (const std::string& t, bool is_full_path=false);
void addSharedMaterial(const std::string& filename);
bool pushTempMaterial (const std::string& filename);
void popTempMaterial ();
};
extern ssgState *fuzzy_gst, *herringbones_gst;

View File

@ -25,7 +25,11 @@ STKConfig* stk_config=0;
void STKConfig::load(const std::string filename)
{
KartProperties::load(filename, "config");
// Use the kart properties loader to read in the default kart
// values, but don't try to load any models or materials */
KartProperties::load(filename, "config",
/*dont_load_models */ true,
/*dont_load_materials*/ true );
// Check that all necessary values are indeed set physics.data file