|
From: symion <sy...@pr...> - 2009-01-12 11:07:28
|
The following program generates a Microsoft Visual C++ Assertion error
message!
It has something to do with a box in a frame and changing opacity!
Symion
from __future__ import division
from visual import *
from random import uniform,random
# Derek Harrison, The Knoware Archive, December 2008
def wireframe(w,h,d):
# For point, curve and convex Object position.
x=w/2.0
y=h/2.0
z=d/2.0
mat=[(-x,-y,-z),(x,-y,-z),(x,y,-z),(-x,y,-z),
(-x,-y,-z),(-x,-y,z),(x,-y,z),(x,y,z),
(-x,y,z),(-x,-y,z),(x,-y,z),(x,-y,-z),
(x,y,-z),(x,y,z),(-x,y,z),(-x,y,-z)]
return mat
def start():
scene.visible=0
scene.range=4.0
scene.fov=1.103
scene.ambient=0.5
scene.userzoom=1
scene.userspin=1
scene.x=0
scene.y=0
scene.width=600
scene.height=400
scene.title='Project : Symion 2008'
scene.forward=vector(0.622, 0.638, -0.455)
start()
#
old=False
f1=frame(pos=(0,0,0))
f2=frame(pos=(0,0,0))
f3=frame(pos=(0,0,0))
f4=frame(pos=(0,0,0))
#
if old:
curve(frame=f1,pos=wireframe(1/4,4,4),color=color.orange)
convex(frame=f1,pos=wireframe(1/4,4,4),color=color.red)
curve(frame=f2,pos=wireframe(1/3,3,3),color=color.yellow)
convex(frame=f2,pos=wireframe(1/3,3,3),color=color.orange)
curve(frame=f3,pos=wireframe(1/2,2,2),color=color.white)
convex(frame=f3,pos=wireframe(1/2,2,2),color=color.yellow)
curve(frame=f4,pos=wireframe(1,1,1),color=color.blue)
convex(frame=f4,pos=wireframe(1,1,1),color=color.white)
else:
box(frame=f1,size=(1/4,4,4),color=color.orange)
box(frame=f2,size=(1/3,3,3),color=color.yellow)
box(frame=f3,size=(1/2,2,2),color=color.white)
box(frame=f4,size=(1,1,1),color=color.blue)
scene.visible=1
a=radians(1**2)
b=radians(2**2)
c=radians(3**2)
d=radians(4**2)
while 1:
rate(10)
f1.rotate(angle=a)
f2.rotate(angle=b)
f3.rotate(angle=c)
f4.rotate(angle=d)
if scene.mouse.events>0:
m=scene.mouse.getevent()
if m.release=='left':
if m.pick:
if m.pick.__class__ is box:
scene.center=m.pick.pos
m.pick.opacity=random()
else:
scene.center=m.pickpos
m.pick.color=(random(),random(),random())
else:
scene.center=scene.mouse.pos
else:
pass
else:
pass
|