PDA

View Full Version : Urgent help needed for drawing mesh!!



beachboy1976
03-22-2002, 11:05 AM
Hi,
I get a vertex array for handling my data.
There are ten numbers in my array:
{ 4.11196e+006 -156404 0.000000
4.11631e+006 -156406 0.000000
4.11631e+006 156.249 0.000000
4.11196e+006 156.249 0.000000
4.11601e+006 -152445 -1.80000
4.11620e+006 -155162 -12.8000
4.11596e+006 -152238 -1.50000
4.11597e+006 -152368 -1.20000
4.11585e+006 -150986 -3.00000
4.11600e+006 -152979 -4.80000
}

I tried to use those data. However, I won't able to see anything on the screen. I use the following code to do the drawing

glNewList(1, GL_COMPILE);

//Where objects should draw, etc...
glTranslatef(0.0f,0.0f,-10.0f);
glBegin(GL_QUADS); glColor3f(1.0f,0.0f,0.0f);
for( int i = 0; i < 10; i++ ) {
glVertex3f( (float)(tempVertexArray[i].x), (float)(tempVertexArray[i].y), (float)(tempVertexArray[i].z) );
}
glEnd();
glEndList();

Thank you for any help

Coconut
03-22-2002, 11:22 AM
Originally posted by beachboy1976:
Hi,
I get a vertex array for handling my data.
There are ten numbers in my array:
{ 4.11196e+006 -156404 0.000000
4.11631e+006 -156406 0.000000
4.11631e+006 156.249 0.000000
4.11196e+006 156.249 0.000000
4.11601e+006 -152445 -1.80000
4.11620e+006 -155162 -12.8000
4.11596e+006 -152238 -1.50000
4.11597e+006 -152368 -1.20000
4.11585e+006 -150986 -3.00000
4.11600e+006 -152979 -4.80000
}

I tried to use those data. However, I won't able to see anything on the screen. I use the following code to do the drawing

glNewList(1, GL_COMPILE);

//Where objects should draw, etc...
glTranslatef(0.0f,0.0f,-10.0f);
glBegin(GL_QUADS); glColor3f(1.0f,0.0f,0.0f);
for( int i = 0; i < 10; i++ ) {
glVertex3f( (float)(tempVertexArray[i].x), (float)(tempVertexArray[i].y), (float)(tempVertexArray[i].z) );
}
glEnd();
glEndList();

Thank you for any help

First of all, your are drawing quads.
That means the first 4 vertices will form a quad, next four vertices will form another quad. The last two vertices in your list of ten vertices will be ignored by OpenGL.
Also, OpenGL assumes 4 vertices lie on a plane, otherwise the result is undefined.
Thirdly, you don't draw things with this code. You only compile a list of comands to be called later on. You need to call glCallLists(..) to execute the stuff in your list.

Hope it helps,

Coconut



[This message has been edited by Coconut (edited 03-22-2002).]

beachboy1976
03-22-2002, 12:03 PM
I am totally a beginner to OpenGL. Based on the data I have, how can I draw something on the screen, such as triangles, or quads.

Thank you for helping me


Originally posted by Coconut:
First of all, your are drawing quads.
That means the first 4 vertices will form a quad, next four vertices will form another quad. The last two vertices in your list of ten vertices will be ignored by OpenGL.
Also, OpenGL assumes 4 vertices lie on a plane, otherwise the result is undefined.
Thirdly, you don't draw things with this code. You only compile a list of comands to be called later on. You need to call glCallLists(..) to execute the stuff in your list.

Hope it helps,

Coconut

[This message has been edited by Coconut (edited 03-22-2002).]

Furrage
03-22-2002, 12:13 PM
glCallList(<ListID> ) after creating the list. In your case <ListID> = 1. Alternatively, use the code you had without the List condstructors.

Coconut
03-22-2002, 12:36 PM
First of all, what kind of data you have?
The order of vertices in the array you pass to OpenGL will affect the result.

zeckensack
03-22-2002, 12:36 PM
Your geometry coordinates are faaaaaaar out there.

beachboy1976
03-22-2002, 12:49 PM
I know. However, I don't have any option. Those data have been set by the client. I have to make a mesh based on those data.
If there any way I can do this?


Originally posted by zeckensack:
Your geometry coordinates are faaaaaaar out there.

beachboy1976
03-22-2002, 12:51 PM
The data was created based on logitude and latitude of earth. I have to use those data to create a mesh to show the client.
Please help me out with this. Is there any way I can use those data to draw a mesh?


Originally posted by Coconut:
First of all, what kind of data you have?
The order of vertices in the array you pass to OpenGL will affect the result.

Coconut
03-22-2002, 12:55 PM
I will use a simple example:
Let's say we have four vertices P1, P2, P3 and P4.
Passing the array of {P1, P2, P3, P4} will be different from {P1, P2, P4, P3}.
Can you understand this?

beachboy1976
03-22-2002, 01:13 PM
Yes Coconut.
What do we do next?

Originally posted by Coconut:
I will use a simple example:
Let's say we have four vertices P1, P2, P3 and P4.
Passing the array of {P1, P2, P3, P4} will be different from {P1, P2, P4, P3}.
Can you understand this?

Jambolo
03-24-2002, 11:56 AM
Hey BeachBoy,

Looking for someone to teach you OpenGL via this forum is not going to work. More effective would be to get a book and/or go through some tutorials.

Try this URL: http://www.opengl.org/developers/code/tutorials.html

Coconut
03-25-2002, 05:24 AM
That means you cannnot only have a list of vertices of arbitrary order. You need information at a higher level. For example, a list of triangles.
If what you have is just a list of vertices of arbitrary order, you have to build triangle list from those vertices.
In this case, you may want to read about "triangulation", "surface reconstruction".