Mesh - mesh collision detection in OPCODE

View previous topic View next topic Go down

Mesh - mesh collision detection in OPCODE

Post by labrap50 on Wed Dec 09, 2015 12:55 pm

Hello everybody!!
This is the first time that I am posting a topic in this forum. I am currently using OPCODE for collision detection in virtual reality environment. As you may know that in OPCODE there is a 'collider' which collides with a triangle-mesh object. We can get the triangles (from the mesh surface) which are 'in contact' with the collider (I am using LSS and CapsuleMeshQuery as in CDTestFramework example). But, I wanted to get the contact triangles in the collider itself as well. According to the OPCODE user manual, there is a Mesh-mesh collision query that might fit my need. However, I am having difficulty while trying to understand the step and implement it, as there is no demo for this one.

Has anybody tried to implement mesh-mesh collision query, and retrieve the contact triangles from both the object and the collider? I would appreciate if I get your help on this.

- labrap

labrap50
Guest


Back to top Go down

Re: Mesh - mesh collision detection in OPCODE

Post by fengerfafa on Wed Dec 09, 2015 12:56 pm

I have the same problem!mesh vs mesh using opcode ,there lost the demo

fengerfafa
Guest


Back to top Go down

Re: Mesh - mesh collision detection in OPCODE

Post by Hanz on Wed Dec 09, 2015 12:57 pm

If I understand your question correctly, for contact between, say obj1 and obj2, you want to get the collision triangles in both objects. Right?
Then it is not that difficult. Here is the main procedure:

Code:
 
        // suppose you have set up the collision environment for obj1 and obj2
        bool IsOK = Collider.Collide(ColCache, &worldObj1, &worldObj2);

        if (IsOK) {

            // Get collision status => if true, objects overlap
            if ( Collider.GetContactStatus() ) {

                // Number of colliding pairs and list of pairs
                int TriCount = Collider.GetNbPairs();
                const Pair* CollidingPairs = Collider.GetPairs();

                if (TriCount > 0) {

                    int id1, id2;

                    for(int i = 0; i< TriCount; i++){
                        id1 = CollidingPairs[i].id0;
                        id2 = CollidingPairs[i].id1;

                        Opcode::VertexPointers VP;
                        Opcode::ConversionArea VC;

                        // obj1.getMeshData()->m_Mesh returns the mesh you set for collision object
                        obj1.getMeshData()->m_Mesh.GetTriangle(VP, id1, VC);

                        // now you get the [i]i[/i]th triangle vertex information for obj1
                        //                VP.Vertex[j]->x
                        //                VP.Vertex[j]->y
                        //                VP.Vertex[j]->z

                        // same for the other object obj2
                        obj2.getMeshData()->m_Mesh.GetTriangle(VP, id2, VC);

                        // now you get the [i]i[/i]th triangle vertex information for obj2
                        //                VP.Vertex[j]->x
                        //                VP.Vertex[j]->y
                        //                VP.Vertex[j]->z

                    }
                }
            }

Hanz
Guest


Back to top Go down

Re: Mesh - mesh collision detection in OPCODE

Post by Zizo on Wed Dec 09, 2015 12:58 pm

Hello,

I am just beginner to OpCode and actually I do not have any idea about how to use it even could not configure it with visual studio 2005. I am trying to find a simple collision detection library too detect the collision between mesh and sphere.

please, can any one help me with how to start using opcode or any advice regarding which collision detection library will help me to get my project done.

Thank you,

Zizo
Guest


Back to top Go down

Re: Mesh - mesh collision detection in OPCODE

Post by Erwin Coumans on Wed Dec 09, 2015 12:59 pm

I am trying to find a simple collision detection library too detect the collision between mesh and sphere.

Bullet collision detection can do that and it is pretty simple. You don't need to use the rigid body or soft body dynamics, they are separate libraries.

Either setup a btCollisionWorld and perform the queries, or go more low-level if needed.
Thanks,
Erwin

Erwin Coumans
Guest


Back to top Go down

Re: Mesh - mesh collision detection in OPCODE

Post by Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum