WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 12-20-2011, 05:21 AM
sxu04 sxu04 is offline
Member
 
Join Date: Dec 2011
Posts: 4
Updating object color

I’m really hoping that someone could kindly steer me in the right direction……

I have 12 balls positioned in an environment and (using the ‘Experiment’ example in the Vizard Help) these balls only show their colour when the subject is near them. On approach, the balls will either turn red or green based on a predetermined sequence. However, in addition I need the red balls to have a 1 in 10 chance of turning orange and for this to update every 3 seconds. I am however having issues updating the colour of the balls once the colour has been assigned.

Any help would be very much appreciated!


a1=-37.5
a2=-12.5
a3=12.5
a4=37.5
x=2.75
y=3.85
z=1.1
b1=34.5
b2=16.5
b3=8.5
b4=-8.5
b5=-16.5
b6=-34.5

positions = [[a1,x,b1],[a1,x,b2],[a1,x,b3],[a1,x,b4],[a1,x,b5],[a1,x,b6],[a1,z,b1],[a1,z,b2],[a1,z,b3],[a1,z,b4],[a1,z,b5],[a1,z,b6]]

R=viz.RED
G=viz.GREEN

colors=[R,R,R,R,R,R,G,G,G,G,G,G]


balls=[]

def col():
while True:
yield viztask.waitTime(1)

for i in range(0,12):
model=vizshape.addSphere(1,10,10)
model.setPosition(positions[i])
ball = viz.Data()
ball.model = model

x=random.randint(1,10)

if x == 1:
if colors[i]==R:
#ball.model.clearAttribute(viz.ATTR_COLOR)
#model=vizshape.addSphere(1,10,10)
#model.setPosition(positions[i])
#model.setScale(1.1,1.1,1.1)

ball.color=(viz.ORANGE)

ball.colorShowing = False


balls.append(ball)
#print 'red'
if colors[i]==G:


ball.color=(colors[i])
ball.colorShowing = False
balls.append(ball)


else:
ball.color=(colors[i])
#print 'green'
ball.colorShowing = False
balls.append(ball)


viztask.schedule( col() )

def changeColor():
viewPos = viz.MainView.getPosition()
for ball in balls:
ballPos = ball.model.getPosition()
distance = vizmat.Distance(viewPos, ballPos)

if ball.colorShowing is False:
if distance < 11 :
showColor=vizact.sequence(vizact.waittime(0.1),viz act.fadeTo(ball.color,time=0.7))
ball.model.runAction(showColor)
ball.colorShowing = True
else:
if distance > 11 :
showWhite = vizact.fadeTo(viz.WHITE,time=4)
ball.model.runAction(showWhite)
ball.colorShowing = False

vizact.ontimer(0,changeColor)
Reply With Quote
 

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to render a texture of the transparent object and then blur it whj Vizard 1 09-25-2012 03:15 PM
retrieve Object names Geoffrey Vizard 11 12-11-2009 04:26 AM
Trouble with listener updating position? GiudiceLab Vizard 7 11-05-2009 11:40 AM
imported 3DModel - Color Write - Problem Boerske Vizard 4 10-09-2009 10:18 AM
rotate to object jargon Vizard 1 08-08-2005 12:20 PM


All times are GMT -7. The time now is 05:52 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Copyright 2002-2018 WorldViz LLC