The faceBuff=bs.readBytes(xxx*2) is most likely because faces/triangles/whatever name they use are usually stored in unsigned shorts ( = 2 bytes) therefore you read double the amount of bytes read to get your buffer
The reason you crash is because you're telling noesis to read the wrong amount of bytes in your rpgCommitTriangles
You have to tell it to parse the amount of indices and not the amount of faces. Most formats I've seen use triangles (3 indices for a face), I'm guessing it's because you're using noesis.RPGEO_TRIANGLE but the number you give isn't dividable by 3.
For the textures, I can't say because I don't know how your facebuffers are built.
Are they stored as 1 large buffer or are they seperate buffers where the numbers start allover again
Meshes with the same material might get merged into 1 mesh, I haven't really looked into Noesis' behavior for that, but you basically need to redefine
Code: Select all
rapi.rpgSetMaterial() // set the material for the mesh
rapi.rpgBindPositionBufferOfs () //You can keep using the large vertexbuffer or you can cut it up in pieces, it doesn't really matter just make sure the numbers match
rapi.rpgBindUV1BufferOfs ()
rapi.rpgCommitTriangles () //everything must be put before this
for each mesh
There are a bunch of formats you can use with the rpgCommitTriangles:
Code: Select all
PYNOECONSTN(RPGEO_NONE),
PYNOECONSTN(RPGEO_POINTS),
PYNOECONSTN(RPGEO_TRIANGLE),
PYNOECONSTN(RPGEO_TRIANGLE_STRIP),
PYNOECONSTN(RPGEO_QUAD), //ABC_DCB
PYNOECONSTN(RPGEO_POLYGON),
PYNOECONSTN(RPGEO_TRIANGLE_FAN),
PYNOECONSTN(RPGEO_QUAD_STRIP),
PYNOECONSTN(RPGEO_TRIANGLE_STRIP_FLIPPED),
PYNOECONSTN(NUM_RPGEO_TYPES),
PYNOECONSTN(RPGEO_QUAD_ABC_BCD),
PYNOECONSTN(RPGEO_QUAD_ABC_ACD),
PYNOECONSTN(RPGEO_QUAD_ABC_DCA),
if you just want to do a quick test
try this
rapi.rpgCommitTriangles(None, noesis.RPGEODATA_USHORT, numVertices, noesis.RPGEO_POINTS,1) to only have points instead of faces that way you can see if your vertexbuffer is set up correctly without having to feed facedata.
As for the "self" I'm not sure how to explain you can look at it like a custom-made container/dictionary/wrapper (i'm not sure what to use here) for which you can create functions, they belong to classes
The NoeBitStream is a class, which has serveral variables and functions.
You usually do bitstream = NoeBitStream(data)
the 'internal' noesis python scripts take the "data" and begin performing functions on it and putting it in containers/variables
for instance bitstream.data now holds all the bytes.
When defining the class you can define functions for it
for example the readByte would sort of look like this:
Code: Select all
def readByte(self): //self tells this function the first arguement is the container itself
It can then access the data variable ( which would be the bitstream.data) as self.data inside the class itself.
[url]http://cpython_sandbox.readthedocs.org/en/latest/tutorial/classes.html[/url]