Exemplo n.º 1
0
ext.Graphs2OBJ(BIGDATA+"WaterBottle.obj",Gs,"scene")
######################### SCENE 1 END

######################## SCENE 2 BEGIN
# Save CoffeeCup into new scene G,Gs to file
# "CoffeeCup.obj" as Scene 2
G = {}
G['V'] = []
G['E'] = []
G['F'] = []
G['N'] = []
G['pts'] = []
Gs = []
# coffee cup
Hcc = CoffeeCup()
ext.Graph2OBJ(BIGDATA+"CoffeeCup.obj",Hcc,"scene")
# add two obj files later to include CoffeeCup.obj
Gs = ext.Append(Gs,Hcc)
G = ext.GraphUnionS(G,Hcc)
ext.Graphs2OBJ(BIGDATA+"CoffeeCup.obj",Gs,"scene")
######################### SCENE 2 END

######################## SCENE 3 BEGIN
# Save Donut into new scene G,Gs to file
# "Donut.obj" as Scene 2
G = {}
G['V'] = []
G['E'] = []
G['F'] = []
G['N'] = []
G['pts'] = []
#G = ext.GraphUnionS(G,H3)

ext.Graphs2OBJ("WaterBottle.obj",Gs,"scene")
f_ = open("WaterBottle.obj",'r')
txt = f_.read()
f_.close()
G_small = ext.OBJ2Graph(txt)

degrees = 0
axis = [0,1,0]
q = aff.HH.rotation_quaternion(degrees,axis[0],axis[1],axis[2])
scale = .1
s = [scale,scale,scale] # the same scale as previous for caps
t = [0.,0.,0.]
pts = G_small['pts']
q = aff.HH.rotation_quaternion(degrees,axis[0],axis[1],axis[2])
C = aff.Center(pts)
pts = aff.Translate(pts,-C[0],-C[1],-C[2],align=False)
pts = aff.Rotate(pts,q,align=False)
pts = aff.Scale(pts, s[0],s[1],s[2],align=False)
pts = aff.Translate(pts,t[0],t[1],t[2],align=False)
G_small['pts'] = pts

G_coffee = deepcopy(G_small)

ext.Graph2OBJ("CoffeeCup.obj",G_coffee,"scene")

import os
print "Open WaterBottle_small.obj with 3D Viewer by double-clicking on it"
os.system("CoffeeCup.obj")
    q = aff.HH.rotation_quaternion(degrees, axis[0], axis[1], axis[2])
    s = [20, 20, 20]  # the same scale as previous for caps
    t = [20, 0, 0]
    pts = aff.Translate(path, -C[0], -C[1], -C[2], align=False)
    pts = aff.Rotate(pts, q, align=False)
    pts = aff.Scale(pts, s[0], s[1], s[2], align=False)
    pts = aff.Translate(pts, t[0], t[1], t[2], align=False)
    path = pts
    #path = [[0,0,0],[10,1,0],[20,4,0],[30,9,0]]
    H = ext.Extrusion0(doc1, path, spath)
    return H


G = {}
G['V'] = []
G['E'] = []
G['F'] = []
G['N'] = []
G['pts'] = []
Gs = []

#H = ext.TreefoilKnot()
H = WaterBottle()
Gs = ext.Append(Gs, H)
G = ext.GraphUnionS(G, H)

ext.Graph2OBJ(BIGDATA + "WaterBottle-0.obj", G, "scene")
import os
print("Open WaterBottle.obj with 3D Viewer by double-clicking on it")
os.system(BIGDATA + "WaterBottle-0.obj")
Exemplo n.º 4
0
BIGDATA = r"C:/_BigData/_3D/my_scenes/"

G = {}
G['V'] = []
G['E'] = []
G['F'] = []
G['N'] = []
G['pts'] = []
Gs = []

w, h, d = 10, 10, 10
degrees = 90
axis = [0, 0, 1]
q = ext.aff.HH.rotation_quaternion(degrees, axis[0], axis[1], axis[2])
t = [-50, 0, 0]
s = [1, 1, 1]
G2 = ext.CubeObj(w, h, d, t, q, s)
Gs = ext.Append(Gs, G2)
G = ext.GraphUnionS(G, G2)

#H = Parabola()
H = ext.TrefoilKnot()
Gs = ext.Append(Gs, H)
G = ext.GraphUnionS(G, H)

ext.Graph2OBJ(BIGDATA + "extrude-1.obj", G, "scene")
import os
print("Open extrude-1.obj with 3D Viewer by double-clicking on it")
os.system(BIGDATA + "extrude-1.obj")
Exemplo n.º 5
0
pts = aff.Translate(pts, -C[0], -C[1], -C[2], align=False)
pts = aff.Rotate(pts, q, align=False)
pts = aff.Scale(pts, s[0], s[1], s[2], align=False)
pts = aff.Translate(pts, t[0], t[1], t[2], align=False)
H0['pts'] = pts
Gs = ext.Append(Gs, H0)
G = ext.GraphUnionS(G, H0)

# square table
H1 = SquareTable1()
Gs = ext.Append(Gs, H1)
G = ext.GraphUnionS(G, H1)

# coffee cup
Hcc = CoffeeCup()
ext.Graph2OBJ(BIGDATA + "CoffeeCup.obj", Hcc, "scene")
# add two obj files later to include CoffeeCup.obj

# N1 x N2 water bottles
N1 = 1
N2 = 1
for j in range(N2):
    for i in range(N1):
        H2 = rc.WaterBottle(n=10)
        degrees = -90
        axis = [0, 1, 0]
        q = aff.HH.rotation_quaternion(degrees, axis[0], axis[1], axis[2])
        scale = 1.
        s = [scale, scale, scale]  # the same scale as previous for caps
        r = 40.
        t0 = [N1 * r, -N2 * r, 55.]