added egl plugin commit
This commit is contained in:
@@ -1367,6 +1367,8 @@ void BulletURDFImporter::convertLinkVisualShapes2(int linkIndex, int urdfIndex,
|
||||
UrdfLink*const* linkPtr = model.m_links.getAtIndex(urdfIndex);
|
||||
if (linkPtr)
|
||||
{
|
||||
//(gdb) p *model.m_links.m_valueArray.m_data[0]
|
||||
std::cout << "mvp " << (*linkPtr)->m_visualArray.size() << std::endl;
|
||||
m_data->m_customVisualShapesConverter->convertVisualShapes(linkIndex,pathPrefix,localInertiaFrame, *linkPtr, &model, colObj->getBroadphaseHandle()->getUid(), bodyUniqueId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,8 +36,11 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <glad/gl.h>
|
||||
#include <glad/egl.h>
|
||||
#include "OpenGLInclude.h"
|
||||
|
||||
#include "EGL/egl.h"
|
||||
#include "EGL/eglext.h"
|
||||
#include "GL/gl.h"
|
||||
|
||||
#include "EGLOpenGLWindow.h"
|
||||
|
||||
|
||||
@@ -220,7 +220,13 @@ int b3PluginManager::loadPlugin(const char* pluginPath, const char* postFixStr)
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
b3Warning("Warning: couldn't load plugin %s\n", pluginPath);
|
||||
#ifdef _WIN32
|
||||
#else
|
||||
b3Warning("Error: %s\n", dlerror() );
|
||||
#endif
|
||||
|
||||
}
|
||||
if (!ok)
|
||||
{
|
||||
|
||||
25
examples/SharedMemory/plugins/eglPlugin/bullet.py
Normal file
25
examples/SharedMemory/plugins/eglPlugin/bullet.py
Normal file
@@ -0,0 +1,25 @@
|
||||
import os
|
||||
import time
|
||||
import subprocess
|
||||
import pybullet as p
|
||||
#subprocess.call(["hardening-check", p.__file__])
|
||||
|
||||
p.connect(p.DIRECT)
|
||||
|
||||
plugin_fn = '/home/argusm/lang/bullet3/build/lib.linux-x86_64-3.5/eglRenderer.cpython-35m-x86_64-linux-gnu.so'
|
||||
plugin = p.loadPlugin(plugin_fn,"_tinyRendererPlugin")
|
||||
print("plugin =",plugin)
|
||||
|
||||
path = '/home/argusm/lang/bullet3/examples/pybullet/gym/pybullet_data/r2d2.urdf'
|
||||
path = '/home/argusm/lang/gym-grasping/gym_grasping/robots/models/kuka_iiwa/kuka_weiss_bolt.sdf'
|
||||
#p.loadURDF(path)
|
||||
p.loadSDF(path)
|
||||
|
||||
start = time.time()
|
||||
for i in range(2000):
|
||||
p.getCameraImage(80,80)
|
||||
if i % 100 == 0 and i > 0:
|
||||
print("FPS",100/(time.time()-start))
|
||||
start = time.time()
|
||||
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
|
||||
//tinyRenderer plugin
|
||||
|
||||
/*
|
||||
import pybullet as p
|
||||
p.connect(p.GUI)
|
||||
plugin = p.loadPlugin("e:/develop/bullet3/bin/pybullet_tinyRendererPlugin_vs2010_x64_debug.dll","_tinyRendererPlugin")
|
||||
print("plugin=",plugin)
|
||||
p.loadURDF("r2d2.urdf")
|
||||
while (1):
|
||||
p.getCameraImage(320,200)
|
||||
*/
|
||||
|
||||
#include "eglRendererPlugin.h"
|
||||
#include "eglRendererVisualShapeConverter.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;
|
||||
}
|
||||
|
||||
25
examples/SharedMemory/plugins/eglPlugin/eglRendererPlugin.h
Normal file
25
examples/SharedMemory/plugins/eglPlugin/eglRendererPlugin.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef TINY_RENDERER_PLUGIN_H
|
||||
#define TINY_RENDERER_PLUGIN_H
|
||||
|
||||
#include "../b3PluginAPI.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
//initPlugin, exitPlugin and executePluginCommand are required, otherwise plugin won't load
|
||||
B3_SHARED_API int initPlugin_tinyRendererPlugin(struct b3PluginContext* context);
|
||||
B3_SHARED_API void exitPlugin_tinyRendererPlugin(struct b3PluginContext* context);
|
||||
B3_SHARED_API int executePluginCommand_tinyRendererPlugin(struct b3PluginContext* context, const struct b3PluginArguments* arguments);
|
||||
|
||||
//all the APIs below are optional
|
||||
B3_SHARED_API struct UrdfRenderingInterface* getRenderInterface_tinyRendererPlugin(struct b3PluginContext* context);
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif//#define TEST_PLUGIN_H
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,63 @@
|
||||
#ifndef EGL_RENDERER_VISUAL_SHAPE_CONVERTER_H
|
||||
#define EGL_RENDERER_VISUAL_SHAPE_CONVERTER_H
|
||||
|
||||
#include "../../../Importers/ImportURDFDemo/UrdfRenderingInterface.h"
|
||||
|
||||
struct TinyRendererVisualShapeConverter : public UrdfRenderingInterface
|
||||
{
|
||||
|
||||
struct TinyRendererVisualShapeConverterInternalData* m_data;
|
||||
|
||||
TinyRendererVisualShapeConverter();
|
||||
|
||||
virtual ~TinyRendererVisualShapeConverter();
|
||||
|
||||
virtual void convertVisualShapes(int linkIndex, const char* pathPrefix, const btTransform& localInertiaFrame, const UrdfLink* linkPtr, const UrdfModel* model, int shapeUid, int objectIndex);
|
||||
|
||||
virtual int getNumVisualShapes(int bodyUniqueId);
|
||||
|
||||
virtual int getVisualShapesData(int bodyUniqueId, int shapeIndex, struct b3VisualShapeData* shapeData);
|
||||
|
||||
virtual void changeRGBAColor(int bodyUniqueId, int linkIndex, int shapeIndex, const double rgbaColor[4]);
|
||||
|
||||
virtual void changeShapeTexture(int objectUniqueId, int linkIndex, int shapeIndex, int textureUniqueId);
|
||||
|
||||
virtual void removeVisualShape(int shapeUid);
|
||||
|
||||
virtual void setUpAxis(int axis);
|
||||
|
||||
virtual void resetCamera(float camDist, float yaw, float pitch, float camPosX,float camPosY, float camPosZ);
|
||||
|
||||
virtual void clearBuffers(struct TGAColor& clearColor);
|
||||
|
||||
virtual void resetAll();
|
||||
|
||||
virtual void getWidthAndHeight(int& width, int& height);
|
||||
virtual void setWidthAndHeight(int width, int height);
|
||||
virtual void setLightDirection(float x, float y, float z);
|
||||
virtual void setLightColor(float x, float y, float z);
|
||||
virtual void setLightDistance(float dist);
|
||||
virtual void setLightAmbientCoeff(float ambientCoeff);
|
||||
virtual void setLightDiffuseCoeff(float diffuseCoeff);
|
||||
virtual void setLightSpecularCoeff(float specularCoeff);
|
||||
virtual void setShadow(bool hasShadow);
|
||||
virtual void setFlags(int flags);
|
||||
|
||||
virtual void copyCameraImageData(unsigned char* pixelsRGBA, int rgbaBufferSizeInPixels, float* depthBuffer, int depthBufferSizeInPixels,int* segmentationMaskBuffer, int segmentationMaskSizeInPixels, int startPixelIndex, int* widthPtr, int* heightPtr, int* numPixelsCopied);
|
||||
|
||||
virtual void render();
|
||||
virtual void render(const float viewMat[16], const float projMat[16]);
|
||||
|
||||
virtual int loadTextureFile(const char* filename);
|
||||
virtual int registerTexture(unsigned char* texels, int width, int height);
|
||||
|
||||
|
||||
|
||||
virtual void syncTransform(int shapeUid, const class btTransform& worldTransform, const class btVector3& localScaling);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif //EGL_RENDERER_VISUAL_SHAPE_CONVERTER_H
|
||||
53
examples/SharedMemory/plugins/eglPlugin/premake4.lua
Normal file
53
examples/SharedMemory/plugins/eglPlugin/premake4.lua
Normal file
@@ -0,0 +1,53 @@
|
||||
|
||||
|
||||
project ("pybullet_eglRendererPlugin")
|
||||
language "C++"
|
||||
kind "SharedLib"
|
||||
|
||||
includedirs {".","../../../../src", "../../../../examples",
|
||||
"../../../ThirdPartyLibs"}
|
||||
defines {"PHYSICS_IN_PROCESS_EXAMPLE_BROWSER"}
|
||||
hasCL = findOpenCL("clew")
|
||||
|
||||
links{"BulletCollision", "Bullet3Common", "LinearMath"}
|
||||
|
||||
if os.is("MacOSX") then
|
||||
-- targetextension {"so"}
|
||||
links{"Cocoa.framework","Python"}
|
||||
end
|
||||
|
||||
|
||||
files {
|
||||
"eglRendererPlugin.cpp",
|
||||
"eglRendererPlugin.h",
|
||||
"TinyRendererVisualShapeConverter.cpp",
|
||||
"TinyRendererVisualShapeConverter.h",
|
||||
"../../../Importers/ImportColladaDemo/LoadMeshFromCollada.cpp",
|
||||
"../../../Importers/ImportColladaDemo/LoadMeshFromCollada.h",
|
||||
"../../../Importers/ImportMeshUtility/b3ImportMeshUtility.cpp",
|
||||
"../../../Importers/ImportMeshUtility/b3ImportMeshUtility.h",
|
||||
"../../../Importers/ImportObjDemo/LoadMeshFromObj.cpp",
|
||||
"../../../Importers/ImportObjDemo/LoadMeshFromObj.h",
|
||||
"../../../Importers/ImportObjDemo/Wavefront2GLInstanceGraphicsShape.cpp",
|
||||
"../../../Importers/ImportObjDemo/Wavefront2GLInstanceGraphicsShape.h",
|
||||
"../../../TinyRenderer/geometry.cpp",
|
||||
"../../../TinyRenderer/model.cpp",
|
||||
"../../../TinyRenderer/our_gl.cpp",
|
||||
"../../../TinyRenderer/tgaimage.cpp",
|
||||
"../../../TinyRenderer/TinyRenderer.cpp",
|
||||
"../../../ThirdPartyLibs/Wavefront/egl_obj_loader.cpp",
|
||||
"../../../ThirdPartyLibs/Wavefront/egl_obj_loader.h",
|
||||
"../../../ThirdPartyLibs/stb_image/stb_image.cpp",
|
||||
"../../../ThirdPartyLibs/stb_image/stb_image.h",
|
||||
"../../../ThirdPartyLibs/eglxml2/eglxml2.cpp",
|
||||
"../../../ThirdPartyLibs/eglxml2/eglxml2.h",
|
||||
"../../../OpenGLWindow/SimpleCamera.cpp",
|
||||
"../../../OpenGLWindow/SimpleCamera.h",
|
||||
"../../../Utils/b3Clock.cpp",
|
||||
"../../../Utils/b3Clock.h",
|
||||
"../../../Utils/b3ResourcePath.cpp",
|
||||
"../../../Utils/b3ResourcePath.h",
|
||||
}
|
||||
|
||||
|
||||
|
||||
50
setup.py
50
setup.py
@@ -394,6 +394,7 @@ if _platform == "linux" or _platform == "linux2":
|
||||
CXX_FLAGS += '-DDYNAMIC_LOAD_X11_FUNCTIONS '
|
||||
CXX_FLAGS += '-DHAS_SOCKLEN_T '
|
||||
CXX_FLAGS += '-fno-inline-functions-called-once '
|
||||
CXX_FLAGS += '-fPIC ' # for plugins
|
||||
sources = sources + ["examples/ThirdPartyLibs/enet/unix.c"]\
|
||||
+["examples/OpenGLWindow/X11OpenGLWindow.cpp"]\
|
||||
+["examples/ThirdPartyLibs/glad/gl.c"]\
|
||||
@@ -438,6 +439,7 @@ else:
|
||||
+["examples/ThirdPartyLibs/glad/gl.c"]\
|
||||
+ sources
|
||||
|
||||
|
||||
setup_py_dir = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
need_files = []
|
||||
@@ -458,6 +460,52 @@ print("packages")
|
||||
print(find_packages('examples/pybullet/gym'))
|
||||
print("-----")
|
||||
|
||||
egl_renderer_sources = \
|
||||
["examples/SharedMemory/plugins/eglPlugin/eglRendererVisualShapeConverter.cpp"]\
|
||||
+["examples/SharedMemory/plugins/eglPlugin/eglRendererPlugin.cpp"]\
|
||||
+["examples/Importers/ImportColladaDemo/LoadMeshFromCollada.cpp"]\
|
||||
+["examples/Importers/ImportObjDemo/LoadMeshFromObj.cpp"]\
|
||||
+["examples/Importers/ImportMeshUtility/b3ImportMeshUtility.cpp"]\
|
||||
+["examples/Importers/ImportObjDemo/Wavefront2GLInstanceGraphicsShape.cpp"]\
|
||||
+["examples/TinyRenderer/geometry.cpp"]\
|
||||
+["examples/TinyRenderer/model.cpp"]\
|
||||
+["examples/TinyRenderer/tgaimage.cpp"]\
|
||||
+["examples/TinyRenderer/our_gl.cpp"]\
|
||||
+["examples/TinyRenderer/TinyRenderer.cpp"]\
|
||||
+["examples/ThirdPartyLibs/Wavefront/tiny_obj_loader.cpp"]\
|
||||
+["examples/ThirdPartyLibs/stb_image/stb_image.cpp"]\
|
||||
+["examples/ThirdPartyLibs/tinyxml2/tinyxml2.cpp"]\
|
||||
+["examples/OpenGLWindow/SimpleCamera.cpp"]\
|
||||
+["examples/Utils/b3Clock.cpp"]\
|
||||
+["examples/Utils/b3ResourcePath.cpp"]\
|
||||
+["src/BulletCollision/CollisionShapes/btShapeHull.cpp"]\
|
||||
+["src/BulletCollision/CollisionShapes/btConvexHullShape.cpp"]\
|
||||
+["src/BulletCollision/CollisionShapes/btBoxShape.cpp"]\
|
||||
+["src/BulletCollision/CollisionShapes/btSphereShape.cpp"]\
|
||||
+["src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp"]\
|
||||
+["src/BulletCollision/CollisionShapes/btConvexShape.cpp"]\
|
||||
+["src/BulletCollision/CollisionShapes/btCollisionShape.cpp"]\
|
||||
+["src/BulletCollision/CollisionShapes/btConvexPolyhedron.cpp"]\
|
||||
+["src/BulletCollision/CollisionShapes/btConvexInternalShape.cpp"]\
|
||||
+["src/Bullet3Common/b3Logging.cpp"]\
|
||||
+["src/LinearMath/btAlignedAllocator.cpp"]\
|
||||
+["src/LinearMath/btGeometryUtil.cpp"]\
|
||||
+["src/LinearMath/btConvexHull.cpp"]\
|
||||
+["src/LinearMath/btConvexHullComputer.cpp"]\
|
||||
+["src/Bullet3Common/b3AlignedAllocator.cpp"] \
|
||||
+["examples/ThirdPartyLibs/glad/glad.c"]\
|
||||
+["examples/ThirdPartyLibs/glad/glad_glx.c"] \
|
||||
+["examples/OpenGLWindow/GLInstancingRenderer.cpp"]\
|
||||
+["examples/OpenGLWindow/EGLOpenGLWindow.cpp"]\
|
||||
+["examples/OpenGLWindow/GLRenderToTexture.cpp"]\
|
||||
|
||||
|
||||
eglRender = Extension("eglRenderer",
|
||||
sources = egl_renderer_sources,
|
||||
libraries = libraries,
|
||||
extra_compile_args=(CXX_FLAGS+'-DBT_USE_EGL ').split(),
|
||||
include_dirs = include_dirs + ["src","examples/ThirdPartyLibs","examples/ThirdPartyLibs/glad", "examples/ThirdPartyLibs/enet/include","examples/ThirdPartyLibs/clsocket/src"]
|
||||
)
|
||||
setup(
|
||||
name = 'pybullet',
|
||||
version='2.1.3',
|
||||
@@ -469,7 +517,7 @@ setup(
|
||||
license='zlib',
|
||||
platforms='any',
|
||||
keywords=['game development', 'virtual reality', 'physics simulation', 'robotics', 'collision detection', 'opengl'],
|
||||
ext_modules = [Extension("pybullet",
|
||||
ext_modules = [eglRender, Extension("pybullet",
|
||||
sources = sources,
|
||||
libraries = libraries,
|
||||
extra_compile_args=CXX_FLAGS.split(),
|
||||
|
||||
Reference in New Issue
Block a user