Jump to content

collision visualisation, callback, mask


Recommended Posts

Hello

Working with physics in VR, and so visualizer are not render a thing in VR(https://developer.unigine.com/forum/topic/4446-turn-on-visualizer-in-vr/?tab=comments#comment-23169)... I'd like to see where player collide with scene (because of unexpected collision response sometime)

1. looking at examples - there only Body collision callbacks, how to call back for collided surfaces?

for example collision of VR controller and scene:

2. I should set controller transformation with setLinearVelocity... instead of setWorldTransform to get right collisions, right?

because in code for \demos\vr_template_demo_windows_2.6.0.1\source\PlayerVR\Players\PlayerVive.cpp, I see:

mat4 transform = vive.getDevicePose(device_id);  
controller[num]->setWorldTransform(player_transform * Mat4(transform));

does it mean 'if vr_template' had controller collisions - this would not work properly?

3. how to set collision mask without VRcontroller having body assigned, only surface - in editor I can see "Surfaces->Collision mask" and Body type "none" - and it has collisions in scene

https://developer.unigine.com/en/docs/2.6/code/usage/enabling_collision/?rlang=cpp&words=setcollisionmask#highlight

thanks

 

Edited by lightmap
Link to comment

Hi!

1. looking at examples - there only Body collision callbacks, how to call back for collided surfaces?
The surfaces themselves do not collide with other surfaces. Only bodies collides with surfaces (or with other bodies).
So, use int getContactSurface(int num) to get surface of the body, which is in contact. But, unfortunately, you can not take a collision of an object without Body.

2. I should set controller transformation with setLinearVelocity... instead of setWorldTransform to get right collisions, right?
Yes, you should. But, in this case, the controllers will collide with all objects (walls, tables, etc.) around. Heavy objects will be difficult to move with hands (your hands will always be somewhere behind).

3. how to set collision mask without VRcontroller having body assigned
The same way, as with the objects that have body. At the end of the page, from the link you provided, this is written:

	// setting shape collision mask for the first box  [00000000000000000000000000000010]
	box1->getBody()->getShape(0)->setCollisionMask(2);

	// setting shape collision mask for the second box  [00000000000000000000000000000001]
	box2->getBody()->getShape(0)->setCollisionMask(1);

	// setting collision mask for the plane surface  [00000000000000000000000000000010]
	plane->setCollisionMask(2, 0);

Best regards,
Alexander

  • Like 1
Link to comment

Hi, thanks

1. use int getContactSurface(int num) to get surface of the body, which is in contact. But, unfortunately, you can not take a collision of an object without Body

my VRcontroller has ObjectMeshSkinned and ->getBody() returns NULL

so https://developer.unigine.com/en/docs/2.6/api/library/objects/class.objectmeshskinned how to add (in code) a Body to ObjectMeshSkinned? do I need to cast ObjectMeshSkinned to Object https://developer.unigine.com/en/docs/2.6/api/library/objects/class.object and call "->setBody(new Body())"?

or assigning Body->Shape() are necessary too, to catch collision pos with surfaces?

Link to comment

how to add (in code) a Body to ObjectMeshSkinned?
There are two ways:
1) BodyRigidPtr body = BodyRigid::create(your_object_mesh_skinned->getObject());
or
2)  BodyRigidPtr body = BodyRigid::create();
your_object_mesh_skinned->setBody(body->getBody());

assigning Body->Shape() are necessary too, to catch collision pos with surfaces?
Yes, of course. Body without any shape - it is an infinitesimal point.

Link to comment
×
×
  • Create New...