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();
Originally posted by beachboy1976:
[b]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[/b]
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).]
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:
[b] 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).][/b]
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.
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.
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?
Originally posted by Coconut:
[b]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?
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”.