From c17625a4d07736034f177e143f8c48493ed435db Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Sat, 1 Jul 2017 09:15:00 -0700 Subject: [PATCH 1/6] texture check fix --- examples/OpenGLWindow/GLInstancingRenderer.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/examples/OpenGLWindow/GLInstancingRenderer.cpp b/examples/OpenGLWindow/GLInstancingRenderer.cpp index 92a11f417..7b0c617ed 100644 --- a/examples/OpenGLWindow/GLInstancingRenderer.cpp +++ b/examples/OpenGLWindow/GLInstancingRenderer.cpp @@ -118,14 +118,14 @@ GLint lineWidthRange[2]={1,1}; enum { eGfxTransparency=1, + eGfxHasTexture = 2, }; struct b3GraphicsInstance { - GLuint m_cube_vao; - GLuint m_index_vbo; - GLuint m_textureIndex; - + GLuint m_cube_vao; + GLuint m_index_vbo; + GLuint m_textureIndex; int m_numIndices; int m_numVertices; @@ -974,6 +974,7 @@ void GLInstancingRenderer::replaceTexture(int shapeIndex, int textureId) if (textureId>=0) { gfxObj->m_textureIndex = textureId; + gfxObj->m_flags |= eGfxHasTexture; } } @@ -1052,6 +1053,7 @@ int GLInstancingRenderer::registerShape(const float* vertices, int numvertices, if (textureId>=0) { gfxObj->m_textureIndex = textureId; + gfxObj->m_flags |= eGfxHasTexture; } gfxObj->m_primitiveType = primitiveType; @@ -1438,8 +1440,8 @@ void GLInstancingRenderer::updateCamera(int upAxis) -//#define STB_IMAGE_WRITE_IMPLEMENTATION -#include "stb_image/stb_image_write.h" +////#define STB_IMAGE_WRITE_IMPLEMENTATION +#include "third_party/stblib/stb_image_write.h" void writeTextureToPng(int textureWidth, int textureHeight, const char* fileName, int numComponents) { @@ -2204,7 +2206,7 @@ b3Assert(glGetError() ==GL_NO_ERROR); { glActiveTexture(GL_TEXTURE0); GLuint curBindTexture = 0; - if (gfxObj->m_textureIndex>=0) + if (gfxObj->m_flags & eGfxHasTexture) { curBindTexture = m_data->m_textureHandles[gfxObj->m_textureIndex].m_glTexture; From 9cf747b35b6140c1000a4a55c9f79fc9bce93e42 Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Sat, 1 Jul 2017 10:01:55 -0700 Subject: [PATCH 2/6] a few compile/warning fixes --- data/multibody.bullet | Bin 14844 -> 14844 bytes examples/ExampleBrowser/OpenGLGuiHelper.cpp | 4 ++-- .../OpenGLWindow/GLInstancingRenderer.cpp | 4 ++-- examples/pybullet/pybullet.c | 5 ----- 4 files changed, 4 insertions(+), 9 deletions(-) diff --git a/data/multibody.bullet b/data/multibody.bullet index 0dee8f14afc067fbc54030a22bd9941df44f6edd..b071e4eb732e8af9e2708912d4ed2875df2e1bb5 100644 GIT binary patch delta 487 zcmexU{HJ)rmdPTVHWNS8OfFz$$z=e80}c=xL~6m94<@KG+Dxx!U~p)^&%_86<$}pT zX=XUT!JdHugdt!_!QOo!7T5K~wg|exo^kR-CUK3|LI;X}vNLShBm$-%_%T3CXJCN1 zBJW$hz0b=E>&Y@qYJ3a~kF6W*r!I-N7i90TnmmEUWby_^mWd@olMPs;SV0b8o;;C7 ze)0__<@yH<>JaxvR6$L26EvS*@66x^G|^?jV(axH?R!A(`S)$b?$5vL?PujFg88wl z+iWDxD%rgFTo3lcKg$ODD+l83b#|9qfz%VH-wd|_b;8}df9z(o{aPXdw(w|xk)5Y= zw2k-b&3h+rU{*2Mu!jL0(jePF0GZDN1_tiQ6Im=LeyTD7vNr=U7~I$#YybcMe>*65OG;YWJ}8?3CJt1y ze{uqohy_S7OcF#dDcB2F4B{{3JO|?2zX&?IS8?}ryR@`4`&lz*+D*J5CdI%|;eH4x z+hEVY2!u#rvJ8`&`X;!*hJOncLGlK_7b=1T7kr2CD`uTxV4VDrQJD7uR7JvGpv+`N z7Ht7$pgIs{0b-!5|4-h)A~yLJlcFd?*-r*rpdf?N^Rj&l@~7^ykau;MY``kw020jR zj*A7+AaEdd0oYmy50#$+6a*Oy0x+jfW?|7_1qt|04&+dtyoFi82dvc+Y5SC}Ii`H8Y2Z!T1mwD#q|Yec65{<9+)4`$X44}qTD JyplcG2mkm_glApp->m_renderer->updateTexture(textureUniqueId, texels,flipPixelsY); + m_data->m_glApp->m_renderer->updateTexture(textureUniqueId, rgbTexels,flipPixelsY); } diff --git a/examples/OpenGLWindow/GLInstancingRenderer.cpp b/examples/OpenGLWindow/GLInstancingRenderer.cpp index 7b0c617ed..c00f41be4 100644 --- a/examples/OpenGLWindow/GLInstancingRenderer.cpp +++ b/examples/OpenGLWindow/GLInstancingRenderer.cpp @@ -1440,8 +1440,8 @@ void GLInstancingRenderer::updateCamera(int upAxis) -////#define STB_IMAGE_WRITE_IMPLEMENTATION -#include "third_party/stblib/stb_image_write.h" +//#define STB_IMAGE_WRITE_IMPLEMENTATION +#include "stb_image/stb_image_write.h" void writeTextureToPng(int textureWidth, int textureHeight, const char* fileName, int numComponents) { diff --git a/examples/pybullet/pybullet.c b/examples/pybullet/pybullet.c index 4cf3eb6ac..637899e6c 100644 --- a/examples/pybullet/pybullet.c +++ b/examples/pybullet/pybullet.c @@ -4651,11 +4651,6 @@ static PyObject* pybullet_loadTexture(PyObject* self, PyObject* args, PyObject* item = PyInt_FromLong(b3GetStatusTextureUniqueId(statusHandle)); return item; } - else - { - PyErr_SetString(SpamError, "Error loading texture"); - return NULL; - } } PyErr_SetString(SpamError, "Error loading texture"); From 5178ad4abcc420f4fda0f7e097a89e3f80d31a45 Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Sat, 1 Jul 2017 10:28:28 -0700 Subject: [PATCH 3/6] add proper pointer casts --- examples/pybullet/pybullet.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/pybullet/pybullet.c b/examples/pybullet/pybullet.c index 637899e6c..aba9c69c2 100644 --- a/examples/pybullet/pybullet.c +++ b/examples/pybullet/pybullet.c @@ -4583,7 +4583,7 @@ static PyObject* pybullet_changeTexture(PyObject* self, PyObject* args, PyObject PyObject* item; int i; int numPixels = width*height; - unsigned char* pixelBuffer = (char*) malloc (numPixels*3); + unsigned char* pixelBuffer = (unsigned char*) malloc (numPixels*3); if (PyList_Check(seqPixels)) { for (i=0;i Date: Sat, 1 Jul 2017 10:43:02 -0700 Subject: [PATCH 4/6] bump up pybullet version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index d146cecc6..1a04f4de5 100644 --- a/setup.py +++ b/setup.py @@ -419,7 +419,7 @@ else: setup( name = 'pybullet', - version='1.1.8', + version='1.2.0', description='Official Python Interface for the Bullet Physics SDK Robotics Simulator', long_description='pybullet is an easy to use Python module for physics simulation, robotics and machine learning based on the Bullet Physics SDK. With pybullet you can load articulated bodies from URDF, SDF and other file formats. pybullet provides forward dynamics simulation, inverse dynamics computation, forward and inverse kinematics and collision detection and ray intersection queries. Aside from physics simulation, pybullet supports to rendering, with a CPU renderer and OpenGL visualization and support for virtual reality headsets.', url='https://github.com/bulletphysics/bullet3', From e6f7eb486a1da9a5f589f56b3aec5126ea6b8a90 Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Sat, 1 Jul 2017 10:55:13 -0700 Subject: [PATCH 5/6] bump up pybullet setup.py version --- setup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 1a04f4de5..d487f86e9 100644 --- a/setup.py +++ b/setup.py @@ -386,6 +386,7 @@ if _platform == "linux" or _platform == "linux2": sources = sources + ["examples/ThirdPartyLibs/enet/unix.c"]\ +["examples/OpenGLWindow/X11OpenGLWindow.cpp"]\ +["examples/ThirdPartyLibs/Glew/glew.c"] + include_dirs += ["examples/ThirdPartyLibs/optionalX11"] elif _platform == "win32": print("win32!") libraries = ['Ws2_32','Winmm','User32','Opengl32','kernel32','glu32','Gdi32','Comdlg32'] @@ -419,7 +420,7 @@ else: setup( name = 'pybullet', - version='1.2.0', + version='1.2.1', description='Official Python Interface for the Bullet Physics SDK Robotics Simulator', long_description='pybullet is an easy to use Python module for physics simulation, robotics and machine learning based on the Bullet Physics SDK. With pybullet you can load articulated bodies from URDF, SDF and other file formats. pybullet provides forward dynamics simulation, inverse dynamics computation, forward and inverse kinematics and collision detection and ray intersection queries. Aside from physics simulation, pybullet supports to rendering, with a CPU renderer and OpenGL visualization and support for virtual reality headsets.', url='https://github.com/bulletphysics/bullet3', From b63023c6920019fe409bc2e4638ce1da0fb9c440 Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Sat, 1 Jul 2017 11:47:57 -0700 Subject: [PATCH 6/6] add transparent plane --- data/plane_transparent.mtl | 14 ++++++++++++++ data/plane_transparent.obj | 18 ++++++++++++++++++ data/plane_transparent.urdf | 29 +++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 data/plane_transparent.mtl create mode 100644 data/plane_transparent.obj create mode 100644 data/plane_transparent.urdf diff --git a/data/plane_transparent.mtl b/data/plane_transparent.mtl new file mode 100644 index 000000000..6b700a066 --- /dev/null +++ b/data/plane_transparent.mtl @@ -0,0 +1,14 @@ +newmtl Material + Ns 10.0000 + Ni 1.5000 + d 1.0000 + Tr 0.0000 + Tf 1.0000 1.0000 1.0000 + illum 2 + Ka 0.0000 0.0000 0.0000 + Kd 0.5880 0.5880 0.5880 + Ks 0.0000 0.0000 0.0000 + Ke 0.0000 0.0000 0.0000 + map_Kd tex4x4.png + + diff --git a/data/plane_transparent.obj b/data/plane_transparent.obj new file mode 100644 index 000000000..b1317066e --- /dev/null +++ b/data/plane_transparent.obj @@ -0,0 +1,18 @@ +# Blender v2.66 (sub 1) OBJ File: '' +# www.blender.org +mtllib plane_transparent.mtl +o Plane +v 15.000000 -15.000000 0.000000 +v 15.000000 15.000000 0.000000 +v -15.000000 15.000000 0.000000 +v -15.000000 -15.000000 0.000000 + +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 + +usemtl Material +s off +f 1/1 2/2 3/3 +f 1/1 3/3 4/4 diff --git a/data/plane_transparent.urdf b/data/plane_transparent.urdf new file mode 100644 index 000000000..4054d2948 --- /dev/null +++ b/data/plane_transparent.urdf @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +