#1
|
|||
|
|||
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.
|
#2
|
|||
|
|||
I think the viewpoint is colliding with the car. Stop that with the following:
car.disable( viz.COLLISION ) |
#3
|
|||
|
|||
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? |
#4
|
|||
|
|||
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.
|
#5
|
|||
|
|||
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?
|
#6
|
|||
|
|||
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. |
#7
|
|||
|
|||
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 |
Thread Tools | |
Display Modes | Rate This Thread |
|
|