First Torque3D resource!
by Konrad Kiss · in Torque 3D Professional · 05/05/2009 (10:06 am) · 22 replies
Hehe, I'm being childish again, but I'm celebrating my Torque3D T-Shirt! :)
I've just submitted a resource, that some of you guys may will find useful when painting terrains:
Rule based layer distribution for Torque3D terrains
I've just submitted a resource, that some of you guys may will find useful when painting terrains:
Rule based layer distribution for Torque3D terrains
About the author
http://about.me/konrad.kiss
#2
I've been planning a more complex system around this that would allow for rule sets to be defined for one terrain. A rule set is just a list of rules in a specific order.
Whenever the terrain would be changed, the actual selection would have the rule set run on it afterwards. So when you carve something out of the terrain or smooth a cliff, voila, it'd already be properly textured.
Also, this would look really really cool / convincing at shows. :) (Maybe that will help GG decide on this feature. :)
05/05/2009 (11:58 pm)
Thanks Tom, that sounds really nice..I've been planning a more complex system around this that would allow for rule sets to be defined for one terrain. A rule set is just a list of rules in a specific order.
Whenever the terrain would be changed, the actual selection would have the rule set run on it afterwards. So when you carve something out of the terrain or smooth a cliff, voila, it'd already be properly textured.
Also, this would look really really cool / convincing at shows. :) (Maybe that will help GG decide on this feature. :)
#3
05/06/2009 (12:29 am)
Sounds like a great resource, but the images won't load.
#4
05/06/2009 (12:33 am)
The server just changed IPs recently, I changed the image urls to use IPs, please see if they work now.
#5
I tryed with beta 3 first got 28 errors then added a little thing and it went up to 36 so deleted that then changed another thing and it went to 18 with 5 warnings. Tryed finding out how to fix those but i to new at this failed on those.
11/02/2010 (10:55 pm)
I tryed getting this to work but after tryed everything that was in comments I have given up.I tryed with beta 3 first got 28 errors then added a little thing and it went up to 36 so deleted that then changed another thing and it went to 18 with 5 warnings. Tryed finding out how to fix those but i to new at this failed on those.
#6
11/03/2010 (7:36 am)
edit stupid remark....
#7
I've used this Resource a lot across a variety of projects and versions, so it does work.
11/03/2010 (9:44 am)
Quote:Ask questions, don't give up.
I tryed getting this to work but after tryed everything that was in comments I have given up.
I tryed with beta 3 first got 28 errors then added a little thing and it went up to 36 so deleted that then changed another thing and it went to 18 with 5 warnings. Tryed finding out how to fix those but i to new at this failed on those.
I've used this Resource a lot across a variety of projects and versions, so it does work.
#8
ok well i put the first code in
T3D_Tutorial_Project DLL/Source Files/Engine/gui/worldEditor/terrainEditor.cpp
then go to my project
and put the next line of code in
game/tools/worldEditor/main.cs
right under echo(" % - Initializing World Editor");
next i made a file in
game/tools/worldEditor/gui/guiTerrainPainterProceduralGui.gui
useing Visual C++ 2008 Express and Notepad++
thats where i get 26 errors
error file
http://rapidshare.com/files/428730443/build_log.txt
This is without any mods from the comments. If you need any other info tell me.
11/03/2010 (7:56 pm)
well i have not given up just i am sick right now so must not be in a good mood.ok well i put the first code in
T3D_Tutorial_Project DLL/Source Files/Engine/gui/worldEditor/terrainEditor.cpp
then go to my project
and put the next line of code in
game/tools/worldEditor/main.cs
right under echo(" % - Initializing World Editor");
next i made a file in
game/tools/worldEditor/gui/guiTerrainPainterProceduralGui.gui
useing Visual C++ 2008 Express and Notepad++
thats where i get 26 errors
error file
http://rapidshare.com/files/428730443/build_log.txt
This is without any mods from the comments. If you need any other info tell me.
#9
11/03/2010 (8:10 pm)
@Brandon: You need to declare these variables in the header (.h) file.
#10
i know one guy in the comments said to put
void TerrainEditor::autoMaterialLayer( F32, F32, F32, F32 )
that just makes it 36 errors instead of 26. i tryed the same line but instead of putting F32 i added some of the undeclared identifier's but i get even more then 36 when i add only 3 its more in the 60 errors.
11/04/2010 (2:59 am)
That don't help me much went over documentation on variable and i don't think i quite getting what to put.i know one guy in the comments said to put
void TerrainEditor::autoMaterialLayer( F32, F32, F32, F32 )
that just makes it 36 errors instead of 26. i tryed the same line but instead of putting F32 i added some of the undeclared identifier's but i get even more then 36 when i add only 3 its more in the 60 errors.
#11
The resource might not work out of the box with Torque 3D 1.1 Beta 3. I've reworked my version to have the function on the TerrainBlock level rather than the editor level, because I needed this for procedural map genertion.
I have no idea if this is going to work for you (probably not out of the box with the rest of the resource), but give it a try. (into terrData.cpp, not terrainEditor.cpp) It now works somewhat differently, so you can decide whether you want to fix the old one or rework this one. Hope this helps.
11/04/2010 (3:22 am)
Hmm, looking at it I don't think this is your fault. The resource might not work out of the box with Torque 3D 1.1 Beta 3. I've reworked my version to have the function on the TerrainBlock level rather than the editor level, because I needed this for procedural map genertion.
I have no idea if this is going to work for you (probably not out of the box with the rest of the resource), but give it a try. (into terrData.cpp, not terrainEditor.cpp) It now works somewhat differently, so you can decide whether you want to fix the old one or rework this one. Hope this helps.
void TerrainBlock::autoMaterialLayer( F32 mMinHeight, F32 mMaxHeight, F32 mMinSlope, F32 mMaxSlope, U8 layerIndex )
{
if (layerIndex == -1)
return;
U32 terrBlocks = getBlockSize();
for (U32 y=0;y<terrBlocks;y++) {
for (U32 x=0;x<terrBlocks;x++) {
if (getFile()->getLayerIndex(x,y)==layerIndex)
continue;
Point3F wp;
const MatrixF & mat = getTransform();
Point3F origin;
mat.getColumn(3, &origin);
wp.x = x * getSquareSize() + origin.x;
wp.y = y * getSquareSize() + origin.y;
wp.z = fixedToFloat( getFile()->getHeight( x, y ) ) + origin.z;
if (!(wp.z>=mMinHeight && wp.z<=mMaxHeight))
continue;
// transform wp to object space
Point3F op;
getWorldTransform().mulP(wp, &op);
Point3F norm;
getNormal(Point2F(op.x, op.y), &norm, true);
if (mMinSlope>0)
if (norm.z > mSin(mDegToRad(90.0f-mMinSlope)))
continue;
if (mMaxSlope<90)
if (norm.z < mSin(mDegToRad(90.0f-mMaxSlope)))
continue;
// ok, looks like we can change the material here
getFile()->setLayerIndex( x, y, layerIndex );
}
}
}
ConsoleMethod( TerrainBlock, autoMaterialLayer, void, 7, 7, "(float minHeight, float maxHeight, float minSlope, float maxSlope, int layerIndex )")
{
object->autoMaterialLayer( dAtof( argv[2] ), dAtof( argv[3] ), dAtof( argv[4] ), dAtof( argv[5] ), dAtoi( argv[6]) );
}
#12
11/04/2010 (6:57 am)
that works will see what i can do to get the rest to work.
#13
11/04/2010 (10:28 am)
Cool. Remember to use that function with the TerrainBlock on your level instead of the TerrainEditor, that should save you some time.
#14
I was thinking, maybe, that in a few days I would be able to post some update instructions for the Resource to get it working near the box with the current version of T3D. Realized that what I'm using is some kind of bastard hybrid that most likely wouldn't work for others, so I'll need to actually install beta3 and see what's going wrong.
11/04/2010 (2:49 pm)
And help did happen :)I was thinking, maybe, that in a few days I would be able to post some update instructions for the Resource to get it working near the box with the current version of T3D. Realized that what I'm using is some kind of bastard hybrid that most likely wouldn't work for others, so I'll need to actually install beta3 and see what's going wrong.
#15
Oh well, I wish I could help more. I'm trying to push out a new version of our game for the beta testers and I'm more than a week behind schedule.
I'll probably want to show more of the procedural generation in Xenocell sometime, it's just impossible to actually find some time.
The little time I did find this week - Minecraft ate that. We've broken up since then, but the memory still haunts.
So many distractions coming out nearing the end of the year. So many I haven't been distracted by... Choices, choices.
11/04/2010 (3:57 pm)
:) Oh well, I wish I could help more. I'm trying to push out a new version of our game for the beta testers and I'm more than a week behind schedule.
I'll probably want to show more of the procedural generation in Xenocell sometime, it's just impossible to actually find some time.
The little time I did find this week - Minecraft ate that. We've broken up since then, but the memory still haunts.
So many distractions coming out nearing the end of the year. So many I haven't been distracted by... Choices, choices.
#16
Duplicated here from the Resource for convenience and future reference
That completes the Resource installation as per Konrad's instructions. The only changes were taking
account for the renamed files/directories and the missing step for modifying the header file.
But lets go ahead and add a button to the TerrainPainter window so that you don't have to type "autoLayers();" in the console. Open up TerrainPainterWindow.ed.gui and find the EPainterPreview window section. Add the following to the end (as the last child) of the EPainterPreview control:
11/07/2010 (7:49 pm)
I added this into 1.1B3 with no issues -- it works practically out of the box! A possible problem that could be easily overlooked though would be the missing instruction to modify the header file.- Add the autoMaterialLayer function and console method - no changes. Note that source/gui/missionEditor/terrainEditor.cpp is now source/gui/worldEditor/terrainEditor.cpp
- Don't forget to add the function prototype to the header file. In source/gui/worldEditor/terrainEditor.h add this line to the TerrainEditor class (in public section):
- Create the guiTerrainPainterProceduralGUI.gui file inside of tools/WorldEditor/gui/ Note that MissionEditor directory has been renamed WorldEditor
- Add the exec statement for the guiTerrainPainterProceduralGUI.gui to tools/WorldEditor/main, somewhere near the top of initializeWorldEditor() Note that initializeMissionEditor has been renamed initializedWorldEditor
void TerrainEditor::autoMaterialLayer(F32, F32, F32, F32);
That completes the Resource installation as per Konrad's instructions. The only changes were taking
account for the renamed files/directories and the missing step for modifying the header file.
But lets go ahead and add a button to the TerrainPainter window so that you don't have to type "autoLayers();" in the console. Open up TerrainPainterWindow.ed.gui and find the EPainterPreview window section. Add the following to the end (as the last child) of the EPainterPreview control:
new GuiButtonCtrl() {
canSaveDynamicFields = "0";
isContainer = "0";
Profile = "GuiButtonProfile";
HorizSizing = "left";
VertSizing = "bottom";
Position = "100 229";
Extent = "50 18";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
Command = "autoLayers();";
tooltipprofile = "GuiToolTipProfile";
hovertime = "1000";
text = "AutoPaint";
groupNum = "-1";
buttonType = "PushButton";
useMouseEvents = "0";
};
#17
11/07/2010 (7:56 pm)
Thanks, Michael! Very nice of you to share this.
#18
11/07/2010 (8:18 pm)
Nah, it was nice of you to share the Resource! I just wanted to verify that it still worked with Torque3D.
#19
i skiped on trying to get it to work and going though my C++ books i have so i could try editing the other code he gave which gives me no errors though it don't work.
i can put autoLayers(); and get the editor but not that button but even doing that it don't paint anything gives some errors when it trys to paint.
if you want to try to help me to get it working can talk though windowslive name is bigdog1787@att.net
11/08/2010 (12:18 am)
i still get errors also that button code never gives a button on the editor tryed placeing in many spots in the line of code. this is a clean build to i doing it on. i even tryed on other betas and even 1.01 and some of the other older ones still get errors on all.i skiped on trying to get it to work and going though my C++ books i have so i could try editing the other code he gave which gives me no errors though it don't work.
i can put autoLayers(); and get the editor but not that button but even doing that it don't paint anything gives some errors when it trys to paint.
if you want to try to help me to get it working can talk though windowslive name is bigdog1787@att.net
#20
Send me an error log at my email -- you'll find it under my profile. Chances are you're possible putting the modification for the header in the wrong place which will cause a whole series of errors. I'm thinking that's the most likely problem because there is nothing else that needs to added to or changed for the Resource code (other than mission to world name change) to work.
The button placement could also be a little tricky, just make sure it's the last control added to the EPainterPreview section before the closing brace of the section and not the closing brace of the window control itself. Also keep in mind that the button only appears when you're in the terrain painter window and nowhere else.
11/09/2010 (5:19 am)
@Brandon:Send me an error log at my email -- you'll find it under my profile. Chances are you're possible putting the modification for the header in the wrong place which will cause a whole series of errors. I'm thinking that's the most likely problem because there is nothing else that needs to added to or changed for the Resource code (other than mission to world name change) to work.
The button placement could also be a little tricky, just make sure it's the last control added to the EPainterPreview section before the closing brace of the section and not the closing brace of the window control itself. Also keep in mind that the button only appears when you're in the terrain painter window and nowhere else.
Associate Tom Spilman
Sickhead Games
We've been talking internally about adding these sorts of limiters to the terrain painter brush. If we can do that and add a button for "Fill Layer"... it would work for both cases.
I cannot promise anything, but maybe someone here or on the GG tools team can tackle integrating this.