Datablock size problem
by Brian Carter · in Torque Game Builder · 02/26/2008 (9:38 am) · 6 replies
I'm not sure if I've stumbled on a bug, or if I've done something wrong - probably the later :)
I'm messing around with a basic puzzle game, developing it from scratch. I've created a datablock as follows:
datablock t2dSceneObjectDatablock(GemDatablock) {
Layer = "5";
Size = "9 9";
Rotation = "45";
};
Very simple, and very basic. I then attached the datablock to the "redGem" object (but none of the others) and I get the result as follows:

This shows me that the dataconfig is working due to the 45 degree rotation; however, in regards to the size it is incorrect. All of the "gems" are created at 6 x 6 - which is being displayed. The red gem through the dataconfig should be 9 x 9 and bigger than the rest.
Is this a bug, or have I done something wrong in regards to setting the size in the dataconfig?
I'm messing around with a basic puzzle game, developing it from scratch. I've created a datablock as follows:
datablock t2dSceneObjectDatablock(GemDatablock) {
Layer = "5";
Size = "9 9";
Rotation = "45";
};
Very simple, and very basic. I then attached the datablock to the "redGem" object (but none of the others) and I get the result as follows:

This shows me that the dataconfig is working due to the 45 degree rotation; however, in regards to the size it is incorrect. All of the "gems" are created at 6 x 6 - which is being displayed. The red gem through the dataconfig should be 9 x 9 and bigger than the rest.
Is this a bug, or have I done something wrong in regards to setting the size in the dataconfig?
#2
If I modify the datablock to read:
datablock t2dSceneObjectDatablock(GemDatablock) {
Class = "GemClass";
};
and then create a class script file which has:
function GemClass::onAddToScene(%this, %scenegraph)
{
%this.size = "9.0 9.0";
}
It works fine, but thats not the point :) The point is that setting the size through the datablock should work .. shouldn't it? If not then somebody needs to know about it - hence this potential bug report.
When I search on the documentation with "config datablocks" it shows:
datablock t2dSceneObjectDatablock(TestConfig)
{
Layer = 1;
Size = "100 100";
};
Anyhoo, thank you for the suggestion.
02/26/2008 (12:02 pm)
It works in TorqueScript but not in the datablock, which is why I think there is a bug.If I modify the datablock to read:
datablock t2dSceneObjectDatablock(GemDatablock) {
Class = "GemClass";
};
and then create a class script file which has:
function GemClass::onAddToScene(%this, %scenegraph)
{
%this.size = "9.0 9.0";
}
It works fine, but thats not the point :) The point is that setting the size through the datablock should work .. shouldn't it? If not then somebody needs to know about it - hence this potential bug report.
When I search on the documentation with "config datablocks" it shows:
datablock t2dSceneObjectDatablock(TestConfig)
{
Layer = 1;
Size = "100 100";
};
Anyhoo, thank you for the suggestion.
#3
You have to remember that when you rotate an object, the size will remain the same. However, in this case, the height of the object appears to be sqrt(2 * 81) = 12.72 units. Do you understand what I am getting at?
If you want the object to appear 9x9 with a 45 degree rotation, you should change the size to 6.36 x 6.36 (sqrt(81 / 2)).
02/26/2008 (3:23 pm)
Brian, I think the size of the object is being applied. I copied the image to Photoshop, rotated one of the red blocks by 45 degrees and it was the same size as the others.You have to remember that when you rotate an object, the size will remain the same. However, in this case, the height of the object appears to be sqrt(2 * 81) = 12.72 units. Do you understand what I am getting at?
If you want the object to appear 9x9 with a 45 degree rotation, you should change the size to 6.36 x 6.36 (sqrt(81 / 2)).
#4
Unfortunately I dont have the source code version of TGB right now, so I cant investigate this further like I normally would.
02/26/2008 (4:04 pm)
The 45 degree rotation was to proove the point that my datablock was assigned correctly to the red square. All of the squares that arn't rotated are size 6.5. If I take the rotation off of the red block and just leave the size="9 9" on the datablock is remains 6.5 square like all of the other blocks. The size in the datablock isnt working, but in a class script file it is.Unfortunately I dont have the source code version of TGB right now, so I cant investigate this further like I normally would.
#5
I suspect that you are overriding the size change somewhere along the line. I recommend that you follow your code using Torsion to see exactly what is happening. I know that there is no problem with datablocks setting the size of an object, or any other setting for that matter.
02/26/2008 (9:43 pm)
How do you create the red gem? Something like:%redGem = new t2dStaticSprite()
{
config = GemDatablock;
imageMap = redGemImageMap;
position = %position;
};I suspect that you are overriding the size change somewhere along the line. I recommend that you follow your code using Torsion to see exactly what is happening. I know that there is no problem with datablocks setting the size of an object, or any other setting for that matter.
#6
02/27/2008 (3:40 am)
I create the blocks inside the TGB editor and set the sizes to 6.5 width and height. The datablock then sets up a default 9 x 9, and for some reason its not picking up that default. It picks up the default for rotation as I showed in my image above so I know the datablock is active on the blocks. It just wont change the size, and I don't know why. As I also mentioned above, if I put Class="GemClass" into the datablock, and then set the size in the gemClass.cs file it sets the size correctly. It only seems to not work in the datablock for some reason.
Torque Owner Carpenter Software
$object.size = "6 6";
Carpenter Software