Created
April 3, 2015 01:03
-
-
Save thouis/ed15adbfe620c8be064b to your computer and use it in GitHub Desktop.
PLY file to minecraft world via CanaryRaspberryJuice plugin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import plyfile | |
import pylab | |
import sys | |
import mcpi.minecraft as minecraft | |
import mcpi.block as block | |
import numpy as np | |
scale = 150 | |
dat = plyfile.PlyData.read(sys.argv[1]) | |
verts = [d.data for d in dat.elements if d.name == 'vertex'][0] | |
verts = verts.view((np.float32, len(verts.dtype.names))) | |
verts = verts[:, [1, 2, 0]] | |
verts -= verts.min(axis=0) | |
verts /= verts.max() | |
verts *= scale | |
blobdim = verts.max(axis=0).astype(int) + 1 | |
blob = np.zeros(blobdim, np.uint8) | |
blob[...] = block.AIR.id | |
for i, j, k in verts.astype(int): | |
blob[i, j, k] = block.IRON_BLOCK.id | |
mc = minecraft.Minecraft.create() | |
mc.setBlocks(1, 1, 1, blobdim[2], blobdim[0], blobdim[1], blob.ravel('F')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment