SgDecalProjector help
by Scott Peal · in · 11/28/2006 (7:46 pm) · 9 replies
Can anyone point me to the documentation on how to project a decal onto the ground using sgDecalProjector? I found this link, but it is not enough to duplicate the function they are showing in the photo http://tdn.garagegames.com/wiki/Torque/LightingSystem/Misc_Effects
About the author
Step 1) be the indie, step 2) make enough to buy a commercial license :)
#2
BTW, I found that placing the projector under the ground made it appear on the top of the ground. That's a cool feature.
Thanks again for the great help.
11/29/2006 (6:42 am)
Wow, great instructions to follow. I got it to work! Quick question, please. The decal.png that I see in my browser from the link in your post is not what I see in the game. An arrow shows up in the game.BTW, I found that placing the projector under the ground made it appear on the top of the ground. That's a cool feature.
Thanks again for the great help.
#3
11/29/2006 (6:44 am)
Does anyone know if the projected decal gets clipped when not in view of a character? I need to make long lines on the ground with it and wondering about performance.
#4
11/29/2006 (10:55 am)
Decals are always rendered, it's best to use them for simpler detail textures (like dirt, liquid, signs, ...).
#5
I am looking to create a line on the ground which shows property lines. The user can turn this on or off when needed. I thought using a decal projector showing from under the ground would work.
11/29/2006 (11:11 am)
Thanks BobTheCBuilder. Any chance you can enlighten me on how to create the decal for a decal projector? I am looking to create a line on the ground which shows property lines. The user can turn this on or off when needed. I thought using a decal projector showing from under the ground would work.
#6
One thing I thought was cool, is the fact that the decal being projected uses the same colors as the PNG file. I thought that all projected decals were just white for some reason.
11/29/2006 (2:09 pm)
I figured out what was going on. I forgot to put a semi-colon at the end of the datablock code and you have to change the name of the decal ("GlowDecal") as it was already put in TGE1.5 as part of the TLK examples. So when I selected the GlowDecal datablock in the dropdown, I was not selecting the new one I just added, but the one from the examples. Here is a copy of my code for any that wish to cut and paste into a new file.One thing I thought was cool, is the fact that the decal being projected uses the same colors as the PNG file. I thought that all projected decals were just white for some reason.
//--------------------------------------------------------------------------------------
// FUNCTION: Display a light on the ground using a Decal Projector
//
// NOTES: Make sure to call this file from the Game.cs file
//
// GLOBAL VARIABLES POSSIBLE VALUES DESCRIPTION
// $pref::Decal::decalTimeout = ""; Positive integer, 0 Sets the amount of
// Default=5 time in milliseconds
// for how long a decal
// stays in the game world
//
// $pref::Decal::maxNumDecals = ""; Positive integer, 0 Sets the maximum number
// Default=200 of decals allowed to be
// rendered in the game world
//
// $pref::decalsOn = ""; 0,1 Enables or disables decals
// Default=1 in the game world. It
// 0=false overrides the above global
// 1=true settings
//--------------------------------------------------------------------------------------
datablock DecalData(MyGlowDecal)
{
sizeX = "100"; //1.0 equals 1 world unit 'wide'
sizeY = "100"; //0.25 equals 0.25 world units 'tall'
textureName = "~/data/special/DECAL.PNG"; //This is the location of the decal file
SelfIlluminated = true; //Set to true to make it light up
LifeSpan = 1000000000; //How long this decal will stay lite up for
};
#7
The MASK can be as simple as black and white, with the white being the parts you will see.
11/29/2006 (2:52 pm)
To make a Transparent PNG open a new image in your 'art' program and if you have the option pick 'Transparent' for the background. If you wish to use an .jpg make an image MASK in gray shades and name it like: TEXTURENAME.ALPHA.JPGThe MASK can be as simple as black and white, with the white being the parts you will see.
#8
Unfortunately, I have discovered that the projected decal does not follow the contours of the ground and will not work for what I am looking for. Do you have any suggestions by chance?
11/29/2006 (5:34 pm)
Thanks Caylo. That helped a lot. Unfortunately, I have discovered that the projected decal does not follow the contours of the ground and will not work for what I am looking for. Do you have any suggestions by chance?
#9
11/29/2006 (7:02 pm)
Ah.. I have been thinking about that also.. I notice a shadow will conform to whatever it is 'projected' onto, but a shadow is not the same as a projected decal. So that is about as far as i have gotten. I recall once fiddling with the projected decals 'offset' and made it 'land' # units OFF from what it was aimed at... I cant recall what bit of code, but it is in sgDecalManager.cc someplace around where it is getting the scale set, (as i recall, im not on my programing computer).
Torque 3D Owner Caylo Gypsyblood
datablock DecalData(GlowDecal)
{
sizeX = 10;
sizeY = 10;
textureName = "~/data/DECAL.PNG";
SelfIlluminated = true;
LifeSpan = 1000000000;
}
Be sure whatever .cs file you locate this in, is being 'exec' from the game.cs script (server/scripts folder) :
exec("./decaldata.cs"); //load my decal projectors file
Also be sure you have a DECAL.PNG file or change the file name to something else.
OR you could for the reason of testing, put that data block right at the TOP of game.cs (or into any of the scripts that are already being exec-ed from the server side.)
Next once your in the mission you wish to have a projector, press F11 Then goto World Editor Creator (F4), in the lower panel to the right click the 'Mission Objects' then open 'Environment' find 'sgDecalProjector' near the end of that list. Click it, enter a name in the box that pop up, and pick a datablock where is reads 'Decal Data' Once you hit the "OK" button it will place the projector in your mission. Now move it about until the "Z" axes points to the place you want the decal projected onto. The projector by default will only work projected onto terrain or DIFF. If you wish the decal to work on a DTS i can post a bit of code that will make it possible. (or email me asking for it. )
Good luck, Projectors are fun and useful for some neat FX.
decal.png If you need one, put it in your /data folder.