WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 05-18-2006, 04:06 PM
paulpars paulpars is offline
Member
 
Join Date: May 2006
Location: Kingston, Ontario
Posts: 14
problem with collision detection

I am currently having a problem with collision detection in that whenever I turn it on, my view keeps getting higher along the y axis and doesn't stop. I am using files that came with vizard and basically what I've done is add a car and a road using a texquad to the 'playground.wrl' file. I have set it so the viewpoint is inside the car and I think this is what is creating the problem. As soon as I start the program the car just starts floating up away from the ground. Does anyone have any ideas on how to fix this? Thanks.
Reply With Quote
  #2  
Old 05-18-2006, 05:05 PM
Gladsomebeast Gladsomebeast is offline
Member
 
Join Date: Mar 2005
Location: Isla Vizta, CA
Posts: 397
I think the viewpoint is colliding with the car. Stop that with the following:

car.disable( viz.COLLISION )
Reply With Quote
  #3  
Old 05-19-2006, 08:24 AM
paulpars paulpars is offline
Member
 
Join Date: May 2006
Location: Kingston, Ontario
Posts: 14
ok that's much better, thanks!
I have another problem now...if I understand correctly, there is no way to make it so that the car will collide with every other object in the world, so I would have to do it manually...is this correct? and how would I go about doing that?
Reply With Quote
  #4  
Old 05-19-2006, 09:34 AM
Gladsomebeast Gladsomebeast is offline
Member
 
Join Date: Mar 2005
Location: Isla Vizta, CA
Posts: 397
A simple collision detection method would use viz.intersect() to draw a line in front of the car checking if any objects are in the way. Check out the Using real-time physics tutorial for an example of this method.
Reply With Quote
  #5  
Old 05-19-2006, 11:40 AM
paulpars paulpars is offline
Member
 
Join Date: May 2006
Location: Kingston, Ontario
Posts: 14
ok thanks, i've found the tutorial online, but i don't seem to have any of the tutorial files....can i download them somewhere?
Reply With Quote
  #6  
Old 05-19-2006, 12:14 PM
Gladsomebeast Gladsomebeast is offline
Member
 
Join Date: Mar 2005
Location: Isla Vizta, CA
Posts: 397
Can't seem to find the files eather. Basicly what you are interesed in is the following code. The future and current position points are computed. Then the line between these points is supplied to the viz.intersect command. This command will return a struture with an intersected attribute. If intersected is true, then there is an object intersecting the line. Because you have called car.disable( viz.COLLISION ), this line will never intersect with car.



Code:
def ontimer(num):
global vector, whirling, active
if num == ANIMATION:
  #Get the amount of time elapsed since this timer started running.
  elapsed = viz.elapsed()
   #If the dart is active, move it.
  if active: 
     #Get the dart's current position.
     current = dart.get(viz.POSITION)
     #Get the vector for the direction in which the dart is positioned.
     vector = dart.get(viz.LOOK)
     #Find the dart's future position if it travels along the vector .1 meter.
     future = vizmat.MoveAlongVector(current, vector,.1)
     #Draw a line between the current and future positions and 
     #see if it intersects anything.
     hit = viz.intersect(current, future)
     
     #If the dart has hit anything, stop it. 
     if hit.intersected:
        active = 0
     

        #Move the dart to the future position. 
     dart.translate(future)
      

viz.callback(viz.TIMER_EVENT,ontimer)
viz.starttimer(ANIMATION,.01,viz.PERPETUAL)

Call the following code to visualize the line for your develpment:

Code:
viz.startlayer(viz.LINE_LOOP)
viz.vertex(p1)
viz.vertex(p2)
line = viz.endlayer()

p1 and p2 are the current and future points of the car. You are going to have to offset these points the lenght of the car, in the z direction, in the car's viz.LOCAL_RELETIVE coordinates.
Reply With Quote
  #7  
Old 06-09-2006, 06:03 PM
mspusch mspusch is offline
WorldViz Team Member
 
Join Date: Feb 2003
Posts: 211
Location of physics demo files:
With the standard Vizard 2.5xx installation, the physics files can be found at
program files / vizard25/examples/physics.
The one that shows the intersect is physics2.py.

Driving simulation tutorial:
You might have already seen this, but a tutorial that shows how to put together a basic driving demo can be found at:
http://www.worldviz.com/vizhelp/VizH...nt_control.htm
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


All times are GMT -7. The time now is 05:43 PM.


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