Results 1 to 9 of 9

Thread: How to create a mesh

  1. #1

    Thread Starter
    Fanatic Member pradeepkrao's Avatar
    Join Date
    Sep 2001
    Location
    New Jersey
    Posts
    534

    How to create a mesh

    Hi,

    I have n number of 3d points..
    Now i have to create a mesh out of it.. I have implemented the logic.. But it doesnt really cover the entire surface..

    Can any body tell me how to go about ..

    Thanks,
    Pradeep
    Learn by others experience as you cannot live long to experience them all.
    www.freewebs.com/pradeepkrao

    LOOK AT MY GAMES AT MY WEB SITE.

  2. #2
    Addicted Member ChuckB's Avatar
    Join Date
    Jul 2002
    Location
    South Carolina, USA
    Posts
    157
    Hi,
    I am not sure I understand your question. Here is my understanding of the concept of MESH. Let me know if this is incorrect or okay.

    Imagine two quads sharing a line.

    a **** b **** c
    * * *
    * * *
    d **** e **** f

    I use .OBJ style formats for saving this data...

    //these are vertices from above
    v a.x, a.y, a.z
    v b.x, b.y, b.z
    v . . .
    v f.x, f.y, f.z

    //this defines the two quads or 'faces'...could have used triangles
    f a,d,e,b //using CCW direction
    f b,e,c,f

    I would have two arrays (or in C++ vectors). One array would contain the vertices a through f. The second array would contain the definitions of each quad or face. Something like this for the first quad on left side...(using pseudocode)

    //stores the x,y,z components of each vertex
    vertexarray[1][1]= x coordinate of 'a'
    vertexarray[1][2]= y coordinate of 'a'
    vertexarray[1][3]= z coordinate of 'a'
    //repeat for remaining vertices

    //quad number 1 would contain these 4 vertices
    quadarray[1][1] = vertex a
    quadarray[1][2] = vertex d
    quadarray[1][3] = vertex e
    quadarray[1][4] = vertex b
    //repeat for second quad

    //drawing in OpenGL for example
    glBegin (GL_QUADS)
    increment variable m from 1 to the number of quads in mesh
    //this is 1st point
    glVertex3f( vertexarray[quadarray[m][1]] [1], //X coordinate
    vertexarray[quadarray[m][1]] [2], //Y coordinate
    vertexarray[quadarray[m][1]] [3] )//Z coordinate
    glVertex3f( vertexarray[quadarray[m][2]] [1], //X coordinate
    vertexarray[quadarray[m][2]] [2], //Y coordinate
    vertexarray[quadarray[m][2]] [3] )//Z coordinate
    glVertex3f( vertexarray[quadarray[m][3]] [1], //X coordinate
    vertexarray[quadarray[m][3]] [2], //Y coordinate
    vertexarray[quadarray[m][3]] [3] )//Z coordinate
    glVertex3f( vertexarray[quadarray[m][4]] [1], //X coordinate
    vertexarray[quadarray[m][4]] [2], //Y coordinate
    vertexarray[quadarray[m][4]] [3] )//Z coordinate
    glEnd

    Now, you say you have implemented the logic but it does not cover the entire surface. This could mean several things I suppose. I assume you have a 3D object and you are referring to its surface (should have asked this first before typing all of this stuff. :-)

    1. Missing vertices...not enough points to define your models surface.

    2. You have CCW quads or triangles mixed with CW facing quads or triangles...they're mixed...so only one type is actually showing. My example above puts all quads in CCW facing. This has been my biggest source of aggravation with 3D objects. :-(

    That's all I can think of for now.

    Well, my coffee break is well over...must go.
    Regards,
    ChuckB

  3. #3
    Addicted Member ChuckB's Avatar
    Join Date
    Jul 2002
    Location
    South Carolina, USA
    Posts
    157
    Oops!
    The asterisks '*' should have lined up to show lines between points b and e, c and f.
    ChuckB

  4. #4

    Thread Starter
    Fanatic Member pradeepkrao's Avatar
    Join Date
    Sep 2001
    Location
    New Jersey
    Posts
    534

    Thankx

    I have many 3D points.. all i have to do is connect them so that i can draw a surface..

    I am reading Delaunay Triangulation .. Seems to be a bit complex of now..

    My algorithm doesnt connect all the points to form a triangle..

    Could any one help me out..
    Pradeep
    Learn by others experience as you cannot live long to experience them all.
    www.freewebs.com/pradeepkrao

    LOOK AT MY GAMES AT MY WEB SITE.

  5. #5
    Addicted Member ChuckB's Avatar
    Join Date
    Jul 2002
    Location
    South Carolina, USA
    Posts
    157
    Hi Pradeepkrao,
    My pseudo code above works like a 'champ' in C++ and using OpenGL. I used indexed arrays. You can find tutorials on this on the internet.

    Are you using a similar method? Are you using DirectX or OpenGL? What language?

    Without any more info on your part I have NO idea what to write.

    Regards,
    ChuckB

  6. #6
    Frenzied Member Zaei's Avatar
    Join Date
    Jul 2002
    Location
    My own little world...
    Posts
    1,710
    Yeah, Chuck, youve converted to C++ =).

    He is working on a software engine in VB, from what I can tell.

    Z.

  7. #7
    Addicted Member ChuckB's Avatar
    Join Date
    Jul 2002
    Location
    South Carolina, USA
    Posts
    157
    Z,
    I have to teach VB6 intro to several engineers in 8 hours. Not sure if I can remember how to program in VB. :-) One thing for sure, VB doesn't like a comment to begin with //.

    Regards,
    ChuckB

  8. #8
    Frenzied Member Zaei's Avatar
    Join Date
    Jul 2002
    Location
    My own little world...
    Posts
    1,710
    My comments in VB start like this '// =).

    Z.

  9. #9

    Thread Starter
    Fanatic Member pradeepkrao's Avatar
    Join Date
    Sep 2001
    Location
    New Jersey
    Posts
    534

    Hi

    Hi ChuckB,

    Thank you...
    For your information..
    I am coding the application in VB as well as VC++..
    I am opting VC++ as it has multithreading..

    I am initially coding in VB and then in VC++..
    I am not using any DirectX or OpenGL..

    I am using functions like Polygon, PolyBezier etc etc...

    I would like to learn DirectX.. Can you please direct me to some good sites where they teach programing in DirectX..

    Thanks in advance,
    Pradeep
    Learn by others experience as you cannot live long to experience them all.
    www.freewebs.com/pradeepkrao

    LOOK AT MY GAMES AT MY WEB SITE.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width