WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 03-16-2015, 10:36 AM
BSUGeek BSUGeek is offline
Member
 
Join Date: Oct 2014
Posts: 23
Question Help with the slider

I'm having trouble using the slider to change the speed of my viewpoints movement. While i'm moving i want to be able to use the slider to increase or decrease my movement speed. How can i do that?
Reply With Quote
  #2  
Old 03-16-2015, 10:47 AM
shivanangel shivanangel is offline
Member
 
Join Date: Feb 2006
Location: New Jersey
Posts: 182
What are you using to move around?
Just grab the sliders value

pos = slider.get()

Multiply by some movement speed to make the value larger than 0 to 1

Set the speed equal to the newly calculated rate/force/speed/etc.. you are using to move around the environment with.
Reply With Quote
  #3  
Old 03-16-2015, 11:04 AM
BSUGeek BSUGeek is offline
Member
 
Join Date: Oct 2014
Posts: 23
Here's the code i have so far. I'm not sure how i should have my move_speed increase and decrease with the slider

Code:
MOVE_SPEED = 60
TURN_SPEED = 60

sliderPanel = vizinfo.InfoPanel(text=None, icon=False)
slider = sliderPanel.addLabelItem('Speed', viz.addSlider())
slider.set(0)

def mySlider(pos):
      ????
      ????

vizact.onslider(slider,mySlider)

def updatecar():

    #move view forward and backward
    if viz.key.isDown(viz.KEY_DOWN):
        view.move([0,0,MOVE_SPEED*viz.elapsed()],viz.BODY_ORI)
    if viz.key.isDown(viz.KEY_UP):
        view.move([0,0,-MOVE_SPEED*viz.elapsed()],viz.BODY_ORI)

	#rotate body of view left and right
    if viz.key.isDown(viz.KEY_RIGHT):
        view.setEuler([TURN_SPEED*viz.elapsed(),0,0],viz.BODY_ORI,viz.REL_PARENT)
    elif viz.key.isDown(viz.KEY_LEFT):
        view.setEuler([-TURN_SPEED*viz.elapsed(),0,0],viz.BODY_ORI,viz.REL_PARENT)
vizact.ontimer(0,updatecar)
Reply With Quote
  #4  
Old 03-16-2015, 11:09 AM
shivanangel shivanangel is offline
Member
 
Join Date: Feb 2006
Location: New Jersey
Posts: 182
For the easy way out, you can read the state of the slider in the updateCar method.

If you multiply the movement speed by the slider value, it will allow you to scale between 0 and your max speed, which is 60 in this case.

view.move([0, 0, MOVE_SPEED*slider.get()*viz.elapsed()], viz.BODY_ORI)

Do this for each movement call you make. You are now scaling the speed of the car by the amount of time since the last update and the value of the slider.

Last edited by shivanangel; 03-16-2015 at 11:13 AM.
Reply With Quote
  #5  
Old 03-16-2015, 11:15 AM
BSUGeek BSUGeek is offline
Member
 
Join Date: Oct 2014
Posts: 23
Thumbs up

that worked great! thanks alot for your help!
Reply With Quote
  #6  
Old 03-16-2015, 11:19 AM
BSUGeek BSUGeek is offline
Member
 
Join Date: Oct 2014
Posts: 23
Is there a way to show your speed on the screen as it's changing?
Reply With Quote
  #7  
Old 03-16-2015, 11:23 AM
shivanangel shivanangel is offline
Member
 
Join Date: Feb 2006
Location: New Jersey
Posts: 182
Create a text object on the screen.
Look up text node basics in the Vizard help file.
Grab the value and set the text equal to it.
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
Slider Assistance new_horizon Vizard 3 05-16-2012 07:32 AM
adding more than 1 action for avatar animation slider control yak Vizard 0 07-21-2009 11:22 AM
help with slider code yak Vizard 2 07-20-2009 12:12 PM
Vizmenu slider bug? Gladsomebeast Vizard 2 10-22-2008 08:05 PM
Blending/Fading 5 Textures with a Slider south_bank Vizard 2 05-15-2008 07:59 AM


All times are GMT -7. The time now is 04:32 PM.


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