def WaterBottleScene(G,Gs,t,q,s): f_ = open(BIGDATA+"WaterBottle.obj",'r') txt = f_.read() f_.close() G_small = ext.OBJ2Graph(txt) pts = G_small['pts'] C = aff.Center(pts) pts = aff.Translate(pts,-C[0],-C[1],-C[2],align=False) G_small['pts'] = pts # Add special textbook to scene pts2 = G_sp['pts'] C2 = aff.Center(pts2) pts2 = aff.Translate(pts2,-C2[0],-C2[1],-C2[2],align=False) degrees = 90+30 axis = [0,0,1] q_sp = aff.HH.rotation_quaternion(degrees,axis[0],axis[1],axis[2]) pts2 = aff.Rotate(pts2,q_sp,align=False) t2 = [180.,180.,rec_sp.d/2.] pts2 = aff.Translate(pts2,t2[0],t2[1],t2[2],align=False) G_sp['pts'] = pts2 G_small = GraphUnionS(G_small,G_sp) pts = G_small['pts'] 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 Gs = Append(Gs,G_small) G = GraphUnionS(G,G_small) return G,Gs
s = [scale,scale,scale] # the same scale as previous for caps Hdon = bs.Torus(r1,r2,t,q,s, m=10,n=60) ext.Graph2OBJ(BIGDATA+"Donut.obj",Hdon,"scene") Gs = ext.Append(Gs,Hdon) G = ext.GraphUnionS(G,Hdon) ext.Graphs2OBJ(BIGDATA+"Donut.obj",Gs,"scene") ######################### SCENE 3 END ################ MERGE BEGIN SCENE 1, 2 and 3 ### Open Scene 1 f_ = open(BIGDATA+"WaterBottleTable.obj",'r') txt = f_.read() f_.close() G_scene1 = ext.OBJ2Graph(txt) # use scene1 as global scene ### ### Open Scene 2 f_ = open(BIGDATA+"CoffeeCup.obj",'r') txt = f_.read() f_.close() G_scene2 = ext.OBJ2Graph(txt) ### Open Scene 3 f_ = open(BIGDATA+"Donut.obj",'r') txt = f_.read() f_.close() G_scene3 = ext.OBJ2Graph(txt)
w,h,d = [500*2,500*2,5] 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 = [-w/2.,-h/2.,-d/2.-250] #H3 = ext.CubeObj(w,h,d, t,q,s) #Gs = ext.Append(Gs,H3) #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