Author Topic: Actual size of a brick  (Read 811 times)

How do you convert a fxDTSBrick's .brickSizeX/Y/Z into Torque Units?
« Last Edit: December 28, 2013, 10:38:32 PM by 0xBRIANSMITH »

In my experience, getPosition() seems to get around the feet area. That's why you use getHackPosition() to get the position near the center.

In my experience, getPosition() seems to get around the feet area. That's why you use getHackPosition() to get the position near the center.
oh it does lol.

function fxDtsBrick::boundingBox(%brick)
{
     //%brick.getWorldBox(); does all of this, unless I'm remembering the name wrong
    //That's not the point, though, because this is just supposed to be an example.
    %data = %brick.getDatablock();
    if(%brick.getAngleID() & 1)
    { %sizeX = %data.brickSizeY / 2; %sizeY = %data.brickSizeX / 2; }
    else { %sizeX = %data.brickSizeX / 2; %sizeY = %data.brickSizeY / 2; }
    %sizeZ = %data.brickSizeZ / 5;
    return %sizeX SPC %sizeY SPC %sizeZ;   //The size of the brick in Torque units.
      //Explanation: The width and length of the brick are in studs, which are a half TU each.
     //The height, however, is in plates - if you plant down a 4x cube, you'll see it's 4 studs wide and 10 plates high.
    //Divide 4 studs by 2 studs/TU to get 2 TU, then divide 10 plates by that 2 TU to get 5 plates/TU - there's your answer.
}

EDIT: Also, don't completely overwrite your original post to ask a new question - make it clear that the first issue is solved and add a new one. Otherwise people might not be able to find the already-solved answer to their question and have to post the same exact topic again.
« Last Edit: December 29, 2013, 02:12:43 AM by Xalos »

Xalos' post is correct. You'll have to divide both X and Y by 2 (or multiply by .5) and divide Z by 5 (or multiply by .2). The reason I mention the multiplicative equivalents is because that's how much you have to add to that respective direction to move by 1 stud / plate.

//%brick.getWorldBox(); does all of this, unless I'm remembering the name wrong

Not exactly. FxDTSBrick::getWorldBox() returns 6 words, the first 3 being the -X -Y -Z corner and the last 3 being the +X +Y +Z corner.

%box = %obj.getWorldBox();
%pos = getWord(%obj.getPosition(), 0) SPC getWord(%box, 1) SPC getWord(%box, 5)


In the case of %pos, the X coordinate is centered on the brick, the Y coordinate is on the far negative side and the Z coordinate is on the top face of the brick.

Conversely, it can be used to do the same thing though:

%box = %obj.getWorldBox();
%size = vectorSub(getWords(%box, 3, 5), getWords(%box, 0, 2));