problem using bullet.btTriangleIndexVertexArray

alek314

09-03-2010 07:05:25

hi!
i try to use the bullet.btTriangleIndexVertexArray class in python, and use ctype to allocate the vertex and index buffer, but when i call the constructor, i got the following error:

Boost.Python.ArgumentError: Python argument types in
btTriangleIndexVertexArray.__init__(btTriangleIndexVertexArray, int, LP_c_long, int, int, LP_c_float, int)
did not match C++ signature:
__init__(struct _object *, int numTriangles, int * triangleIndexBase, int triangleIndexStride, int numVertices, float * vertexBase, int vertexStride)

any idea?
Thanks
alek314

andy

11-03-2010 08:03:11

I may have to hand wrap this function -- could you send through the test code as you have it and I'll take a look//

Andy

alek314

12-03-2010 03:09:46

import ogre.renderer.OGRE as ogre
import ogre.physics.bullet as bullet
import ctypes

class btVector3Proxy(ctypes.Structure):
_fields_ = [("m_floats", ctypes.c_float*4)]

def setValue(self, x, y, z):
self.m_floats[0] = x
self.m_floats[1] = y
self.m_floats[2] = z
self.m_floats[3] = 0

indices = (ctypes.c_int*3)()
indices[0] = 0
indices[1] = 1
indices[2] = 2

vertices = (btVector3Proxy*3)()
vertices[0].setValue(1,0,0)
vertices[1].setValue(0,1,0)
vertices[2].setValue(0,0,1)

vertexArray = bullet.btTriangleIndexVertexArray(
1, ctypes.cast(ctypes.addressof(indices), ctypes.POINTER(ctypes.c_int)), 3*ctypes.sizeof(ctypes.c_int),
3, ctypes.cast(ctypes.addressof(vertices), ctypes.POINTER(ctypes.c_float)), ctypes.sizeof(btVector3Proxy)
)