#1
|
|||
|
|||
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. |
#2
|
|||
|
|||
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' |
#3
|
|||
|
|||
Quote:
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' Johannes |
#4
|
|||
|
|||
Is the table a subchild of another object?
|
#5
|
|||
|
|||
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 |
Thread Tools | |
Display Modes | Rate This Thread |
|
|