dg = Bxyz.evald(u)
d2g = Bxyz.evald2(u)

r = Br.eval(u)[:, 1]
dr = Br.evald(u)[:, 1]

e = canal_surface(g.T, dg.T, d2g.T, r, dr, v)

verts, faces = lbu.tensor_product_mesh_vf(e[:, :, 0],
                                          e[:, :, 1],
                                          e[:, :, 2],
                                          periodv=True)

EdS = lbu.pydata_to_mesh(verts, faces, edges=None, name='EdSpropre')

lbe.set_smooth(EdS)
#EdS.show_wire = True
#EdS.show_all_edges = True
EdS.show_transparent = True

mat_EdS = bpy.data.materials.new('mat_EdS')
mat_EdS.diffuse_color = (0.527, 0.800, 0.213)
mat_EdS.diffuse_intensity = 1
mat_EdS.use_transparency = True
mat_EdS.alpha = 0.68
mat_EdS.emit = 1.0
mat_EdS.specular_intensity = 0.5
mat_EdS.specular_hardness = 30
mat_EdS.raytrace_transparency.fresnel = 2.7
mat_EdS.use_shadows = False
mat_EdS.use_cast_buffer_shadows = False
cam.data.angle += numpy.pi / 180.0  # increase FOV angle by 1 degree
bpy.ops.object.delete()
#################################################

clf = numpy.loadtxt(pthout + 'face_color.dat')
clf = lco.cc_hsv(clf, fs=1.2, fv=1.0)

tri = numpy.loadtxt(pthin + 'brepmesh/tri_' + strf + '.dat', dtype=int) - 1
xyz = numpy.loadtxt(pthin + 'brepmesh/xyz_' + strf + '.dat', dtype=float)

verts = [[x for x in p] for p in xyz]
faces = [[int(v) for v in t] for t in tri]

obj = lbu.pydata_to_mesh(verts, faces, name='face')

lbe.set_smooth(obj)

# material
mat = bpy.data.materials.new('mat_face')
mat.diffuse_color = clf[iface]
mat.diffuse_intensity = 1
mat.specular_intensity = 0
mat.specular_hardness = 30
mat.use_transparency = False
obj.data.materials.append(mat)

# make group for Freestyle
bpy.ops.object.select_all(action='DESELECT')
scene.objects.active = obj
obj.select = True
bpy.ops.group.create(name='face_group')
import lib_chebyshev as lch


lbu.clear_scene(True, True, True)

cs = lch.read_polynomial2(ROOT+'GitHub/FFTsurf/test/coeffstest/C2_test10.txt')
m = 100
u = numpy.linspace(-1, 1, m)
xyz = chebgrid2d(u, u, cs)
v, f = lbu.tensor_product_mesh_vf(xyz[0], xyz[1], xyz[2])
surf = lbu.pydata_to_mesh(
    v,
    f,
    name='surface'
)
lbe.set_smooth(surf)

hmin = 1e-3
hmax = 1
tolchord = 1e-3

N = 6
cc = (2*numpy.random.rand(N,2) - 1)/numpy.tile(numpy.arange(1,N+1)**2, (2,1)).T
cc[0,:] = 0
cc = 3*cc

xyz, uv, t = lcad.discretize_curve_on_surface(
    cc,
    cs,
    hmin,
    hmax,
nf = len(V.faces)

corners = []

for iloc, iface in enumerate(V.faces):
    strf = format(iface, '03')

    mat = bpy.data.materials.new('mat_face_' + strf)
    mat.diffuse_color = color_face[iface - 1]

    c = lcheb.read_polynomial2(pthin + 'brepmesh/c_' + strf + '.cheb')

    xyz = chebgrid2d(u, u, c)
    mverts, mfaces = lbu.tensor_product_mesh_vf(xyz[0], xyz[1], xyz[2])
    obj = lbu.pydata_to_mesh(mverts, mfaces, name='face_' + strf)
    lbe.set_smooth(obj)
    obj.data.materials.append(mat)

    # OFFSET
    c = lcheb.read_polynomial2(pthin + 'brepmesh_eos/c_' + strf + '.cheb')
    xyz = chebgrid2d(u, u, c)
    mverts, mfaces = lbu.tensor_product_mesh_vf(xyz[0], xyz[1], xyz[2])
    obj = lbu.pydata_to_mesh(mverts, mfaces, name='EdS_face_' + strf)
    lbe.set_smooth(obj)
    obj.data.materials.append(mat)

    #
    xyz = chebval2d(Vuv[iloc][0], Vuv[iloc][1], c)
    corners.append(xyz)

corner_avg = numpy.zeros(3)
示例#5
0
## Set Lighting
lbu.add_point_light(name="lamp",
                    energy=1,
                    shadow_method='RAY_SHADOW',
                    shadow_ray_samples=1,
                    shadow_soft_size=0.01,
                    location=[1.37, -1.89, 0.9])
#################################################

#################################################
bpy.ops.import_scene.obj(
    filepath='/d/bandrieu/GitHub/FFTsurf/test/demo_EoS_MAT/mesh_eos_optim.obj',
    axis_forward='Y',
    axis_up='Z')
eds = bpy.data.objects['mesh_eos_optim']
lbe.set_smooth(eds)

mat_eds = bpy.data.materials['mat1']
mat_eds.diffuse_color = (0.5, 1, 0.5)
mat_eds.diffuse_intensity = 1
mat_eds.specular_intensity = 0.2
mat_eds.specular_hardness = 30
mat_eds.use_transparency = True
mat_eds.alpha = 0.25
eds.show_transparent = True
eds.hide_render = True

bpy.ops.object.select_all(action='DESELECT')
eds.select = True
bpy.ops.view3d.camera_to_view_selected()  # set camera to fit surf in screen
cam.data.angle += numpy.pi / 180.0  # increase FOV angle by 1 degree
示例#6
0
nf = len(V.faces)

corners = []

for iloc, iface in enumerate(V.faces):
    strf = format(iface, '03')

    mat = bpy.data.materials.new('mat_face_' + strf)
    mat.diffuse_color = color_face[iface - 1]

    c = lcheb.read_polynomial2(pthin + 'brepmesh/c_' + strf + '.cheb')

    xyz = chebgrid2d(u, u, c)
    mverts, mfaces = lbu.tensor_product_mesh_vf(xyz[0], xyz[1], xyz[2])
    obj = lbu.pydata_to_mesh(mverts, mfaces, name='face_' + strf)
    lbe.set_smooth(obj)
    obj.data.materials.append(mat)

    # OFFSET
    c = lcheb.read_polynomial2(pthin + 'brepmesh_eos/c_' + strf + '.cheb')
    xyz = chebgrid2d(u, u, c)
    mverts, mfaces = lbu.tensor_product_mesh_vf(xyz[0], xyz[1], xyz[2])
    obj = lbu.pydata_to_mesh(mverts, mfaces, name='EdS_face_' + strf)
    lbe.set_smooth(obj)
    obj.data.materials.append(mat)

    #
    xyz = chebval2d(Vuv[iloc][0], Vuv[iloc][1], c)
    corners.append(xyz)

# SPHERE RADIUS
示例#7
0
colors = numpy.vstack([colorR, colorL])
cc_colors = lco.cc_hsv(colors, fs=0.9, fv=1.1)
colorR = cc_colors[0]
colorL = cc_colors[1]
################################################################

################################################################
# LOAD CURRENT INTERFACE'S MESH
bpy.ops.import_scene.obj(filepath=pthin + 'mesh/mesh.obj',
                         axis_forward='Y',
                         axis_up='Z')
surf = bpy.data.objects['mesh']
surf.name = 'surface'
# set smooth shading
lbe.set_smooth(surf)

# set materials
for slot in surf.material_slots:
    iface = int(slot.material.name[3:])
    mat = slot.material
    if iface == ifaceRL[0]:
        mat.diffuse_color = colorR
    elif iface == ifaceRL[1]:
        mat.diffuse_color = colorL
    else:
        mat.diffuse_color = (1, 1, 1)
        if True:
            mat.specular_intensity = 0
            mat.use_transparency = True
            mat.alpha = 0