#61727 - Webez - Tue Nov 22, 2005 10:09 pm
Hi.
Let's see if someone can help me this time (it seems I ask boring questions). I'm doing a direct md2 loader for nds. I put .md2 and .pcx files in the data directory so they can be converted to .bin. The .pcx is 256x256, 8 bits. The model shows ok but there is something wrong with the texture mapping.
This piece of code shows how textcoords are loaded from md2
This is how texcoords are used
And texture is loaded like this
I also have upload a demo that shows the problem.
http://www.4shared.com/file/506245/312bee26/md2.html
Thanks
Let's see if someone can help me this time (it seems I ask boring questions). I'm doing a direct md2 loader for nds. I put .md2 and .pcx files in the data directory so they can be converted to .bin. The .pcx is 256x256, 8 bits. The model shows ok but there is something wrong with the texture mapping.
This piece of code shows how textcoords are loaded from md2
Code: |
for (i=0;i<md2Header->numTexCoords;i++){
memcpy(m_pTexCoords, &file[indice+(i*sizeof(tMd2TexCoord))], sizeof(tMd2TexCoord)); mesh->maps.push_back(new DS_TexMap(intot16(m_pTexCoords->u),intot16(256-m_pTexCoords->v))); } |
This is how texcoords are used
Code: |
glTexCoord2t16(mesh->maps[mesh->mapIndex[i]->indexA]->u,mesh->maps[mesh->mapIndex[i]->indexA]->v); |
And texture is loaded like this
Code: |
sImage file;
int texture,sizeX,sizeY; loadPCX((u8*)name, &file); image8to16(&file); switch (file.height){ case 8: sizeX= TEXTURE_SIZE_8; break; case 16: sizeX= TEXTURE_SIZE_16; break; case 32: sizeX= TEXTURE_SIZE_32; break; case 64: sizeX= TEXTURE_SIZE_64; break; case 128: sizeX= TEXTURE_SIZE_128; break; case 256: sizeX= TEXTURE_SIZE_256; break; case 512: sizeX= TEXTURE_SIZE_512; break; case 1024: sizeX= TEXTURE_SIZE_1024; break; default: return 0; } switch (file.width){ case 8: sizeY= TEXTURE_SIZE_8; break; case 16: sizeY= TEXTURE_SIZE_16; break; case 32: sizeY= TEXTURE_SIZE_32; break; case 64: sizeY= TEXTURE_SIZE_64; break; case 128: sizeY= TEXTURE_SIZE_128; break; case 256: sizeY= TEXTURE_SIZE_256; break; case 512: sizeY= TEXTURE_SIZE_512; break; case 1024: sizeY= TEXTURE_SIZE_1024; break; default: return 0; } glGenTextures(1, &texture); glBindTexture(0, texture); glTexImage2D(0, 0, GL_RGB, sizeX , sizeY, 0, TEXGEN_TEXCOORD, file.data8); imageDestroy(&file); |
I also have upload a demo that shows the problem.
http://www.4shared.com/file/506245/312bee26/md2.html
Thanks