- December 4, 2009 at 9:02 pm #29999
While writing an exporter for POD files I hit a problem when trying to export EPODDataUnsignedByte based vertex data.
Essentially when exporting sBoneIdx data I want to keep the whole vertex stream aligned at 4 bytes which means in case of just 1 or 2 bones per vertex I want to pad the sBoneIdx vertex data to 4 bytes.
To do that I create an instance of CPODData which looks something like this:
EPVRTDataType eType = EPODDataUnsignedByte;
unsigned int n = 1;
unsigned int nStride = whatever stride I need to keep everything aligned at 4 bytes ( in this case it means padding it with 3 bytes)
unsigned char * pData
The problem is that the CPVRTModelPOD.SavePoD(..) method is not taking nStride into account when exporting data.
What it does is that for each vertex entry it stores CPODData.n worth of data ( in this case just one byte).
On the other hand the WriteMarker(pFile, ePODFileMeshInterleaved, false, mesh.nNumVertex * mesh.sVertex.nStride)) method
is storing a marker which correctly reflects the size of the vertex buffer.
In the end the marker and the stride value stored in the POD file indicate the correct size of the buffer but the actual vertex stream stored in the file is smaller
than that,which causes CPVRTModelPOD.ReadFromMemory to fail.
Unless I am missing something here, this makes it impossible to create 4bytes aligned POD files.December 9, 2009 at 11:53 am #33582
ScottModeratorwarmi wrote:Unless I am missing something here, this makes it impossible to create 4bytes aligned POD files.Hi,You’re correct in the current release this function does make it impossible to create 4 byte aligned POD files. For our 2.6 SDK release to incorporate data alignment in our POD exporters this function has been rewritten. If you send an email to firstname.lastname@example.org we’d gladly send you the updated code though as it is still in development it may change between now and our next release and may contain bugs.Thanks,Scott