move zipfFileIO into own header
route loadTextureFile from fileIO plugin fix B3_ENABLE_FILEIO_PLUGIN logic
This commit is contained in:
@@ -1170,12 +1170,39 @@ int TinyRendererVisualShapeConverter::registerTexture(unsigned char* texels, int
|
||||
return m_data->m_textures.size() - 1;
|
||||
}
|
||||
|
||||
int TinyRendererVisualShapeConverter::loadTextureFile(const char* filename)
|
||||
int TinyRendererVisualShapeConverter::loadTextureFile(const char* filename, struct CommonFileIOInterface* fileIO)
|
||||
{
|
||||
B3_PROFILE("loadTextureFile");
|
||||
int width, height, n;
|
||||
unsigned char* image = 0;
|
||||
image = stbi_load(filename, &width, &height, &n, 3);
|
||||
if (fileIO)
|
||||
{
|
||||
b3AlignedObjectArray<char> buffer;
|
||||
buffer.reserve(1024);
|
||||
int fileId = fileIO->fileOpen(filename,"rb");
|
||||
if (fileId>=0)
|
||||
{
|
||||
int size = fileIO->getFileSize(fileId);
|
||||
if (size>0)
|
||||
{
|
||||
buffer.resize(size);
|
||||
int actual = fileIO->fileRead(fileId,&buffer[0],size);
|
||||
if (actual != size)
|
||||
{
|
||||
b3Warning("image filesize mismatch!\n");
|
||||
buffer.resize(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (buffer.size())
|
||||
{
|
||||
image = stbi_load_from_memory((const unsigned char*)&buffer[0], buffer.size(), &width, &height, &n, 3);
|
||||
}
|
||||
} else
|
||||
{
|
||||
image = stbi_load(filename, &width, &height, &n, 3);
|
||||
}
|
||||
|
||||
if (image && (width >= 0) && (height >= 0))
|
||||
{
|
||||
return registerTexture(image, width, height);
|
||||
|
||||
@@ -47,7 +47,7 @@ struct TinyRendererVisualShapeConverter : public UrdfRenderingInterface
|
||||
virtual void render();
|
||||
virtual void render(const float viewMat[16], const float projMat[16]);
|
||||
|
||||
virtual int loadTextureFile(const char* filename);
|
||||
virtual int loadTextureFile(const char* filename, struct CommonFileIOInterface* fileIO);
|
||||
virtual int registerTexture(unsigned char* texels, int width, int height);
|
||||
|
||||
virtual void syncTransform(int shapeUid, const class btTransform& worldTransform, const class btVector3& localScaling);
|
||||
|
||||
Reference in New Issue
Block a user