move stb_image/stb_image_write.cpp into a cpp file instead of random files with the magic 'STB_IMAGE_WRITE_IMPLEMENTATION' define
move setup.py back to eglRenderer extension, use pkgutil.get_loader('eglRenderer').get_filename()
disable dlmopen by default, unless B3_USE_DLMOPEN is defined.
This commit is contained in:
@@ -344,7 +344,7 @@ SET(BulletExampleBrowser_SRCS
|
||||
|
||||
../ThirdPartyLibs/stb_image/stb_image.cpp
|
||||
../ThirdPartyLibs/stb_image/stb_image.h
|
||||
|
||||
../ThirdPartyLibs/stb_image/stb_image_write.cpp
|
||||
../ThirdPartyLibs/Wavefront/tiny_obj_loader.cpp
|
||||
|
||||
../ThirdPartyLibs/tinyxml2/tinyxml2.cpp
|
||||
|
||||
@@ -182,7 +182,7 @@ project "App_BulletExampleBrowser"
|
||||
"../MultiBody/MultiBodyConstraintFeedback.cpp",
|
||||
"../MultiBody/InvertedPendulumPDControl.cpp",
|
||||
"../RigidBody/RigidBodySoftContact.cpp",
|
||||
"../ThirdPartyLibs/stb_image/*",
|
||||
"../ThirdPartyLibs/stb_image/stb_image.cpp",
|
||||
"../ThirdPartyLibs/Wavefront/tiny_obj_loader.*",
|
||||
"../ThirdPartyLibs/BussIK/*",
|
||||
"../GyroscopicDemo/GyroscopicSetup.cpp",
|
||||
|
||||
@@ -51,6 +51,7 @@ IF(BUILD_EGL)
|
||||
SET(OpenGLWindow_SRCS ${OpenGLWindow_SRCS} ${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs/glad/egl.c)
|
||||
ENDIF(BUILD_EGL)
|
||||
|
||||
SET(OpenGLWindow_SRCS ${OpenGLWindow_SRCS} ${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs/stb_image/stb_image_write.cpp)
|
||||
|
||||
|
||||
ADD_LIBRARY(OpenGLWindow ${OpenGLWindow_SRCS} ${OpenGLWindow_HDRS})
|
||||
|
||||
@@ -80,6 +80,7 @@ float shadowMapWorldSize=10;
|
||||
#include "Shaders/linesVS.h"
|
||||
|
||||
#include "GLRenderToTexture.h"
|
||||
#include "stb_image/stb_image_write.h"
|
||||
|
||||
|
||||
|
||||
@@ -1542,10 +1543,6 @@ void GLInstancingRenderer::updateCamera(int upAxis)
|
||||
|
||||
|
||||
|
||||
#ifdef STB_AGAIN // first defn in examples/OpenGLWindow/opengl_fontstashcallbacks.cpp
|
||||
#define STB_IMAGE_WRITE_IMPLEMENTATION
|
||||
#endif //STB_AGAIN
|
||||
#include "stb_image/stb_image_write.h"
|
||||
void writeTextureToPng(int textureWidth, int textureHeight, const char* fileName, int numComponents)
|
||||
{
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#define STB_IMAGE_WRITE_IMPLEMENTATION
|
||||
#include "stb_image/stb_image_write.h"
|
||||
|
||||
|
||||
|
||||
@@ -25,9 +25,12 @@
|
||||
"*.h",
|
||||
"OpenGLWindow/*.c",
|
||||
"OpenGLWindow/*.h",
|
||||
"OpenGLWindow/GL/*.h"
|
||||
"OpenGLWindow/GL/*.h",
|
||||
"../ThirdPartyLibs/stb_image/stb_image_write.cpp",
|
||||
}
|
||||
|
||||
|
||||
|
||||
if not os.is("Windows") then
|
||||
excludes {
|
||||
"Win32OpenGLWindow.cpp",
|
||||
|
||||
@@ -18,13 +18,13 @@
|
||||
#define B3_DYNLIB_IMPORT GetProcAddress
|
||||
#else
|
||||
#include <dlfcn.h>
|
||||
|
||||
|
||||
typedef void* B3_DYNLIB_HANDLE;
|
||||
|
||||
#ifdef __APPLE__
|
||||
#define B3_DYNLIB_OPEN(path) dlopen(path, RTLD_NOW | RTLD_GLOBAL)
|
||||
#else
|
||||
#ifdef B3_USE_DLMOPEN
|
||||
#define B3_DYNLIB_OPEN(path) dlmopen(LM_ID_NEWLM, path, RTLD_LAZY)
|
||||
#else
|
||||
#define B3_DYNLIB_OPEN(path) dlopen(path, RTLD_NOW | RTLD_GLOBAL)
|
||||
#endif
|
||||
#define B3_DYNLIB_CLOSE dlclose
|
||||
#define B3_DYNLIB_IMPORT dlsym
|
||||
@@ -40,16 +40,16 @@ struct b3Plugin
|
||||
PFN_INIT m_initFunc;
|
||||
PFN_EXIT m_exitFunc;
|
||||
PFN_EXECUTE m_executeCommandFunc;
|
||||
|
||||
|
||||
PFN_TICK m_preTickFunc;
|
||||
PFN_TICK m_postTickFunc;
|
||||
PFN_TICK m_processNotificationsFunc;
|
||||
PFN_TICK m_processClientCommandsFunc;
|
||||
|
||||
PFN_GET_RENDER_INTERFACE m_getRendererFunc;
|
||||
|
||||
|
||||
void* m_userPointer;
|
||||
|
||||
|
||||
b3Plugin()
|
||||
:m_pluginHandle(0),
|
||||
m_ownsPluginHandle(false),
|
||||
@@ -332,7 +332,7 @@ void b3PluginManager::tickPlugins(double timeStep, b3PluginManagerTickMode tickM
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
PFN_TICK tick = 0;
|
||||
switch (tickMode)
|
||||
{
|
||||
@@ -355,7 +355,7 @@ void b3PluginManager::tickPlugins(double timeStep, b3PluginManagerTickMode tickM
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (tick)
|
||||
{
|
||||
b3PluginContext context = { 0 };
|
||||
@@ -437,7 +437,7 @@ int b3PluginManager::registerStaticLinkedPlugin(const char* pluginPath, PFN_INIT
|
||||
{
|
||||
|
||||
b3Plugin orgPlugin;
|
||||
|
||||
|
||||
int pluginUniqueId = m_data->m_plugins.allocHandle();
|
||||
b3PluginHandle* pluginHandle = m_data->m_plugins.getHandle(pluginUniqueId);
|
||||
pluginHandle->m_pluginHandle = 0;
|
||||
@@ -453,7 +453,7 @@ int b3PluginManager::registerStaticLinkedPlugin(const char* pluginPath, PFN_INIT
|
||||
pluginHandle->m_pluginHandle = 0;
|
||||
pluginHandle->m_pluginPath = pluginPath;
|
||||
pluginHandle->m_userPointer = 0;
|
||||
|
||||
|
||||
|
||||
if (pluginHandle->m_processNotificationsFunc)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
|
||||
#ifdef EGL_ADD_PYTHON_INIT
|
||||
#if defined(__APPLE__) && (!defined(B3_NO_PYTHON_FRAMEWORK))
|
||||
#include <Python/Python.h>
|
||||
#else
|
||||
#include <Python.h>
|
||||
#endif
|
||||
#endif //EGL_ADD_PYTHON_INIT
|
||||
|
||||
//eglRenderer plugin
|
||||
|
||||
//see Bullet/examples/pybullet/examples/eglRendererTest.py
|
||||
@@ -52,3 +60,15 @@ B3_SHARED_API struct UrdfRenderingInterface* getRenderInterface_eglRendererPlugi
|
||||
return &obj->m_renderer;
|
||||
}
|
||||
|
||||
|
||||
#ifdef EGL_ADD_PYTHON_INIT
|
||||
PyMODINIT_FUNC
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
PyInit_eglRenderer(void)
|
||||
#else
|
||||
initeglRenderer(void)
|
||||
#endif
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif //EGL_ADD_PYTHON_INIT
|
||||
|
||||
@@ -795,7 +795,7 @@ void EGLRendererVisualShapeConverter::convertVisualShapes(
|
||||
// register mesh to m_instancingRenderer too.
|
||||
|
||||
int shapeIndex = m_data->m_instancingRenderer->registerShape(&vertices[0].xyzw[0], vertices.size(), &indices[0], indices.size(),B3_GL_TRIANGLES, textureIndex);
|
||||
btVector3 scaling(1,1,1);
|
||||
double scaling[3]={1,1,1};
|
||||
visuals->m_graphicsInstanceId = m_data->m_instancingRenderer->registerGraphicsInstance(shapeIndex, &visualShape.m_localVisualFrame[0], &visualShape.m_localVisualFrame[3], &visualShape.m_rgbaColor[0],scaling);
|
||||
|
||||
m_data->m_instancingRenderer->writeTransforms();
|
||||
|
||||
@@ -6,7 +6,7 @@ project ("pybullet_eglRendererPlugin")
|
||||
initEGL()
|
||||
|
||||
includedirs {".","../../../../src", "../../../../examples",
|
||||
"../../../ThirdPartyLibs", "../../examples/ThirdPartyLibs/glad"}
|
||||
"../../../ThirdPartyLibs", "../../../ThirdPartyLibs/glad"}
|
||||
defines {"PHYSICS_IN_PROCESS_EXAMPLE_BROWSER", "STB_AGAIN"}
|
||||
hasCL = findOpenCL("clew")
|
||||
|
||||
@@ -25,7 +25,8 @@ project ("pybullet_eglRendererPlugin")
|
||||
end
|
||||
|
||||
if os.is("Linux") then
|
||||
files {"../../../ThirdPartyLibs/glad/glx.c",}
|
||||
files {"../../../OpenGLWindow/EGLOpenGLWindow.cpp"}
|
||||
|
||||
end
|
||||
|
||||
files {
|
||||
|
||||
@@ -98,7 +98,8 @@ myfiles =
|
||||
"../ThirdPartyLibs/Wavefront/tiny_obj_loader.cpp",
|
||||
"../ThirdPartyLibs/tinyxml2/tinyxml2.cpp",
|
||||
"../Importers/ImportMeshUtility/b3ImportMeshUtility.cpp",
|
||||
"../ThirdPartyLibs/stb_image/stb_image.cpp",
|
||||
"../ThirdPartyLibs/stb_image/stb_image.cpp",
|
||||
"../ThirdPartyLibs/stb_image/stb_image_write.cpp",
|
||||
|
||||
}
|
||||
|
||||
|
||||
2
examples/ThirdPartyLibs/stb_image/stb_image_write.cpp
Normal file
2
examples/ThirdPartyLibs/stb_image/stb_image_write.cpp
Normal file
@@ -0,0 +1,2 @@
|
||||
#define STB_IMAGE_WRITE_IMPLEMENTATION
|
||||
#include "stb_image_write.h"
|
||||
@@ -73,6 +73,7 @@ SET(pybullet_SRCS
|
||||
../../examples/ThirdPartyLibs/Wavefront/tiny_obj_loader.cpp
|
||||
../../examples/ThirdPartyLibs/Wavefront/tiny_obj_loader.h
|
||||
../../examples/ThirdPartyLibs/stb_image/stb_image.cpp
|
||||
../../examples/ThirdPartyLibs/stb_image/stb_image_write.cpp
|
||||
../../examples/Importers/ImportColladaDemo/LoadMeshFromCollada.cpp
|
||||
../../examples/Importers/ImportObjDemo/LoadMeshFromObj.cpp
|
||||
../../examples/Importers/ImportObjDemo/Wavefront2GLInstanceGraphicsShape.cpp
|
||||
|
||||
40
examples/pybullet/examples/eglRenderTest.py
Normal file
40
examples/pybullet/examples/eglRenderTest.py
Normal file
@@ -0,0 +1,40 @@
|
||||
|
||||
import pybullet as p
|
||||
import time
|
||||
import pkgutil
|
||||
egl = pkgutil.get_loader('eglRenderer')
|
||||
|
||||
p.connect(p.SHARED_MEMORY_SERVER)
|
||||
|
||||
plugin = p.loadPlugin(egl.get_filename(), "_eglRendererPlugin")
|
||||
print("plugin=",plugin)
|
||||
|
||||
p.configureDebugVisualizer(p.COV_ENABLE_RENDERING, 0)
|
||||
p.configureDebugVisualizer(p.COV_ENABLE_GUI, 0)
|
||||
|
||||
p.setGravity(0,0,-10)
|
||||
p.loadURDF("plane.urdf",[0,0,-1])
|
||||
p.loadURDF("r2d2.urdf")
|
||||
|
||||
pixelWidth = 320
|
||||
pixelHeight = 220
|
||||
camTargetPos = [0,0,0]
|
||||
camDistance = 4
|
||||
pitch = -10.0
|
||||
roll=0
|
||||
upAxisIndex = 2
|
||||
|
||||
|
||||
while (p.isConnected()):
|
||||
|
||||
for yaw in range (0,360,10) :
|
||||
p.stepSimulation()
|
||||
#viewMatrix = [1.0, 0.0, -0.0, 0.0, -0.0, 0.1736481785774231, -0.9848078489303589, 0.0, 0.0, 0.9848078489303589, 0.1736481785774231, 0.0, -0.0, -5.960464477539063e-08, -4.0, 1.0]
|
||||
viewMatrix = p.computeViewMatrixFromYawPitchRoll(camTargetPos, camDistance, yaw, pitch, roll, upAxisIndex)
|
||||
projectionMatrix = [1.0825318098068237, 0.0, 0.0, 0.0, 0.0, 1.732050895690918, 0.0, 0.0, 0.0, 0.0, -1.0002000331878662, -1.0, 0.0, 0.0, -0.020002000033855438, 0.0]
|
||||
img_arr = p.getCameraImage(pixelWidth, pixelHeight, viewMatrix=viewMatrix, projectionMatrix=projectionMatrix, shadow=1,lightDirection=[1,1,1])
|
||||
#time.sleep(.1)
|
||||
#print("img_arr=",img_arr)
|
||||
|
||||
|
||||
p.unloadPlugin(plugin)
|
||||
@@ -9,7 +9,7 @@ import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
import pybullet
|
||||
import time
|
||||
|
||||
import pkgutil
|
||||
|
||||
plt.ion()
|
||||
|
||||
@@ -20,7 +20,9 @@ ax = plt.gca()
|
||||
|
||||
pybullet.connect(pybullet.DIRECT)
|
||||
|
||||
pybullet.loadPlugin("eglRendererPlugin")
|
||||
egl = pkgutil.get_loader('eglRenderer')
|
||||
|
||||
pybullet.loadPlugin(egl.get_filename(), "_eglRendererPlugin")
|
||||
pybullet.loadURDF("plane.urdf",[0,0,-1])
|
||||
pybullet.loadURDF("r2d2.urdf")
|
||||
|
||||
|
||||
@@ -153,6 +153,7 @@ if not _OPTIONS["no-enet"] then
|
||||
"../../examples/ThirdPartyLibs/Wavefront/tiny_obj_loader.cpp",
|
||||
"../../examples/ThirdPartyLibs/Wavefront/tiny_obj_loader.h",
|
||||
"../../examples/ThirdPartyLibs/stb_image/stb_image.cpp",
|
||||
"../../examples/ThirdPartyLibs/stb_image/stb_image_write.cpp",
|
||||
"../../examples/Importers/ImportColladaDemo/LoadMeshFromCollada.cpp",
|
||||
"../../examples/Importers/ImportObjDemo/LoadMeshFromObj.cpp",
|
||||
"../../examples/Importers/ImportObjDemo/Wavefront2GLInstanceGraphicsShape.cpp",
|
||||
|
||||
Reference in New Issue
Block a user