PDA

Click to See Complete Forum and Search --> : How to create a mesh


pradeepkrao
Oct 1st, 2002, 04:00 AM
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

ChuckB
Oct 1st, 2002, 07:08 AM
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

ChuckB
Oct 1st, 2002, 07:09 AM
Oops!
The asterisks '*' should have lined up to show lines between points b and e, c and f.
ChuckB

pradeepkrao
Oct 1st, 2002, 07:13 AM
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

ChuckB
Oct 1st, 2002, 11:22 AM
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

Zaei
Oct 1st, 2002, 12:43 PM
Yeah, Chuck, youve converted to C++ =).

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

Z.

ChuckB
Oct 1st, 2002, 10:25 PM
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

Zaei
Oct 1st, 2002, 10:30 PM
My comments in VB start like this '// =).

Z.

pradeepkrao
Oct 2nd, 2002, 11:02 PM
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