Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/vrmedia2/public_html/forums/Sources/Load.php(225) : runtime-created function on line 3
about collisions
Welcome, Guest. Please login or register.
June 28, 2017, 07:09:21 AM

Login with username, password and session length
Search:     Advanced search
SMF - Just Installed
1444 Posts in 465 Topics by 370 Members
Latest Member: landiandrea
* Home Help Search Login Register
|-+  Programming with XVR
| |-+  Real-Time Physics (Moderators: ilmale, Cristina)
| | |-+  about collisions
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Print
Author Topic: about collisions  (Read 5962 times)
Offline Offline

Posts: 3

« on: June 10, 2009, 04:43:38 AM »

One can find just EVERYTHING in this forum!!!

I was wondering since 2 days how I could "drive" an object with an external device (i.e. using setposition), and at the same time avoid that it penetrates other existing objects... then I found this:

the triad dynamic empty object, fixed joint and physical object works perfectly.
Thanks Rosario.

Now I need to understand how to work with collisions. It's not clear at all to me, how they work.
The examples and tutorials that I could find are based on previous versions of the library.
What example/tutorial could I start with?

Global Moderator
Hero Member
Offline Offline

Posts: 140

« Reply #1 on: June 10, 2009, 03:42:36 PM »

 to retrieve collision you have to:
a- call setupCollisionReport that enable the collision report between two object. Collision report is quite expensive if is done for every collision, so by default is disabled.
this is the function:
phManager.setupCollisionReport(actor1, actor2, flag, getForce);
actor1 and 2 are the two object that you want to get the collision, if you want to check the collision with the intere scene you have to call setupCollisionReport for every couple. :-S
flag can be:
  • NOTIFY_ON_START_TOUCH: report is generated when the object start colliding
  • NOTIFY_ON_TOUCH: report is generated in every step the object are in collision
  • NOTIFY_ON_END_TOUCH: report is generated when the object stop colling
The last parameter is a boolean that tell the function to retrieve the collision force and

Then you have to create some collisionStruct to retrieve the collision value, i suggest you to create these collision only one time as global variable.

collisions = array(42);
for(var i = 0; i < 42; ++i)
collisions[i] = collisionStruct();

then you have to call
ret = phManager.getGlobalCollision(&collisions);
this function fill the collisions structs and return the number of collision occurred since the last call of this function.

The collision buffer is very limited so I suggest you to call the getGlobalColision every simulation step to not overflow it.
If the buffer is overflowed the first collision is overwritten, don't rely on the fact that after a START_COLLISION you always get a END_COLLISION.

Note: The collision are signaled only if they really occour, if two object of different collision group are touching you will get a collision point only if the collision are not disabled.

Don't abuse of these function because are quite slow (and the buffer is small).

I have attached some other demo to the post, you will find a demo called "Contatti" that you how to retrieve collision (I think you have to work a bit on the paths the make them works)

~ ~ I tell you, realtime 3D is made of blood, sweat and screams! ~ ~
Offline Offline

Posts: 3

« Reply #2 on: June 16, 2009, 03:39:43 AM »

Thanks a lot.
sorry for the late answer...
I had more or less precisely found the way to do that, so I didn't chech the thread for a while...

thanks a lot
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.8 | SMF © 2006-2008, Simple Machines LLC Valid XHTML 1.0! Valid CSS!