WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 04-23-2008, 10:45 AM
nige777 nige777 is offline
Member
 
Join Date: Nov 2007
Location: UK
Posts: 78
Quick Question

Calling all Vizards,

I am trying to add the ability to mount and dismount a vehicle (FLT) in my scene. When dismounted the user should be able to walk around the environment as normal. Problem is when I only seem to able to perform this action once, maybe I am trying to do this the wrong way . Here is a snippet of code to illustrate the way I am trying to achieve this.

Code:
import vizcam

def orbitCamera():
	cam = vizcam.PivotNavigate(distance=4)
	cam.centerNode(run)
	bodyLink.remove()
	
def normalView():
	bodyLink = viz.link(body,view,dstFlag=viz.LINK_BODY)
	bodyLink.preTrans([0,-0.29,0.2])

def buttonTimer():
	if joy.isButtonDown (3):
		vizact.choice([orbitCamera(),normalView()],vizact.LOOP)
vizact.ontimer(viz.FASTEST_EXPIRATION,buttonTimer)
Do I need to use groups? If so, how?

Thanks for any help in advance,

Regards,

Nige
Reply With Quote
  #2  
Old 04-23-2008, 06:23 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Are you trying to toggle between the orbit camera and normal view when joystick button 3 is pressed? If so, you will need to modify your code to look something like this:
Code:
import vizcam

cam = vizcam.PivotNavigate(distance=4)
cam.enabled = False

bodyLink = viz.link(body,view,dstFlag=viz.LINK_BODY)
bodyLink.preTrans([0,-0.29,0.2])

def joydown(e):
	if e.button == 3:
		cam.enabled = not cam.enabled
		if cam.enabled:
			bodyLink.disable()
			cam.centerNode(run)
		else:
			bodyLink.enable()

viz.callback(vizjoy.BUTTONDOWN_EVENT,joydown)
This code should properly toggle between the camera and body link. Let me know if anything is not clear.
Reply With Quote
  #3  
Old 04-24-2008, 09:51 AM
nige777 nige777 is offline
Member
 
Join Date: Nov 2007
Location: UK
Posts: 78
RE: Right answer, wrong question!

Thanks for the suggestion, it works really well. Unfortunately I posted the question when I was half asleep, so I apologies for the fact that I will now have to ask you a revised question. I actually need to be able to dismount the the truck and move around. I control the truck with a joypad with the head ori of the view set to mouselook and envisage controlling the view in the same way when I dismount. Here's the joypad script I'm using to drive the FLT:

Code:
#Use joystick to control FLT navigation
def UpdateMovement():
    
    #Get the joystick position
    x,y,z = joy.getPosition()
    
    #Get the twist of the joystick
    twist = joy.getTwist()
        
    #Using the z value off the twist control for up and down
    if abs(y) > 0.3 or abs(y) < -0.3:
        SetThrottle(-y)
        
    if abs(y) <0.3 and abs(y) >-0.3:
        SetThrottle(0)
    
    if abs(twist) > 0.2 or abs(twist) < -0.2:
        steer(twist*70)
        steerWheel(-twist*65)
    
    elif abs(twist) < 0.2 or abs(twist) > -0.2:
        steer(0)
        steerWheel(0)

#UpdateJoystick every frame
vizact.ontimer(viz.FASTEST_EXPIRATION,UpdateMovement)
So what I think I am asking is how do I mount and dismount from the truck while using the same controls to manipulate the main view.

Thanks for your patience,

Nige
Reply With Quote
  #4  
Old 04-28-2008, 01:33 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
I'm not exactly clear on what you are trying to accomplish. It seems like you just need to disable the UpdateMovement function while you are dismounted from the truck, and enable it when you are mounted. Let me know if I misunderstood your question.
Reply With Quote
  #5  
Old 05-07-2008, 03:39 PM
nige777 nige777 is offline
Member
 
Join Date: Nov 2007
Location: UK
Posts: 78
Hi fashizzo,

Yes, you are quite right, I need to disable the UpdateFLTMovement() function whilst dismounted from the truck. However, I now have 2 functions, one for moving the truck, one for moving the view, but am unable (in my sleep deprived state ) to switch toggle between them. I have tried all manner of enable and disable combinations - but to no avail. I feel that (once again) I am missing something really simple

All help gratefully received
Reply With Quote
  #6  
Old 05-08-2008, 06:50 AM
nige777 nige777 is offline
Member
 
Join Date: Nov 2007
Location: UK
Posts: 78
RE:Ignore me!

Please disregard the last post - I have had some sleep and my brain has started working again

I just put the two functions in a timer and just call or kill whichever one I want!


Cheers

Nige
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 11:15 AM
Stereo Overlap question JMOwens Vizard 2 01-08-2008 09:54 AM
viztask question asimbh Vizard 1 11-20-2007 10:12 AM
Another color question mjabon Vizard 4 07-31-2007 04:04 PM
Basic Joystick Navigation Question Plasma Vizard 2 01-29-2004 08:08 PM


All times are GMT -7. The time now is 07:33 AM.


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