-
-
Save rikkimax/8595894 to your computer and use it in GitHub Desktop.
A zpm model generator for blender 2.6, No material generation present.
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 bpy | |
import random | |
from math import sin, cos | |
cubeobject = bpy.ops.mesh.primitive_cube_add | |
torusobject = bpy.ops.mesh.primitive_torus_add | |
coneobject = bpy.ops.mesh.primitive_cone_add | |
planeobject = bpy.ops.mesh.primitive_plane_add | |
resizeObject = bpy.ops.transform.resize | |
rotateObject = bpy.ops.transform.rotate | |
translateObject = bpy.ops.transform.translate | |
radialdist = 3 | |
crystalsAround = 10 | |
mainCrystalHeight = 3 | |
rInVal = 0.1 | |
crystalsAroundSize = crystalsAround - 8 | |
twopi_over = 6.28 / crystalsAround | |
xpos = 0 | |
ypos = 0 | |
zpos = 15 | |
xsize = 1.0 | |
ysize = 1.0 | |
zsize = 1.0 | |
theta = 0.0 | |
torusobject(location=(xpos, ypos, zpos + 0.35), major_radius=radialdist, minor_radius=.75, major_segments=crystalsAround) | |
resizeObject(value=(1.16, 1.16, 1)) | |
planeobject(radius=1.3, location=(xpos, ypos, zpos + 1.14)) | |
torusobject(location=(xpos, ypos, zpos - mainCrystalHeight * 1.4), major_radius=radialdist / 2, minor_radius=.5, major_segments=crystalsAround) | |
resizeObject(value=(1.16, 1.16, mainCrystalHeight * 3)) | |
while theta < 6.28: | |
x = xpos + radialdist * cos(theta) | |
y = ypos + radialdist * sin(theta) | |
z = zpos | |
random.seed(theta) | |
xrvalue = 0 | |
xraxis = (0, 0, 0) | |
if x > xpos: | |
xraxis = (0, 1, 0) | |
xrvalue = rInVal | |
elif x < xpos: | |
xraxis = (0, -1, 0) | |
xrvalue = rInVal | |
yrvalue = 0 | |
yraxis = (0, 0, 0) | |
if y < ypos: | |
yraxis = (1, 0, 0) | |
yrvalue = rInVal | |
elif y > ypos: | |
yraxis = (-1, 0, 0) | |
yrvalue = rInVal | |
x = xpos + (radialdist * 0.75) * cos(theta) | |
y = ypos + (radialdist * 0.75) * sin(theta) | |
z1 = zpos + 0.75 | |
z2 = zpos - mainCrystalHeight | |
for i in range(0, 2): | |
randNum = random.random() | |
cubeobject(location=(x, y, z1)) | |
translateObject(value=(xraxis[1] * 0.25, 0, 0)) | |
translateObject(value=(0, yraxis[0] * -0.3, 0)) | |
resizeObject(value=(1.4, 1.4, 0.4)) | |
rotateObject(value=randNum, axis=(0, 0, 1)) | |
cubeobject(location=(x, y, z2)) | |
resizeObject(value=(1, 1, mainCrystalHeight)) | |
rotateObject(value=randNum, axis=(0, 0, 1)) | |
rotateObject(value=xrvalue, axis=xraxis) | |
rotateObject(value=yrvalue, axis=yraxis) | |
for j in range(0, 2): | |
z3 = z1 - mainCrystalHeight * 2.3 | |
coneobject(location=(x, y, z3), rotation=(xraxis[2] * randNum / 2, yraxis[0] * randNum / 2, 0), radius1=crystalsAroundSize * 0.35, radius2=0.1, depth=1.5, vertices=crystalsAround) | |
rotateObject(value=3.14, axis=(1, 1, 0)) | |
translateObject(value=(xraxis[1] * randNum * j * 0.4, yraxis[0] * randNum* j * 0.4, 0)) | |
cubeobject(location=(x, y, z2 - mainCrystalHeight)) | |
translateObject(value=(xraxis[1] * -0.25, 0, 0)) | |
translateObject(value=(0, yraxis[0] * 0.3, 0)) | |
translateObject(value=(0, 0, -mainCrystalHeight / 2)) | |
resizeObject(value=(0.3, 0.3, mainCrystalHeight / 2)) | |
rotateObject(value=randNum, axis=(0, 0, 1)) | |
rotateObject(value=xrvalue, axis=xraxis) | |
rotateObject(value=yrvalue, axis=yraxis) | |
for j in range(0, 5): | |
z3 = z1 - mainCrystalHeight * 3.4 | |
coneobject(location=(x, y, z3), rotation=(xraxis[2] * randNum / 2, yraxis[0] * randNum / 2, 0), radius1=crystalsAroundSize * 0.2, radius2=0.07, depth=1, vertices=crystalsAround) | |
rotateObject(value=3.14, axis=(1, 1, 0)) | |
translateObject(value=(xraxis[1] * -1.05, yraxis[0] * 1.05, 0)) | |
x = xpos + (radialdist * 0.83) * cos(theta) | |
y = ypos + (radialdist * 0.83) * sin(theta) | |
z = zpos - mainCrystalHeight | |
cubeobject(location=(x, y, z)) | |
xrvalue *= 0.75 | |
yrvalue *= 0.75 | |
resizeObject(value=(0.5 * crystalsAroundSize, 0.5 * crystalsAroundSize, mainCrystalHeight)) | |
rotateObject(value=random.random(), axis=(0, 0, 1)) | |
rotateObject(value=xrvalue, axis=xraxis) | |
rotateObject(value=yrvalue, axis=yraxis) | |
x = xpos + (radialdist * 0.52) * cos(theta) | |
y = ypos + (radialdist * 0.52) * sin(theta) | |
z = zpos - mainCrystalHeight * 2 | |
cubeobject(location=(x, y, z)) | |
xrvalue *= 0.75 | |
yrvalue *= 0.75 | |
translateObject(value=(0, 0, -mainCrystalHeight / 2)) | |
resizeObject(value=(0.2 * crystalsAroundSize, 0.2 * crystalsAroundSize, mainCrystalHeight / 2)) | |
rotateObject(value=random.random(), axis=(0, 0, 1)) | |
rotateObject(value=xrvalue, axis=xraxis) | |
rotateObject(value=yrvalue, axis=yraxis) | |
theta += twopi_over | |
coneobject(location=(xpos, ypos, zpos - mainCrystalHeight * 3), rotation=(3.14, 0, 0), radius1=crystalsAroundSize * 0.7, radius2=0.2, depth=0.6, vertices=crystalsAround) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment