View Single Post
Old 05-19-2006, 12:14 PM
Gladsomebeast Gladsomebeast is offline
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.

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. 


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

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