Page 1 of 1

How to obtain handles from objects in scene in plugin

Posted: 06 Mar 2024, 18:43
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

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

Posted: 06 Mar 2024, 20:28
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

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

Posted: 06 Mar 2024, 21:11
by gregor_ws
Thanks fferri for your response, I'll check the API.