From 7753547b701a45304f537fe26eb43773e1aea629 Mon Sep 17 00:00:00 2001 From: Willian Padovani Germano Date: Tue, 17 May 2005 19:56:29 +0000 Subject: No cvs freeze msg yet, so thought I could go with a last minute new script: Scripts: - license info for camera changer (thanks Tom for pointing), made it GPL since it's stricter and so can be "downgraded" w/o problems, but emailed the author to confirm and if necessary will fix before release. - adding Discombobulator by Evan J. Rosky (in Mesh menu): http://evan.nerdsofparadise.com/programs/discombobulator/index.html This is a fun script to play with, giving quite interesting results. It's good for that "high-tech" look in buildings, spaceships and walls. Thanks Evan for contributing it. GUI should have further updates in the future, like an added "horizontal" layout. (Note: ignore mention in its online docs of a problem with edit mode, the script was fixed.) --- release/scripts/bpymodules/BPyMathutils.py | 123 +++ release/scripts/bpymodules/defaultdoodads.py | 694 +++++++++++++++ release/scripts/camera_changer.py | 22 + release/scripts/discombobulator.py | 1229 ++++++++++++++++++++++++++ 4 files changed, 2068 insertions(+) create mode 100644 release/scripts/bpymodules/BPyMathutils.py create mode 100644 release/scripts/bpymodules/defaultdoodads.py create mode 100644 release/scripts/discombobulator.py (limited to 'release') diff --git a/release/scripts/bpymodules/BPyMathutils.py b/release/scripts/bpymodules/BPyMathutils.py new file mode 100644 index 00000000000..dd402b66a8c --- /dev/null +++ b/release/scripts/bpymodules/BPyMathutils.py @@ -0,0 +1,123 @@ +# $Id$ +# +# -------------------------------------------------------------------------- +# helper functions to be used by other scripts +# -------------------------------------------------------------------------- +# ***** BEGIN GPL LICENSE BLOCK ***** +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# ***** END GPL LICENCE BLOCK ***** +# -------------------------------------------------------------------------- + +import Blender +from Blender.Mathutils import * + +# ------ Mersenne Twister - start + +# Copyright (C) 1997 Makoto Matsumoto and Takuji Nishimura. +# Any feedback is very welcome. For any question, comments, +# see http://www.math.keio.ac.jp/matumoto/emt.html or email +# matumoto@math.keio.ac.jp + +# The link above is dead, this is the new one: +# http://www.math.sci.hiroshima-u.ac.jp/m-mat/MT/emt.html +# And here the license info, from Mr. Matsumoto's site: +# Until 2001/4/6, MT had been distributed under GNU Public License, +# but after 2001/4/6, we decided to let MT be used for any purpose, including +# commercial use. 2002-versions mt19937ar.c, mt19937ar-cok.c are considered +# to be usable freely. +# +# So from the year above (1997), this code is under GPL. + +# Period parameters +N = 624 +M = 397 +MATRIX_A = 0x9908b0dfL # constant vector a +UPPER_MASK = 0x80000000L # most significant w-r bits +LOWER_MASK = 0x7fffffffL # least significant r bits + +# Tempering parameters +TEMPERING_MASK_B = 0x9d2c5680L +TEMPERING_MASK_C = 0xefc60000L + +def TEMPERING_SHIFT_U(y): + return (y >> 11) + +def TEMPERING_SHIFT_S(y): + return (y << 7) + +def TEMPERING_SHIFT_T(y): + return (y << 15) + +def TEMPERING_SHIFT_L(y): + return (y >> 18) + +mt = [] # the array for the state vector +mti = N+1 # mti==N+1 means mt[N] is not initialized + +# initializing the array with a NONZERO seed +def sgenrand(seed): + # setting initial seeds to mt[N] using + # the generator Line 25 of Table 1 in + # [KNUTH 1981, The Art of Computer Programming + # Vol. 2 (2nd Ed.), pp102] + + global mt, mti + + mt = [] + + mt.append(seed & 0xffffffffL) + for i in xrange(1, N + 1): + mt.append((69069 * mt[i-1]) & 0xffffffffL) + + mti = i +# end sgenrand + + +def genrand(): + global mt, mti + + mag01 = [0x0L, MATRIX_A] + # mag01[x] = x * MATRIX_A for x=0,1 + y = 0 + + if mti >= N: # generate N words at one time + if mti == N+1: # if sgenrand() has not been called, + sgenrand(4357) # a default initial seed is used + + for kk in xrange((N-M) + 1): + y = (mt[kk]&UPPER_MASK)|(mt[kk+1]&LOWER_MASK) + mt[kk] = mt[kk+M] ^ (y >> 1) ^ mag01[y & 0x1] + + for kk in xrange(kk, N): + y = (mt[kk]&UPPER_MASK)|(mt[kk+1]&LOWER_MASK) + mt[kk] = mt[kk+(M-N)] ^ (y >> 1) ^ mag01[y & 0x1] + + y = (mt[N-1]&UPPER_MASK)|(mt[0]&LOWER_MASK) + mt[N-1] = mt[M-1] ^ (y >> 1) ^ mag01[y & 0x1] + + mti = 0 + + y = mt[mti] + mti += 1 + y ^= TEMPERING_SHIFT_U(y) + y ^= TEMPERING_SHIFT_S(y) & TEMPERING_MASK_B + y ^= TEMPERING_SHIFT_T(y) & TEMPERING_MASK_C + y ^= TEMPERING_SHIFT_L(y) + + return ( float(y) / 0xffffffffL ) # reals + +#------ Mersenne Twister -- end diff --git a/release/scripts/bpymodules/defaultdoodads.py b/release/scripts/bpymodules/defaultdoodads.py new file mode 100644 index 00000000000..b36f285e904 --- /dev/null +++ b/release/scripts/bpymodules/defaultdoodads.py @@ -0,0 +1,694 @@ +# Default Doodad Set for Discombobulator +# by Evan J. Rosky, 2005 +# GPL- http://www.gnu.org/copyleft/gpl.html +# +# $Id$ +# -------------------------------------------------------------------------- +# ***** BEGIN GPL LICENSE BLOCK ***** +# +# Copyright (C) 2005: Evan J. Rosky +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# ***** END GPL LICENCE BLOCK ***** +# -------------------------------------------------------------------------- + + +#Run discombobulator.py, not this. + +import Blender +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() + +#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): + global seltopsonly + seltopsonly = seltops + +#Find center and orientation of doodad +def findDoodadCenter(sizeX, sizeY): + #globalizing junk + global face + global xmin + global xmax + global ymin + global ymax + global orientation + global doodadCenter + global center + global tosel + global mxmin + global mxmax + global mymin + global mymax + global tempx + global seltopsonly + + #Find the center of the face + center = Vector([0,0,0]) + for pt in face.v: + center = center + pt.co + center = 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 + + #Find Center of doodad + amtx = randnum(0.0,1.0) + amty = randnum(0.0,1.0) + thepoint = (((((txmin - txmax)*amtx + txmax) - ((tymin - tymax)*amty + tymax))*.5 + ((tymin - tymax)*amty + tymax)) - center)*2 + center + 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 + + #Find x/y equivs for whole face + ve1 = (txmin - txmax)*amtx + txmax + ve1 = ve1 - mxmax + nax = ve1.length + ve1 = (mxmin - mxmax) + nax = nax/ve1.length + + ve1 = (tymin - tymax)*amty + tymax + ve1 = ve1 - mymax + nay = ve1.length + ve1 = (mymin - mymax) + nay = nay/ve1.length + + #Find new box thing + tempx = [] + amtx = nax-sizeX/2 + amty = nay-sizeY/2 + tempx.append((((((mxmin - mxmax)*amtx + mxmax) - ((mymin - mymax)*amty + mymax))*.5 + ((mymin - mymax)*amty + mymax)) - center)*2 + center) + + amtx = nax-sizeX/2 + amty = nay+sizeY/2 + tempx.append((((((mxmin - mxmax)*amtx + mxmax) - ((mymin - mymax)*amty + mymax))*.5 + ((mymin - mymax)*amty + mymax)) - center)*2 + center) + + amtx = nax+sizeX/2 + amty = nay+sizeY/2 + tempx.append((((((mxmin - mxmax)*amtx + mxmax) - ((mymin - mymax)*amty + mymax))*.5 + ((mymin - mymax)*amty + mymax)) - center)*2 + center) + + amtx = nax+sizeX/2 + amty = nay-sizeY/2 + 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 + +#Make a point +def makePoint(x,y,z=0): + global xmin + global xmax + global ymin + global ymax + global doodadCenter + global tosel + global seltopsonly + global face + + amtx = x + amty = y + thepoint = (((((xmin - xmax)*amtx + xmax) - ((ymin - ymax)*amty + ymax))*.5 + ((ymin - ymax)*amty + ymax)) - doodadCenter)*2 + doodadCenter + thepoint = thepoint + z*Vector(face.no) + tver = Vert(thepoint[0],thepoint[1],thepoint[2]) + if tosel == 1 and seltopsonly == 0 and z == 0: + tver.sel = 1 + return tver + +#extrude ground-plane(s) +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 + 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 + doodadMesh.faces.append(face) + + return topVArray + +#For switching face vertices +def fixvertindex(ind): + if ind > 3: + indx = ind - 4 + else: + indx = ind + return indx + +#runs doodads +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))) + + 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 + +#Single Box Doodad +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 + doodadMesh.faces.append(face) + +#Double Box Doodad +def doubleBox(facel, Xsize, Ysize, height): + #globaling junk + global face + global tosel + global doodadMesh + + face = Face() + face = facel + + findDoodadCenter(Xsize, Ysize) + + vertArray = [] + + #place first box + vertArray.append(makePoint(0,0)) + vertArray.append(makePoint(0,1)) + vertArray.append(makePoint(0.45,1)) + vertArray.append(makePoint(0.45,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 + doodadMesh.faces.append(face) + + vertArray = [] + + #place second box + vertArray.append(makePoint(0.55,0)) + vertArray.append(makePoint(0.55,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 + doodadMesh.faces.append(face) + +#Triple Box Doodad +def tripleBox(facel, Xsize, Ysize, height): + #globaling junk + global face + global tosel + global doodadMesh + + face = Face() + face = facel + + findDoodadCenter(Xsize, Ysize) + + vertArray = [] + + #place first box + vertArray.append(makePoint(0,0)) + vertArray.append(makePoint(0,1)) + vertArray.append(makePoint(0.3,1)) + vertArray.append(makePoint(0.3,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 + doodadMesh.faces.append(face) + + vertArray = [] + + #place second box + vertArray.append(makePoint(0.35,0)) + vertArray.append(makePoint(0.35,1)) + vertArray.append(makePoint(0.65,1)) + vertArray.append(makePoint(0.65,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 + doodadMesh.faces.append(face) + + vertArray = [] + + #place third box + vertArray.append(makePoint(0.7,0)) + vertArray.append(makePoint(0.7,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 + doodadMesh.faces.append(face) + +#The "L" Shape +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) + + face = Face() + face.v.extend([vertArray[0],vertArray[1],vertArray[4],vertArray[7]]) + face.v.reverse() + doodadMesh.faces.append(face) + face = Face() + face.v.extend([vertArray[1],vertArray[2],vertArray[3],vertArray[4]]) + face.v.reverse() + doodadMesh.faces.append(face) + face = Face() + face.v.extend([vertArray[4],vertArray[5],vertArray[6],vertArray[7]]) + face.v.reverse() + doodadMesh.faces.append(face) + + face = Face() + face.v.extend([topVertArray[0],topVertArray[1],topVertArray[4],topVertArray[7]]) + if tosel == 1: + face.sel = 1 + doodadMesh.faces.append(face) + face = Face() + face.v.extend([topVertArray[1],topVertArray[2],topVertArray[3],topVertArray[4]]) + if tosel == 1: + face.sel = 1 + doodadMesh.faces.append(face) + face = Face() + face.v.extend([topVertArray[4],topVertArray[5],topVertArray[6],topVertArray[7]]) + if tosel == 1: + face.sel = 1 + doodadMesh.faces.append(face) + +#The "T" Shape +def TShape(facel, Xsize, Ysize, height): + #globaling junk + global face + global tosel + global doodadMesh + + face = Face() + face = facel + + findDoodadCenter(Xsize, Ysize) + + rcony = randnum(0.25,0.75) + rconx1 = randnum(0.1,0.49) + rconx2 = randnum(0.51,0.9) + + vertArray = [] + + #place T shape + vertArray.append(makePoint(0,0)) + vertArray.append(makePoint(0,rcony)) + vertArray.append(makePoint(rconx1,rcony)) + vertArray.append(makePoint(rconx1,1)) + vertArray.append(makePoint(rconx2,1)) + vertArray.append(makePoint(rconx2,rcony)) + vertArray.append(makePoint(1,rcony)) + vertArray.append(makePoint(1,0)) + vertArray.append(makePoint(rconx2,0)) + vertArray.append(makePoint(rconx1,0)) + topVertArray = extrudedoodad(vertArray,height) + + face = Face() + face.v.extend([vertArray[0],vertArray[1],vertArray[2],vertArray[9]]) + face.v.reverse() + doodadMesh.faces.append(face) + face = Face() + face.v.extend([vertArray[2],vertArray[3],vertArray[4],vertArray[5]]) + face.v.reverse() + doodadMesh.faces.append(face) + face = Face() + face.v.extend([vertArray[5],vertArray[6],vertArray[7],vertArray[8]]) + face.v.reverse() + doodadMesh.faces.append(face) + face = Face() + face.v.extend([vertArray[8],vertArray[9],vertArray[2],vertArray[5]]) + face.v.reverse() + doodadMesh.faces.append(face) + + face = Face() + face.v.extend([topVertArray[0],topVertArray[1],topVertArray[2],topVertArray[9]]) + if tosel == 1: + face.sel = 1 + doodadMesh.faces.append(face) + face = Face() + face.v.extend([topVertArray[2],topVertArray[3],topVertArray[4],topVertArray[5]]) + if tosel == 1: + face.sel = 1 + doodadMesh.faces.append(face) + face = Face() + face.v.extend([topVertArray[5],topVertArray[6],topVertArray[7],topVertArray[8]]) + if tosel == 1: + face.sel = 1 + doodadMesh.faces.append(face) + face = Face() + face.v.extend([topVertArray[8],topVertArray[9],topVertArray[2],topVertArray[5]]) + if tosel == 1: + face.sel = 1 + doodadMesh.faces.append(face) + +#The "S" or "Z" Shapes +def SShape(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 S shape + vertArray.append(makePoint(0,0)) + vertArray.append(makePoint(0,rcony1)) + vertArray.append(makePoint(rconx1,rcony1)) + vertArray.append(makePoint(rconx1,rcony2)) + vertArray.append(makePoint(rconx1,1)) + vertArray.append(makePoint(rconx2,1)) + vertArray.append(makePoint(1,1)) + vertArray.append(makePoint(1,rcony2)) + vertArray.append(makePoint(rconx2,rcony2)) + vertArray.append(makePoint(rconx2,rcony1)) + vertArray.append(makePoint(rconx2,0)) + vertArray.append(makePoint(rconx1,0)) + topVertArray = extrudedoodad(vertArray,height) + + face = Face() + face.v.extend([vertArray[0],vertArray[1],vertArray[2],vertArray[11]]) + face.v.reverse() + doodadMesh.faces.append(face) + face = Face() + face.v.extend([vertArray[2],vertArray[9],vertArray[10],vertArray[11]]) + face.v.reverse() + doodadMesh.faces.append(face) + face = Face() + face.v.extend([vertArray[2],vertArray[3],vertArray[8],vertArray[9]]) + face.v.reverse() + doodadMesh.faces.append(face) + face = Face() + face.v.extend([vertArray[3],vertArray[4],vertArray[5],vertArray[8]]) + face.v.reverse() + doodadMesh.faces.append(face) + face = Face() + face.v.extend([vertArray[5],vertArray[6],vertArray[7],vertArray[8]]) + face.v.reverse() + doodadMesh.faces.append(face) + + face = Face() + face.v.extend([topVertArray[0],topVertArray[1],topVertArray[2],topVertArray[11]]) + if tosel == 1: + face.sel = 1 + doodadMesh.faces.append(face) + face = Face() + face.v.extend([topVertArray[2],topVertArray[9],topVertArray[10],topVertArray[11]]) + if tosel == 1: + face.sel = 1 + doodadMesh.faces.append(face) + face = Face() + face.v.extend([topVertArray[2],topVertArray[3],topVertArray[8],topVertArray[9]]) + if tosel == 1: + face.sel = 1 + doodadMesh.faces.append(face) + face = Face() + face.v.extend([topVertArray[3],topVertArray[4],topVertArray[5],topVertArray[8]]) + if tosel == 1: + face.sel = 1 + doodadMesh.faces.append(face) + face = Face() + face.v.extend([topVertArray[5],topVertArray[6],topVertArray[7],topVertArray[8]]) + if tosel == 1: + face.sel = 1 + doodadMesh.faces.append(face) + +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) + + face = Face() + face.v.extend([vertArray[0],vertArray[1],vertArray[10],vertArray[11]]) + face.v.reverse() + doodadMesh.faces.append(face) + face = Face() + face.v.extend([vertArray[1],vertArray[2],vertArray[3],vertArray[10]]) + face.v.reverse() + doodadMesh.faces.append(face) + face = Face() + face.v.extend([vertArray[3],vertArray[4],vertArray[9],vertArray[10]]) + face.v.reverse() + doodadMesh.faces.append(face) + face = Face() + face.v.extend([vertArray[4],vertArray[7],vertArray[8],vertArray[9]]) + face.v.reverse() + doodadMesh.faces.append(face) + face = Face() + face.v.extend([vertArray[4],vertArray[5],vertArray[6],vertArray[7]]) + face.v.reverse() + doodadMesh.faces.append(face) + + face = Face() + face.v.extend([topVertArray[0],topVertArray[1],topVertArray[10],topVertArray[11]]) + if tosel == 1: + face.sel = 1 + doodadMesh.faces.append(face) + face = Face() + face.v.extend([topVertArray[1],topVertArray[2],topVertArray[3],topVertArray[10]]) + if tosel == 1: + face.sel = 1 + doodadMesh.faces.append(face) + face = Face() + face.v.extend([topVertArray[3],topVertArray[4],topVertArray[9],topVertArray[10]]) + if tosel == 1: + face.sel = 1 + doodadMesh.faces.append(face) + face = Face() + face.v.extend([topVertArray[4],topVertArray[7],topVertArray[8],topVertArray[9]]) + if tosel == 1: + face.sel = 1 + doodadMesh.faces.append(face) + face = Face() + face.v.extend([topVertArray[4],topVertArray[5],topVertArray[6],topVertArray[7]]) + if tosel == 1: + face.sel = 1 + doodadMesh.faces.append(face) + diff --git a/release/scripts/camera_changer.py b/release/scripts/camera_changer.py index fe08c6d6338..a117f635a11 100644 --- a/release/scripts/camera_changer.py +++ b/release/scripts/camera_changer.py @@ -35,6 +35,28 @@ you can choose if you want to rename or overwrite it. # $Id$ # +# -------------------------------------------------------------------------- +# ***** BEGIN GPL LICENSE BLOCK ***** +# +# Copyright (C) 2004-2005: Regis Montoya +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# ***** END GPL LICENCE BLOCK ***** +# -------------------------------------------------------------------------- + #Script in the same idea that this one : #http://jmsoler.free.fr/didacticiel/blender/tutor/cpl_changerdecamera.htm # diff --git a/release/scripts/discombobulator.py b/release/scripts/discombobulator.py new file mode 100644 index 00000000000..1128c51c731 --- /dev/null +++ b/release/scripts/discombobulator.py @@ -0,0 +1,1229 @@ +#!BPY + +""" +Name: 'Discombobulator' +Blender: 236 +Group: 'Mesh' +Tip: 'Adds random geometry to a mesh' +""" + +__author__ = "Evan J. Rosky (syrux)" +__url__ = ("Script's homepage, http://evan.nerdsofparadise.com/programs/discombobulator/index.html") +__version__ = "236" +__bpydoc__ = """\ +Discombobulator adds random geometry to a mesh. + +As an example, this script can easily give a "high-tech" +look to walls and spaceships. + +Definitions:
+ - Protrusions: extrusions of each original face on the mesh. +You may have from 1 to 4 protrusions on each face.
+ - Taper: The tips of each protrusion will be a percentage +smaller than the base.
+ - Doodads: small extruded blocks/shapes that are randomly placed +about the top of a protrusion or face. + + +Usage:
+ Input your settings, make sure the mesh you would like to modify +is selected (active) and then click on "Discombobulate". + +Notes:
+ - Modifications can be restricted to selected faces +by setting "Only selected faces" for protrusions and/or +doodads.
+ - It's possible to restrict mesh generation to add only +protrusions or only doodads instead of both.
+ - You may also choose to have Discombobulator select the +tops of created protrusions by clicking the corresponding +number of protrusion buttons under "Select Tops". You may +also do the same for doodads by choosing "Select Doodads" and +"Only Select Tops". You may choose to select the whole doodads +by leaving "Only Select Tops" off.
+ - By selecting "Deselect Selected" you can have +discombobulator deselect everything but the selections it +makes.
+ - The "Face %" option will set the percentage of faces that +will be modified either for the doodads or the protrusions.
+ - "Copy Before Modifying" will create a new object with the +modifications where leaving it off will overwrite the original +mesh.
+ +You can find more information at the Link above. +""" + + +# $Id$ +# +# -------------------------------------------------------------------------- +# Discombobulator v5.3.5.406893.potato +# by Evan J. Rosky, 2005 +# This plugin is protected by the GPL: Gnu Public Licence +# GPL - http://www.gnu.org/copyleft/gpl.html +# -------------------------------------------------------------------------- +# ***** BEGIN GPL LICENSE BLOCK ***** +# +# Copyright (C) 2005: Evan J. Rosky +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# ***** END GPL LICENCE BLOCK ***** +# -------------------------------------------------------------------------- + +#Hit Alt-P to run + +import Blender +from Blender import NMesh,Object,Material,Window +from Blender.NMesh import Vert,Face +from Blender.Mathutils import * + +import defaultdoodads +import BPyMathutils +from BPyMathutils import genrand +a = BPyMathutils.sgenrand(int(round(Rand(1000,99999),0))) + +#Create random numbers +def randnum(low,high): + num = genrand() + num = num*(high-low) + num = num+low + return num + + +origmesh = NMesh.GetRaw() +newmesh = NMesh.GetRaw() +origobj = Object.Get() +newobj = Object.Get() + +#Global Vars +makenewobj = 1 +errortext = "Remember to select an object." +editmode = 0 + +#Protrusion Vars +makeprots = 1 +faceschangedpercent = 1.0 +minimumheight = 0.2 +maximumheight = 0.4 +subface1 = 1 +subface2 = 1 +subface3 = 1 +subface4 = 1 +subfaceArray = [1,2,3,4] +minsubfaces = 1 +minimumtaperpercent = 0.15 +maximumtaperpercent = 0.35 +useselectedfaces = 0 +selectface1 = 1 +selectface2 = 1 +selectface3 = 1 +selectface4 = 1 +deselface = 1 +#vertselected = 0 + +#Doodad Vars +makedoodads = 1 +doodadfacepercent = 1.0 +selectdoodad = 0 +onlyonprotrusions = 0 +doodonselectedfaces = 0 +selectdoodadtoponly = 0 +doodad1 = 1 +doodad2 = 1 +doodad3 = 1 +doodad4 = 1 +doodad5 = 1 +doodad6 = 1 +doodadminperface = 2 +doodadmaxperface = 6 +doodadminsize = 0.15 +doodadmaxsize = 0.45 +doodadminheight = 0.0 +doodadmaxheight = 0.1 +doodadArray = [1,2,3,4,5,6] + +SEL = NMesh.FaceFlags['SELECT'] + +def isselectedface(theface): + for vertic in theface.v: + if vertic.sel == 0: + return 0 + return 1 + +def makeSubfaceArray(): + global subfaceArray + global subface1 + global subface2 + global subface3 + global subface4 + + subfaceArray = [] + if subface1 > 0: + subfaceArray.append(1) + if subface2 > 0: + subfaceArray.append(2) + if subface3 > 0: + subfaceArray.append(3) + if subface4 > 0: + subfaceArray.append(4) + +def makeDoodadArray(): + global doodadArray + global doodad1 + global doodad2 + global doodad3 + global doodad4 + global doodad5 + global doodad6 + + doodadArray = [] + if doodad1 > 0: + doodadArray.append(1) + if doodad2 > 0: + doodadArray.append(2) + if doodad3 > 0: + doodadArray.append(3) + if doodad4 > 0: + doodadArray.append(4) + if doodad5 > 0: + doodadArray.append(5) + if doodad6 > 0: + doodadArray.append(6) + +def copyObjStuff(startObj,endObj): + endObj.setDeltaLocation(startObj.getDeltaLocation()) + endObj.setDrawMode(startObj.getDrawMode()) + endObj.setDrawType(startObj.getDrawType()) + endObj.setEuler(startObj.getEuler()) + if(startObj.getIpo() != None): + endObj.setIpo(startObj.getIpo()) + endObj.setLocation(startObj.getLocation()) + endObj.setMaterials(startObj.getMaterials()) + endObj.setMatrix(startObj.getMatrix()) + endObj.setSize(startObj.getSize()) + endObj.setTimeOffset(startObj.getTimeOffset()) + + +def extrude(mid,nor,protrusion,v1,v2,v3,v4,tosel=1,flipnor=0): + taper = 1 - randnum(minimumtaperpercent,maximumtaperpercent) + + vert = newmesh.verts[v1] + point = (vert.co - mid)*taper + mid + protrusion*Vector(nor) + ver = Vert(point[0],point[1],point[2]) + ver.sel = tosel + newmesh.verts.append(ver) + vert = newmesh.verts[v2] + point = (vert.co - mid)*taper + mid + protrusion*Vector(nor) + ver = Vert(point[0],point[1],point[2]) + ver.sel = tosel + newmesh.verts.append(ver) + vert = newmesh.verts[v3] + point = (vert.co - mid)*taper + mid + protrusion*Vector(nor) + ver = Vert(point[0],point[1],point[2]) + ver.sel = tosel + newmesh.verts.append(ver) + vert = newmesh.verts[v4] + point = (vert.co - mid)*taper + mid + protrusion*Vector(nor) + ver = Vert(point[0],point[1],point[2]) + ver.sel = tosel + newmesh.verts.append(ver) + + faceindex = len(newmesh.verts) - 4 + + #face 1 + face = Face() + face.v.append(newmesh.verts[v1]) + face.v.append(newmesh.verts[v2]) + face.v.append(newmesh.verts[faceindex+1]) + face.v.append(newmesh.verts[faceindex]) + if flipnor != 0: + face.v.reverse() + newmesh.faces.append(face) + + #face 2 + face = Face() + face.v.append(newmesh.verts[v2]) + face.v.append(newmesh.verts[v3]) + face.v.append(newmesh.verts[faceindex+2]) + face.v.append(newmesh.verts[faceindex+1]) + if flipnor != 0: + face.v.reverse() + newmesh.faces.append(face) + + #face 3 + face = Face() + face.v.append(newmesh.verts[v3]) + face.v.append(newmesh.verts[v4]) + face.v.append(newmesh.verts[faceindex+3]) + face.v.append(newmesh.verts[faceindex+2]) + if flipnor != 0: + face.v.reverse() + newmesh.faces.append(face) + + #face 4 + face = Face() + face.v.append(newmesh.verts[v4]) + face.v.append(newmesh.verts[v1]) + face.v.append(newmesh.verts[faceindex]) + face.v.append(newmesh.verts[faceindex+3]) + if flipnor != 0: + face.v.reverse() + newmesh.faces.append(face) + + face = Face() + face.v = newmesh.verts[-4:] + if flipnor != 0: + face.v.reverse() + if tosel == 1: + face.sel = 1 + newmesh.faces.append(face) + return face + +def discombobulate(p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,g0,d0,d1,d2,d3,d4,d5,d6,d7,d8,d9,d10,d11,d12,d13,d14,d15,d16,d17): + + #Global + global origmesh + global newmesh + global makenewobj + global origobj + global newobj + global messagetext + global errortext + global editmode + + #Protrusions + global makeprots + global minimumtaperpercent + global maximumtaperpercent + global faceschangedpercent + global minimumheight + global maximumheight + global subface1 + global subface2 + global subface3 + global subface4 + global useselectedfaces + global selectface1 + global selectface2 + global selectface3 + global selectface4 + global deselface + #global vertselected + global subfaceArray + + #Doodads + global makedoodads + global doodadfacepercent + global selectdoodad + global onlyonprotrusions + global doodad1 + global doodad2 + global doodad3 + global doodad4 + global doodad5 + global doodad6 + global doodadminperface + global doodadmaxperface + global doodadminsize + global doodadmaxsize + global doodadminheight + global doodadmaxheight + global doodadArray + global doodonselectedfaces + global selectdoodadtoponly + + #Global + try: + origobj = Object.GetSelected()[0] + except: + glRasterPos2d(10,50) + errortext = "YOU MUST SELECT AN OBJECT!" + messagetext = ErrorText(errortext) + Blender.Redraw() + return + + #Leave Editmode + editmode = Window.EditMode() + if editmode: Window.EditMode(0) + + newobj = Object.Get() + origmesh = origobj.getData() + newmesh = NMesh.GetRaw() + newmesh.verts = [] + makenewobj = g0 + + #Protrusions + makeprots = p0 + faceschangedpercent = p1 + minimumheight = p2 + maximumheight = p3 + subface1 = p4 + subface2 = p5 + subface3 = p6 + subface4 = p7 + minimumtaperpercent = p8 + maximumtaperpercent = p9 + useselectedfaces = p10 + selectface1 = p11 + selectface2 = p12 + selectface3 = p13 + selectface4 = p14 + deselface = p15 + makeSubfaceArray() + if len(subfaceArray) == 0: + makeprots = 0 + + + #Doodads + makedoodads = d0 + doodadfacepercent = d1 + selectdoodad = d2 + onlyonprotrusions = d3 + doodad1 = d4 + doodad2 = d5 + doodad3 = d6 + doodad4 = d7 + doodad5 = d8 + doodad6 = d9 + doodadminperface = d10 + doodadmaxperface = d11 + doodadminsize = d12 + doodadmaxsize = d13 + doodadminheight = d14 + doodadmaxheight = d15 + doodonselectedfaces = d16 + selectdoodadtoponly = d17 + makeDoodadArray() + if len(doodadArray) == 0: + makedoodads = 0 + defaultdoodads.topsonly(selectdoodadtoponly) + + if minimumheight > maximumheight: + glColor3f(1.0,0.0,0.0) + glRasterPos2d(10,50) + errortext = "MIN HEIGHT MUST BE LESS THAN OR EQUAL TO MAX HEIGHT!" + messagetext = ErrorText(errortext) + Blender.Redraw() + return + elif minimumtaperpercent > maximumtaperpercent: + glColor3f(1.0,0.0,0.0) + glRasterPos2d(10,50) + errortext = "MIN TAPER MUST BE LESS THAN OR EQUAL TO MAX TAPER!" + messagetext = ErrorText(errortext) + Blender.Redraw() + return + elif doodadminperface > doodadmaxperface: + glColor3f(1.0,0.0,0.0) + glRasterPos2d(10,50) + errortext = "MIN NUMBER OF DOODADS MUST BE LESS THAN OR EQUAL TO MAX!" + messagetext = ErrorText(errortext) + Blender.Redraw() + return + elif doodadminsize > doodadmaxsize: + glColor3f(1.0,0.0,0.0) + glRasterPos2d(10,50) + errortext = "MIN DOODAD SIZE MUST BE LESS THAN OR EQUAL TO MAX!" + messagetext = ErrorText(errortext) + Blender.Redraw() + return + elif doodadminheight > doodadmaxheight: + glColor3f(1.0,0.0,0.0) + glRasterPos2d(10,50) + errortext = "MIN DOODAD HEIGHT MUST BE LESS THAN OR EQUAL TO MAX!" + messagetext = ErrorText(errortext) + Blender.Redraw() + return + + newmesh.verts.extend(origmesh.verts) + + for currface in origmesh.faces: + + #Check if it is a triangle + if len(currface.v)<4: + face = Face() + face.v.extend([newmesh.verts[currface.v[0].index],newmesh.verts[currface.v[1].index],newmesh.verts[currface.v[2].index]]) + newmesh.faces.append(face) + continue + + #Check whether or not to make protrusions + if makeprots == 0: + face = Face() + face.v.extend([newmesh.verts[currface.v[0].index],newmesh.verts[currface.v[1].index],newmesh.verts[currface.v[2].index],newmesh.verts[currface.v[3].index]]) + newmesh.faces.append(face) + if makedoodads == 1 and onlyonprotrusions == 0: + if doodonselectedfaces == 1: + if currface.sel: + tempmesh = NMesh.GetRaw() + tempmesh = defaultdoodads.createDoodad(doodadArray,face, doodadminsize, doodadmaxsize, doodadminheight,doodadmaxheight, selectdoodad, doodadminperface, doodadmaxperface, doodadfacepercent) + newmesh.verts.extend(tempmesh.verts) + newmesh.faces.extend(tempmesh.faces) + else: + tempmesh = NMesh.GetRaw() + tempmesh = defaultdoodads.createDoodad(doodadArray,face, doodadminsize, doodadmaxsize, doodadminheight,doodadmaxheight, selectdoodad, doodadminperface, doodadmaxperface, doodadfacepercent) + newmesh.verts.extend(tempmesh.verts) + newmesh.faces.extend(tempmesh.faces) + continue + + #Check if only changing selected faces + if useselectedfaces == 1: + #check if currface is selected + if currface.sel: + a = 1 + else: + face = Face() + face.v.extend([newmesh.verts[currface.v[0].index],newmesh.verts[currface.v[1].index],newmesh.verts[currface.v[2].index],newmesh.verts[currface.v[3].index]]) + newmesh.faces.append(face) + if makedoodads == 1 and onlyonprotrusions == 0: + if doodonselectedfaces != 1: + tempmesh = NMesh.GetRaw() + tempmesh = defaultdoodads.createDoodad(doodadArray,face, doodadminsize, doodadmaxsize, doodadminheight,doodadmaxheight, selectdoodad, doodadminperface, doodadmaxperface, doodadfacepercent) + newmesh.verts.extend(tempmesh.verts) + newmesh.faces.extend(tempmesh.faces) + continue + #Check if face should be modified by random chance + if randnum(0,1)>faceschangedpercent: + face = Face() + face.v.extend([newmesh.verts[currface.v[0].index],newmesh.verts[currface.v[1].index],newmesh.verts[currface.v[2].index],newmesh.verts[currface.v[3].index]]) + newmesh.faces.append(face) + if makedoodads == 1 and onlyonprotrusions == 0: + if doodonselectedfaces == 1: + if currface.sel: + tempmesh = NMesh.GetRaw() + tempmesh = defaultdoodads.createDoodad(doodadArray,face, doodadminsize, doodadmaxsize, doodadminheight,doodadmaxheight, selectdoodad, doodadminperface, doodadmaxperface, doodadfacepercent) + newmesh.verts.extend(tempmesh.verts) + newmesh.faces.extend(tempmesh.faces) + else: + tempmesh = NMesh.GetRaw() + tempmesh = defaultdoodads.createDoodad(doodadArray,face, doodadminsize, doodadmaxsize, doodadminheight,doodadmaxheight, selectdoodad, doodadminperface, doodadmaxperface, doodadfacepercent) + newmesh.verts.extend(tempmesh.verts) + newmesh.faces.extend(tempmesh.faces) + continue + + center = Vector([0,0,0]) + for pt in currface.v: + center = center + pt.co + center = center/len(currface.v) + + #Determine amount of subfaces + subfaces = round(randnum(1,len(subfaceArray)),0) + subfaces = subfaceArray[(int(subfaces) - 1)] + + if subfaces == 1: + prot = randnum(minimumheight,maximumheight) + tempface = extrude(center,currface.no,prot,currface.v[0].index,currface.v[1].index,currface.v[2].index,currface.v[3].index,selectface1) + if makedoodads == 1: + if doodonselectedfaces == 1: + if currface.sel: + tempmesh = NMesh.GetRaw() + tempmesh = defaultdoodads.createDoodad(doodadArray, tempface, doodadminsize, doodadmaxsize, doodadminheight,doodadmaxheight, selectdoodad, doodadminperface, doodadmaxperface, doodadfacepercent) + newmesh.verts.extend(tempmesh.verts) + newmesh.faces.extend(tempmesh.faces) + else: + tempmesh = NMesh.GetRaw() + tempmesh = defaultdoodads.createDoodad(doodadArray, tempface, doodadminsize, doodadmaxsize, doodadminheight,doodadmaxheight, selectdoodad, doodadminperface, doodadmaxperface, doodadfacepercent) + newmesh.verts.extend(tempmesh.verts) + newmesh.faces.extend(tempmesh.faces) + + elif subfaces == 2: + orientation = int(round(randnum(0,1))) + p1 = currface.v[orientation] + p2 = currface.v[orientation + 1] + p3 = (p2.co - p1.co)/2 + p1.co + ve1 = Vert(p3[0],p3[1],p3[2]) + ve1.sel = 0 + p1 = currface.v[2 + orientation] + if orientation < 0.5: + p2 = currface.v[3] + else: + p2 = currface.v[0] + p3 = (p2.co - p1.co)/2 + p1.co + ve2 = Vert(p3[0],p3[1],p3[2]) + ve2.sel = 0 + if orientation < 0.5: + verti = currface.v[3] + p3 = verti.index + v1 = p3 + verti = currface.v[0] + p0 = verti.index + v2 = p0 + else: + verti = currface.v[0] + p0 = verti.index + v1 = p0 + verti = currface.v[1] + p1 = verti.index + v2 = p1 + newmesh.verts.append(ve1) + newmesh.verts.append(ve2) + index = len(newmesh.verts) - 2 + v4 = index + 1 + v3 = index + center = Vector([0, 0, 0]) + for pt in [newmesh.verts[v1],newmesh.verts[v2],newmesh.verts[v3],newmesh.verts[v4]]: + center = center + pt.co + center = center/4 + prot = randnum(minimumheight,maximumheight) + tempface = extrude(center,currface.no,prot,v1,v2,v3,v4,selectface2) + if makedoodads == 1: + if doodonselectedfaces == 1: + if currface.sel: + tempmesh = NMesh.GetRaw() + tempmesh = defaultdoodads.createDoodad(doodadArray, tempface, doodadminsize, doodadmaxsize, doodadminheight,doodadmaxheight, selectdoodad, doodadminperface, doodadmaxperface, doodadfacepercent) + newmesh.verts.extend(tempmesh.verts) + newmesh.faces.extend(tempmesh.faces) + else: + tempmesh = NMesh.GetRaw() + tempmesh = defaultdoodads.createDoodad(doodadArray, tempface, doodadminsize, doodadmaxsize, doodadminheight,doodadmaxheight, selectdoodad, doodadminperface, doodadmaxperface, doodadfacepercent) + newmesh.verts.extend(tempmesh.verts) + newmesh.faces.extend(tempmesh.faces) + if orientation < 0.5: + verti = currface.v[1] + p1 = verti.index + v1 = p1 + verti = currface.v[2] + p2 = verti.index + v2 = p2 + else: + verti = currface.v[2] + p2 = verti.index + v1 = p2 + verti = currface.v[3] + p3 = verti.index + v2 = p3 + center = Vector([0]*3) + for pt in [newmesh.verts[v1],newmesh.verts[v2],newmesh.verts[v3],newmesh.verts[v4]]: + center = center + pt.co + center = center/4 + prot = randnum(minimumheight,maximumheight) + tempface = extrude(center,currface.no,prot,v1,v2,v4,v3,selectface2) + if makedoodads == 1: + if doodonselectedfaces == 1: + if currface.sel: + tempmesh = NMesh.GetRaw() + tempmesh = defaultdoodads.createDoodad(doodadArray, tempface, doodadminsize, doodadmaxsize, doodadminheight,doodadmaxheight, selectdoodad, doodadminperface, doodadmaxperface, doodadfacepercent) + newmesh.verts.extend(tempmesh.verts) + newmesh.faces.extend(tempmesh.faces) + else: + tempmesh = NMesh.GetRaw() + tempmesh = defaultdoodads.createDoodad(doodadArray, tempface, doodadminsize, doodadmaxsize, doodadminheight,doodadmaxheight, selectdoodad, doodadminperface, doodadmaxperface, doodadfacepercent) + newmesh.verts.extend(tempmesh.verts) + newmesh.faces.extend(tempmesh.faces) + if orientation < 0.5: + face = Face() + face.v.extend([newmesh.verts[p0],newmesh.verts[p1],newmesh.verts[v3]]) + newmesh.faces.append(face) + face = Face() + face.v.extend([newmesh.verts[p2],newmesh.verts[p3],newmesh.verts[v4]]) + newmesh.faces.append(face) + else: + face = Face() + face.v.extend([newmesh.verts[p1],newmesh.verts[p2],newmesh.verts[v3]]) + newmesh.faces.append(face) + face = Face() + face.v.extend([newmesh.verts[p3],newmesh.verts[p0],newmesh.verts[v4]]) + newmesh.faces.append(face) + + elif subfaces == 3: + layer2inds = [] + layer2verts = [] + orientation = int(round(randnum(0,1))) + rotation = int(round(randnum(0,1))) + p1 = currface.v[orientation] + p2 = currface.v[orientation + 1] + p3 = (p2.co - p1.co)/2 + p1.co + ve1 = Vert(p3[0],p3[1],p3[2]) + ve1.sel = 0 + p1 = currface.v[2 + orientation] + if orientation < 0.5: + p2 = currface.v[3] + else: + p2 = currface.v[0] + p3 = (p2.co - p1.co)/2 + p1.co + ve2 = Vert(p3[0],p3[1],p3[2]) + ve2.sel = 0 + fp = [] + + #make first protrusion + if rotation < 0.5: + if orientation < 0.5: + verti = currface.v[3] + fp.append(verti.index) + v1 = verti.index + verti = currface.v[0] + fp.append(verti.index) + v2 = verti.index + layer2verts.extend([newmesh.verts[currface.v[1].index],newmesh.verts[currface.v[2].index]]) + else: + verti = currface.v[0] + fp.append(verti.index) + v1 = verti.index + verti = currface.v[1] + fp.append(verti.index) + v2 = verti.index + layer2verts.extend([newmesh.verts[currface.v[2].index],newmesh.verts[currface.v[3].index]]) + newmesh.verts.append(ve1) + newmesh.verts.append(ve2) + index = len(newmesh.verts) - 2 + v4 = index + 1 + v3 = index + center = Vector([0]*3) + for pt in [newmesh.verts[v1],newmesh.verts[v2],newmesh.verts[v3],newmesh.verts[v4]]: + center = center + pt.co + center = center/4 + prot = randnum(minimumheight,maximumheight) + layer2inds.extend([v3,v4]) + tempface = extrude(center,currface.no,prot,v1,v2,v3,v4,selectface3) + if makedoodads == 1: + if doodonselectedfaces == 1: + if currface.sel: + tempmesh = NMesh.GetRaw() + tempmesh = defaultdoodads.createDoodad(doodadArray, tempface, doodadminsize, doodadmaxsize, doodadminheight,doodadmaxheight, selectdoodad, doodadminperface, doodadmaxperface, doodadfacepercent) + newmesh.verts.extend(tempmesh.verts) + newmesh.faces.extend(tempmesh.faces) + else: + tempmesh = NMesh.GetRaw() + tempmesh = defaultdoodads.createDoodad(doodadArray, tempface, doodadminsize, doodadmaxsize, doodadminheight,doodadmaxheight, selectdoodad, doodadminperface, doodadmaxperface, doodadfacepercent) + newmesh.verts.extend(tempmesh.verts) + newmesh.faces.extend(tempmesh.faces) + #Still first protrusion + else: + if orientation < 0.5: + verti = currface.v[1] + fp.append(verti.index) + v1 = verti.index + verti = currface.v[2] + fp.append(verti.index) + v2 = verti.index + layer2verts.extend([newmesh.verts[currface.v[0].index],newmesh.verts[currface.v[3].index]]) + else: + verti = currface.v[2] + fp.append(verti.index) + v1 = verti.index + verti = currface.v[3] + fp.append(verti.index) + v2 = verti.index + layer2verts.extend([newmesh.verts[currface.v[1].index],newmesh.verts[currface.v[0].index]]) + newmesh.verts.append(ve2) + newmesh.verts.append(ve1) + index = len(newmesh.verts) - 2 + v4 = index + v3 = index + 1 + center = Vector([0]*3) + for pt in [newmesh.verts[v1],newmesh.verts[v2],newmesh.verts[v3],newmesh.verts[v4]]: + center = center + pt.co + center = center/4 + prot = randnum(minimumheight,maximumheight) + layer2inds.extend([index, index +1]) + tempface = extrude(center,currface.no,prot,v1,v2,v4,v3,selectface3) + if makedoodads == 1: + if doodonselectedfaces == 1: + if currface.sel: + tempmesh = NMesh.GetRaw() + tempmesh = defaultdoodads.createDoodad(doodadArray, tempface, doodadminsize, doodadmaxsize, doodadminheight,doodadmaxheight, selectdoodad, doodadminperface, doodadmaxperface, doodadfacepercent) + newmesh.verts.extend(tempmesh.verts) + newmesh.faces.extend(tempmesh.faces) + else: + tempmesh = NMesh.GetRaw() + tempmesh = defaultdoodads.createDoodad(doodadArray, tempface, doodadminsize, doodadmaxsize, doodadminheight,doodadmaxheight, selectdoodad, doodadminperface, doodadmaxperface, doodadfacepercent) + newmesh.verts.extend(tempmesh.verts) + newmesh.faces.extend(tempmesh.faces) + + #split next rect(pre-arranged, no orientation crud)--make flag in extruder for only one existing vert in mesh + p1 = newmesh.verts[layer2inds[0]] + p2 = newmesh.verts[layer2inds[1]] + p3 = (p2.co - p1.co)/2 + p1.co + ve3 = Vert(p3[0],p3[1],p3[2]) + ve3.sel = 0 + p1 = layer2verts[0] + p2 = layer2verts[1] + p3 = (p2.co - p1.co)/2 + p1.co + ve4 = Vert(p3[0],p3[1],p3[2]) + ve4.sel = 0 + newmesh.verts.append(ve3) + newmesh.verts.append(ve4) + tempindex = len(newmesh.verts) - 2 + v5 = tempindex + v6 = tempindex + 1 + verti = layer2verts[0] + t0 = verti.index + center = Vector([0]*3) + for pt in [newmesh.verts[v5],newmesh.verts[v6],newmesh.verts[t0],newmesh.verts[v3]]: + center = center + pt.co + center = center/4 + prot = randnum(minimumheight,maximumheight) + if rotation < 0.5: flino = 1 + else: flino = 0 + tempface = extrude(center,currface.no,prot,v3,v5,v6,t0,selectface3,flino) + if makedoodads == 1: + if doodonselectedfaces == 1: + if currface.sel: + tempmesh = NMesh.GetRaw() + tempmesh = defaultdoodads.createDoodad(doodadArray, tempface, doodadminsize, doodadmaxsize, doodadminheight,doodadmaxheight, selectdoodad, doodadminperface, doodadmaxperface, doodadfacepercent) + newmesh.verts.extend(tempmesh.verts) + newmesh.faces.extend(tempmesh.faces) + tempmesh = NMesh.GetRaw() + tempmesh = defaultdoodads.createDoodad(doodadArray, tempface, doodadminsize, doodadmaxsize, doodadminheight,doodadmaxheight, selectdoodad, doodadminperface, doodadmaxperface, doodadfacepercent) + newmesh.verts.extend(tempmesh.verts) + newmesh.faces.extend(tempmesh.faces) + if rotation < 0.5: + face = Face() + fpt = t0 + face.v.extend([newmesh.verts[fp[1]],newmesh.verts[fpt],newmesh.verts[v3]]) + newmesh.faces.append(face) + else: + face = Face() + fpt = t0 + face.v.extend([newmesh.verts[fp[0]],newmesh.verts[v3],newmesh.verts[fpt]]) + newmesh.faces.append(face) + verti = layer2verts[1] + tempindex = verti.index + center = Vector([0]*3) + for pt in [newmesh.verts[v5],newmesh.verts[v6],newmesh.verts[tempindex],newmesh.verts[v4]]: + center = center + pt.co + center = center/4 + prot = randnum(minimumheight,maximumheight) + tempface = extrude(center,currface.no,prot,v6,v5,v4,tempindex,selectface3,flino) + if makedoodads == 1: + if doodonselectedfaces == 1: + if currface.sel: + tempmesh = NMesh.GetRaw() + tempmesh = defaultdoodads.createDoodad(doodadArray, tempface, doodadminsize, doodadmaxsize, doodadminheight,doodadmaxheight, selectdoodad, doodadminperface, doodadmaxperface, doodadfacepercent) + newmesh.verts.extend(tempmesh.verts) + newmesh.faces.extend(tempmesh.faces) + else: + tempmesh = NMesh.GetRaw() + tempmesh = defaultdoodads.createDoodad(doodadArray, tempface, doodadminsize, doodadmaxsize, doodadminheight,doodadmaxheight, selectdoodad, doodadminperface, doodadmaxperface, doodadfacepercent) + newmesh.verts.extend(tempmesh.verts) + newmesh.faces.extend(tempmesh.faces) + if rotation < 0.5: + face = Face() + face.v.extend([newmesh.verts[tempindex],newmesh.verts[fp[0]],newmesh.verts[v4]]) + newmesh.faces.append(face) + face = Face() + face.v.extend([newmesh.verts[fpt],newmesh.verts[tempindex],newmesh.verts[v6]]) + newmesh.faces.append(face) + else: + face = Face() + face.v.extend([newmesh.verts[tempindex],newmesh.verts[v4],newmesh.verts[fp[1]]]) + newmesh.faces.append(face) + face = Face() + face.v.extend([newmesh.verts[tempindex],newmesh.verts[fpt],newmesh.verts[v6]]) + newmesh.faces.append(face) + + else: + #get all points + verti = currface.v[0] + p0 = verti.index + + verti = currface.v[1] + p1 = verti.index + + pt = (newmesh.verts[p1].co - newmesh.verts[p0].co)/2 + newmesh.verts[p0].co + v1 = Vert(pt[0],pt[1],pt[2]) + v1.sel = 0 + + verti = currface.v[2] + p2 = verti.index + + pt = (newmesh.verts[p2].co - newmesh.verts[p1].co)/2 + newmesh.verts[p1].co + v2 = Vert(pt[0],pt[1],pt[2]) + v2.sel = 0 + + verti = currface.v[3] + p3 = verti.index + + pt = (newmesh.verts[p3].co - newmesh.verts[p2].co)/2 + newmesh.verts[p2].co + v3 = Vert(pt[0],pt[1],pt[2]) + v3.sel = 0 + + pt = (newmesh.verts[p0].co - newmesh.verts[p3].co)/2 + newmesh.verts[p3].co + v4 = Vert(pt[0],pt[1],pt[2]) + v4.sel = 0 + + pt = (v3.co - v1.co)/2 + v1.co + m = Vert(pt[0],pt[1],pt[2]) + m.sel = 0 + + #extrusion 1 + newmesh.verts.extend([v1,m,v4]) + index = len(newmesh.verts) - 3 + v1 = index + m = index + 1 + v4 = index + 2 + center = Vector([0]*3) + for pt in [newmesh.verts[p0],newmesh.verts[v1],newmesh.verts[m],newmesh.verts[v4]]: + center = center + pt.co + center = center/4 + prot = randnum(minimumheight,maximumheight) + tempface = extrude(center,currface.no,prot,p0,v1,m,v4,selectface4) + if makedoodads == 1: + if doodonselectedfaces == 1: + if currface.sel: + tempmesh = NMesh.GetRaw() + tempmesh = defaultdoodads.createDoodad(doodadArray, tempface, doodadminsize, doodadmaxsize, doodadminheight,doodadmaxheight, selectdoodad, doodadminperface, doodadmaxperface, doodadfacepercent) + newmesh.verts.extend(tempmesh.verts) + newmesh.faces.extend(tempmesh.faces) + else: + tempmesh = NMesh.GetRaw() + tempmesh = defaultdoodads.createDoodad(doodadArray, tempface, doodadminsize, doodadmaxsize, doodadminheight,doodadmaxheight, selectdoodad, doodadminperface, doodadmaxperface, doodadfacepercent) + newmesh.verts.extend(tempmesh.verts) + newmesh.faces.extend(tempmesh.faces) + + #extrusion 2 + newmesh.verts.extend([v2]) + index = len(newmesh.verts) - 1 + v2 = index + center = Vector([0]*3) + for pt in [newmesh.verts[m],newmesh.verts[v1],newmesh.verts[p1],newmesh.verts[v2]]: + center = center + pt.co + center = center/4 + prot = randnum(minimumheight,maximumheight) + tempface = extrude(center,currface.no,prot,m,v1,p1,v2,selectface4) + if makedoodads == 1: + if doodonselectedfaces == 1: + if currface.sel: + tempmesh = NMesh.GetRaw() + tempmesh = defaultdoodads.createDoodad(doodadArray, tempface, doodadminsize, doodadmaxsize, doodadminheight,doodadmaxheight, selectdoodad, doodadminperface, doodadmaxperface, doodadfacepercent) + newmesh.verts.extend(tempmesh.verts) + newmesh.faces.extend(tempmesh.faces) + else: + tempmesh = NMesh.GetRaw() + tempmesh = defaultdoodads.createDoodad(doodadArray, tempface, doodadminsize, doodadmaxsize, doodadminheight,doodadmaxheight, selectdoodad, doodadminperface, doodadmaxperface, doodadfacepercent) + newmesh.verts.extend(tempmesh.verts) + newmesh.faces.extend(tempmesh.faces) + + #extrusion 3 + newmesh.verts.extend([v3]) + index = len(newmesh.verts) - 1 + v3 = index + center = Vector([0]*3) + for pt in [newmesh.verts[m],newmesh.verts[v2],newmesh.verts[p2],newmesh.verts[v3]]: + center = center + pt.co + center = center/4 + prot = randnum(minimumheight,maximumheight) + tempface = extrude(center,currface.no,prot,m,v2,p2,v3,selectface4) + if makedoodads == 1: + if doodonselectedfaces == 1: + if currface.sel: + tempmesh = NMesh.GetRaw() + tempmesh = defaultdoodads.createDoodad(doodadArray, tempface, doodadminsize, doodadmaxsize, doodadminheight,doodadmaxheight, selectdoodad, doodadminperface, doodadmaxperface, doodadfacepercent) + newmesh.verts.extend(tempmesh.verts) + newmesh.faces.extend(tempmesh.faces) + else: + tempmesh = NMesh.GetRaw() + tempmesh = defaultdoodads.createDoodad(doodadArray, tempface, doodadminsize, doodadmaxsize, doodadminheight,doodadmaxheight, selectdoodad, doodadminperface, doodadmaxperface, doodadfacepercent) + newmesh.verts.extend(tempmesh.verts) + newmesh.faces.extend(tempmesh.faces) + + #extrusion 4 + center = Vector([0]*3) + for pt in [newmesh.verts[m],newmesh.verts[v3],newmesh.verts[p3],newmesh.verts[v4]]: + center = center + pt.co + center = center/4 + prot = randnum(minimumheight,maximumheight) + tempface = extrude(center,currface.no,prot,v4,m,v3,p3,selectface4) + if makedoodads == 1: + if doodonselectedfaces == 1: + if currface.sel: + tempmesh = NMesh.GetRaw() + tempmesh = defaultdoodads.createDoodad(doodadArray, tempface, doodadminsize, doodadmaxsize, doodadminheight,doodadmaxheight, selectdoodad, doodadminperface, doodadmaxperface, doodadfacepercent) + newmesh.verts.extend(tempmesh.verts) + newmesh.faces.extend(tempmesh.faces) + else: + tempmesh = NMesh.GetRaw() + tempmesh = defaultdoodads.createDoodad(doodadArray, tempface, doodadminsize, doodadmaxsize, doodadminheight,doodadmaxheight, selectdoodad, doodadminperface, doodadmaxperface, doodadfacepercent) + newmesh.verts.extend(tempmesh.verts) + newmesh.faces.extend(tempmesh.faces) + + face = Face() + face.v.extend([newmesh.verts[p0],newmesh.verts[p1],newmesh.verts[v1]]) + newmesh.faces.append(face) + face = Face() + face.v.extend([newmesh.verts[p1],newmesh.verts[p2],newmesh.verts[v2]]) + newmesh.faces.append(face) + face = Face() + face.v.extend([newmesh.verts[p2],newmesh.verts[p3],newmesh.verts[v3]]) + newmesh.faces.append(face) + face = Face() + face.v.extend([newmesh.verts[p3],newmesh.verts[p0],newmesh.verts[v4]]) + newmesh.faces.append(face) + + #NMesh.PutRaw(newmesh) + if deselface == 1: + for unvert in origmesh.verts: + newmesh.verts[unvert.index].sel = 0 + if makenewobj == 1: + newobj = Object.New('Mesh') + copyObjStuff(origobj,newobj) + newobj.link(newmesh) + scene = Blender.Scene.getCurrent() + scene.link(newobj) + origobj.select(0) + newobj.select(1) + else: + origobj.link(newmesh) + + #Return to Editmode if previously in it + if editmode: Window.EditMode(1) + + +####################### gui ###################### +from Blender.BGL import * +from Blender.Draw import * + +def ErrorText(errortext): + Window.WaitCursor(0) + Text(errortext) + PupMenu("ERROR: %s" % errortext.lower()) + +#Global Buttons +makenewobject = Create(makenewobj) +messagetext = Create(errortext) + +#Protrusion Buttons +doprots = Create(makeprots) +facechange = Create(faceschangedpercent*100) +minheight = Create(minimumheight) +maxheight = Create(maximumheight) +sub1 = Create(subface1) +sub2 = Create(subface2) +sub3 = Create(subface3) +sub4 = Create(subface4) +mintaper = Create(minimumtaperpercent*100) +maxtaper = Create(maximumtaperpercent*100) +useselected = Create(useselectedfaces) +selface1 = Create(selectface1) +selface2 = Create(selectface2) +selface3 = Create(selectface3) +selface4 = Create(selectface4) +deselectvertices = Create(deselface) +#selectbyverts = Create(vertselected) + +#Doodad Buttons +dodoodads = Create(makedoodads) +doodadfacechange = Create(doodadfacepercent*100) +seldoodad = Create(selectdoodad) +onprot = Create(onlyonprotrusions) +dood1 = Create(doodad1) +dood2 = Create(doodad2) +dood3 = Create(doodad3) +dood4 = Create(doodad4) +dood5 = Create(doodad5) +dood6 = Create(doodad6) +doodadminamount = Create(doodadminperface) +doodadmaxamount = Create(doodadmaxperface) +doodsizemin = Create(doodadminsize*100) +doodsizemax = Create(doodadmaxsize*100) +doodheightmin = Create(doodadminheight) +doodheightmax = Create(doodadmaxheight) +doodonselface = Create(doodonselectedfaces) +seldoodtop = Create(selectdoodadtoponly) + + +# Events +EVENT_NONE = 1 +EVENT_DISCOMBOBULATE = 2 +EVENT_EXIT = 3 + +def colorbox(x,y,xright,bottom): + glColor3f(0.75, 0.75, 0.75) + glRecti(x + 1, y + 1, xright - 1, bottom - 1) + +def draw(): + + #Protrusions + global doprots + global facechange + global minheight + global maxheight + global sub1 + global sub2 + global sub3 + global sub4 + global mintaper + global maxtaper + global useselected + global selface1 + global selface2 + global selface3 + global selface4 + global deselectvertices + #global selectbyverts + + #Doodads + global dodoodads + global doodadfacechange + global seldoodad + global onprot + global dood1 + global dood2 + global dood3 + global dood4 + global dood5 + global dood6 + global doodadminamount + global doodadmaxamount + global doodsizemin + global doodsizemax + global doodheightmin + global doodheightmax + global doodonselface + global seldoodtop + + #Global Settings + global makenewobject + global messagetext + global errortext + global EVENT_NONE,EVENT_DRAW,EVENT_EXIT + + #Height Addition, this is for changing the gui + hadd = 10 + + #Title :420high + glClearColor(0.6, 0.6, 0.6, 1.0) + glClear(GL_COLOR_BUFFER_BIT) + glColor3f(0.0,0.0,0.0) + glRasterPos2d(8, 400+hadd) + Text("Discombobulator v5.3.5.406893.potato") + + #Protrusion + colorbox(8,385+hadd,312,230+hadd) + glColor3f(0.0,0.0,0.0) + glRasterPos2d(12, 375+hadd) + Text("Protrusions:") + doprots = Toggle("Make Protrusions",EVENT_NONE,12,352+hadd,145,18,doprots.val,"Make Protrusions?") + facechange = Number("Face %: ",EVENT_NONE,162,352+hadd,145,18,facechange.val,0,100,"Percentage of faces that will grow protrusions") + useselected = Toggle("Only selected faces",EVENT_NONE,12,332+hadd,145,18,useselected.val,"If on, only selected faces will be modified") + deselectvertices = Toggle("Deselect Selected",EVENT_NONE,162,332+hadd,145,18,deselectvertices.val,"Deselects any selected vertex except for ones selected by \"Select Tops\"") + + #Protrusion properties + glColor3f(0.0,0.0,0.0) + glRasterPos2d(12, 315+hadd) + Text("Protrusion Properties:") + minheight = Number("Min Height: ",EVENT_NONE,12,292+hadd,145,18,minheight.val,-100.0,100.0,"Minimum height of any protrusion") + maxheight = Number("Max Height: ",EVENT_NONE,162,292+hadd,145,18,maxheight.val,-100.0,100.0,"Maximum height of any protrusion") + mintaper = Number("Min Taper %: ",EVENT_NONE,12,272+hadd,145,18,mintaper.val,0,100,"Minimum taper percentage of protrusion") + maxtaper = Number("Max Taper %: ",EVENT_NONE,162,272+hadd,145,18,maxtaper.val,0,100,"Maximum taper percentage of protrusion") + glRasterPos2d(19, 257+hadd) + Text("Number of protrusions:") + sub1 = Toggle("1",EVENT_NONE,12,235+hadd,34,18,sub1.val,"One Protrusion") + sub2 = Toggle("2",EVENT_NONE,48,235+hadd,34,18,sub2.val,"Two Protrusions") + sub3 = Toggle("3",EVENT_NONE,84,235+hadd,34,18,sub3.val,"Three Protrusions") + sub4 = Toggle("4",EVENT_NONE,120,235+hadd,34,18,sub4.val,"Four Protrusions") + glRasterPos2d(195, 257+hadd) + Text("Select tops of:") + selface1 = Toggle("1",EVENT_NONE,165,235+hadd,34,18,selface1.val,"Select the tip of the protrusion when it is created") + selface2 = Toggle("2",EVENT_NONE,201,235+hadd,34,18,selface2.val,"Select the tips of each protrusion when they are created") + selface3 = Toggle("3",EVENT_NONE,237,235+hadd,34,18,selface3.val,"Select the tips of each protrusion when they are created") + selface4 = Toggle("4",EVENT_NONE,273,235+hadd,34,18,selface4.val,"Select the tips of each protrusion when they are created") + + #Doodad + colorbox(8,220+hadd,312,40+hadd) + glColor3f(0.0,0.0,0.0) + glRasterPos2d(12, 210+hadd) + Text("Doodads:") + dood1 = Toggle("1 Box",EVENT_NONE,12,207+hadd-20,45,18,dood1.val,"Creates a rectangular box") + dood2 = Toggle("2 Box",EVENT_NONE,61,207+hadd-20,45,18,dood2.val,"Creates 2 side-by-side rectangular boxes") + dood3 = Toggle("3 Box",EVENT_NONE,110,207+hadd-20,45,18,dood3.val,"Creates 3 side-by-side rectangular boxes") + dood4 = Toggle("\"L\"",EVENT_NONE,164,207+hadd-20,45,18,dood4.val,"Creates a Tetris-style \"L\" shape") + dood5 = Toggle("\"T\"",EVENT_NONE,213,207+hadd-20,45,18,dood5.val,"Creates a Tetris-style \"T\" shape") + dood6 = Toggle("\"S\"",EVENT_NONE,262,207+hadd-20,45,18,dood6.val,"Creates a sort-of \"S\" or \"Z\" shape") + dodoodads = Toggle("Make Doodads",EVENT_NONE,12,165+hadd,145,18,dodoodads.val,"Make Doodads?") + doodadfacechange = Number("Face %: ",EVENT_NONE,162,165+hadd,145,18,doodadfacechange.val,0,100,"Percentage of faces that will gain doodads") + seldoodad = Toggle("Select Doodads",EVENT_NONE,12,145+hadd,145,18,seldoodad.val,"Selects doodads when they are created") + seldoodtop = Toggle("Only Select Tops",EVENT_NONE,162,145+hadd,145,18,seldoodtop.val,"Only Selects tops of doodads when\"Select Doodads\" is on") + doodonselface = Toggle("Only selected faces",EVENT_NONE,12,125+hadd,145,18,doodonselface.val,"Only create doodads on selected faces") + onprot = Toggle("Only on Protrusions",EVENT_NONE,162,125+hadd,145,18,onprot.val,"Only place doodads on protrusions") + glColor3f(0.0,0.0,0.0) + glRasterPos2d(12, 108+hadd) + Text("Doodad Properties:") + doodadminamount = Number("Min Amount: ",EVENT_NONE,12,85+hadd,145,18,doodadminamount.val,0,100,"Minimum number of doodads per face") + doodadmaxamount = Number("Max Amount: ",EVENT_NONE,162,85+hadd,145,18,doodadmaxamount.val,0,100,"Maximum number of doodads per face") + doodheightmin = Number("Min Height: ",EVENT_NONE,12,65+hadd,145,18,doodheightmin.val,0.0,100.0,"Minimum height of any doodad") + doodheightmax = Number("Max Height: ",EVENT_NONE,162,65+hadd,145,18,doodheightmax.val,0.0,100.0,"Maximum height of any doodad") + doodsizemin = Number("Min Size %: ",EVENT_NONE,12,45+hadd,145,18,doodsizemin.val,0.0,100.0,"Minimum size of any doodad in percentage of face") + doodsizemax = Number("Max Size %: ",EVENT_NONE,162,45+hadd,145,18,doodsizemax.val,0.0,100.0,"Maximum size of any doodad in percentage of face") + + #Global Parts + glColor3f(1.0,0.0,0.0) + glRasterPos2d(10,35) + messagetext = Text(errortext) + glColor3f(0.0,0.0,0.0) + makenewobject = Toggle("Copy Before Modifying",EVENT_NONE,162,10,145,18,makenewobject.val,"If selected, the original object will be copied before it is changed") + Button("Discombobulate",EVENT_DISCOMBOBULATE,12,10,100,18) + Button("Exit",EVENT_EXIT,120,10,30,18) + +def event(evt, val): + if (evt == QKEY and not val): + Exit() + +def bevent(evt): + + #Protrusions + global doprots + global facechange + global minheight + global maxheight + global sub1 + global sub2 + global sub3 + global sub4 + global mintaper + global maxtaper + global useselected + global selface1 + global selface2 + global selface3 + global selface4 + global deselectvertices + #global selectbyverts + + #Doodads + global dodoodads + global doodadfacechange + global seldoodad + global onprot + global dood1 + global dood2 + global dood3 + global dood4 + global dood5 + global dood6 + global doodadminamount + global doodadmaxamount + global doodsizemin + global doodsizemax + global doodheightmin + global doodheightmax + global doodonselface + global seldoodtop + + #Global Settings + global makenewobject + global messagetext + global errortext + global EVENT_NONE,EVENT_DRAW,EVENT_EXIT + + ######### Manages GUI events + if evt==EVENT_EXIT: + Exit() + elif evt==EVENT_DISCOMBOBULATE: + Window.WaitCursor(1) + discombobulate(doprots.val,facechange.val/100,minheight.val,maxheight.val,sub1.val,sub2.val,sub3.val,sub4.val,mintaper.val/100,maxtaper.val/100,useselected.val,selface1.val,selface2.val,selface3.val,selface4.val,deselectvertices.val,makenewobject.val,dodoodads.val,doodadfacechange.val/100,seldoodad.val,onprot.val,dood1.val,dood2.val,dood3.val,dood4.val,dood5.val,dood6.val,doodadminamount.val,doodadmaxamount.val,doodsizemin.val/100,doodsizemax.val/100,doodheightmin.val,doodheightmax.val,doodonselface.val,seldoodtop.val) + Window.WaitCursor(0) + Blender.Redraw() + +Register(draw, event, bevent) -- cgit v1.2.3