T2D: How to load your fxImageMapDatablock2D
by Dave Calabrese · 03/25/2005 (9:18 pm) · 3 comments
As soon as I first started using Torque, I always wished there was a better way to load the massive amounts of datablocks that can be needed. In T2D, it was even more-so with all the fxImageMapDatablock2D definitions required - one for every graphic in your game. However, with a little bit of thinking, I found a simple way around that which works.
Here is some example code...
Simply enough, all we are doing is defining a datablock with the name newImageMap then changing the name. To explain the need for this code, you have to realize that you cannot define a datablock's name with a variable.
Which means this following code does not work:
That code will always cause your code to not compile. You could just toss the entire declaration into the the 'eval()' function, and that will allow the code to compile, but you can get some really weird results, especially if you are using a variable for your directory location.
So there you have it! That is how to create all your datablock fxImageMapDatablock2D datablock's with just one definition. I welcome anyone to improve upon this concept!
-Dave C.
Here is some example code...
function loadMyfxImageMapDatablock2Ds()
{
for(%count = 1; %count <= %numberOfDatablocks; %count++)
{
switch(%count)
{
case 1: %imageMap = testA;
case 2: %imageMap = testB;
}
datablock fxImageMapDatablock2D(newImageMap)
{
mode = full;
textureName = %graphicsDirectory @ %imageMap;
};
newImageMap.setName(%imageMap);
}
}Simply enough, all we are doing is defining a datablock with the name newImageMap then changing the name. To explain the need for this code, you have to realize that you cannot define a datablock's name with a variable.
Which means this following code does not work:
datablock fxImageMapDatablock2D(%graphic)
That code will always cause your code to not compile. You could just toss the entire declaration into the the 'eval()' function, and that will allow the code to compile, but you can get some really weird results, especially if you are using a variable for your directory location.
So there you have it! That is how to create all your datablock fxImageMapDatablock2D datablock's with just one definition. I welcome anyone to improve upon this concept!
-Dave C.
#2
I think I will be using your tool as well, Chris.
03/26/2005 (9:02 am)
And not only did you improve upon it but you had already written a whole T2D applet that beats it... nice! =)I think I will be using your tool as well, Chris.
#3
As soon as i get that done ill submit that as a resource.
03/26/2005 (1:48 pm)
Thanks man, i just wish my server was back online (maintance), so i can upload the new version already. Im adding the ability to load an existing script file that was created by the tool, so you can add more images and editt the other ones.As soon as i get that done ill submit that as a resource.
Torque Owner Chris Newman
Introducing the T2D Image Datablock Tool
www.garagegames.com/mg/forums/result.thread.php?qt=27697
Just by a click of a button it can add all the images as the full type by default and editing a few variables any of the other types.