PDA

View Full Version : Wire shape works solid is screwed up



nukem
06-12-2002, 02:59 PM
I wrote a 3d character file and when I load it with the code to draw a solid form the simpal shapes (triangle, square both 2d) draw fine but the more advanced shapes (a gun 3d) dosnt seem to work. Is there a way to make my code draw the more advanced shapes with being so screwed up or is there a diffrent way of making the file(changing the coords in the file) that I should do.

Wire gun
http://zonkbonk.virtualave.net/wiregun.jpg

Solid gun
http://zonkbonk.virtualave.net/gun.jpg

Here is the coords file it goes
Point_ID
X
Y
Z

25
0
0
0
24
0
0
-0.2
23
0.4
0
-0.2
22
0.4
0
0
21
0.4
0
-0.2
20
0.4
0.6
-0.2
19
0.4
0.6
0
18
0.4
0.6
-0.2
17
1.1
0.6
-0.2
16
1.1
0.6
0
15
1.1
0.6
-0.2
14
1.1
.8
-0.2
13
1.1
.8
0
12
1.1
0.8
-0.2
11
0
0.8
-0.2
10
0
0.8
0
9
0
0.8
-0.2
8
0
0
-0.2
7
0
0
0
6
0.4
0
0
5
0.4
0.6
0
4
1.1
0.6
0
3
1.1
0.8
0
2
0
0.8
0
1
0
0
0
0

Here is the code to draw it



void Draw()
{
AXIS axy;
int a = 0;

glBegin(GL_QUADS);

//glBegin(GL_TRIANGLES);

while(Print(ngc, a, &axy))
{
glVertex3f(axy.x, axy.y, axy.z);
a++;
}

glEnd();
}


thx
nuke

mikael_aronsson
06-12-2002, 11:24 PM
Hi !

A wild guess is that some of the triangles are not counter clockwise or clockwise depending on how you have setup OpenGL and then you have backface culling on maybe ? then the triangles with flipped winding order will not be displayed even though they should, could that be the problem ?

Mikael

Deiussum
06-13-2002, 04:55 AM
My guess is that you are trying to use the vertices in the same order using GL_TRIANGLES as you do for GL_LINES. You seem to be missing something from your data. Indices used for the triangles. I just took a brief look at your vertex data, but it doesn't appear any of it is duplicated as much as I would expect.

Deiussum
06-13-2002, 05:18 AM
Out of curiositiy, I loaded your data into a quick app of my own. It does appear that you have the vertices arranged for drawing line strips. For obvious reasons, you cannot use the vertices in the same order for line strips as you would for triangles or quads. A line needs only 2 points to be defined, while triangles and quads need 3 and 4. You'll either have to duplicate more vertices in the appropriate places, or have indices, which say which 3 vertices to use for each triangle (or 4 if you use quads).


Edit: They are called TRIANGLES, not TRIANGES. Me and my stupid spelling mistakes. http://www.opengl.org/discussion_boards/ubb/smile.gif


[This message has been edited by Deiussum (edited 06-13-2002).]