Hello,
I want to plot surface graph, the graph is XYZ points.
I tried using LINE_STRIP but the graph looks wiredframe, how can i make it look more solid?
The basic primitive in 3d graphics is the triangle, so you'll need to specify TRIANGLES as the drawing mode. Check this page for a great explanation of how different primitives work.
I tried TRIANGLES, LINES, QUADS, it gives me the same result with slight difference.
I saw screenshots of very beautyful surface plottings, how do they that?
1. Imagine a x,y grid of points.
2. Now imagine plotting points at the coordinates given by (x, y, z) where z = f(x,y)
3. Now you have the "structure" of the graph - it's vertices.
4. You want to connect these (x,y,z) points together using triangles.
5. Think of one grid cell, having four (x,y) corners making it a square:
a b
c d
6. You could draw this square using two triangles adb and acd.
7. The vertice coordinates a, b, c, d can be computed using your four corners (x,y) and the function z=f(x,y)
8. Draw the two triangles using GL_TRIANGLES primitives
9. Repeat for each grid cell!
You may want to color different corners of the triangles using for example the z value for the corner. Adding lighting and normals at each vertice using glNormal would further enhance the visual appeal of the graph.
First, try creating the surface without any textures/lighting etc. Once that is working correctly start adding features until you manage to achieve the appearance you'd like (both textures and lighting follow the same basic principles as described by objarni).
Beziers are a little more complicated - they are a mathematical representation of the surface, so you first have to "evaluate" the points of the surface (at a desired level of detail) and then connect these points to form triangles. In other words, you'll need to build upon the part you are working on right now. :)
Start from the basics and work up - this is quite a fascinating topic!
Comments
Aug 07
09:56:00Re: 3D Plot Help
posted by the FiddlerThe basic primitive in 3d graphics is the triangle, so you'll need to specify TRIANGLES as the drawing mode. Check this page for a great explanation of how different primitives work.
Aug 07
10:34:46Re: 3D Plot Help
posted by khdaniI tried TRIANGLES, LINES, QUADS, it gives me the same result with slight difference.
I saw screenshots of very beautyful surface plottings, how do they that?
Aug 07
11:32:55Re: 3D Plot Help
posted by objarni1. Imagine a x,y grid of points.
2. Now imagine plotting points at the coordinates given by (x, y, z) where z = f(x,y)
3. Now you have the "structure" of the graph - it's vertices.
4. You want to connect these (x,y,z) points together using triangles.
5. Think of one grid cell, having four (x,y) corners making it a square:
a b
c d
6. You could draw this square using two triangles adb and acd.
7. The vertice coordinates a, b, c, d can be computed using your four corners (x,y) and the function z=f(x,y)
8. Draw the two triangles using GL_TRIANGLES primitives
9. Repeat for each grid cell!
You may want to color different corners of the triangles using for example the z value for the corner. Adding lighting and normals at each vertice using glNormal would further enhance the visual appeal of the graph.
Good luck
Aug 07
11:47:56Re: 3D Plot Help
posted by khdaniThank You Objarni,
I'll try that!
Should I use any textures?
I also read about Bezier surfaces, would it be better to use it ?
Aug 07
12:04:24Re: 3D Plot Help
posted by the FiddlerFirst, try creating the surface without any textures/lighting etc. Once that is working correctly start adding features until you manage to achieve the appearance you'd like (both textures and lighting follow the same basic principles as described by objarni).
Beziers are a little more complicated - they are a mathematical representation of the surface, so you first have to "evaluate" the points of the surface (at a desired level of detail) and then connect these points to form triangles. In other words, you'll need to build upon the part you are working on right now. :)
Start from the basics and work up - this is quite a fascinating topic!
Aug 07
13:15:37Re: 3D Plot Help
posted by khdaniThank You!
Aug 13
14:25:45Re: 3D Plot Help
posted by khdaniThank you the Fiddler and Objarni for your help, I've managed to plot solid 3D surface, with nice lightings.
Thank you!
Aug 13
19:29:52Re: 3D Plot Help
posted by objarniYou have a screenshot for us ;) ?
Aug 14
11:11:51Re: 3D Plot Help
posted by khdaniWith pleasure :)
Aug 14
12:00:11Re: 3D Plot Help
posted by objarniCool!