OcTree Plugin

Typically: "How do I... ", "How can I... " questions
formica
Posts: 52
Joined: 13 Mar 2013, 12:13

OcTree Plugin

Post by formica » 06 Nov 2015, 18:14

Hi Coppelia,
I would like to write a plugin to instantiate an Octree of the scene environment's.
Starting from the tutorial and various example I can suppose how to write down the code.
But I don't figured out how to DRAW the octree in the environment (I imagine something like boundingbox or a wireframe).
As alternatives I can generate a big set of non-collidable/non-solid box shapes with transparent color.

Image

Any idea or suggestion?
Regards

Roberto

formica
Posts: 52
Joined: 13 Mar 2013, 12:13

Re: OcTree Plugin

Post by formica » 06 Nov 2015, 19:00

Image

coppelia
Site Admin
Posts: 7388
Joined: 14 Dec 2012, 00:25

Re: OcTree Plugin

Post by coppelia » 07 Nov 2015, 15:39

Hello Roberto,

you have 2 possibilities:
  • You can use simAddDrawingObject and simAddDrawingObjectItem.
  • You can directly draw via openGl commands from your plugin. For that, you need to enable a callback with: simEnableEventCallback(sim_message_eventcallback_opengl,"MyPlugin",-1); Then, the sim_message_eventcallback_opengl message will be generated many times for each camera rendering. Make sure to respond to the casllback only for one specific call location
Cheers

formica
Posts: 52
Joined: 13 Mar 2013, 12:13

Re: OcTree Plugin

Post by formica » 07 Nov 2015, 19:40

What do you think should be the faster solution?

Regards
Roberto

coppelia
Site Admin
Posts: 7388
Joined: 14 Dec 2012, 00:25

Re: OcTree Plugin

Post by coppelia » 08 Nov 2015, 14:25

I would first try with the drawing object, since this is very quickly implemented. And there shouldn't be too large speed differences between the two methods.

Cheers

formica
Posts: 52
Joined: 13 Mar 2013, 12:13

Re: OcTree Plugin

Post by formica » 09 Nov 2015, 17:12

Thanks coppelia, I choosed to write a plugin.

Where I should put the simEnableEventCallback(sim_message_eventcallback_opengl, "Octree", -1)??
It is a regular Api function without LUA version according to the manual (it is not recognized by vrep, inside a script), so I guess should be inserted in the plugin code.

Roberto

formica
Posts: 52
Joined: 13 Mar 2013, 12:13

Re: OcTree Plugin

Post by formica » 09 Nov 2015, 17:44

FOUND IT!

I have put the function in v_repStart and it works: I'm intercepting the opengl callback message.
My two cents!

Now,
1. which version of OpenGL I have to use on Linux?
2. Can you explain the meaning of the field auxilaryData?
sim_message_eventcallback_opengl. Enable via simEnableEventCallback. (called from the UI thread)
the user can perform openGl calls from the plugin, in order to draw custom graphics into the V-REP scene. This has a different functionality from the simAddDrawingObject API function. Following data is sent to the plugins:
auxiliaryData[0]=index of the program location where the call occured (e.g. 0=before first V-REP rendering, 5=after last V-REP rendering). Refer to the source code for details.
auxiliaryData[1]=current rendering attributes
auxiliaryData[2]=handle of the camera
auxiliaryData[3]=index of the view, or -1 if view is unassociated
Regards
Roberto

coppelia
Site Admin
Posts: 7388
Joined: 14 Dec 2012, 00:25

Re: OcTree Plugin

Post by coppelia » 10 Nov 2015, 09:53

You should use regular or old-fashioned GL calls for a start, and see from there.
About the auxiliary data:
  • auxiliaryData[0]: your plugin will be called-back several times for the same camera rendering. But depending on the call location, you can render first (before V-REP renders anything), or last (after V-REP has rendered its stuff), with all the steps in-between. This is more meant when you deal with transparent or overlapping rendering. For now, just watch out a message where auxiliaryData[0] is 5.
  • auxiliaryData[1]: no need in your case
  • auxiliaryData[2]: the handle of the camera that is currently rendering the view. A V-REP scene might contain several cameras and views, and each display will trigger several camera renderings.
  • auxiliaryData[3]: no need in your case
From your plugin you can also call simAddDrawingObject and simAddDrawingObjectItem. This would be the quicker and simpler approach.

Cheers

formica
Posts: 52
Joined: 13 Mar 2013, 12:13

Re: OcTree Plugin

Post by formica » 10 Nov 2015, 10:20

Thanks for your hints.
I'm searching for a way to use simAddDrawingObject for my purpose. I need to draw a lattice as a set of wireframe transparent (non-solid) cubes centered on a set of points.
From what I understand, I cannot draw a cube but a cube-point (or a sphere-point). I could use lines but It will be too hard...
so I'm focusing on a pure OpenGL approach.

But maybe I'm not getting something...

cheers

coppelia
Site Admin
Posts: 7388
Joined: 14 Dec 2012, 00:25

Re: OcTree Plugin

Post by coppelia » 10 Nov 2015, 10:31

Well, if you need to draw triangular faces, then you could use simAddDrawingObject with sim_drawing_triangles. But for a cube you would have to draw 12 triangles, which makes the second solution slowly more appealing.

Cheers

Post Reply