WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 02-26-2008, 10:10 AM
Psirus Psirus is offline
Member
 
Join Date: Feb 2008
Posts: 3
3D Music Interface

I am currently using the trial version of Vizard, and I must say it is pretty fun.
I am doing a project for university, and I am a bit stuck, hoping someone can help me.

I have cubes in my interface, and you can select the cubes which you want and they will play a track according to the cube you select.

I have the sounds in constantly running and looping with 0 volume. This is so they are in sync.

I want it so when you select a cube, it moves and turns the volume of the assigned track up so you can hear it. You click on it again, it moves to its original position and the volume goes back down to 0.


I though it would be a lot simpler, basically I imagined it to be:

on mousedown_leftbutton
box1.translate(50,0,0)
sound1.volume(50)
on mousedown_rightbutton
box1.translate(-50,0,0)
sound1.volume(0)


Obviously this is not the case.

I managed to get it to ..
When you left click any box box1 moves and changes the volume.
Here is the code for that:

def left_mouseclick(button):
if button == viz.MOUSEBUTTON_LEFT in box1:
object = viz.pick()
if object.valid():
box1.visible(viz.ON)
box1.translate(0,60,30)
sound1.volume(300)
if button == viz.MOUSEBUTTON_RIGHT:
object = viz.pick()
if object.valid():
box1.visible(viz.ON)
box1.translate(0,0,0)
sound1.volume(0)

viz.callback(viz.MOUSEDOWN_EVENT,left_mouseclick)



I have also managed to get individual picking, but when I try to set is as onpick(sound1.volume(50)) the sound just starts at volume 50, which is baffling me. Here is the code for that:

#Add a node to apply an action to.
sound1 = viz.addAudio('1.wav')
sound1.loop(viz.ON)
sound1.volume(0)
sound1.pause()
#Add the node that you'll pick.
box1 = viz.add( '1.wrl' )
#Apply the action to the node when you pick the other object.
vizact.onpick( box1, sound1.volume(50))



Completely baffled now, I have run out of ideas. I also tried doing this:

def onPick(button):
if button == viz.MOUSEBUTTON_LEFT in box1:
sound1.volume(50)
elif button == viz.MOUSEBUTTON_RIGHT in box1:
sound1.volume(0)
viz.callback(viz.MOUSEDOWN_EVENT,onMouseDown)


But I do not think that is the proper use of 'in' and it does not work at all.

Any help would be greatly appreciated.

Thanks, Dan
Reply With Quote
  #2  
Old 02-26-2008, 10:31 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
You are using the vizact.onpick function incorrectly. Here is a sample script that shows how to use it. Clicking a box will slide it to the other side of the screen and set the volume up.
Code:
import viz
viz.go()

viz.clearcolor(viz.GRAY)
viz.mouse(viz.OFF)

#Array of sounds
FILES = ['bounce.wav','carousel.wav','bach_air.mid']

def ToggleBox(box):
	box.active = not box.active
	if box.active:
		box.runAction(vizact.moveTo(pos=box.onPos,speed=20))
		box.audio.volume(1)
	else:
		box.runAction(vizact.moveTo(pos=box.offPos,speed=20))
		box.audio.volume(0)

#Create boxes
boxes = []
for i,f in enumerate(FILES):
	box = viz.add('box.wrl')
	box.audio = viz.addAudio(f,loop=True,volume=0.0)
	box.active = False
	box.offPos = (-2,i*2,10)
	box.onPos = (2,i*2,10)
	box.setPosition(box.offPos)
	vizact.onpick(box,ToggleBox,box)
	boxes.append(box)

#Start sounds
for b in boxes:
	b.audio.play()
Reply With Quote
  #3  
Old 02-26-2008, 10:37 AM
Psirus Psirus is offline
Member
 
Join Date: Feb 2008
Posts: 3
Ah ok thanks.
I will give it a go and get back to you with the results.

Thank you very much for the quick reply!
Reply With Quote
  #4  
Old 02-26-2008, 11:48 AM
Psirus Psirus is offline
Member
 
Join Date: Feb 2008
Posts: 3
Thank you so much.
I got it working perfectly with this.
Reply With Quote
Reply

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
Interface with Tobii Eye Tracker Uttama_vizard Precision Position Tracker (PPT) 1 12-12-2007 11:31 AM
Status bar in user interface AlyssaK Vizard 3 10-26-2007 12:05 AM
Basic soundtrack Plymouth Vizard 6 01-30-2007 01:34 AM


All times are GMT -7. The time now is 03:09 AM.


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