Advertisement

.RAW Sphere.. Odd Results.. Help!

Started by October 23, 2000 12:07 AM
8 comments, last by OpenGLNewbie 24 years, 1 month ago
Ok, I made a simple sphere in Milkshape(Yes I know its not a great program), exported to RAW, and loaded each vertex, and then pumped them all out as 1 polygon. I tried it several different ways, the above mentioned having the most favorable results, however wrong. There are 321 vertices, making 107 triangles. And then is what I get drawing them as one big poly. This looks cool, with blending on, and the color set to green. I tried making triangles, triangle strips, and fans, yada yada, the form would be spherical, but it only had weird shape triangles here and there about it.. its hard to explain but it wasn't whole. Heres an example of my code... File containing triangles like such..(In 3 per line) -0.338932 0.169466 8.000000 1.847201 0.169466 7.695507 0.336620 2.248601 7.695507 1.847201 0.169466 7.695507 3.866917 0.169466 6.805206 2.555495 2.272390 7.155417 I load them all, and draw in the same order as the load... Any advice would be great ----------------------------- What doesn't kill me today, will be there tomorrow.. Edited by - OpenGLNewbie on 10/23/00 12:08:40 AM
-----------------------------What doesn''t kill me today,will be there tomorrow..
if u made it all into one polygon (which methinks is not possible)
why dont u use GL_POLYGON

http://members.xoom.com/myBollux
Advertisement
As I mentioned before, I tried all of them, GL_TRIANGLE, GL_TRIANGLE_FAN & STRIP, POLYGON, and what not.

Heres my result using GL_TRIANGLE and code below.
Source Example 1 Results:


Source Example 2 Results:


//
    // Source Example 1glColor4f(0.0f, 1.0f, 0.0f, 1.0f);for(int poly=0; poly < Sphere.NumTriangles; poly++){glBegin(GL_TRIANGLES);glVertex3f(Sphere.triangle[poly*3].vertex->x, Sphere.triangle[poly*3].vertex->y, Sphere.triangle[poly*3].vertex->z);glVertex3f(Sphere.triangle[poly*3 + 1].vertex->x, Sphere.triangle[poly*3 + 1].vertex->y, Sphere.triangle[poly*3 + 1].vertex->z);glVertex3f(Sphere.triangle[poly*3 + 2].vertex->x, Sphere.triangle[poly*3 + 2].vertex->y, Sphere.triangle[poly*3 + 2].vertex->z);glEnd();}glColor4f(0.5f, 0.5f, 0.5f, 1.0f);glTranslatef(xpos, ypos, z);////////////////////////////////////////////// Source Example 2glBegin(GL_TRIANGLES);glColor4f(0.0f, 1.0f, 0.0f, 1.0f);for(int poly=0; poly < Sphere.NumTriangles; poly++){glVertex3f(Sphere.triangle[poly*3].vertex->x, Sphere.triangle[poly*3].vertex->y, Sphere.triangle[poly*3].vertex->z);glVertex3f(Sphere.triangle[poly*3 + 1].vertex->x, Sphere.triangle[poly*3 + 1].vertex->y, Sphere.triangle[poly*3 + 1].vertex->z);glVertex3f(Sphere.triangle[poly*3 + 2].vertex->x, Sphere.triangle[poly*3 + 2].vertex->y, Sphere.triangle[poly*3 + 2].vertex->z);glTranslatef(Sphere.triangle[poly*3 + 2].vertex->x, Sphere.triangle[poly*3 + 2].vertex->y, Sphere.triangle[poly*3 + 2].vertex->z);}glEnd();glColor4f(0.5f, 0.5f, 0.5f, 1.0f);glTranslatef(xpos, ypos, z);//////////////////////////////////////////////////// Source Example 3 - See Source Example 1 ResultsglColor4f(0.0f, 1.0f, 0.0f, 1.0f);for(int poly=0; poly < Sphere.NumTriangles; poly++){	glBegin(GL_POLYGON);	glVertex3f(Sphere.triangle[poly*3].vertex->x, Sphere.triangle[poly*3].vertex->y, Sphere.triangle[poly*3].vertex->z);	glVertex3f(Sphere.triangle[poly*3 + 1].vertex->x, Sphere.triangle[poly*3 + 1].vertex->y, Sphere.triangle[poly*3 + 1].vertex->z);	glVertex3f(Sphere.triangle[poly*3 + 2].vertex->x, Sphere.triangle[poly*3 + 2].vertex->y, Sphere.triangle[poly*3 + 2].vertex->z);	glEnd();	glTranslatef(Sphere.triangle[poly*3 + 2].vertex->x, Sphere.triangle[poly*3 + 2].vertex->y, Sphere.triangle[poly*3 + 2].vertex->z);}	glColor4f(0.5f, 0.5f, 0.5f, 1.0f);glTranslatef(xpos, ypos, z);/////////////////////////////////////    


First I''d like to apologize for those with slower connections, for all the images. Being new to this I found no better way to explain what happens when I do this and that.
In the code, Sphere is an object structure, which contains numtriangles, and a TRIANGLE * triangles which is allocated to the number of vertices loaded from the file divided by three. Triangle stores a structure VERTEX which is simple float x,y,z,u,v; Basics from NeHe tutorials.

If you need more info, please ask, as I mentioned I''m new to this and lack the understanding to better explain.

-----------------------------
What doesn''t kill me today,
will be there tomorrow..
-----------------------------What doesn''t kill me today,will be there tomorrow..
He did try GL_POLYGON, as well as a number of others. That''s what he meant by: "and then pumped them all out as 1 polygon".

The problem is, for some reason no matter what we do, we get either hash, or, if we do it as one poly we get the above pic (which while more interesting than a geosphere, is still not a geosphere )

The model was exported from MilkShape 3D as a RAW format, then parsed from the file and drawn. Does MilkShape use some strange vertex order, or unusual coordinate system?

____________________________________________________

"Two wrongs do not make a right; it usually takes 3 or more."

____________________________________________________
"Two wrongs do not make a right; it usually takes 3 or more."
Some mistakes are too much fun to only make once.
Never anger a dragon, for you are crunchy and you go well with brie.

I think you''re both insane or something... Those are OBVIOUSLY perfect spheres... Can''t you _see_ that?! Holy smokes, Batman!

No, just kidding. I know, shouldn''t kid... I''ll get kicked from this forum some day for kidding too much... Anywho, I tried to do something like this, too... Only, I tried to do it on my own, hard coding... With for loops... That was annoying. Maybe it''s spitting the verticies in a different order than you think, or maybe you''re reading them in wrong... Hmmm... The numbers you gave in the first post aren''t making too much sense to me, maybe I just don''t know what I''m talking about, though...

x y z
-0.338932 0.169466 8.000000
1.847201 0.169466 7.695507
0.336620 2.248601 7.695507
1.847201 0.169466 7.695507
3.866917 0.169466 6.805206
2.555495 2.272390 7.155417

This is either two triangles (not three as you stated in your first post) or four triangles used in a strip or fan. Or, maybe they''ve put the triangles as these

x : -0.338932 0.169466 8.000000 1.847201 0.169466 7.695507
y : 0.336620 2.248601 7.695507 1.847201 0.169466 7.695507
z : 3.866917 0.169466 6.805206 2.555495 2.272390 7.155417

I dunno, I might be wrong and deserve to be shot down and flamed etc for not knowing what I''m talking about, but hey, I''m trying to help. (Even though I may completely throw you guys off in the process...)

S.
Have you tried turning off backside culling, btw? That may be it... It may have all been drawn properly for some wierd reason, but the verticies are wound the wrong way for your code...

S.
Advertisement
Who cares if it doesn''t do what you wanted? By the look of your 1st post it''s incredibly cool anyway!! Now if you can get them animating, then I''ll be really impressed...
[size="2"]www.coldcity.com code, art, life
don''t know if this helps you or not, but i had way similiar results when trying to load data from an .mdl (QII) model that was exported with...err...some shareware program.

once i stopped reading in the surface normals and texture co-ordinates and parsed out the vertices, it looked like the model it was supposed to
Are you sure RAW files don''t have polygon definitions as well as vertices? most formats do. You might try ASE files, I''m positive they have them, and they''re *very* easy to read in.
Brought to you by: [email=ogapo@ithink.net]O.G.A.P.O.[/email] +----------------------------------------+| Surgeon General's Warning - || OGAPO can cause serious mental damage || if taken in large doses. |+----------------------------------------+/* Never underestimate the power of stupid people in large groups */
BTW I'm working with Newbie, which is why I'm answering the posts
quote:
I think you're both insane or something... Those are OBVIOUSLY perfect spheres... Can't you _see_ that?!


quote:
Who cares if it doesn't do what you wanted? By the look of your 1st post it's incredibly cool anyway!! Now if you can get them animating, then I'll be really impressed...

LOL yeah I've been trying to come up with a way of preserving this effect while actually doing it the 'right' way. Fanning out the leaves would create one hell of an interesting effect!
quote:
Have you tried turning off backside culling, btw? That may be it... It may have all been drawn properly for some wierd reason, but the verticies are wound the wrong way for your code...

Not sure how to do it, but I'll try it.
quote:
...once i stopped reading in the surface normals and texture co-ordinates and parsed out the vertices, it looked like the model it was supposed to

&
quote:
Are you sure RAW files don't have polygon definitions as well as vertices? most formats do. You might try ASE files, I'm positive they have them, and they're *very* easy to read in.

I'm really not sure exactly WHAT the file contains, but it was formatted in three columns of numbers (3 floating points per line, space delimited) so we assumed that it only contained the vertices. I'll play around with it, and some other file formats tonight and see what I can get.

Thx for the replies!


____________________________________________________

"Two wrongs do not make a right; it usually takes 3 or more."



Edited by - ratheous on October 24, 2000 5:50:40 PM

Edited by - Ratheous on October 24, 2000 5:57:21 PM

____________________________________________________
"Two wrongs do not make a right; it usually takes 3 or more."
Some mistakes are too much fun to only make once.
Never anger a dragon, for you are crunchy and you go well with brie.

This topic is closed to new replies.

Advertisement