shchoe Posted January 26, 2022 Share Posted January 26, 2022 Hi, I want to access the node and control the collision with the code. How can i access collision in node?? I want to implement the function of Grabbing nodes. Regards, shchoe Link to comment
silent Posted January 26, 2022 Share Posted January 26, 2022 shchoe What do you mean by collision access? You can check grabbing objects logic in VR Sample or even in Superposition demo that you can download via SDK Browser. Thanks! How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
shchoe Posted January 26, 2022 Author Share Posted January 26, 2022 I want grab node, use hand tracking I'm curious about surface collision of the object ex) mesh collider I'm looking for a way to access the surface collision with the code. Thank you Link to comment
karpych11 Posted January 31, 2022 Share Posted January 31, 2022 Hello. You can get information about contacts using the ShapeContact class. For example, let's create interactive objects using ObjectMeshStatic. Add a rigid body and one shape to each of them. Objects will be grab at close range, so sphere intersecton will be used to check. We will only get contacts for nearby objects and then check if the mesh is in collision. void getObjContacts(const ObjectPtr &obj, float radius, Vector<ShapeContactPtr> &all_contacts) { all_contacts.clear(); WorldBoundSphere bs(obj->getWorldPosition(), radius); Vector<NodePtr> nodes; World::getIntersection(bs, Node::OBJECT_MESH_STATIC, nodes); for (int i = 0; i < nodes.size(); i++) { BodyPtr body = nodes[i]->getObjectBody(); if (!body || body->getNumShapes() == 0) continue; ShapePtr shape = body->getShape(0); Vector<ShapeContactPtr> contacts; shape->getCollision(contacts); for (int j = 0; j < contacts.size(); j++) { if (contacts[j]->getObject() == obj) all_contacts.append(contacts[j]); } } } The result of this function looks like this: 1 Link to comment
Recommended Posts