Author Topic: Spawn brick aligned to grid help  (Read 1738 times)

Im trying to make a generator for "Terrain Like" formations...

Ive looked at countless codes for teh answer...

I know:
Code: [Select]
%brick = new fxDTSBrick()
{
datablock = brick4xCubeData;
position = vectorAdd(%pos,"0 0 -1.0");
isPlanted = 1;

colorID = %obj.client.currentColor;
};

if(!isObject(BrickGroup_10103))
{
new SimGroup(BrickGroup_10103)
{
bl_id = 10103;
name = "MARBLE MAN";
};

MainBrickGroup.add(BrickGroup_10103);
}

I want to know how to spawn it in a radius aligned to a grid.....
Terragen code doesnt help me much...
Please help!

look at my terrain generator.
let me explain how these work anyway...
so you got your position
%pos
and you want to have to allign to a 4xCube Brick. Since positions go from the center, you have to use 2, since theres 2 studs from the center of a 4xCube.
Then it's just a bit of math. Basically you multiply it by two then divide it by two. Then since you round it. i still dont know why.

%x = getWord(%pos,0);
%y = getWord(%pos,1);
%z = getWord9%pos,2);
%x = mFloatLength((%x * 2) / 2,0);
%y = mFloatLength((%y * 2) / 2,0);
%z = mFloatLength((%z * 2) / 2,0);
%pos = %x SPC %y SPC %z;
« Last Edit: April 06, 2012, 10:46:55 PM by Brian Smithers »


do you want it to be a perfect circle around the player or is a box/diamond okay?

Bricks automatically align themselves to the brickgrid. If I told torque to plant a 4x cube at "440.564 525.64 467.367", a new 4x cube would appear at "440.5 525.5 467.4"

Bricks automatically align themselves to the brickgrid. If I told torque to plant a 4x cube at "440.564 525.64 467.367", a new 4x cube would appear at "440.5 525.5 467.4"
I thought torque rounded it to the nearest .5 ... But yes, it does automatically allign to the grid.

I thought torque rounded it to the nearest .5 ... But yes, it does automatically allign to the grid.

X and Y are rounded to the nearest half of a unit, and Z is rounded to the nearest sixth? of a unit.

do you want it to be a perfect circle around the player or is a box/diamond okay?

How would a perfect circle be a problem anyway? vectorDist( vec1, vec2 ).

X and Y are rounded to the nearest half of a unit, and Z is rounded to the nearest sixth? of a unit.
Not exactly, it depends on the brick. If I planted a 2x2 brick somewhere it would be placed at either n.5 or n.0. Conversely, if I planted a 1x1 brick some where it would be at either n.25 or n.75. Height also matters. A baseplate's z position will be rounded to the nearest tenth, while a cube would be rounded to the nearest fifth.

This is because the position of a brick is always it's centroid. Imagine for a second, a solid cube of invisible 1x1 plates, and you have your wrench out. Every vertical line will fall on a multiple of 0.5, and every horizontal line will fall on a multiple of 0.2. The position of the brick is not necessarily on one of these lines. For example, the four corners of a 1x1 brick could be at (0, 0), (0, 0.5), (0.5, 0), and (0.5, 0.5). The xy position of the brick in this case is (0.25, 0.25).

Not exactly, it depends on the brick. If I planted a 2x2 brick somewhere it would be placed at either n.5 or n.0. Conversely, if I planted a 1x1 brick some where it would be at either n.25 or n.75. Height also matters. A baseplate's z position will be rounded to the nearest tenth, while a cube would be rounded to the nearest fifth.

This is because the position of a brick is always it's centroid. Imagine for a second, a solid cube of invisible 1x1 plates, and you have your wrench out. Every vertical line will fall on a multiple of 0.5, and every horizontal line will fall on a multiple of 0.2. The position of the brick is not necessarily on one of these lines. For example, the four corners of a 1x1 brick could be at (0, 0), (0, 0.5), (0.5, 0), and (0.5, 0.5). The xy position of the brick in this case is (0.25, 0.25).

This kind of stuff gave me nightmares while trying to make BuildBot account for it