|
From: Bruce S. <Bru...@nc...> - 2008-03-24 23:27:32
|
I think you probably meant
lefteye.look(20)
rhyteye.look(20)
to be
lefteye.look(s=20)
rhyteye.look(s=20)
It's interesting that this program does not run in Visual 4, because
scene.objects lists frames, not the objects in those frames. So the
reference to scene.objects[1] refers to a frame, which doesn't have a
radius attribute. We certainly are trying not to break existing
programs, and no one noticed this incompatibility. The intent was to
make better sense out of scene.objects, in which listing both frames and
the objects inside those frames is a bit odd.
In Visual 3 lights are solely at infinity, so there's no good way to
light orbiting planets appropriately. You can of course continually
change the direction of these infinitely-far-away lights, but that's not
really what you want. In Visual 4 there are local lights which may do
the trick. In Visual 4 there are also spotlights, but in the current
review of Visual 4 there are questions about supporting spotlights. And
in any case, the Sun isn't a spotlight.....
Bruce Sherwood
Symion wrote:
> Hi there.
> Here is a short python program that draws a simple face with roving
> eyes. As you right mouse the image, the eyes follow you.
> Change the position of the eyes with the cursor keys.
>
> Next step is to develop a topographic head with moving eyelids and
> eyebrows, then a little more work on the mouth and hey presto - A
> robotic head!
>
> Demonstrates how easy Vpython is to use.
>
> My Wish List:
> Figure out how to use the *scene.lights* function, so that orbiting
> objects are illuminated from a single source.
> i.e. Planets orbiting the Sun must change the angle of illumination.
> I've tried a few ideas but so far nothing works!
> Does anyone have a solution?
>
> Cheers Symion
>
> from __future__ import division
> from visual import *
> from random import *
> print '''Crazy Eyeballs -(c) Symion 2008
>
> Use cursor keys to control eye position and width'''
>
> class eyeball:
> def __init__(self,p=(0,0,0),r=1.0,c=[(1,0,0)]*6,a=(0,1,0)):
> self.pos=p
> self.radius=r
> self.color=c
> self.axis=a
> self.eye=frame()
> sphere(frame=self.eye,pos=p,radius=r,axis=a,color=c[0])
> for a in range(1,6):
>
> sphere(frame=self.eye,pos=vector(scene.objects[-1].pos.x+scene.objects[-1].radius/1.618,scene.objects[-1].pos.y,scene.objects[-1].pos.z),radius=scene.objects[-1].radius/1.618,color=c[a])
>
> def look(self,k=True,s=1.0):
> if k==True and s!=0:
> self.eye.rotate(angle=((2*pi)/s))
>
> self.eye.axis=(scene.mouse.camera-self.eye.pos)
>
> ##
> d=[(3,3,3)]
> for a in range(1,5):
> d.append((uniform(0,1),uniform(0,1),uniform(0,1)))
>
> d.append((0,0,0))
> ## Initialize Display
> scene.autoscale=0
> scene.title='Crazy EyeBalls - (c) 2008 Symion'
> scene.background=(0,0.1,0.2)
> scene.ambient=0.5
> ## Begin
> eyesize=1.4
> lefteye=eyeball(p=(0,0,0),r=eyesize,a=(1,0,0),c=d)
> rhyteye=eyeball(p=(0,0,0),r=eyesize,a=(1,0,0),c=d)
> ## Draw Face - Eyebrows
> box(pos=(0,5,-3),length=4,width=1,height=1,axis=(-1,-1,2),color=(0.4,0.4,0.4))
> obj=scene.objects
> box(pos=vector(obj[-1].pos.x+1.5,obj[-1].pos.y,obj[-1].pos.z-3),length=3,width=1,height=1,axis=(-1,1,2),color=(0.4,0.4,0.4))
> box(pos=(0,5,3),length=4,width=1,height=1,axis=(1,1,2),color=(0.4,0.4,0.4))
> obj=scene.objects
> box(pos=vector(obj[-1].pos.x+1.5,obj[-1].pos.y,obj[-1].pos.z+3),length=3,width=1,height=1,axis=(1,-1,2),color=(0.4,0.4,0.4))
> ## Nose
> box(pos=vector(-1,0,0),length=5,width=1,height=1,axis=(.5,1,0),color=(1,1,1))
> obj=scene.objects
> box(pos=vector(obj[-1].pos.x-.5,obj[-1].pos.y-1.8,obj[-1].pos.z),length=1,width=3,height=1,axis=(0,1,0),color=(1,1,1))
> obj=scene.objects
> ## Lips
> box(pos=vector(obj[-1].pos.x,obj[-1].pos.y-3,obj[-1].pos.z),length=.5,width=4,height=.8,color=(1,0,0))
> box(pos=vector(obj[-1].pos.x,obj[-1].pos.y-2,obj[-1].pos.z),length=.5,width=5,height=.5,color=(1,0,0))
> ## Position Eyes
> lefteye.eye.pos=(0,2.0,-2.5)
> rhyteye.eye.pos=(0,2.0, 2.5)
> ## Select viewing angle
> scene.forward=vector(14.1868312021088, -3.63010737884212,
> 0.00013678986975335)
> scene.range=vector(8,8,8)
> scene.fov=1
>
> while 1:
> rate(100)
> lefteye.look(20)
> rhyteye.look(20)
>
> if scene.kb.keys>0:
> kb=scene.kb.getkey()
> if kb=='down':
> lefteye.eye.pos.y-=0.5
> rhyteye.eye.pos.y-=0.5
> elif kb=='up':
> lefteye.eye.pos.y+=0.5
> rhyteye.eye.pos.y+=0.5
> elif kb=='left':
> lefteye.eye.pos.z-=0.5
> rhyteye.eye.pos.z+=0.5
> elif kb=='right':
> lefteye.eye.pos.z+=0.5
> rhyteye.eye.pos.z-=0.5
> else:
> pass
> else:
> pass
>
>
> ------------------------------------------------------------------------
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Visualpython-users mailing list
> Vis...@li...
> https://lists.sourceforge.net/lists/listinfo/visualpython-users
|