Blockland Forums > General Discussion
Minecraft - MC_NO_WORLD
<< < (65/92) > >>
Destiny/Zack0Wack0:
http://dl.dropbox.com/u/551734/dev/torque/perlin.cs
+

--- Code: ---if(!isObject($perlin))
$perlin = new ScriptObject() {
class = Perlin;
};

function generate(%seed, %bg, %ox, %oy, %oz, %ix, %iy, %iz, %width, %length, %depth) {
%iters = 3;

for(%xd = 0; %xd < %width; %xd++) {
for(%yd = 0; %yd < %length; %yd++) {
for(%zd = 0; %zd < %depth; %zd++) {
%quality = 2 + %seed;
%density = 0;
%x = %ix + %xd;
%y = %iy + %yd;
%z = %iz + %zd;

for(%j = 0; %j < %iters; %j++) {
%density += $perlin.noise((%x / %seed) / %quality, (%y / %seed) / %quality, (%z / %seed) / %quality) * %quality;
%quality *= 4;
}

if(%density < 0) // air
continue;

%bx = %ox + (%x * 2);
%by = %oy + (%y * 2);
%bz = %oz + (%z * 2);
%bpos = %bx SPC %by SPC %bz;
%brick = new fxDTSBrick() {
position = %bpos;
datablock = brick4xCubeData;
isPlanted = 1;
client = %client;
colorID = 2;
};

%brick.setTrusted(1);
%brick.plant();
%bg.add(%brick);
}
}
}
}
function tweenGenerate(%seed, %bg, %ox, %oy, %oz, %gx, %gy, %width, %length, %depth) {
cancel($tweenGenerate);
generate(%seed, %bg, %ox, %oy, %oz, %gx, %gy, 0, 1, 1, %depth);

%gx++;

if(%gx == %width)
%gy++;
if(!(%gx == %width && %gy == %length)) {
if(%gx == %width)
%gx = 0;

$tweenGenerate = schedule(20, 0, tweenGenerate, %seed, %bg, %ox, %oy, %oz, %gx, %gy, %width, %length, %depth);
}
}
function serverCmdStopPerlinTest(%client) {
if(!%client.isSuperAdmin)
return;

cancel($tweenGenerate);
}
function serverCmdPerlinTest(%client, %width, %length, %depth) {
if(!%client.isSuperAdmin || !isObject(%client.player))
return;

%player = %client.player;
%pp = %player.getPosition();
%px = getWord(%pp, 0);
%py = getWord(%pp, 1);
%pz = getWord(%pp, 2);
%seed = getRandom();

tweenGenerate(%seed, %client.brickGroup, %px, %py, %pz, 0, 0, %width, %length, %depth);
}

--- End code ---
It's a bit eccentric sometimes, but lowering the octaves / making sure the perlin class is correct will fix it (this is an old version, I loss the new perlin class I had that had a bugfix).
Lugnut:
that's perlin though
isn't perlin the static one that doesn't allow minecraftian spread-as-you-go building/generating?
Destiny/Zack0Wack0:

--- Quote from: Lugnut1206 on April 13, 2012, 04:55:08 AM ---that's perlin though
isn't perlin the static one that doesn't allow minecraftian spread-as-you-go building/generating?

--- End quote ---
um.. no? Minecraft uses the exact method I just showed you. Whoever said it can't just doesn't know that you need to offset the position based on the chunk position.
Port:

--- Quote from: Destiny/Zack0Wack0 on April 13, 2012, 03:36:16 AM ---
--- End quote ---

Oh, you're z0w0? Should have guessed (Zack0Wack0).
Lugnut:

--- Quote from: Port on April 13, 2012, 06:08:26 AM ---Oh, you're z0w0? Should have guessed (Zack0Wack0).

--- End quote ---
port god damn you you gave me false information

(see my most recent post)
Navigation
Message Index
Next page
Previous page

Go to full version