[Bf-extensions-cvs] [7ca5058] master: fix for errors, updated by teldredge > Task T38194
Brendon Murphy
noreply at git.blender.org
Mon Jul 7 14:38:21 CEST 2014
Commit: 7ca5058f00e9f115129469ebb0d93e38b502b7c0
Author: Brendon Murphy
Date: Mon Jul 7 22:37:02 2014 +1000
https://developer.blender.org/rBAC7ca5058f00e9f115129469ebb0d93e38b502b7c0
fix for errors, updated by teldredge > Task T38194
Signed-off-by: Brendon Murphy <meta.androcto1 at gmail.com>
===================================================================
M object_laplace_lightning.py
===================================================================
diff --git a/object_laplace_lightning.py b/object_laplace_lightning.py
index 60187f4..79bbd02 100644
--- a/object_laplace_lightning.py
+++ b/object_laplace_lightning.py
@@ -15,25 +15,24 @@
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# ***** END GPL LICENCE BLOCK *****
-
bl_info = {
"name": "Laplacian Lightning",
"author": "teldredge",
- "version": (0, 2, 6),
- "blender": (2, 61, 0),
+ "version": (0, 2, 7),
+ "blender": (2, 71, 0),
"location": "View3D > ToolShelf > Laplacian Lightning",
"description": "Lightning mesh generator using laplacian growth algorithm",
- "warning": "Beta/Buggy",
+ "warning": "Beta",
"wiki_url": "http://www.funkboxing.com/wordpress/?p=301",
- "tracker_url": "https://developer.blender.org/T27189",
+ "tracker_url": "http://www.funkboxing.com/wordpress/?p=301",
"category": "Object"}
-
-
+
######################################################################
######################################################################
##################### BLENDER LAPLACIAN LIGHTNING ####################
############################ teldredge ###############################
######################## www.funkboxing.com ##########################
+################# https://developer.blender.org/T27189 ###############
######################################################################
######################## using algorithm from ########################
######################################################################
@@ -46,7 +45,6 @@ bl_info = {
################ http://gamma.cs.unc.edu/FAST_LIGHTNING/ #############
######################################################################
######################################################################
-
""" -----RELEASE LOG/NOTES/PONTIFICATIONS-----
v0.1.0 - 04.11.11
basic generate functions and UI
@@ -60,7 +58,7 @@ v0.2.0 - 04.15.11
v0.2.1 - 04.16.11
mesh classification speedup
v0.2.2 - 04.21.11
- fxns to write/read array to file
+ fxns to write/read array to file
restrict growth to insulator cells (object bounding box)
origin/ground defineable by object
gridunit more like 'resolution'
@@ -69,7 +67,7 @@ v0.2.3 - 04.24.11
secondary path orders (hOrder) disabled in UI (set to 1)
v0.2.4 - 04.26.11
fixed object selection in UI
- will not run if required object not selected
+ will not run if required object not selected
moved to view 3d > toolbox
v0.2.5 - 05.08.11
testing for 2.57b
@@ -84,20 +82,25 @@ v0.2.6 - 06.20.11
must have rot=0, scale=1, origin set to geometry
often fails to block bolt with curved/complex shapes
separate single and multi mesh creation
+v0.2.7 - 01.05.13
+ fixed the issue that prevented enabling the add-on
+ fixed makeMeshCube fxn
+ disabled visualization for voxels
v0.x -
+ -prevent create_setup_objects from generating duplicates
-fix vis fxn to only buildCPGraph once for VM or VS
-improve list fxns (rid of ((x,y,z),w) and use (x,y,z,w)), use 'sets'
-create python cmodule for a few of most costly fxns
i have pretty much no idea how to do this yet
-cloud and insulator can be groups of MESH objs
- -?text output, possibly to save on interrupt, allow continue from text
+ -text output, possibly to save on interrupt, allow continue from text
-?hook modifiers from tips->sides->main, weight w/ vert groups
-user defined 'attractor' path
-fix add curve function
- -animated arcs via. ionization path
- -environment map boundary conditions - requires Eqn. 15 from FSLG...
- -?assign wattage at each segment for HDRI
+ -animated arcs via. ionization path
+ -environment map boundary conditions - requires Eqn. 15 from FSLG.
+ -assign wattage at each segment for HDRI
-?default settings for -lightning, -teslacoil, -spark/arc
-fix hOrder functionality
-multiple 'MAIN' brances for non-lightning discharges
@@ -117,6 +120,7 @@ import bisect
import os.path
notZero = 0.0000000001
#scn = bpy.context.scene
+winmgr = bpy.context.window_manager
######################################################################
########################### UTILITY FXNS #############################
@@ -159,7 +163,7 @@ def weightedRandomChoice(aList):
if weight > 0.0:
tweight += weight
tL.append((tweight, idex))
- i = bisect.bisect(tL, (random.uniform(0, tweight), None))
+ i = bisect.bisect(tL, (random.uniform(0, tweight), None))
r = tL[i][1]
return r
@@ -182,7 +186,7 @@ def jitterCells(aList, jit):
bList.append((ax, ay, az))
return bList
-def deDupe(seq, idfun=None):
+def deDupe(seq, idfun=None):
###---THANKS TO THIS GUY - http://www.peterbe.com/plog/uniqifiers-benchmark
if idfun is None:
def idfun(x): return x
@@ -215,7 +219,7 @@ def writeArrayToVoxel(arr, filename):
file.write(struct.pack('B', aGrid[x][y][z]))
file.flush()
file.close()
-
+
def writeArrayToFile(arr, filename):
file = open(filename, "w")
for a in arr:
@@ -231,7 +235,7 @@ def readArrayFromFile(filename):
arr.append((int(pt[0]), int(pt[1]), int(pt[2])))
return arr
-def makeMeshCube(msize):
+def makeMeshCube_OLD(msize):
msize = msize/2
mmesh = bpy.data.meshes.new('q')
mmesh.vertices.add(8)
@@ -253,6 +257,26 @@ def makeMeshCube(msize):
mmesh.update(calc_edges=True)
return(mmesh)
+def makeMeshCube(msize):
+ m2 = msize/2
+ #verts = [(0,0,0),(0,5,0),(5,5,0),(5,0,0),(0,0,5),(0,5,5),(5,5,5),(5,0,5)]
+ verts = [(-m2,-m2,-m2),(-m2,m2,-m2),(m2,m2,-m2),(m2,-m2,-m2),
+ (-m2,-m2,m2),(-m2,m2,m2),(m2,m2,m2),(m2,-m2,m2)]
+ faces = [(0,1,2,3), (4,5,6,7), (0,4,5,1), (1,5,6,2), (2,6,7,3), (3,7,4,0)]
+
+ #Define mesh and object
+ mmesh = bpy.data.meshes.new("Cube")
+ #mobject = bpy.data.objects.new("Cube", mmesh)
+
+ #Set location and scene of object
+ #mobject.location = bpy.context.scene.cursor_location
+ #bpy.context.scene.objects.link(mobject)
+
+ #Create mesh
+ mmesh.from_pydata(verts,[],faces)
+ mmesh.update(calc_edges=True)
+ return(mmesh)
+
def writeArrayToCubes(arr, gridBU, orig, cBOOL = False, jBOOL = True):
for a in arr:
x = a[0]; y = a[1]; z = a[2]
@@ -266,7 +290,7 @@ def writeArrayToCubes(arr, gridBU, orig, cBOOL = False, jBOOL = True):
col = (1.0, 1.0, 1.0, 1.0)
if a[3] == 0: col = (0.0, 0.0, 0.0, 1.0)
if a[3] < 0: col = (-a[3], 0.0, 0.0, 1.0)
- if a[3] > 0: col = (0.0, 0.0, a[3], 1.0)
+ if a[3] > 0: col = (0.0, 0.0, a[3], 1.0)
ob.color = col
bpy.context.scene.objects.link(ob)
bpy.context.scene.update()
@@ -295,13 +319,13 @@ def addEdge(ob, va, vb):
mmesh.edges.add(1)
ecounti = len(mmesh.edges)-1
mmesh.edges[ecounti].vertices = [va, vb]
- mmesh.update()
+ mmesh.update()
def newMesh(mname):
mmesh = bpy.data.meshes.new(mname)
omesh = bpy.data.objects.new(mname, mmesh)
bpy.context.scene.objects.link(omesh)
- return omesh
+ return omesh
def writeArrayToMesh(mname, arr, gridBU, rpt = None):
mob = newMesh(mname)
@@ -311,15 +335,15 @@ def writeArrayToMesh(mname, arr, gridBU, rpt = None):
for ai in range(1, len(arr)):
a = arr[ai]
addVert(mob, a, ai-1)
- return mob
+ return mob
###---!!!OUT OF ORDER - SOME PROBLEM WITH IT ADDING (0,0,0)
def writeArrayToCurves(cname, arr, gridBU, bd = .05, rpt = None):
cur = bpy.data.curves.new('fslg_curve', 'CURVE')
cur.use_fill_front = False
- cur.use_fill_back = False
+ cur.use_fill_back = False
cur.bevel_depth = bd
- cur.bevel_resolution = 2
+ cur.bevel_resolution = 2
cob = bpy.data.objects.new(cname, cur)
cob.scale = (gridBU, gridBU, gridBU)
if rpt: addReportProp(cob, rpt)
@@ -336,7 +360,7 @@ def writeArrayToCurves(cname, arr, gridBU, bd = .05, rpt = None):
hy = arr[a][1] - ((arr[a][1]-arr[a-1][1]) / div)
hz = arr[a][2] - ((arr[a][2]-arr[a-1][2]) / div)
hL = (hx,hy,hz)
-
+
if a+1 > len(arr)-1: hR = arr[a]
else:
hx = arr[a][0] + ((arr[a+1][0]-arr[a][0]) / div)
@@ -366,11 +390,11 @@ def writeStokeToMesh(arr, jarr, MAINi, HORDERi, TIPSi, orig, gs, rpt=None):
for x in MAINi:
llmain.append(jarr[x])
mob = writeArrayToMesh('la0MAIN', llmain, gs)
- mob.location = orig
+ mob.location = orig
###---hORDER BRANCHES
for hOi in range(len(HORDERi)):
- print(' WRITING ORDER', hOi)
+ print(' WRITING ORDER', hOi)
hO = HORDERi[hOi]
hob = newMesh('la1H'+str(hOi))
@@ -383,17 +407,17 @@ def writeStokeToMesh(arr, jarr, MAINi, HORDERi, TIPSi, orig, gs, rpt=None):
hob.location = orig
###---TIPS
- print(' WRITING TIP PATHS')
+ print(' WRITING TIP PATHS')
tob = newMesh('la2TIPS')
for y in TIPSi:
- llt = []
+ llt = []
for x in y:
llt.append(jarr[x])
addArrayToMesh(tob, llt)
tob.scale = (gs, gs, gs)
tob.location = orig
- ###---ADD MATERIALS TO OBJECTS (IF THEY EXIST)
+ ###---ADD MATERIALS TO OBJECTS (IF THEY EXIST)
try:
addMaterial(mob, 'edgeMAT-h0')
addMaterial(hob, 'edgeMAT-h1')
@@ -404,9 +428,9 @@ def writeStokeToMesh(arr, jarr, MAINi, HORDERi, TIPSi, orig, gs, rpt=None):
if rpt:
addReportProp(mob, rpt)
addReportProp(hob, rpt)
- addReportProp(tob, rpt)
+ addReportProp(tob, rpt)
-def writeStokeToSingleMesh(arr, jarr, orig, gs, mct, rpt=None):
+def writeStokeToSingleMesh(arr, jarr, orig, gs, mct, rpt=None):
sgarr = buildCPGraph(arr, mct)
llALL = []
@@ -437,17 +461,17 @@ def visualizeArray(cg, oob, gs, vm, vs, vc, vv, rst):
if vm: ###---WRITE ARRAY TO MULTI MESH
-
- aMi, aHi, aTi = classifyStroke(cg, oct, scn.HORDER)
- print(':::WRITING TO
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list