I've made a little script in Python for making mathematical shapes.
Basically it helps you use a function block_type(x,y,z) which outputs block type from coordinates. The script then saves this to a MCEdit schematics-file which can be inserted into a level with MCEdit.
The core is pymclevel by codewarrior. I've only added a little bit on top of this.
Here's the script (save as mineplot.py):
"""
-- string name, function myfunc, tuple ranges ---
Work in progress: 3D function plotter for Minecraft
Made by Gommle, inspired by Voxelizer.
Contact: [email protected]
Dependencies:
pymclevel by codewarrior ( DL: http://github.com/codewarrior0/pymclevel )
numpy (DL: http://www.scipy.org/Download )
Major credits to codewarrior for making this possible.
"""
from pymclevel import *
"""
See
http://www.minecraftwiki.net/wiki/Data_values
"""
def plot(name, myfunc, ranges):
# Useful stuff
(xr, yr, zr) = ranges
w = xr[1]-xr[0] + 1 # width
h = zr[1]-zr[0] + 1 # height
l = yr[1]-yr[0] + 1 # lengt
size = (w, h, l); #NB: USES X, Z, Y
schematic = MCSchematic(shape=size, mats='Alpha');
types = {}
blocks = 0
for x in range(xr[0], xr[1]+1):
for y in range(yr[0], yr[1]+1):
for z in range(zr[0], zr[1]+1):
block_type = myfunc(x, y, z) #
if block_type != 0:
blocks += 1
schematic.setBlockAt(x - xr[0], z - zr[0], y - yr[0], block_type) #NB: USES X, Z, Y
filename = name + '.schematic'
schematic.saveToFile(filename)
print "Wrote " + str(blocks) + " blocks to " + filename
Put the folder pymclevel in the same folder as mineplot.py.
Here is an example of an advanced function, which makes a HUGE decorated torus: (save as mp_something.py in the same folder as mineplot.py)
import mineplot
from math import sqrt, pow, fabs, sin
# Variables
name = "mp_toroid_space_station" #Without file ending
R = 20 # Main radius
r = 20 # Tube radius
def myfunc(x,y,z):
btype = 0 # air is default block
# Distance from center of torus. Remove z for horizontal distance.
dist = sqrt(x**2 + y**2 + z**2)
if abs((x**2 + y**2 + z**2 + R**2 - r**2)**2 - 4*R**2*(x**2 + y**2)) < 200000:
# Z-options
if z == -4:
btype = 45 # brick
elif z == -17: # Bottom floor
btype = 2 # grass
elif z > -4: # Upper part
btype = 20 # glass
elif z < -14: # Two levels above and including bottom floor
btype = 49 # obsidian
else: # Bottom part
btype = 45 # brick
# Distance options
# Make a hollow sphere in the middle section
if dist < 10:
btype = 0 # air
else:
if z == 0: # Make a balcony in the middle of the torus
if dist < 0.5*(R+r) or (dist > 0.7*(R+r) and dist < R+r):
# From both sides, but not all the way over
if round(dist) % 4 == 0: # Every other row is gold
btype = 41 # gold
else:
btype = 20 # glass
else:
btype = 0
return btype
# Coordinate ranges
xr = [-(R+r), R+r] # Main radius + tube radius
yr = xr
zr = [-r, r] # Tube radius
ranges = [xr, yr, zr]
mineplot.plot(name, myfunc, ranges)
Oh, and a little heads up for something that is based on this: array2minecraft
Dudecon made some awesome python scripts back in the days of indev, like castle generators and other awesomeness, including the big tree's we see today in Alpha. Maybe you can contact him to allow his scripts for Alpha use...
Rollback Post to RevisionRollBack
HλLF A LIFE
(My works: Art, Music, MINECRAFT and other stuff)
p = R+G*cos(b*u)+r*cos(v)
z = G*sin(b*u)+r*sin(v)
q = a*u
x = p*cos(q)
y = p*sin(q)
Then you use x, y, and z.
It's a torus knot, so it's a tube of radius G around a curve in the surface of an invisible torus defined by:
R = radius of the ring
r = radius of the torus' tube
Since it's a trefoil knot, you have: a = 2, b = 3.
Changing these will let you get any other torus knot.
MrTorus, I don't suppose I could bother you for the MCEdit schematics for that trefoil knot?
I've been fiddling with Python for the better part of an hour now, and can't seem to make your scripts work.
It's a combination I'm sure of Python 2.6 vs Python 3.1, x64 architecture vs x86, etc.
If you could just run the script and upload the MCEdit file somewhere it would be much appreciated.
I really want to put it underground and make it a sort of maze.
Basically it helps you use a function block_type(x,y,z) which outputs block type from coordinates. The script then saves this to a MCEdit schematics-file which can be inserted into a level with MCEdit.
The core is pymclevel by codewarrior. I've only added a little bit on top of this.
Here's the script (save as mineplot.py):
Put the folder pymclevel in the same folder as mineplot.py.
Here is an example of an advanced function, which makes a HUGE decorated torus: (save as mp_something.py in the same folder as mineplot.py)
Oh, and a little heads up for something that is based on this:
array2minecraft
Here is a simpler function, which makes a toroid:
And simpler still:
A huge ball:
Another torus, a long with a sphere where the bottom half is filled with ground.
I hope you guys enjoy this
You should make it use UV-mapped textures too, based on functions. This is what my voxelizer script (also in Python) does:
But it just generates the blueprints of each layer and the previews.
MINECRAFT FACTS: BIG LIST OF WHAT NOTCH HAS ACTUALLY SAID ABOUT THE PLANNED FEATURES OF MINECRAFT
This was fun to make. Because I wrote the program entirely in interactive mode, I lost the source. Let me see if I can do it again...
"We will absolutely not keep in mind what external mapeditors will have to do to read data from the disk, that makes no sense whatsoever." - Grum
(My works: Art, Music, MINECRAFT and other stuff)
What's the equation/equations for that knot?
It's in cylindrical coordinates:
p = R+G*cos(b*u)+r*cos(v)
z = G*sin(b*u)+r*sin(v)
q = a*u
x = p*cos(q)
y = p*sin(q)
Then you use x, y, and z.
It's a torus knot, so it's a tube of radius G around a curve in the surface of an invisible torus defined by:
R = radius of the ring
r = radius of the torus' tube
Since it's a trefoil knot, you have: a = 2, b = 3.
Changing these will let you get any other torus knot.
MINECRAFT FACTS: BIG LIST OF WHAT NOTCH HAS ACTUALLY SAID ABOUT THE PLANNED FEATURES OF MINECRAFT
I've been fiddling with Python for the better part of an hour now, and can't seem to make your scripts work.
It's a combination I'm sure of Python 2.6 vs Python 3.1, x64 architecture vs x86, etc.
If you could just run the script and upload the MCEdit file somewhere it would be much appreciated.
I really want to put it underground and make it a sort of maze.
Many thanks!
It has air inside and around tho. Use the fill tool after placing it underground to remove air.
That's no moon...
Sure! heh heh... :smile.gif:
Perfect!
Thanks so much gommle.
While that does work admirably, it's a little on the big side?
I hate doing this, but again, I've been futzing with Python installs for the longest time.
I've installed every combination of Python 2.6, Python 3.1, Windows x32, and Windowsx64, and I'm still getting version errors.
At least I got past the numpy step... but still.
If any kind soul could link me to an MCEdit version of that trefoil knot that will fit inside my mountain (32x32), I would be eternally obliged.
There you go.