Copying starter.fps for tinkering
by EddieRay · in Torque Game Engine · 11/18/2004 (5:47 am) · 9 replies
I made a copy of the entire starter.fps directory tree and named it starter.ed so that I could tinker with it. It seems to work just like starter.fps except that the terrain textures can't be found. Is there a way to convert the pathnames in the stronghold.ter file (which appears to have "starter.fps/blah/blah..." hard-coded into the pathnames) so that it can find the texture files in my new directory tree?
Thanks,
Ed
Thanks,
Ed
About the author
#2
Edit: David was faster :)
@David: What do you mean by "required files"? As I said, I thought that the paths are stored in the *.ter file. Are they plain text? Hm... Have to take a look at that.
11/18/2004 (5:49 am)
I think you have to retexture the terrain. Terraintexutrepaths are stored in the *.ter file as far as I know.Edit: David was faster :)
@David: What do you mean by "required files"? As I said, I thought that the paths are stored in the *.ter file. Are they plain text? Hm... Have to take a look at that.
#3
Am I going to need to "hack" at the terrain editor to give it a "Find the missing textures function"? Or is there a way to configure the terrain loading code to strip the first part of the pathnames, or make it try harder to find the texture files? Seems silly to have hardcoded texture file paths in the .ter file... ;-)
11/18/2004 (5:59 am)
I've already edited the .cs files and for the mostpart, they don't have any specific pathnames in them - just relative paths from where you run the EXE (which is the directory containing my new "starter.ed" directory). However, the .ter files do seem to have paths that include the top-level "starter.fps/"... and they're binary (so no quick "vi" fixup).Am I going to need to "hack" at the terrain editor to give it a "Find the missing textures function"? Or is there a way to configure the terrain loading code to strip the first part of the pathnames, or make it try harder to find the texture files? Seems silly to have hardcoded texture file paths in the .ter file... ;-)
#4
11/18/2004 (6:18 am)
I don't have it nearby, but I thought they were text files. But now that I think about it, I don't think I've ever edited them directly. I've always used the terrain editor. If they are hard-coded paths, then it is indeed strange.
#5
Unfortunetly the only way is the remove the textures and re add them using the editor. The problem is that you have to re add the procedures and redo any manual terrain painting.
It would make sence if the textures files names where not inbedded in the terrain file but where in fact part of the terrain datablock. Maybe someone will do that oneday.
11/18/2004 (6:34 am)
Terrain files are binary, dont edit them yourself unless you are very very sure of what your doing.Unfortunetly the only way is the remove the textures and re add them using the editor. The problem is that you have to re add the procedures and redo any manual terrain painting.
It would make sence if the textures files names where not inbedded in the terrain file but where in fact part of the terrain datablock. Maybe someone will do that oneday.
#6
There are some extra debugging "printf" calls that can be removed, but the few extra lines of code would make a nice official patch... ;-)
EDIT: WARNING - the code below causes a crash when a new mission is created in the World Editor. It needs to be fixed up a bit...
02/28/2005 (10:33 am)
Here's a diff for a change I made to the terrain loader that will make a more reasonable attempt to find textures referenced by the terrain data. This allows terrain files to be moved/copied to a new location - i.e. for my problem of making a copy of the starter.fps or starter.racing trees.There are some extra debugging "printf" calls that can be removed, but the few extra lines of code would make a nice official patch... ;-)
EDIT: WARNING - the code below causes a crash when a new mission is created in the World Editor. It needs to be fixed up a bit...
*** terrData.cc_orig 2004-11-19 12:19:06.000000000 -0500
--- terrData.cc 2004-11-19 15:48:44.000000000 -0500
***************
*** 19,24 ****
--- 19,25 ----
#include "sim/netConnection.h"
#include "terrain/terrRender.h"
#include "terrain/blender.h"
+ #include <stdio.h>
extern bool gDGLRender;
***************
*** 620,629 ****
AssertFatal(mMaterialFileName[i] && *mMaterialFileName[i], "Error, something wacky here");
StringTableEntry fn = mMaterialFileName[i];
//dStrcpyl(fileBuf, sizeof(fileBuf), mFile.getFilePath(), "/", fn, NULL);
GBitmap* pBitmap = TextureManager::loadBitmapInstance(fn);
if (!pBitmap) {
! dStrcpyl(fileBuf, sizeof(fileBuf), mFile.getFilePath(), "/", fn, NULL);
pBitmap = TextureManager::loadBitmapInstance(fileBuf);
if(pBitmap)
mMaterialFileName[i] = StringTable->insert(fileBuf, true);
--- 621,651 ----
AssertFatal(mMaterialFileName[i] && *mMaterialFileName[i], "Error, something wacky here");
StringTableEntry fn = mMaterialFileName[i];
+ printf("fn is %s\n", fn);
//dStrcpyl(fileBuf, sizeof(fileBuf), mFile.getFilePath(), "/", fn, NULL);
GBitmap* pBitmap = TextureManager::loadBitmapInstance(fn);
if (!pBitmap) {
!
! /* Hack for finding terrain textures for a terrain file that's
! * been copied to a new directory, since .ter files seem to have
! * hardcoded project-specific paths for the texture files.
! */
! const char *p1;
! char *p2, *p3;
! char wrk[4096];
! p1 = mFile.getFilePath();
! p2 = dStrstr(mFile.getFilePath(), "data/");
! wrk[p2-p1+5] = '[[6281aedcf3f91]]';
! if (p2)
! dStrncpy(wrk, p1, p2-p1+5);
! else
! dStrcpy(wrk, p1);
! p3 = dStrstr(fn, "data/");
! if (p3)
! dStrcpyl(fileBuf, sizeof(fileBuf), wrk, p3+5, NULL);
! else
! dStrcpyl(fileBuf, sizeof(fileBuf), mFile.getFilePath(), "/", fn, NULL);
! printf("fileBuf is %s\n", fileBuf);
pBitmap = TextureManager::loadBitmapInstance(fileBuf);
if(pBitmap)
mMaterialFileName[i] = StringTable->insert(fileBuf, true);
***************
*** 631,636 ****
--- 653,659 ----
{
// Try the default..
Con::errorf("Missing terrain texture: %s",fileBuf);
+ printf("texture file missing\n", fileBuf);
matsValid = false;
dStrcpyl(fileBuf, sizeof(fileBuf), mFile.getFilePath(), "/","default",NULL);
pBitmap = TextureManager::loadBitmapInstance(fileBuf);
#7
But to save the changes you need to go back to the world editor and move an object... a tree or something, then save.
(I haven't got TGE on this pc so i'm kinda guessing what the windows are called :\ )
02/28/2005 (10:42 am)
The other way is to go in to the editor... pick "terrain painter" (I think that's what it's called) from the drop down menu. you should see 6 box's... 3 of which are for the textures being used, all you have to do is click one and another window should come up listing the textures. just select the reverent ones, there should be grass, sand and patchy.But to save the changes you need to go back to the world editor and move an object... a tree or something, then save.
(I haven't got TGE on this pc so i'm kinda guessing what the windows are called :\ )
#8
02/28/2005 (11:17 am)
Sounds "yucky"... especially the part about "moving a tree or something"... I like the "make the code look in more reasonable and appropriate places" approach better (kinda like it does for texture files in other contexts - like DTS, DIF, etc.). ;-P
#9
02/28/2005 (11:21 am)
I'm not a coder so thats the only way I could do it :(
Associate David Montgomery-Blake
David MontgomeryBlake