Updated Terrain Deformer
by Ronald J Nelson · 12/26/2007 (10:30 am) · 52 comments
Download Code File
This is an update to the original Basic TerrainDeformer Object for Torque resource released by Robert Brower found here:
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=7343
It fixes several bugs in the code to include:
All network issues have been resolved.
Updates all shapebase item's terrain so items don't remain floating in air if they are in the terrain deformation radius (part of the network issues).
Fixes to deformation edges.
Clearing of decals that are on the terrain in the deformation radius. In other words, no floating bullet holes, foot prints, or tire treads.
Added a new unDeform functionality that can be used to clear all terrain deformations on a map and restore original terrain appearance.
KNOWN ISSUES:
You cannot edit the terrain in the editor after using a deformation. The terrain that you see deformed is a cached terrain and not the true terrain. If you try to do so your game will crash.
In the included file are Instructions that show how to add the required code and script to make the terrain deformer work. It also includes some examples of how to use other new added functions.
Let me know if you have any problems.
Thank you Gary for letting me release this with your work included.
This is an update to the original Basic TerrainDeformer Object for Torque resource released by Robert Brower found here:
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=7343
It fixes several bugs in the code to include:
All network issues have been resolved.
Updates all shapebase item's terrain so items don't remain floating in air if they are in the terrain deformation radius (part of the network issues).
Fixes to deformation edges.
Clearing of decals that are on the terrain in the deformation radius. In other words, no floating bullet holes, foot prints, or tire treads.
Added a new unDeform functionality that can be used to clear all terrain deformations on a map and restore original terrain appearance.
KNOWN ISSUES:
You cannot edit the terrain in the editor after using a deformation. The terrain that you see deformed is a cached terrain and not the true terrain. If you try to do so your game will crash.
In the included file are Instructions that show how to add the required code and script to make the terrain deformer work. It also includes some examples of how to use other new added functions.
Let me know if you have any problems.
Thank you Gary for letting me release this with your work included.
#2
12/13/2007 (1:44 pm)
Does this fix the network issues?
#3
Kind of wondering why this is taking so long to get fully approved.
12/13/2007 (3:16 pm)
Yes, it does Adam. Sorry I updated the text to make that more clear.Kind of wondering why this is taking so long to get fully approved.
#4
Just something I was wondering about: TSE lacks the RigidShape.cc/h files. Can this still be implemented without those files?
Thanks so much!
12/15/2007 (4:00 pm)
Awesome work with this. Works wonderfully!Just something I was wondering about: TSE lacks the RigidShape.cc/h files. Can this still be implemented without those files?
Thanks so much!
#5
Yeah just leave out that part and it should be fine.
12/15/2007 (5:58 pm)
I don't see why not. Funny thing is my RigidShape is a different version than TGE's anyway. I didn't like the fact that it was part of the vehicle class and not one of its own.Yeah just leave out that part and it should be fine.
#6
12/26/2007 (5:51 pm)
Oh by the way Mark, if you decide you want to use RigidShapes there was a version released in the TGEA forums that works. Its a lot different from mine since I separated the RigidShape from the vehicle class.
#7
12/28/2007 (8:24 pm)
Ron, I was able to successfully use this resource in TGEA. (Haven't had time to work on the project for the past couple weeks.) However, I was curious about something. I performed a terrain deformation on the world map successfully, and then proceeded to enter the world editor. I was still capable of deforming the terrain without crashing. Do you believe this is a side effect of using this resource in TGEA, perhaps because of Atlas terrain? I'm still working on understanding the engine entirely, as this is the first game engine I've used, so I thought this might be a good point to start learning about how Atlas terrain works, assuming this is connected.
#8
12/28/2007 (8:40 pm)
Could be Mark. I just bought TGEA and am still in the process of porting my stuff over. If so, its a bonus for TGEA owners.
#9
01/02/2008 (5:01 am)
Has anyone tested this over a network? My beta testers reported me, that sometimes TerrainDeformers are not visible for some clients... And sometimes these clients fall into the ground... Could this be true? I'm just starting with C++, so it would be great if someone could help me.
#10
BTW, is that also run on TGEA? Is there anyone who checked it?
01/10/2008 (6:33 am)
Great resource! It reminds the latest game, Fracture.BTW, is that also run on TGEA? Is there anyone who checked it?
#11
01/10/2008 (2:37 pm)
Yes it does. Just remember to remove the references to RigidShape if you haven't added the class back into TGEA
#13
after successfully mergerd the resource into TGEA got the following errors on the console.
01/10/2008 (10:48 pm)
Hey, after successfully mergerd the resource into TGEA got the following errors on the console.
Executijng starter.fps/server/scripts/terrainDeformer.cs. TerrainDeformerData - DefaulTerrainDeformer(110) - invalid value for lifetime: Scaled value must be between 1 and 4095 Error: cannot change namespace parent linkage for TerrainDeformer from GameBase to TerrainDeformerData. TerrainDeformerData - TerrainDeform(111) - invalid value for lifetime: Scaled value must be between 1 and 4095Any ideas?
#14
Do change the following lines in the terraindeformer.cc file:
comment out
#include "dgl/dgl.h"
and
#include "game/fx/particleEngine.h"
01/10/2008 (11:17 pm)
One more thing to build it with TGEA,Do change the following lines in the terraindeformer.cc file:
comment out
#include "dgl/dgl.h"
and
#include "game/fx/particleEngine.h"
#15
Also, thanks for the catch. I know I had to do those things too, but sometimes I am a bit forgetful.
01/10/2008 (11:25 pm)
With the lifetime thing, no I still get it and have tried tons of stuff to get rid of it. It doesn't seem to hurt anything. Also, thanks for the catch. I know I had to do those things too, but sometimes I am a bit forgetful.
#16
Error: cannot change namespace parent linkage for TerrainDeformer from GameBase to TerrainDeformerData.
I'm not a Torque expert though, but when I traced from break point, I guess the parent should be 'GameBaseData' not 'GameBase' but why. I have no idea. :/
When 'DefaultTerrainDeformer' ofn terraindeformer.cs is created its parent classname is recognized as TerrainDeformer not TerrainDeformerData. Why it does?
01/11/2008 (12:20 am)
But what the error is it?Error: cannot change namespace parent linkage for TerrainDeformer from GameBase to TerrainDeformerData.
I'm not a Torque expert though, but when I traced from break point, I guess the parent should be 'GameBaseData' not 'GameBase' but why. I have no idea. :/
When 'DefaultTerrainDeformer' ofn terraindeformer.cs is created its parent classname is recognized as TerrainDeformer not TerrainDeformerData. Why it does?
#17
in terraindeformer.cs file:
But I can't still deform terrain. :/ I have another problem.
After firing projectil (yes, I inserted terraindefomer code bock inside of onCollide script function of projectile) then open console, the console got the followings:
01/11/2008 (1:29 am)
Ok I've resolved the problem.in terraindeformer.cs file:
datablock TerrainDeformerData(DefaultTerrainDeformer)
{
//FIXED: 'TerrainDeformer' should be changed to 'TerrainDeformerData'
className = "TerrainDeformerData";
type = 1; // values: 0=point, 1=rectangle
particleEmitter = DefaultTerrainDeformerSmokeEmitter;
sound = DefaultTerrainDeformerSound;
soundLifetime = 3000;
lifetime = 1;
};The above resolve namespace parent linkage problem what I mentioned above thread.But I can't still deform terrain. :/ I have another problem.
After firing projectil (yes, I inserted terraindefomer code bock inside of onCollide script function of projectile) then open console, the console got the followings:
AtlasResourceTOC<StubType>::cbOnChunkReadComplete - discarding cancelled chunk (4 @ 11, 10)! AtlasResourceTOC<StubType>::cbOnChunkReadComplete - discarding cancelled chunk (3 @ 0, 5)! AtlasResourceTOC<StubType>::cbOnChunkReadComplete - discarding cancelled chunk (4 @ 11, 5)! AtlasResourceTOC<StubType>::cbOnChunkReadComplete - discarding cancelled chunk (4 @ 7, 5)! isGhost()=0, mTerrainblock=-1 Could not get terrain for class: DefaultTerrainDeformer Could not get terrain for class: DefaultTerrainDeformerAny ideas? Does terrain deformer supports altas terrain either?
#18
When I fired, error on console:
The above errors gone now.
01/11/2008 (2:31 am)
Ok, I tried it another mission file which contains GeoTerrain not Altas one.When I fired, error on console:
Object 'DefaultTerrainDeformer' is not a member of the 'GameBaseData' data block class starter.fps/server/scripts/crossbow.cs(773): Register object failed for object (null) of class TerrainDeformer. Set::add: Object "0" doesn't exist.
The above errors gone now.
#19
01/11/2008 (4:34 am)
No surprising about the Atlas. Since this is nothing more than exposing the embeded terrain deformation from the editor to the game environsment, and since TGEA does not have a working Atlas deformation in the editor, it stands to reason that this would not work either.
#20
The above means that there are more than one 'DefaultTerrainDeformer' and one of them is not based on GameBaseData .
Not sure where two object which have same name 'DefaultTerrainDeformer' at the moment.
Ref:
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=1522
Also, I'll try it with Tim Heldna's TGEA port data which is available on the following link:
[url] http://www.garagegames.com/mg/forums/result.thread.php?qt=57563[/url]
01/11/2008 (6:56 am)
Ok, found the solution on the other forum thread about the error:Quote:
Object 'DefaultTerrainDeformer' is not a member of the 'GameBaseData' data block class
The above means that there are more than one 'DefaultTerrainDeformer' and one of them is not based on GameBaseData .
Not sure where two object which have same name 'DefaultTerrainDeformer' at the moment.
Ref:
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=1522
Also, I'll try it with Tim Heldna's TGEA port data which is available on the following link:
[url] http://www.garagegames.com/mg/forums/result.thread.php?qt=57563[/url]

Torque 3D Owner CodingChris