Working on Terrain Manager class...
by Bryan Turner · in Torque Game Engine · 04/04/2002 (9:56 am) · 239 replies
SORRY FOLKS!
Looks like the GORPE updates have fallen off the shelf. I do not have a copy of the most recent TM project, but you are welcome to download my old versions here (pre-Torque 1.2):
www.fractalsacpe.org/TorqueTerrain
www.fractalsacpe.org/TorqueTerrainManager.zip
------------------------------------------------------
Hello again.
I got to working on a Terrain Manager class after digging through the terrain rendering code, and it's coming along nicely.
Basically I took Mark F's suggestions and created a TerrainManager class which is the single point of interface for all terrain functions. Moved the relevent structures to it (Material, BlockSize/Mask/Shift, etc). And stubbed the rest of the functions to point to a TerrainBlock. It hit a lot of files to compile/link, but it's working :)
Now I'm getting to the part where I don't understand..
- Should the TerrainBlock remain a SceneObject? I don't think so, since the TerrainManager should be the only thing in the scene.. But taking this step makes the terrain engine *very* unhappy. I'd like some sort of reassurance that this is the right direction.
- How do I specify a vector of data in the mission file datablocks for things like textures, height map files, etc? Basically I want a datablock for TerrainManager which may contain many TerrainBlock datablocks (which contain resource lists for terrain files, textures, etc..).
Some general terrain engine questions:
- What is a 'square' in the terrain engine, and why does *everyone* need it?
- What is a 'grid block' in the terrain engine? How does it differ from a 'square'?
- What is an MPM (material properties map), and why is it passed around with no encapsulation?
Thanks!
--Bryan
Looks like the GORPE updates have fallen off the shelf. I do not have a copy of the most recent TM project, but you are welcome to download my old versions here (pre-Torque 1.2):
www.fractalsacpe.org/TorqueTerrain
www.fractalsacpe.org/TorqueTerrainManager.zip
------------------------------------------------------
Hello again.
I got to working on a Terrain Manager class after digging through the terrain rendering code, and it's coming along nicely.
Basically I took Mark F's suggestions and created a TerrainManager class which is the single point of interface for all terrain functions. Moved the relevent structures to it (Material, BlockSize/Mask/Shift, etc). And stubbed the rest of the functions to point to a TerrainBlock. It hit a lot of files to compile/link, but it's working :)
Now I'm getting to the part where I don't understand..
- Should the TerrainBlock remain a SceneObject? I don't think so, since the TerrainManager should be the only thing in the scene.. But taking this step makes the terrain engine *very* unhappy. I'd like some sort of reassurance that this is the right direction.
- How do I specify a vector of data in the mission file datablocks for things like textures, height map files, etc? Basically I want a datablock for TerrainManager which may contain many TerrainBlock datablocks (which contain resource lists for terrain files, textures, etc..).
Some general terrain engine questions:
- What is a 'square' in the terrain engine, and why does *everyone* need it?
- What is a 'grid block' in the terrain engine? How does it differ from a 'square'?
- What is an MPM (material properties map), and why is it passed around with no encapsulation?
Thanks!
--Bryan
#42
I'll be providing a 'patch' version of this to Bryan shortly, so standby ;)
05/20/2002 (11:01 am)
Desmond-I'll be providing a 'patch' version of this to Bryan shortly, so standby ;)
#43
If anyone wants it, send me email (jjn@kriln.com) ... it's based on today's HEAD version.
05/20/2002 (12:12 pm)
Ok, well, the patch is done, and sent to Bryan for incorporation to his zip file or something.If anyone wants it, send me email (jjn@kriln.com) ... it's based on today's HEAD version.
#44
If you could send it me that would be great.
Thanks,
Melv. (melv.may@btinternet.com)
05/20/2002 (12:17 pm)
Jeremy,If you could send it me that would be great.
Thanks,
Melv. (melv.may@btinternet.com)
#45
In the module terrainEditor.cc you modified the function...
ConsoleMethod(TerrainEditor, getTerrainMaterials, const char *, 2, 2, "() gets the list of current terrain materials.")
to reflect the use of the TerrainManager instead of the terrain Block.
In looking around I also ran across a Code Snippet from Felix Kollman where he modified the same function in order to create a dynamic return buffer closing a security hole and making better use of the system memory. You can check it out here...
http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=2659
Anyway I combined your work and Felix's and I think it all works correctly. The rewritten function is included below. Just use it instead of the one you created. I'm posting it here so people can see if I made any mistakes and to give proper credit.
Here's the new method. It goes in at about line 1790 on my system in terrainEditor.cc
//--dcd--05/20/02 This new method uses the dynamic allocation fix modified to
// work with the new Terrain Manager.
ConsoleMethod(TerrainEditor, getTerrainMaterials, const char *, 2, 2, "() gets the list of current terrain materials.")
{
TerrainEditor *tEditor = (TerrainEditor *) object;
TerrainManager *terr = tEditor->getTerrainManager();
if(!terr)
return "";
Resource file = terr->GetBlock()->getFile();
// calculate return buffer size
U32 uiBufferSize= 1;
for(U32 s = 0; s < TerrainManager::MaterialGroups; s++)
{
if(file->mMaterialFileName[s])
uiBufferSize+= dStrlen (file->mMaterialFileName[s]);
uiBufferSize++;
}
// continue
char *ret = Con::getReturnBuffer(uiBufferSize);
ret[0] = 0;
for(U32 i = 0; i < TerrainManager::MaterialGroups; i++)
{
if(file->mMaterialFileName[i])
dStrcat(ret, file->mMaterialFileName[i]);
dStrcat(ret, "\n");
}
return ret;
}
05/20/2002 (12:37 pm)
Bryan et al.,In the module terrainEditor.cc you modified the function...
ConsoleMethod(TerrainEditor, getTerrainMaterials, const char *, 2, 2, "() gets the list of current terrain materials.")
to reflect the use of the TerrainManager instead of the terrain Block.
In looking around I also ran across a Code Snippet from Felix Kollman where he modified the same function in order to create a dynamic return buffer closing a security hole and making better use of the system memory. You can check it out here...
http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=2659
Anyway I combined your work and Felix's and I think it all works correctly. The rewritten function is included below. Just use it instead of the one you created. I'm posting it here so people can see if I made any mistakes and to give proper credit.
Here's the new method. It goes in at about line 1790 on my system in terrainEditor.cc
//--dcd--05/20/02 This new method uses the dynamic allocation fix modified to
// work with the new Terrain Manager.
ConsoleMethod(TerrainEditor, getTerrainMaterials, const char *, 2, 2, "() gets the list of current terrain materials.")
{
TerrainEditor *tEditor = (TerrainEditor *) object;
TerrainManager *terr = tEditor->getTerrainManager();
if(!terr)
return "";
Resource
// calculate return buffer size
U32 uiBufferSize= 1;
for(U32 s = 0; s < TerrainManager::MaterialGroups; s++)
{
if(file->mMaterialFileName[s])
uiBufferSize+= dStrlen (file->mMaterialFileName[s]);
uiBufferSize++;
}
// continue
char *ret = Con::getReturnBuffer(uiBufferSize);
ret[0] = 0;
for(U32 i = 0; i < TerrainManager::MaterialGroups; i++)
{
if(file->mMaterialFileName[i])
dStrcat(ret, file->mMaterialFileName[i]);
dStrcat(ret, "\n");
}
return ret;
}
#46
Thanks for the merge, I'll include it in the next version.
Desmond,
Jeremy sent me a patch file he generated, and I've added the link at the top of the thread. Perhaps he'll tell me the magic incantation for this so I can generate the patch file in future versions :)
.. oh, and check out today's Snapshot ..
05/20/2002 (8:23 pm)
David,Thanks for the merge, I'll include it in the next version.
Desmond,
Jeremy sent me a patch file he generated, and I've added the link at the top of the thread. Perhaps he'll tell me the magic incantation for this so I can generate the patch file in future versions :)
.. oh, and check out today's Snapshot ..
#47
Never tried it but there is a set of instructions for creating Patch files on the left side of the screen under Torque Engine SDK - it's the fourth menu item. I think this is the process that is being used.
05/21/2002 (8:26 am)
Bryan,Never tried it but there is a set of instructions for creating Patch files on the left side of the screen under Torque Engine SDK - it's the fourth menu item. I think this is the process that is being used.
#48
I noticed in the patch some code related to dml. Can you explain what this is doing? Also, have you merged the patch?
05/21/2002 (9:50 am)
Thanks Bryan/Jeremy,I noticed in the patch some code related to dml. Can you explain what this is doing? Also, have you merged the patch?
#49
05/21/2002 (10:09 am)
I didn't use the directions you referred to, but the general idea is pretty much the same. Bryan's code required some 'tweakage' to get it to diff properly *grin*
#50
I've implemented this great stuff into my project.
I've got one major problem here. This is about saving.
So if you put some terrains together and edit these terrains throug the editor, you can safe it. but it doesn't work really. he saves. but you can't reopen your mission after this safe. Should this work or isn't that implemented yet?
Thank you for your answer(s)
05/21/2002 (12:23 pm)
Hi all!I've implemented this great stuff into my project.
I've got one major problem here. This is about saving.
So if you put some terrains together and edit these terrains throug the editor, you can safe it. but it doesn't work really. he saves. but you can't reopen your mission after this safe. Should this work or isn't that implemented yet?
Thank you for your answer(s)
#51
Oh scallywag.. I knew I forgot something basic. :) I'll put that on the top of the list to fix.
Please, if anyone finds major missing pieces or bugs which make the class unusable (such as this) let me know. While I intend to fix bugs in my spare time, I'm more apt to fix bugs if they are affecting your project.
Thanks!
--Bryan
05/21/2002 (12:46 pm)
Marco,Oh scallywag.. I knew I forgot something basic. :) I'll put that on the top of the list to fix.
Please, if anyone finds major missing pieces or bugs which make the class unusable (such as this) let me know. While I intend to fix bugs in my spare time, I'm more apt to fix bugs if they are affecting your project.
Thanks!
--Bryan
#52
Much thanks! I know, this isn't probably not easy. And i just wanna say, you're doing a very great job and
keep up this absolutly great work.
BTW: There's also a little Problem with texturing. you can just paint the first terrain. not the other ones. But
i think you already seen this. But this isn't a major problem. Just something i've seen while i was playing
around with this code.
Thank you Bryan!
05/21/2002 (11:17 pm)
Hey Bryan!Much thanks! I know, this isn't probably not easy. And i just wanna say, you're doing a very great job and
keep up this absolutly great work.
BTW: There's also a little Problem with texturing. you can just paint the first terrain. not the other ones. But
i think you already seen this. But this isn't a major problem. Just something i've seen while i was playing
around with this code.
Thank you Bryan!
#53
--------------------Configuration: Torque Demo - Win32 Release--------------------
Linking...
terrManager.obj : error LNK2005: "class Convex sTerrainConvexList" (?sTerrainConvexList@@3VConvex@@A) already defined in terrCollision.obj
terrManager.obj : error LNK2001: unresolved external symbol "public: static void __cdecl TerrainRender::renderBlock(class TerrainManager *,class TerrainBlock *,class Point3F &,class SceneState *)" (?renderBlock@TerrainRender@@SAXPAVTerrainManager@@P
AVTerrainBlock@@AAVPoint3F@@PAVSceneState@@@Z)
terrManager.obj : error LNK2001: unresolved external symbol "public: unsigned short __thiscall TerrainBlock::getHeight(unsigned int,unsigned int)" (?getHeight@TerrainBlock@@QAEGII@Z)
terrManager.obj : error LNK2001: unresolved external symbol "public: unsigned short * __thiscall TerrainBlock::getHeightAddress(unsigned int,unsigned int)" (?getHeightAddress@TerrainBlock@@QAEPAGII@Z)
terrManager.obj : error LNK2001: unresolved external symbol "public: void __thiscall TerrainBlock::clearBaseTextures(void)" (?clearBaseTextures@TerrainBlock@@QAEXXZ)
../example/torqueDemo.exe : fatal error LNK1120: 4 unresolved externals
Error executing link.exe.
torqueDemo.exe - 6 error(s), 0 warning(s)
--------------------Configuration: Torque Demo - Win32 Debug--------------------
Linking...
terrManager.obj : error LNK2005: "class Convex sTerrainConvexList" (?sTerrainConvexList@@3VConvex@@A) already defined in terrCollision.obj
terrManager.obj : error LNK2001: unresolved external symbol "public: static void __cdecl TerrainRender::renderBlock(class TerrainManager *,class TerrainBlock *,class Point3F &,class SceneState *)" (?renderBlock@TerrainRender@@SAXPAVTerrainManager@@P
AVTerrainBlock@@AAVPoint3F@@PAVSceneState@@@Z)
terrManager.obj : error LNK2001: unresolved external symbol "public: void __thiscall TerrainBlock::clearBaseTextures(void)" (?clearBaseTextures@TerrainBlock@@QAEXXZ)
../example/torqueDemo_DEBUG.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.
torqueDemo_DEBUG.exe - 4 error(s), 0 warning(s)
This is from fresh torque source of 1_1_1 build
05/22/2002 (6:10 pm)
hey I got the code for this yesterday, and I put it all where it's soposed to be and all that, and I'm getting these errors--------------------Configuration: Torque Demo - Win32 Release--------------------
Linking...
terrManager.obj : error LNK2005: "class Convex sTerrainConvexList" (?sTerrainConvexList@@3VConvex@@A) already defined in terrCollision.obj
terrManager.obj : error LNK2001: unresolved external symbol "public: static void __cdecl TerrainRender::renderBlock(class TerrainManager *,class TerrainBlock *,class Point3F &,class SceneState *)" (?renderBlock@TerrainRender@@SAXPAVTerrainManager@@P
AVTerrainBlock@@AAVPoint3F@@PAVSceneState@@@Z)
terrManager.obj : error LNK2001: unresolved external symbol "public: unsigned short __thiscall TerrainBlock::getHeight(unsigned int,unsigned int)" (?getHeight@TerrainBlock@@QAEGII@Z)
terrManager.obj : error LNK2001: unresolved external symbol "public: unsigned short * __thiscall TerrainBlock::getHeightAddress(unsigned int,unsigned int)" (?getHeightAddress@TerrainBlock@@QAEPAGII@Z)
terrManager.obj : error LNK2001: unresolved external symbol "public: void __thiscall TerrainBlock::clearBaseTextures(void)" (?clearBaseTextures@TerrainBlock@@QAEXXZ)
../example/torqueDemo.exe : fatal error LNK1120: 4 unresolved externals
Error executing link.exe.
torqueDemo.exe - 6 error(s), 0 warning(s)
--------------------Configuration: Torque Demo - Win32 Debug--------------------
Linking...
terrManager.obj : error LNK2005: "class Convex sTerrainConvexList" (?sTerrainConvexList@@3VConvex@@A) already defined in terrCollision.obj
terrManager.obj : error LNK2001: unresolved external symbol "public: static void __cdecl TerrainRender::renderBlock(class TerrainManager *,class TerrainBlock *,class Point3F &,class SceneState *)" (?renderBlock@TerrainRender@@SAXPAVTerrainManager@@P
AVTerrainBlock@@AAVPoint3F@@PAVSceneState@@@Z)
terrManager.obj : error LNK2001: unresolved external symbol "public: void __thiscall TerrainBlock::clearBaseTextures(void)" (?clearBaseTextures@TerrainBlock@@QAEXXZ)
../example/torqueDemo_DEBUG.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.
torqueDemo_DEBUG.exe - 4 error(s), 0 warning(s)
This is from fresh torque source of 1_1_1 build
#54
checked out the latest head and it works. so maybe it's a problem with this version. But maybe you wait
for Bryans answer.
05/22/2002 (10:51 pm)
That might be a problem. I tested it also first with Torque_1_1_1. But this doesn't worked for me. So i checked out the latest head and it works. so maybe it's a problem with this version. But maybe you wait
for Bryans answer.
#55
05/22/2002 (10:57 pm)
It's not compatible with release_1_1
#56
The .zip file contains code which was merged with the HEAD version from last friday. I belive you can use Jeremy's patch file to merge the changes into the Release_1_1_1 branch, but I don't know what tool to use for that.
On a more general topic: Is there a single tool which works on Mac/Linux/Win32 which will generate patch files and apply patch files?
--Bryan
05/23/2002 (9:58 am)
James/Marco,The .zip file contains code which was merged with the HEAD version from last friday. I belive you can use Jeremy's patch file to merge the changes into the Release_1_1_1 branch, but I don't know what tool to use for that.
On a more general topic: Is there a single tool which works on Mac/Linux/Win32 which will generate patch files and apply patch files?
--Bryan
#57
I use the cygwin ports of these (See http://www.cygwin.com/) under windows.
05/23/2002 (10:17 am)
I don't know about the Mac, but Linux/Unix usually has a pair of tools called 'patch' and 'diff' available for the applying and generation of patches.I use the cygwin ports of these (See http://www.cygwin.com/) under windows.
#59
Try it again. My personal server is at the whim of my ISP. RoadRunner often fidgets with the DHCP lease times, or subnet masks which throw any servers behind their connections off the net. Something about a contract and not running servers off a 'home' connection.. yadda yadda.. ;)
--Bryan
05/28/2002 (10:06 am)
Ken,Try it again. My personal server is at the whim of my ISP. RoadRunner often fidgets with the DHCP lease times, or subnet masks which throw any servers behind their connections off the net. Something about a contract and not running servers off a 'home' connection.. yadda yadda.. ;)
--Bryan
#60
www.garagegames.com/index.php?sec=mg&mod=forums&page=result.thread&qt=5440
05/28/2002 (12:28 pm)
Thanks, I got it finally Bryan. See my other post here:www.garagegames.com/index.php?sec=mg&mod=forums&page=result.thread&qt=5440
Torque Owner Desmond Fletcher
fletcher
I hate to ask this of you after all the nice work you did--but...would you mind providing a changelog since this affects so many files and it appears your changes are not commented with //bt ??