示例#1
0
def singleBox(facel, Xsize, Ysize, height):
	#globaling junk
	global face
	global tosel
	global doodadMesh
	
	face = Face()
	face = facel
	
	findDoodadCenter(Xsize, Ysize)
	
	vertArray = []
	
	#place four points
	vertArray.append(makePoint(0,0))
	vertArray.append(makePoint(0,1))
	vertArray.append(makePoint(1,1))
	vertArray.append(makePoint(1,0))
	topVertArray = extrudedoodad(vertArray,height)
	
	face = Face()
	face.v.extend(vertArray)
	face.v.reverse()
	doodadMesh.faces.append(face)
	face = Face()
	face.v.extend(topVertArray)
	if tosel == 1: 
			face.sel = 1
	if thereAreMats == 1:
		if reassignMats == 0 or doodTopMat == 0:
			face.materialIndex = currmat
		else:
			face.materialIndex = doodTopMat-1
	doodadMesh.faces.append(face)
示例#2
0
def extrudedoodad(vArray,heig):
	global face
	global doodadMesh
	global tosel
	
	topVArray = []
	
	doodadMesh.verts.extend(vArray)
	
	#Create array for extruded verts
	for ind in range(0,(len(vArray))):
		point = vArray[ind].co + heig*Vector(face.no)
		ver = Vert(point[0],point[1],point[2])
		if tosel == 1:
			ver.sel = 1
		topVArray.append(ver)
		doodadMesh.verts.append(topVArray[ind])
	
	#make faces around sides
	for ind in range(0,(len(vArray) - 1)):
		face = Face()
		face.v.extend([vArray[ind],vArray[ind+1],topVArray[ind+1],topVArray[ind]])
		if tosel == 1 and seltopsonly == 0: face.sel = 1
		if thereAreMats == 1:
			if reassignMats == 0 or doodSideMat == 0:
				face.materialIndex = currmat
			else:
				face.materialIndex = doodSideMat-1
		doodadMesh.faces.append(face)
	face = Face()
	face.v.extend([vArray[len(vArray) - 1],vArray[0],topVArray[0],topVArray[len(topVArray) - 1]])
	if tosel == 1 and seltopsonly == 0: 
		face.sel = 1
	if thereAreMats == 1:
		if reassignMats == 0 or doodSideMat == 0:
			face.materialIndex = currmat
		else:
			face.materialIndex = doodSideMat-1
	doodadMesh.faces.append(face)
	
	return topVArray
示例#3
0
def createDoodad(indexArray,facec,minsi,maxsi,minhei,maxhei,selec,amtmin,amtmax,facpercent):
	global doodadMesh
	global seltopsonly
	global tosel
	
	doodadMesh = NMesh.GetRaw()
	
	theamt = round(randnum(amtmin,amtmax),0)
	theamt = int(theamt)
	tosel = selec
	
	for i in range(0,(theamt)):
		if randnum(0,1) <= facpercent:
			index = round(randnum(1,len(indexArray)),0)
			index = indexArray[(int(index) - 1)]
			
			Xsi = randnum(minsi,maxsi)
			Ysi = randnum(minsi,maxsi)
			hei = randnum(minhei,maxhei)
					
			#Determine orientation
			orient = int(round(randnum(0.0,3.0)))
			
			#face to use as range
			facer = Face()
			facer.v.extend([facec.v[orient],facec.v[fixvertindex(1+orient)],facec.v[fixvertindex(2+orient)],facec.v[fixvertindex(3+orient)]])
			
			if index == 1:
				singleBox(facer,Xsi,Ysi,hei)
			if index == 2:
				doubleBox(facer,Xsi,Ysi,hei)
			if index == 3:
				tripleBox(facer,Xsi,Ysi,hei)
			if index == 4:
				LShape(facer,Xsi,Ysi,hei)
			if index == 5:
				TShape(facer,Xsi,Ysi,hei)
			if index == 6:
				if randnum(0.0,1.0) > .5:
					SShape(facer,Xsi,Ysi,hei)
				else:
					ZShape(facer,Xsi,Ysi,hei)
	
	return doodadMesh
示例#4
0
def ZShape(facel, Xsize, Ysize, height):
	#globaling junk
	global face
	global tosel
	global doodadMesh
	
	face = Face()
	face = facel
	
	findDoodadCenter(Xsize, Ysize)
	
	rcony1 = randnum(0.1,0.49)
	rcony2 = randnum(0.51,0.9)
	rconx1 = randnum(0.1,0.49)
	rconx2 = randnum(0.51,0.9)
	
	vertArray = []
	
	#place Z shape
	vertArray.append(makePoint(0,0))
	vertArray.append(makePoint(0,rcony1))
	vertArray.append(makePoint(0,rcony2))
	vertArray.append(makePoint(rconx1,rcony2))
	vertArray.append(makePoint(rconx2,rcony2))
	vertArray.append(makePoint(rconx2,1))
	vertArray.append(makePoint(1,1))
	vertArray.append(makePoint(1,rcony2))
	vertArray.append(makePoint(1,rcony1))
	vertArray.append(makePoint(rconx2,rcony1))
	vertArray.append(makePoint(rconx1,rcony1))
	vertArray.append(makePoint(rconx1,0))
	topVertArray = extrudedoodad(vertArray,height)
	
	#fills bottom with faceness
	face = Face()
	face.v.extend([vertArray[0],vertArray[1],vertArray[10],vertArray[11]])
	face.v.reverse()
	if thereAreMats == 1:
		if reassignMats == 0 or doodTopMat == 0:
			face.materialIndex = currmat
		else:
			face.materialIndex = doodTopMat-1
	doodadMesh.faces.append(face)
	face = Face()
	face.v.extend([vertArray[1],vertArray[2],vertArray[3],vertArray[10]])
	face.v.reverse()
	if thereAreMats == 1:
		if reassignMats == 0 or doodTopMat == 0:
			face.materialIndex = currmat
		else:
			face.materialIndex = doodTopMat-1
	doodadMesh.faces.append(face)
	face = Face()
	face.v.extend([vertArray[3],vertArray[4],vertArray[9],vertArray[10]])
	face.v.reverse()
	if thereAreMats == 1:
		if reassignMats == 0 or doodTopMat == 0:
			face.materialIndex = currmat
		else:
			face.materialIndex = doodTopMat-1
	doodadMesh.faces.append(face)
	face = Face()
	face.v.extend([vertArray[4],vertArray[7],vertArray[8],vertArray[9]])
	face.v.reverse()
	if thereAreMats == 1:
		if reassignMats == 0 or doodTopMat == 0:
			face.materialIndex = currmat
		else:
			face.materialIndex = doodTopMat-1
	doodadMesh.faces.append(face)
	face = Face()
	face.v.extend([vertArray[4],vertArray[5],vertArray[6],vertArray[7]])
	face.v.reverse()
	if thereAreMats == 1:
		if reassignMats == 0 or doodTopMat == 0:
			face.materialIndex = currmat
		else:
			face.materialIndex = doodTopMat-1
	doodadMesh.faces.append(face)
	
	#fills top with faceness
	face = Face()
	face.v.extend([topVertArray[0],topVertArray[1],topVertArray[10],topVertArray[11]])
	if tosel == 1: 
			face.sel = 1
	if thereAreMats == 1:
		if reassignMats == 0 or doodTopMat == 0:
			face.materialIndex = currmat
		else:
			face.materialIndex = doodTopMat-1
	doodadMesh.faces.append(face)
	face = Face()
	face.v.extend([topVertArray[1],topVertArray[2],topVertArray[3],topVertArray[10]])
	if tosel == 1: 
			face.sel = 1
	if thereAreMats == 1:
		if reassignMats == 0 or doodTopMat == 0:
			face.materialIndex = currmat
		else:
			face.materialIndex = doodTopMat-1
	doodadMesh.faces.append(face)
	face = Face()
	face.v.extend([topVertArray[3],topVertArray[4],topVertArray[9],topVertArray[10]])
	if tosel == 1: 
			face.sel = 1
	if thereAreMats == 1:
		if reassignMats == 0 or doodTopMat == 0:
			face.materialIndex = currmat
		else:
			face.materialIndex = doodTopMat-1
	doodadMesh.faces.append(face)
	face = Face()
	face.v.extend([topVertArray[4],topVertArray[7],topVertArray[8],topVertArray[9]])
	if tosel == 1: 
			face.sel = 1
	if thereAreMats == 1:
		if reassignMats == 0 or doodTopMat == 0:
			face.materialIndex = currmat
		else:
			face.materialIndex = doodTopMat-1
	doodadMesh.faces.append(face)
	face = Face()
	face.v.extend([topVertArray[4],topVertArray[5],topVertArray[6],topVertArray[7]])
	if tosel == 1: 
			face.sel = 1
	if thereAreMats == 1:
		if reassignMats == 0 or doodTopMat == 0:
			face.materialIndex = currmat
		else:
			face.materialIndex = doodTopMat-1
	doodadMesh.faces.append(face)
示例#5
0
def LShape(facel, Xsize, Ysize, height):
	#globaling junk
	global face
	global tosel
	global doodadMesh
	
	face = Face()
	face = facel
	
	findDoodadCenter(Xsize, Ysize)
	
	rcon1 = randnum(0.2,0.8)
	rcon2 = randnum(0.2,0.8)
	
	vertArray = []
	
	#place L shape
	vertArray.append(makePoint(0,0))
	vertArray.append(makePoint(0,rcon1))
	vertArray.append(makePoint(0,1))
	vertArray.append(makePoint(rcon2,1))
	vertArray.append(makePoint(rcon2,rcon1))
	vertArray.append(makePoint(1,rcon1))
	vertArray.append(makePoint(1,0))
	vertArray.append(makePoint(rcon2,0))
	topVertArray = extrudedoodad(vertArray,height)
	
	#This fills in the bottom of doodad with faceness
	face = Face()
	face.v.extend([vertArray[0],vertArray[1],vertArray[4],vertArray[7]])
	face.v.reverse()
	if thereAreMats == 1:
		if reassignMats == 0 or doodTopMat == 0:
			face.materialIndex = currmat
		else:
			face.materialIndex = doodTopMat-1
	doodadMesh.faces.append(face)
	face = Face()
	face.v.extend([vertArray[1],vertArray[2],vertArray[3],vertArray[4]])
	face.v.reverse()
	if thereAreMats == 1:
		if reassignMats == 0 or doodTopMat == 0:
			face.materialIndex = currmat
		else:
			face.materialIndex = doodTopMat-1
	doodadMesh.faces.append(face)
	face = Face()
	face.v.extend([vertArray[4],vertArray[5],vertArray[6],vertArray[7]])
	face.v.reverse()
	if thereAreMats == 1:
		if reassignMats == 0 or doodTopMat == 0:
			face.materialIndex = currmat
		else:
			face.materialIndex = doodTopMat-1
	doodadMesh.faces.append(face)
	
	#This fills in the top with faceness
	face = Face()
	face.v.extend([topVertArray[0],topVertArray[1],topVertArray[4],topVertArray[7]])
	if tosel == 1: 
			face.sel = 1
	if thereAreMats == 1:
		if reassignMats == 0 or doodTopMat == 0:
			face.materialIndex = currmat
		else:
			face.materialIndex = doodTopMat-1
	doodadMesh.faces.append(face)
	face = Face()
	face.v.extend([topVertArray[1],topVertArray[2],topVertArray[3],topVertArray[4]])
	if tosel == 1: 
			face.sel = 1
	if thereAreMats == 1:
		if reassignMats == 0 or doodTopMat == 0:
			face.materialIndex = currmat
		else:
			face.materialIndex = doodTopMat-1
	doodadMesh.faces.append(face)
	face = Face()
	face.v.extend([topVertArray[4],topVertArray[5],topVertArray[6],topVertArray[7]])
	if tosel == 1: 
			face.sel = 1
	if thereAreMats == 1:
		if reassignMats == 0 or doodTopMat == 0:
			face.materialIndex = currmat
		else:
			face.materialIndex = doodTopMat-1
	doodadMesh.faces.append(face)
示例#6
0
from Blender import NMesh,Object,Material
from Blender.NMesh import Vert,Face
from Blender.Mathutils import *
		
import BPyMathutils
from BPyMathutils import genrand
a = BPyMathutils.sgenrand(4859)

#Create random numbers
def randnum(low,high):
	num = genrand()
	num = num*(high-low)
	num = num+low
	return num

face = Face()
xmin = Vector([0,0,0])
xmax = Vector([0,0,0])
ymin = Vector([0,0,0])
ymax = Vector([0,0,0])
mxmin = Vector([0,0,0])
mxmax = Vector([0,0,0])
mymin = Vector([0,0,0])
mymax = Vector([0,0,0])
doodadCenter = Vector([0,0,0])
orientation = 0
center = Vector([0,0,0])
tosel = 0
seltopsonly = 0
tempx = []
doodadMesh = NMesh.GetRaw()