WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
Prev Previous Post   Next Post Next
  #5  
Old 10-17-2008, 02:28 AM
Sandro Holzer Sandro Holzer is offline
Member
 
Join Date: Jul 2008
Posts: 19
Hi

The following is a small test code that should show a little bit what i like to do.
You just need the attached objects from the .zip file.

The "bar2" should represents a vehicle, and the "bar" should represent a arm, that is attached to the vehicle and can rotate (something like a lift arm).
The vehicle should be able to "steer" and drive, so it can change its direction on the world plane. This is simulated with the key´s "f" and "g".
The lift arm is controlled with "t" and "b".

In the small test code the Problem occurs just with the lift arm.
In my real code it occurs also for the vehicle when I try to drive around and steer. Then the vehicle changes its direction from one step to the next by 180 or 90 degrees.

I hope someone can point me in the right direction, how to do this in the right way.

Sandro


Code:
import viz
viz.go()
viz.clearcolor(0.1,0.1,1)
ground = viz.add('tut_ground.wrl')
ANCHOR_POS= (0.5,1.8005,6)
bar2 = viz.add('bar.obj',pos=ANCHOR_POS)
bar = bar2.add('bar.obj')

a = 0
b = 0

def mytimer(num):
	global a,b
	if viz.iskeydown('t'):
		a = a + 1
		move()
	if viz.iskeydown('b'):
		a = a - 1
		move()
		
	if viz.iskeydown('f'):
		b = b + 1
		move()
	if viz.iskeydown('h'):
		b = b - 1
		move()

def move():
	euler = bar.getEuler(viz.ABS_PARENT)
	print euler
	euler[1]=a
	bar.setEuler(euler,viz.ABS_PARENT)
	
	euler = bar2.getEuler(viz.ABS_GLOBAL)
	print euler
	euler[0]=b
	bar2.setEuler(euler,viz.ABS_GLOBAL)
	

viz.callback(viz.TIMER_EVENT,mytimer)
viz.starttimer(0,0.02,viz.FOREVER)
Attached Files
File Type: zip bar.zip (1.4 KB, 5794 views)
Reply With Quote
 


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


All times are GMT -7. The time now is 01:42 AM.


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