How to obtain handles from objects in scene in plugin

Typically: "How do I... ", "How can I... " questions
Post Reply
gregor_ws
Posts: 5
Joined: 21 Nov 2023, 16:41

How to obtain handles from objects in scene in plugin

Post by gregor_ws »

Hi,
I've been playing with plugins a bit and wanted to have access to the handle of a specific object in the scene which I know its name. How could I do this from inside the plugin?. In general, how could I obtain information from the simulation back into the plugin?. I've seen that in the OpenGL3 plugin in each message they receive a data pointer, and start grabbing the information from there, like this:

Code: Select all

    if ( (message==sim_message_eventcallback_extrenderer_mesh)&&(currentOffscreen!=nullptr) )
    {
        // Collect mesh data from CoppeliaSim:
        void** valPtr=(void**)data;
        float* vertices=((float*)valPtr[0]);
        int verticesCnt=((int*)valPtr[1])[0];
        int* indices=((int*)valPtr[2]);
        int triangleCnt=((int*)valPtr[3])[0];
        float* normals=((float*)valPtr[4]);
        int normalsCnt=((int*)valPtr[5])[0];
        float* colors=((float*)valPtr[8]);
        C7Vector tr(C4Vector((float*)valPtr[7]),C3Vector((float*)valPtr[6]));
        bool textured=((bool*)valPtr[18])[0];
        float shadingAngle=((float*)valPtr[19])[0];
        bool translucid=((bool*)valPtr[21])[0];
        float opacityFactor=((float*)valPtr[22])[0];
        bool backfaceCulling=((bool*)valPtr[23])[0];
        int geomId=((int*)valPtr[24])[0];
        int texId=((int*)valPtr[25])[0];
        unsigned char* edges=((unsigned char*)valPtr[26]);
        bool visibleEdges=((bool*)valPtr[27])[0];
        ...
Thanks in advance

fferri
Posts: 1230
Joined: 09 Sep 2013, 19:28

Re: How to obtain handles from objects in scene in plugin

Post by fferri »

There's a regular API for C/C++ plugins as well.

If in embedded scripts you would use sim.getObject to retrieve the handle of an object, in a plugin you would use simGetObject: https://manual.coppeliarobotics.com/en/ ... ct_cpp.htm

gregor_ws
Posts: 5
Joined: 21 Nov 2023, 16:41

Re: How to obtain handles from objects in scene in plugin

Post by gregor_ws »

Thanks fferri for your response, I'll check the API.

Post Reply