
Originally Posted by
The Owl
this is litterly pointless and a waste of time because @
GigaToni released sco import for 3ds max, which you can export obj from if you really want but that's pretty much unneeded as you can just work with the raw file....
haha true but a bit too late i already did it :), i guess the good advantage of using this is you can convert multiple files with no trouble.
it was'nt too much to programming anyways the .obj support
Code:
void SaveObj(SCB* s, char* path)
{
FILE *file = fopen(path, "wb");
int i;
for(i = 0; i < s->NumVertices; i++) fprintf(file, "v %.6f %.6f %.6f\n", s->VertexPositions[i].x, s->VertexPositions[i].y, s->VertexPositions[i].z);
fprintf(file, "\n");
for(i = 0; i < s->NumVertices; i++) fprintf(file, "vn %.6f %.6f %.6f\n", s->VertexNormals[i].x, s->VertexNormals[i].y, s->VertexNormals[i].z);
fprintf(file, "\n");
for(i = 0; i < s->Faces; i++)
{
fprintf(file, "vt %.12f %.12f\n", s->VertexUVs[s->IndicesA[i]].x, s->VertexUVs[s->IndicesA[i]].y);
fprintf(file, "vt %.12f %.12f\n", s->VertexUVs[s->IndicesB[i]].x, s->VertexUVs[s->IndicesB[i]].y);
fprintf(file, "vt %.12f %.12f\n", s->VertexUVs[s->IndicesC[i]].x, s->VertexUVs[s->IndicesC[i]].y);
}
int a=0,b=0,c=0, counter = 1, ca, cb,cc;
for(i = 0; i < s->Faces; i++)
{
a = s->IndicesA[i] + 1;
b = s->IndicesB[i] + 1;
c = s->IndicesC[i] + 1;
ca = counter++;
cb = counter++;
cc = counter++;
fprintf(file, "f %d/%d/%d %d/%d/%d %d/%d/%d\n", a, ca, a, b, cb, b, c,cc, c);
}
fclose(file);
}
v1.6: supports converting to .obj (do note you will have to manually place a texture in 3d max)