I am trying to create a geom with vertex data that is stored in a numpy array.
On this topic: [url]Particle simulation nBody] i found the Information that i have to pack the data of the numpy array into a string buffer, and assign it to the geomverteddataarray of the geom.
This works all well (no exception, wrong result) with the exception that some vertices aren’t in the right place.
I guess that the chosen vertex format of panda and my numpy array format doesn’t match exactly (v3n3t2 <> 8*float32).
This is the critical part of the code:
format=GeomVertexFormat.getV3n3t2() #vertex 3 normal 3 texture 2 (v3n3t2)
vdata=GeomVertexData('geometry', format, Geom.UHStatic)
tri=GeomTriangles(Geom.UHStatic)
geomVertexNumpyData = np.empty((vertListLength,8),dtype=np.float32)
#add some data to the array and tri
data = geomVertexNumpyData.tostring()
geomVertexDataArray.modifyArray(0).modifyHandle().setData(data)
geomChunk=Geom(vdata)
geomChunk.addPrimitive(tri)
I want to use pyopencl to calculate the values for the numpy array, therefor the GeomVertexWriter isn’t a option.
In addition to this i am really interested in a way to add data to GeomTriangles(Geom.UHStatic) in a similar way. Is this only a array containing the indices to a triangle in the following form: [[int,int,int],[int,int,int],…]?
Thanks in advance