Results 1 to 8 of 8

Thread: UV Coordinates import from 3DS mesh file

  1. #1
    Guest

    UV Coordinates import from 3DS mesh file

    i wrote a loader for obj file(wavwe front) which is not having any texture support(bmp file with UV coordinates) to import into my GAME. i want to load the mesh object with textures from the file by generating the textures using the referenced files in the file. so i opted 3DS file and started writing a 3ds loader. but i cant find enough information on decoding the texture coordinates and the corrosponding BMP(or TGa or ...) from the 3DS file. can any one help me. i am writing a free combat flight simulation game.any one help me if u know any tutorial or 3DS loader available over the net. is there is any other file format that supports textures with UV's ?
    -indra

  2. #2
    Senior Member Regular Contributor
    Join Date
    Oct 2002
    Location
    San Diego, CA, USA
    Posts
    209

    Re: UV Coordinates import from 3DS mesh file

    Hm... I have had no problems with the 3ds loader I grabbed from www.gametutorials.com. I have been using it for quite a while, and have modified it to my tastes... Check it out, it has worked for me since day 1.




    [This message has been edited by 147-2 (edited 02-25-2004).]

  3. #3
    Senior Member Regular Contributor
    Join Date
    Feb 2000
    Posts
    211

    Re: UV Coordinates import from 3DS mesh file

    *Argh*
    i advice you honestly NOT TO USE the 3DSLOADER from gametutorials.com - because it's total ****ty: it loads only the first mesh out of the file ! (of course, no problem to extend it by yourself but if i proclaim a loader as "useable" it should be useable, and not only 50% of it!)
    DJSnow

  4. #4
    Senior Member Regular Contributor
    Join Date
    Apr 2001
    Location
    Fort Collins, Colorado
    Posts
    446

    Re: UV Coordinates import from 3DS mesh file

    I've found Lev's 3ds loader to be a helpful resource while working on my own:
    http://www.levp.de/3d/index.html

    I've also extensively used this reference to decipher the various chunks in the 3ds file:
    http://www.cyberloonies.com/3DSFTK4.htm

    Hope those links help.

  5. #5
    Guest

    Re: UV Coordinates import from 3DS mesh file

    thanku guys but i wrote my own loader that even reads tex coords and loades the textures an dbulds the lists too.the only problem is vertex normals with out them the vertex and every thing else is quiet good except the faces. they are not smmoth at the borders . each face is seperate plane.iwant more smoothed view . is there is any other thing for that thann increasing polygon tessalation(detail)? will vertex normals work? iam still specifying face normals only!
    thans for ur time
    -indra

  6. #6
    Senior Member Regular Contributor
    Join Date
    Apr 2001
    Location
    Fort Collins, Colorado
    Posts
    446

    Re: UV Coordinates import from 3DS mesh file

    Generating vertex normals will indeed smooth things out. For each vertex, average the normals of all faces that share that vertex.

  7. #7
    Member Newbie
    Join Date
    Nov 2003
    Location
    Gliwice, Slaskie, Poland
    Posts
    45

    Re: UV Coordinates import from 3DS mesh file

    Yes, this exactly what 3DSLoader from www.gametutorials.com does :-p

  8. #8
    Guest

    Re: UV Coordinates import from 3DS mesh file

    vertex normals r introducing another problem. the model looks obscurely shaded .what i mean by that is it is having parallel bands in that which are much significant at larger distances and not much problem at less viewing distances from the object.

    this is the code for calculating face normals and vertex normals for each individual object in the 3ds file.

    void CGLMFC1View::calcAllNormals(MeshObj *p_object)
    { TRACE0("calcAllNormals()");
    GLfloat in[3][3],out[3];
    int a,b,c;
    int i=0,j=0,faces[100],facecounter=0,nfacesV=0;
    GLfloat tempNormal[3];
    //first lets calculate the face normals
    for( i=0;i<p_object->face_qty;i++)
    {


    //get its vertices indexes
    a=p_object->face[i].a;
    b=p_object->face[i].b;
    c=p_object->face[i].c;
    //load the 3 vertices in to the array in[][]
    in[0][0]=p_object->vertex[a].x;
    in[0][1]=p_object->vertex[a].y;
    in[0][2]=p_object->vertex[a].z;
    in[1][0]=p_object->vertex[B].x;
    in[1][1]=p_object->vertex[B].y;
    in[1][2]=p_object->vertex[B].z;
    in[2][0]=p_object->vertex[c].x;
    in[2][1]=p_object->vertex[c].y;
    in[2][2]=p_object->vertex[c].z;

    //calculate and specify the normal
    calcNormal(in,out);
    p_object->facenormal[i].x=out[0];
    p_object->facenormal[i].y=out[1];
    p_object->facenormal[i].z=out[2];
    }
    p_object->face_normal_qty=i-1;

    // now lets calculate the vertex normals by averaging the face normals
    for(i=0;i<p_object->vertices_qty;i++)
    { facecounter=0;
    nfacesV=0;
    //search the for the shared faces of this ith Vertex
    for( j=0;j<p_object->face_qty;j++)
    {
    int temp1=p_object->face[j].a;
    int temp2=p_object->face[j].b;
    int temp3=p_object->face[j].c;
    int l=i;
    if(temp1==l&#0124; &#0124;temp2==l&#0124; &#0124;temp3==l)
    {
    facecounter++;
    faces[nfacesV]=j;
    nfacesV++;
    }
    }
    tempNormal[0]=tempNormal[1]=tempNormal[2]=0.0f;
    for(int k=0;k<facecounter;k++)
    {
    tempNormal[0]+=p_object->facenormal[faces[k]].x;
    tempNormal[1]+=p_object->facenormal[faces[k]].y;
    tempNormal[2]+=p_object->facenormal[faces[k]].z;

    }
    if(facecounter!=0)
    { p_object->vetrtexnormal[i].x=tempNormal[0]/facecounter;
    p_object->vetrtexnormal[i].y=tempNormal[1]/facecounter;
    p_object->vetrtexnormal[i].z=tempNormal[2]/facecounter;
    }
    }


    }

Similar Threads

  1. import .x file
    By appdeveloper in forum OpenGL: Advanced Coding
    Replies: 8
    Last Post: 10-17-2009, 04:25 PM
  2. need .3ds file for import into opengl
    By openglnovice in forum OpenGL: Basic Coding
    Replies: 7
    Last Post: 12-06-2005, 10:51 AM
  3. how can import .flt file in opengl
    By sujudavid in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 11-17-2004, 07:48 PM
  4. .obj File Import
    By JimmyFo in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 09-24-2004, 05:37 AM
  5. how to import a *.max file to opengl?
    By kouwww in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 03-15-2004, 04:31 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean