From: Cettinich E. (LWE) <edw...@lw...> - 2002-11-06 09:35:47
|
Thanks a lot. That helps.=20 Although I prefer a solution with exactly one object shown in two displays = my hope has gone and I suppose it will not be realizable. So I'll go to imp= lement some obj-management which can handle several displays.=20 By the way: There is no need to convert obj.__class__ to a character string= =2E Here's your program without dictionary: ################################ from visual import * x =3D 300 y =3D 400 w =3D 200 h =3D 200 eyeangle =3D 0.15 # interocular angle left =3D display(x=3Dx, y=3Dy, width=3Dw, height=3Dh) right =3D display(x=3Dx+w, y=3Dy, width=3Dw, height=3Dh) left.select() b1=3Dbox(pos=3D(-1,0,0), color=3Dcolor.red) b2=3Dbox(pos=3D(1,-1,0), color=3Dcolor.cyan) a1=3Darrow(pos=3D(-0.5,0,0), axis=3D(1,-1,0), color=3Dcolor.yellow) right.select() for obj in left.objects: newobj=3Dobj.__class__() # create object in 2nd w= indow for member in obj.__members__: if member =3D=3D 'display': continue # avoid putting into scene1 exec 'newobj.'+member+'=3Dobj.'+member # set attribute while 1: right.up =3D left.up leftforward =3D left.center-left.mouse.camera right.forward =3D rotate(leftforward, angle=3Deyeangle, axis=3Dleft.up) ################################ Edwin Cettinich > -----Urspr=FCngliche Nachricht----- > Von: Bruce Sherwood [SMTP:bas...@un...] > Gesendet am: Dienstag, 5. November 2002 17:22 > An: Cettinich Edwin (LWE); vis...@li... > Betreff: Re: [Visualpython-users] 1 objectlist and 2 displays >=20 > I think the problem with copying objects to a second window is that you > can't assign to scene.objects, you can only read it. >=20 > Below is a kludge to copy objects from one window into another. Maybe > someone else can think of a way to convert obj.__class__ to a character > string so that it can be used in exec, instead of having to create a > dictionary of existing Visual objects? Or some other scheme altogether? >=20 > This program creates two cubes and an arrow on the left, then copies thes= e > objects into a second window on the right. The camera positions are adjus= ted > to be different in the two windows, in order to provide a true stereo pai= r > that can be merged by making your eyes "wall-eyed" (the opposite of > cross-eyed). Zoom/rotate in the left window and both camera positions cha= nge > to continue to give you a 3D look. I think I don't have the camera angles > quite right, because I get a headache after brief viewing! >=20 > Bruce Sherwood >=20 > from visual import * > vobjects =3D {box:'box', sphere:'sphere', cylinder:'cylinder', > arrow:'arrow', cone:'cone', ring:'ring', > curve:'curve', convex:'convex', label:'label', > frame:'frame', faces:'faces'} > x =3D 300 > y =3D 400 > w =3D 200 > h =3D 200 > eyeangle =3D 0.15 # interocular angle > left =3D display(x=3Dx, y=3Dy, width=3Dw, height=3Dh) > right =3D display(x=3Dx+w, y=3Dy, width=3Dw, height=3Dh) > left.select() >=20 > b1=3Dbox(pos=3D(-1,0,0), color=3Dcolor.red) > b2=3Dbox(pos=3D(1,-1,0), color=3Dcolor.cyan) > a1=3Darrow(pos=3D(-0.5,0,0), axis=3D(1,-1,0), color=3Dcolor.yellow) >=20 > right.select() > for obj in left.objects: > exec 'newobj=3D'+vobjects[obj.__class__]+'()' # create object in 2nd > window > for member in obj.__members__: > if member =3D=3D 'display': continue # avoid putting into scene1 > exec 'newobj.'+member+'=3Dobj.'+member # set attribute >=20 > while 1: > right.up =3D left.up > leftforward =3D left.center-left.mouse.camera > right.forward =3D rotate(leftforward, angle=3Deyeangle, axis=3Dleft.u= p) >=20 >=20 > ----- Original Message ----- > From: "Cettinich Edwin (LWE)" <edw...@lw...> > To: <vis...@li...> > Sent: Tuesday, November 05, 2002 4:36 AM > Subject: [Visualpython-users] 1 objectlist and 2 displays >=20 >=20 > Hi, >=20 > I try to make 1 objectlist visible in 2 displays. > But neither > ########################################>=20 > from visual import * > scene1=3Ddisplay(title=3D"1st") > b=3Dbox(x=3D-1) > b=3Dbox(x=3D1,y=3D-1) > scene2=3Ddisplay(title=3D"2nd") > scene2.objects=3Dscene1.objects > ######################################## > nor > ######################################## > import copy > from visual import * > scene1=3Ddisplay(title=3D"1st") > b=3Dbox(x=3D-1) > b=3Dbox(x=3D1,y=3D-1) > scene2=3Ddisplay(title=3D"2nd") > scene2.objects=3Dcopy.deepcopy(scene1.objects) > ######################################## > could make scene2 show the objects owned by scene1. >=20 > Does anyone have a suggestion what to do? >=20 > Thanks, >=20 > Edwin >=20 >=20 >=20 >=20 > ------------------------------------------------------- > This sf.net email is sponsored by: See the NEW Palm > Tungsten T handheld. Power & Color in a compact size! > http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0001en > _______________________________________________ > Visualpython-users mailing list > Vis...@li... > https://lists.sourceforge.net/lists/listinfo/visualpython-users >=20 >=20 >=20 >=20 |
From: Bruce S. <bas...@un...> - 2002-11-06 13:12:39
|
Thanks much for showing me how to avoid the dictionary! Bruce Sherwood ----- Original Message ----- From: "Cettinich Edwin (LWE)" <edw...@lw...> To: "Bruce Sherwood" <bas...@un...>; <vis...@li...> Sent: Wednesday, November 06, 2002 4:35 AM Subject: AW: [Visualpython-users] 1 objectlist and 2 displays Thanks a lot. That helps. Although I prefer a solution with exactly one object shown in two displays my hope has gone and I suppose it will not be realizable. So I'll go to implement some obj-management which can handle several displays. By the way: There is no need to convert obj.__class__ to a character string. Here's your program without dictionary: ################################ from visual import * x = 300 y = 400 w = 200 h = 200 eyeangle = 0.15 # interocular angle left = display(x=x, y=y, width=w, height=h) right = display(x=x+w, y=y, width=w, height=h) left.select() b1=box(pos=(-1,0,0), color=color.red) b2=box(pos=(1,-1,0), color=color.cyan) a1=arrow(pos=(-0.5,0,0), axis=(1,-1,0), color=color.yellow) right.select() for obj in left.objects: newobj=obj.__class__() # create object in 2nd window for member in obj.__members__: if member == 'display': continue # avoid putting into scene1 exec 'newobj.'+member+'=obj.'+member # set attribute while 1: right.up = left.up leftforward = left.center-left.mouse.camera right.forward = rotate(leftforward, angle=eyeangle, axis=left.up) ################################ Edwin Cettinich |
From: David S. <da...@vi...> - 2002-11-06 13:23:12
|
> exec 'newobj.'+member+'=obj.'+member # set attribute can be written without exec: setattr(newobj,member,getattr(obj,member)) Dave > -----Original Message----- > From: vis...@li... > [mailto:vis...@li...] On > Behalf Of Bruce Sherwood > Sent: Wednesday, November 06, 2002 8:13 AM > To: Cettinich Edwin (LWE); vis...@li... > Subject: Re: [Visualpython-users] 1 objectlist and 2 displays > > > Thanks much for showing me how to avoid the dictionary! > > Bruce Sherwood > > ----- Original Message ----- > From: "Cettinich Edwin (LWE)" <edw...@lw...> > To: "Bruce Sherwood" <bas...@un...>; > <vis...@li...> > Sent: Wednesday, November 06, 2002 4:35 AM > Subject: AW: [Visualpython-users] 1 objectlist and 2 displays > > > Thanks a lot. That helps. > > Although I prefer a solution with exactly one object shown in > two displays my hope has gone and I suppose it will not be > realizable. So I'll go to implement some obj-management which > can handle several displays. > > By the way: There is no need to convert obj.__class__ to a > character string. Here's your program without dictionary: > ################################ from visual import * > > x = 300 > y = 400 > w = 200 > h = 200 > eyeangle = 0.15 # interocular angle > left = display(x=x, y=y, width=w, height=h) > right = display(x=x+w, y=y, width=w, height=h) > left.select() > > b1=box(pos=(-1,0,0), color=color.red) > b2=box(pos=(1,-1,0), color=color.cyan) > a1=arrow(pos=(-0.5,0,0), axis=(1,-1,0), color=color.yellow) > > right.select() > for obj in left.objects: > newobj=obj.__class__() # create > object in 2nd > window > for member in obj.__members__: > if member == 'display': continue # avoid putting into scene1 > exec 'newobj.'+member+'=obj.'+member # set attribute > > while 1: > right.up = left.up > leftforward = left.center-left.mouse.camera > right.forward = rotate(leftforward, angle=eyeangle, > axis=left.up) ################################ > > Edwin Cettinich > > > > > ------------------------------------------------------- > This sf.net email is sponsored by: See the NEW Palm > Tungsten T handheld. Power & Color in a compact size! http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0001en _______________________________________________ Visualpython-users mailing list Vis...@li... https://lists.sourceforge.net/lists/listinfo/visualpython-users |
From: Bruce S. <bas...@un...> - 2002-11-06 19:07:53
|
And thanks much for the additional tutorial! (There are SO many Python capabilities that I haven't used before....) Bruce Sherwood ----- Original Message ----- From: "David Scherer" <da...@vi...> To: "'Bruce Sherwood'" <bas...@un...>; "'Cettinich Edwin (LWE)'" <edw...@lw...>; <vis...@li...> Sent: Wednesday, November 06, 2002 8:23 AM Subject: RE: [Visualpython-users] 1 objectlist and 2 displays > > exec 'newobj.'+member+'=obj.'+member # set attribute > > can be written without exec: > > setattr(newobj,member,getattr(obj,member)) > > Dave |