示例#1
0
import Blender
import bpy
from Blender import *
from Blender.Mathutils import *
from Blender import Mesh
from Blender import Object
from Blender import Material
from Blender import Mathutils
from Blender import Window, Scene, Draw

bb=[[0, -400.0, -400.0], [400.0, 400.0, 400.0]]

sc = bl.getCurrentScene()
#display fill box
fbb = bl.box('fillpBB',cornerPoints=bb) #maybe /10.
bl.addObjectToScene(sc,fbb)
#fbb = Box('fillpBB', cornerPoints=bb, visible=1)
#vi.AddObject(fbb)

# create master for extra cellular compartment
# 
bg = bl.newEmpty('extra cellular')
orgaToMasterGeom = {}
g = Geom('extra cellular', visible=0)
orgaToMasterGeom[0] = g
orgaToMasterGeom[h1] = g
bl.addObjectToScene(sc,bg)

# display organelle mesh
for orga in h1.organelles:
    # create master for organelle
radii1 = []
colors1 =[]
master = orgaToMasterGeom[h1]
print master

for pos, rot, ingr, ptInd in h1.molecules:
    level = ingr.maxLevel
    px = ingr.transformPoints(pos, rot, ingr.positions[level])
    for ii in range(len(ingr.radii[level])):
        verts1.append( px[level][ii] )
        radii1.append( ingr.radii[level][ii] *2.)
        colors1.append( ingr.color)

print len(verts1)
bg = bl.newEmpty('spheres')
bl.addObjectToScene(scn,bg)
meshsphere=Mesh.Primitives.UVsphere(int(10),int(10),1)
meshsphere.name="basesphere"
for face in meshsphere.faces: face.smooth=1
basesphere=bl.getCurrentScene().objects.new(meshsphere,"basesphere")
basesphere.restrictSelect=True

if len(verts1):
    sphs = bl.instancesSphere('spheres',verts1,radii1,meshsphere,colors1,scn,parent=bg)
    #need create all the sphere..
    #sph = Spheres('spheres', inheritMaterial=False, centers=verts1,
     #             materials=colors1, radii=radii1, visible=1)
    #vi.AddObject(sph, parent=master)

# display extra cellular meshes
meshGeoms = {}
示例#3
0
radii1 = []
colors1 = []
master = orgaToMasterGeom[h1]
print(master)

for pos, rot, ingr, ptInd in h1.molecules:
    level = ingr.maxLevel
    px = ingr.transformPoints(pos, rot, ingr.positions[level])
    for ii in range(len(ingr.radii[level])):
        verts1.append(px[level][ii])
        radii1.append(ingr.radii[level][ii] * 2.)
        colors1.append(ingr.color)

print(len(verts1))
bg = bl.newEmpty('spheres')
bl.addObjectToScene(scn, bg)
meshsphere = Mesh.Primitives.UVsphere(int(10), int(10), 1)
meshsphere.name = "basesphere"
for face in meshsphere.faces:
    face.smooth = 1
basesphere = bl.getCurrentScene().objects.new(meshsphere, "basesphere")
basesphere.restrictSelect = True

if len(verts1):
    sphs = bl.instancesSphere('spheres',
                              verts1,
                              radii1,
                              meshsphere,
                              colors1,
                              scn,
                              parent=bg)