Author Topic: Sphere building?  (Read 902 times)

I remember a couple months ago, someone posted a link to a Blockland tutorial detailing how to build a neat sphere with bricks. Can someone provide me with such a link?




you can use the search with something like tutorial or something

Code: [Select]
function serverCmdMakeSphere(%client, %radius) {
%tempBrick = %client.player.tempBrick;
if(%radius < 2 || !isObject(%tempBrick))
return;
%offset = %tempBrick.position;
for(%i = 0; %i <= 180; %i++) {
%z = mCos(%i);
%z = mFloor(%z * %radius * 5) / 5;
if(%z == %lastZ)
continue;
else
%lastZ = %z;
%thisPlaneRadius = mSin(%i) * %radius;
for(%j = 0; %j < 360; %j++) {
%thisPlanePos = mFloor(mCos(mDegToRad(%j)) * %thisPlaneRadius * 2) / 2 SPC mFloor(mSin(mDegToRad(%j)) * %thisPlaneRadius * 2) / 2;
if(%thisPlanePos $= %lastPlanePos)
continue;
else
%lastPlanePos = %thisPlanePos;
%b = new fxDTSBrick() {
dataBlock = brick1x1fData;
position = vectorAdd(%thisPlanePos SPC %z, %offset);
isPlanted = true;
};
%client.brickGroup.add(%b);
}
}
}

Usage:
/makeSphere <radius>
generates a sphere with the radius given
It's best to fill in the inside of the generated sphere with normal bricks, and then remove the sphere as it is made out of 1x1 bricks which doesn't play nice with the brickcount.
« Last Edit: January 29, 2010, 03:54:25 PM by BobAndRob »

« Last Edit: January 29, 2010, 04:01:03 PM by Captain Crazy »

I wish people weren't so lazy.

Here, I uploaded it to mediafire.

http://www.mediafire.com/?e2v22zd2onj

Put it in your add-ons folder. I hope that goes without saying.



edit: nvm
Oh, well that's nice.
« Last Edit: January 29, 2010, 04:08:54 PM by BobAndRob »

Sorry for my lazyness, Bob :( I cleared the message because I wasn't sure if I had worded my comment correctly. Don't get me wrong, I'm grateful for the code.