WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #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
 


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 10:51 PM.


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