Merge pull request #1217 from erwincoumans/master

texture check fix
This commit is contained in:
erwincoumans 2017-07-01 12:37:09 -07:00 committed by GitHub
commit afd6db7c40
8 changed files with 74 additions and 15 deletions

Binary file not shown.

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,29 @@
<?xml version="0.0" ?>
<robot name="plane">
<link name="planeLink">
<contact>
<lateral_friction value="1"/>
</contact>
<inertial>
<origin rpy="0 0 0" xyz="0 0 0"/>
<mass value=".0"/>
<inertia ixx="0" ixy="0" ixz="0" iyy="0" iyz="0" izz="0"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="plane_transparent.obj" scale="1 1 1"/>
</geometry>
<material name="white">
<color rgba="1 1 1 0.4"/>
</material>
</visual>
<collision>
<origin rpy="0 0 0" xyz="0 0 -5"/>
<geometry>
<box size="30 30 10"/>
</geometry>
</collision>
</link>
</robot>

View File

@ -292,10 +292,10 @@ int OpenGLGuiHelper::registerTexture(const unsigned char* texels, int width, int
return textureId;
}
void OpenGLGuiHelper::changeTexture(int textureUniqueId, const unsigned char* texels, int width, int height)
void OpenGLGuiHelper::changeTexture(int textureUniqueId, const unsigned char* rgbTexels, int width, int height)
{
bool flipPixelsY = true;
m_data->m_glApp->m_renderer->updateTexture(textureUniqueId, texels,flipPixelsY);
m_data->m_glApp->m_renderer->updateTexture(textureUniqueId, rgbTexels,flipPixelsY);
}

View File

@ -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;
@ -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;

View File

@ -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<numPixels*3;i++)
@ -4600,7 +4600,7 @@ static PyObject* pybullet_changeTexture(PyObject* self, PyObject* args, PyObject
}
}
commandHandle = b3CreateChangeTextureCommandInit(sm,textureUniqueId, width,height,pixelBuffer);
commandHandle = b3CreateChangeTextureCommandInit(sm,textureUniqueId, width,height,(const char*) pixelBuffer);
free(pixelBuffer);
statusHandle = b3SubmitClientCommandAndWaitStatus(sm, commandHandle);
statusType = b3GetStatusType(statusHandle);
@ -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");

View File

@ -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.1.8',
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',