Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'release/scripts/bpymodules/defaultdoodads.py')
-rw-r--r--release/scripts/bpymodules/defaultdoodads.py277
1 files changed, 262 insertions, 15 deletions
diff --git a/release/scripts/bpymodules/defaultdoodads.py b/release/scripts/bpymodules/defaultdoodads.py
index b36f285e904..987b8b8ae71 100644
--- a/release/scripts/bpymodules/defaultdoodads.py
+++ b/release/scripts/bpymodules/defaultdoodads.py
@@ -61,13 +61,35 @@ seltopsonly = 0
tempx = []
doodadMesh = NMesh.GetRaw()
+global materialArray
+global reassignMats
+global thereAreMats
+global currmat
+global doodSideMat
+global doodTopMat
+
#face is the face to add the doodad to.
#sizeX and sizeY are values from 0.0 to 1.0 that represents a percentage the face that is covered by the doodad.
#height is how tall the doodad is.
-def topsonly(seltops):
+def settings(seltops,matArr,reasMats,therMats,sidemat,topmat):
global seltopsonly
+ global materialArray
+ global reassignMats
+ global thereAreMats
+ global currmat
+ global doodSideMat
+ global doodTopMat
+ materialArray = matArr
+ reassignMats = reasMats
+ thereAreMats = therMats
seltopsonly = seltops
+ doodSideMat = sidemat
+ doodTopMat = topmat
+
+def setCurrMat(curma):
+ global currmat
+ currmat = curma
#Find center and orientation of doodad
def findDoodadCenter(sizeX, sizeY):
@@ -92,13 +114,13 @@ def findDoodadCenter(sizeX, sizeY):
center = Vector([0,0,0])
for pt in face.v:
center = center + pt.co
- center = center/len(face.v)
+ center = divideVectorByInt(center,len(face.v))
#Find Temp Location Range by looking at the sizes
- txmin = (((face.v[0].co + face.v[3].co)/2) - center)*(1-sizeX) + center
- txmax = (((face.v[1].co + face.v[2].co)/2) - center)*(1-sizeX) + center
- tymin = (((face.v[0].co + face.v[1].co)/2) - center)*(1-sizeY) + center
- tymax = (((face.v[2].co + face.v[3].co)/2) - center)*(1-sizeY) + center
+ txmin = ((divideVectorByInt((face.v[0].co + face.v[3].co),2)) - center)*(1-sizeX) + center
+ txmax = ((divideVectorByInt((face.v[1].co + face.v[2].co),2)) - center)*(1-sizeX) + center
+ tymin = ((divideVectorByInt((face.v[0].co + face.v[1].co),2)) - center)*(1-sizeY) + center
+ tymax = ((divideVectorByInt((face.v[2].co + face.v[3].co),2)) - center)*(1-sizeY) + center
#Find Center of doodad
amtx = randnum(0.0,1.0)
@@ -107,10 +129,10 @@ def findDoodadCenter(sizeX, sizeY):
doodadCenter = Vector([thepoint[0],thepoint[1],thepoint[2]])
#Find Main Range by looking at the sizes
- mxmin = (face.v[0].co + face.v[3].co)/2
- mxmax = (face.v[1].co + face.v[2].co)/2
- mymin = (face.v[0].co + face.v[1].co)/2
- mymax = (face.v[2].co + face.v[3].co)/2
+ mxmin = divideVectorByInt((face.v[0].co + face.v[3].co),2)
+ mxmax = divideVectorByInt((face.v[1].co + face.v[2].co),2)
+ mymin = divideVectorByInt((face.v[0].co + face.v[1].co),2)
+ mymax = divideVectorByInt((face.v[2].co + face.v[3].co),2)
#Find x/y equivs for whole face
ve1 = (txmin - txmax)*amtx + txmax
@@ -144,10 +166,10 @@ def findDoodadCenter(sizeX, sizeY):
tempx.append((((((mxmin - mxmax)*amtx + mxmax) - ((mymin - mymax)*amty + mymax))*.5 + ((mymin - mymax)*amty + mymax)) - center)*2 + center)
#Find New Location Range by looking at the sizes
- xmin = (tempx[0] + tempx[3])/2
- xmax = (tempx[1] + tempx[2])/2
- ymin = (tempx[0] + tempx[1])/2
- ymax = (tempx[2] + tempx[3])/2
+ xmin = divideVectorByInt((tempx[0] + tempx[3]),2)
+ xmax = divideVectorByInt((tempx[1] + tempx[2]),2)
+ ymin = divideVectorByInt((tempx[0] + tempx[1]),2)
+ ymax = divideVectorByInt((tempx[2] + tempx[3]),2)
#Make a point
def makePoint(x,y,z=0):
@@ -193,11 +215,21 @@ def extrudedoodad(vArray,heig):
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
+ 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
@@ -234,6 +266,7 @@ def createDoodad(indexArray,facec,minsi,maxsi,minhei,maxhei,selec,amtmin,amtmax,
#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)]])
@@ -255,6 +288,12 @@ def createDoodad(indexArray,facec,minsi,maxsi,minhei,maxhei,selec,amtmin,amtmax,
return doodadMesh
+def divideVectorByInt(thevect,theint):
+ thevect.x = thevect.x/theint
+ thevect.y = thevect.y/theint
+ thevect.z = thevect.z/theint
+ return thevect
+
#Single Box Doodad
def singleBox(facel, Xsize, Ysize, height):
#globaling junk
@@ -284,6 +323,11 @@ def singleBox(facel, Xsize, Ysize, height):
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)
#Double Box Doodad
@@ -315,6 +359,11 @@ def doubleBox(facel, Xsize, Ysize, height):
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)
vertArray = []
@@ -334,6 +383,11 @@ def doubleBox(facel, Xsize, Ysize, height):
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)
#Triple Box Doodad
@@ -365,6 +419,11 @@ def tripleBox(facel, Xsize, Ysize, height):
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)
vertArray = []
@@ -384,6 +443,11 @@ def tripleBox(facel, Xsize, Ysize, height):
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)
vertArray = []
@@ -403,6 +467,11 @@ def tripleBox(facel, Xsize, Ysize, height):
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)
#The "L" Shape
@@ -433,33 +502,65 @@ def LShape(facel, Xsize, Ysize, height):
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)
#The "T" Shape
@@ -493,42 +594,84 @@ def TShape(facel, Xsize, Ysize, height):
vertArray.append(makePoint(rconx1,0))
topVertArray = extrudedoodad(vertArray,height)
+ #fills bottom with faceness
face = Face()
face.v.extend([vertArray[0],vertArray[1],vertArray[2],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[2],vertArray[3],vertArray[4],vertArray[5]])
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[5],vertArray[6],vertArray[7],vertArray[8]])
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[8],vertArray[9],vertArray[2],vertArray[5]])
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[2],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[2],topVertArray[3],topVertArray[4],topVertArray[5]])
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[5],topVertArray[6],topVertArray[7],topVertArray[8]])
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[8],topVertArray[9],topVertArray[2],topVertArray[5]])
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)
#The "S" or "Z" Shapes
@@ -565,51 +708,103 @@ def SShape(facel, Xsize, Ysize, height):
vertArray.append(makePoint(rconx1,0))
topVertArray = extrudedoodad(vertArray,height)
+ #fills bottom with faceness
face = Face()
face.v.extend([vertArray[0],vertArray[1],vertArray[2],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[2],vertArray[9],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[2],vertArray[3],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[3],vertArray[4],vertArray[5],vertArray[8]])
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[5],vertArray[6],vertArray[7],vertArray[8]])
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[2],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[2],topVertArray[9],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[2],topVertArray[3],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[3],topVertArray[4],topVertArray[5],topVertArray[8]])
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[5],topVertArray[6],topVertArray[7],topVertArray[8]])
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)
def ZShape(facel, Xsize, Ysize, height):
@@ -645,50 +840,102 @@ def ZShape(facel, Xsize, Ysize, height):
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)