WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 03-17-2008, 03:08 AM
dan12345 dan12345 is offline
Member
 
Join Date: Jan 2008
Posts: 58
Question regarding GUI sliders

Hello - i want to add several GUI sliders to my program - inspired by
the slider tutorial.
The problem is that i want each slider to perform different functionality -
and there is no identification for each slider.
Anyway to fix this? does a slider obj have maybe an identity function?
Thanks,
Dan
Reply With Quote
  #2  
Old 03-17-2008, 08:49 AM
realvision realvision is offline
Member
 
Join Date: Mar 2008
Posts: 11
Lightbulb 2nd question - IS vertical slider possible?

Hi all,
As I am slowly learning the very basics, I would really like some help to know the following...

is it possible to display a gui slider vertically?

I have displayed one horizontally and after much fiddling around (I dont know python, still learning slowly) I managed to do what i want , i.e i wanted to display an object and scale it bigger and smaller with a slider with this code
def myslider(obj, pos):
bed.setScale( .01*pos, .01*pos, .01*pos )

viz.callback(viz.SLIDER_EVENT,myslider)

However, can I add:

1) a vertical slider so that the object can be moved up and down? if so what would the code look like?

2) I wanted to use a live webcam as the background image. there is a tutorial that maps the webcam as a texture to a quad.
Can the live webcam image just be mapped as the "background" just like you can clear the background to a basic color, can it be "cleared" to the webcam image?

I tried unsuccessfully to map the webcam live image to the skydome, but that just distorts the webcam image

Thanks in advance!
Reply With Quote
  #3  
Old 03-17-2008, 09:41 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
The identity of a slider object is the object itself. Have a look at the docs for viz.SLIDER_EVENT, it explains how to determine which slider has changed. You can also use vizact.onslider for setting up callbacks for individual slider changes. Here is some sample code:
Code:
import viz
viz.go()

slider1 = viz.addSlider(pos=(0.5,0.1,0))
slider2 = viz.addSlider(pos=(0.5,0.2,0))

def Slider1Change(pos):
	print 'Slider 1 pos',pos
vizact.onslider(slider1,Slider1Change)

def Slider2Change(pos):
	print 'Slider 2 pos',pos
vizact.onslider(slider2,Slider2Change)
Reply With Quote
  #4  
Old 03-17-2008, 09:58 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Quote:
1) a vertical slider so that the object can be moved up and down? if so what would the code look like?
You can make a slider vertical by rotating it 90 degrees along the z-axis. Here is what the code would look like:
Code:
slider.setEuler(0,0,90)
Quote:
2) I wanted to use a live webcam as the background image. there is a tutorial that maps the webcam as a texture to a quad.
Can the live webcam image just be mapped as the "background" just like you can clear the background to a basic color, can it be "cleared" to the webcam image?
Here is some sample code showing how to have a texture show up as the background:
Code:
import viz
viz.go()

viz.add('tut_ground.wrl')


tex = viz.add('ball.jpg')

def setBackgroundTexture(tex):
	background = viz.addRenderNode()
	background.setHUD(0,100,0,100,True)
	background.setOrder(viz.PRE_RENDER)
	background.texture(tex)
	viz.MainWindow.setClearMask(viz.GL_DEPTH_BUFFER_BIT)
	
setBackgroundTexture(tex)
Reply With Quote
  #5  
Old 03-19-2008, 04:23 AM
realvision realvision is offline
Member
 
Join Date: Mar 2008
Posts: 11
Thank you for the code Farshizzo.
I do think I need to read a lot more! I was thinking adding a texture as background would be a one line code :-)

I tried out your example and it does work, but I have no clue as to how to make the live camera appear as the backgorund. Simply substituting 'cam' in place of tex in the above example does not do it

Regards
Reply With Quote
  #6  
Old 03-19-2008, 09:28 AM
realvision realvision is offline
Member
 
Join Date: Mar 2008
Posts: 11
P.s I just had to at least buy a Lite lisence while i keep asking so many questions.
So I did
Reply With Quote
  #7  
Old 03-19-2008, 10:25 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
I replaced the ball texture with a webcam texture and it worked fine for me. Here is the code:
Code:
import viz
viz.go()

viz.add('tut_ground.wrl')

video = viz.add('VideoCamera.dle')
webcam = video.addWebcam()

def setBackgroundTexture(tex):
	background = viz.addRenderNode()
	background.setHUD(0,100,0,100,True)
	background.setOrder(viz.PRE_RENDER)
	background.texture(tex)
	viz.MainWindow.setClearMask(viz.GL_DEPTH_BUFFER_BIT)
	
setBackgroundTexture(webcam)
Reply With Quote
  #8  
Old 03-19-2008, 11:47 AM
realvision realvision is offline
Member
 
Join Date: Mar 2008
Posts: 11
works! I was adding an un nessary line.
Thanks farshizzo!
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
General question and question regarding arrays dan12345 Vizard 1 01-15-2008 10:15 AM
Stereo Overlap question JMOwens Vizard 2 01-08-2008 08:54 AM
viztask question asimbh Vizard 1 11-20-2007 09:12 AM
question about yaw, pitch, roll TunTun Vizard 2 05-23-2007 12:46 PM
Lots of Question Karthi Vizard 4 02-20-2004 06:42 PM


All times are GMT -7. The time now is 11:48 AM.


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