Jump to content
  • Advertisement
Sign in to follow this  
HHKUPM

OpenGL OpenGL with text files

This topic is 3416 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Dear All, I have a question and a problem need to be solved asap so i need your appreciated help. I have a data of (x,y,z) were saved in a text file and i need to show these data in 3D (render them).I used lesson 25 from NeHe's website here and i improved it to fit with my text file and it drew the data but the problem is that they were not in the shape of complete 3D. I got like slices of (x,y) and separated by (z). I need to connect these points so it would look like one complete shape and i have tried all functions of (GL_lines, GL_polygons,GL_points, etc) but none of them did the job. Please if you have any suggestions for me to get good results i would highly appreciate them. If you need more details about my data or the source code just ask and i will support you with all till we get to the final result. I am not that good in programming and i really need your help. Thank you.

Share this post


Link to post
Share on other sites
Advertisement
I sounds like you want to render a volume that encloses all the points, correct? In this case, I am afraid that there is no simple way to do this. You need to construct the convex hull of your set of points, and render that as a polygonal mesh. I don't have a simple answer for you, but here is a decent overview of the possible algorithms to perform this.

Share this post


Link to post
Share on other sites
Thank you for your fast reply swiftcoder and i really appreciate it.Yes as you said i need to render my points and get them to look in decent look. Right now i have them in 3D but the problem is x and y look in slices and z just separate between them but not like sphere or complete 3D. I tried to use mesh function btu did not work with me. Can you give me an examples of how to use mesh or polygonal mesh function? Do you have any source code examples for rendering data from text files please? Sorry for asking too much but im not really good in programming...if you have anything want to send it please send it to my email hassanhadi2@yahoo.com and i will reallt appreciate it for you my friend. Thank you.

Share this post


Link to post
Share on other sites
my problem is how to connect the 3 vertices (x,y,and z) together to look like mesh shape. My data for a gray-scale image and i just need to show my data in simple mesh shape. Does anyone know how to do mesh with these data? Thank you.

my code to show the data is like this:

function DrawGLScene():bool;
var
tx, ty, tz: GLfloat;
q: Vertex;
i: integer;
begin
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(cx,cy,cz);
glRotatef(xrot,1.0,0.0,0.0);
glRotatef(yrot,0.0,1.0,0.0);
glRotatef(zrot,0.0,0.0,1.0);
xrot := xrot + xspeed;
yrot := yrot + yspeed;
zrot := zrot + zspeed;
//glBegin(GL_points);
glLineWidth(20);
glBegin(GL_line_strip);

for i := 0 to morph1.verts - 1 do
begin
if morph then q := Calculate(i)
else
begin
q.x := 0.0;
q.y := 0.0;
q.z := 0.0;
end;
helper.points.x := helper.points.x - q.x;
helper.points.y := helper.points.y - q.y;
helper.points.z := helper.points.z - q.z;
tx := helper.points.x;
ty := helper.points.y;
tz := helper.points.z;

glVertex3f(tx,ty,tz); glColor3f(0.0,0.5,1.0);
tx := tx - q.x;
ty := ty - q.y;
tz := tz - q.z;

glVertex3f(tx,ty,tz); glColor3f(0.0,0.0,1.0);
tx := tx - q.x;
ty := ty - q.y;
tz := tz - q.z;

glVertex3f(tx,ty,tz);
end;
glEnd;

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!