WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 02-25-2005, 09:32 AM
Johannes Johannes is offline
Member
 
Join Date: Jan 2005
Posts: 143
Collision Detection often too slow

Hi,

a few weeks ago you wrote me some docs about the collission features.

Collisions mostly work fine, but as soon as e.g. a ball is moving too fast it will fall through the table or the floor...

As we discussed earlier the reason for this seems to be, that as the simulation is taking place in steps it might miss the collision-object (and this is more likely the faster the object is moving and the smaller both objects are...)

I tried to decrease my stepsize (e.g. viz.waittime(0.0001)) but 0.01 seems to be the shortest, smaller does not seem to make any difference as certainly the code inside my director-function also needs some CPU-Time...

Another idea I had that thin collision-objects as the floor could have some big block below them, so that the ball cannot run through there so easy. Works better but not perfect.

For the table I also tried the following workaround: Insted of collidemesh I used collidebox(.. .. ..). Works better, but the collidebox parameters do not seem to match the 3d-Studio Parameters (height especially). So I used projetiles as a sonar to determine the dimensions of my box-table, but first this takes sooo muuuch time and it still does not work perfectly. As soon as I change the size of the table I would have to start sonar-ing again....

Other option might be to put an invisible block below the Table surface and use this as a collidebox(...) because the dimensions might be more accurate...

Question: How do I include an invisible box? Just make a box and import it and make it box.visible(False) or does visible(False) remove it from the scene?

Help says: When an object is hidden, it is removed from the scene graph...

What would you do to improve collission-detection?

Johannes



P.S. the docs you sent me

collidemesh() - When checking collisions with the object, its underlying geometry will be used. Fore complex objects this is more accurate since the collisions are going to be performed per triangle, however it uses a lot more cpu.

collidesphere(radius) - When checking collisions with the object, a bounding sphere will be used with the given radius. This uses considerably less cpu power than checking collisions with a mesh. And if your object is already spherical, then this will be more accurate also.

collidebox(width,height,depth) - When checking collisions with the object, a bounding box will be used with the given dimensions. If you don't specify the dimensions, then Vizard will automatically calculate the objects bounding box. This also uses considerably less cpu than checking with the mesh.

collidingwith(object,mode) - This checks if the object is colliding with another object. If mode is 0 then this function will return 0 or 1 to signify that the objects are colliding. If mode is 1 then this function will return a VizIntersect object, which contains detailed information about the intersection.
Reply With Quote
  #2  
Old 02-28-2005, 10:41 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
When using the collidebox function, if you don't pass any values Vizard will automatically calculate the bounding box of the object and use it for collisions. Try using this with your tables, however, if you scale the table in Vizard then it won't work.

To make an invisible box you would do as you suggested and set the visibility to 0.

There is a way to make sure the ball doesn't go through walls. Intersect the line from the balls previous position and current position with the scene. If it intersects with the room then you know you have a collision. Example:
Code:
info == room.intersect(prevPos,curPos)
if info.intersected:
	print 'ball has gone through a wall'
Reply With Quote
  #3  
Old 02-28-2005, 11:02 AM
Johannes Johannes is offline
Member
 
Join Date: Jan 2005
Posts: 143
Quote:
Originally posted by farshizzo
When using the collidebox function, if you don't pass any values Vizard will automatically calculate the bounding box of the object and use it for collisions. Try using this with your tables, however, if you scale the table in Vizard then it won't work.
No, this does not work right. I did not scale the table in vizard but the position the Ball hits the table.collidebox() a lot below the actual table-surface.

So I might have to use the invisible box.

Code:
info == room.intersect(prevPos,curPos)
if info.intersected:
	print 'ball has gone through a wall'
Thank you, very nice idea!!
Johannes
Reply With Quote
  #4  
Old 02-28-2005, 11:04 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Is the table a subchild of another object?
Reply With Quote
  #5  
Old 02-28-2005, 11:11 AM
Johannes Johannes is offline
Member
 
Join Date: Jan 2005
Posts: 143
no, it is the normal table of one of the demos. But I enlarged the x and z dimensions (and not the y dimension) in 3D-Studio.
If you would like to see it, I can email it to you. But it is also OK for me to try the invisible box..

Johannes
Reply With Quote
Reply


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 06:20 AM.


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