PyBullet: move TinyRenderer into a plugin, default statically loaded. You can also dynamically load a render plugin, as shown in renderPlugin.py example. premake has a way to compile the tinyRendererPlugin.

This commit is contained in:
erwincoumans
2018-01-17 12:48:48 -08:00
parent df89ce6f92
commit 329a1f5a74
36 changed files with 397 additions and 140 deletions

View File

@@ -0,0 +1,62 @@
//tinyRenderer plugin
/*
import pybullet as p
p.connect(p.GUI)
pluginUid = p.loadPlugin("E:/develop/bullet3/bin/pybullet_testplugin_vs2010_x64_debug.dll")
commandUid = 0
argument = "plane.urdf"
p.executePluginCommand(pluginUid,commandUid,argument)
p.unloadPlugin(pluginUid)
*/
#include "tinyRendererPlugin.h"
#include "TinyRendererVisualShapeConverter.h"
#include "../../SharedMemoryPublic.h"
#include "../b3PluginContext.h"
#include <stdio.h>
struct MyRendererPluginClass
{
TinyRendererVisualShapeConverter m_renderer;
MyRendererPluginClass()
{
}
virtual ~MyRendererPluginClass()
{
}
};
B3_SHARED_API int initPlugin_tinyRendererPlugin(struct b3PluginContext* context)
{
MyRendererPluginClass* obj = new MyRendererPluginClass();
context->m_userPointer = obj;
return SHARED_MEMORY_MAGIC_NUMBER;
}
B3_SHARED_API int executePluginCommand_tinyRendererPlugin(struct b3PluginContext* context, const struct b3PluginArguments* arguments)
{
return -1;
}
B3_SHARED_API void exitPlugin_tinyRendererPlugin(struct b3PluginContext* context)
{
MyRendererPluginClass* obj = (MyRendererPluginClass*) context->m_userPointer;
delete obj;
context->m_userPointer = 0;
}
//all the APIs below are optional
B3_SHARED_API struct UrdfRenderingInterface* getRenderInterface_tinyRendererPlugin(struct b3PluginContext* context)
{
MyRendererPluginClass* obj = (MyRendererPluginClass*) context->m_userPointer;
return &obj->m_renderer;
}