Advertisement

Newbie ReadObject question

Started by October 09, 2002 04:41 AM
2 comments, last by Paulus_newbieus 22 years, 4 months ago
Hello all, I have started reading the nehe shadow tutorial (lesson 27), but I am struggling to understand it already and I havent even got to the shadow casting part yet. It is a rather complex tutorial, and it doesnt help that the source code is slightly different to the code segments written in the tutorial (not a Criticism, just an observation). Even though I know I am not yet at the stage to understanding the stencil buffer, I still would really like to know how the ReadObject function works. When you download the tutorial, you get different text files in the data directory. Each file stores the vertices etc. for an object. Here is the contents of ''SimpleObject.txt'':

4
-1.0  1.0 -1.0
 1.0  1.0 -1.0
 1.0  1.0  1.0
-1.0  1.0  1.0
2
1 4 3
1 3 2
 
If the source code is compiled and run using the above object, a triangle is displayed and it''s shadow is cast. As I understand it, the SimpleObject file contents are - 4 points, each point consisting of x,y and z. 2 planes, consisting of vertices (but no normals in this specific object?) Im sorry, but I dont understand how these object values relate to a triangle, because I understand a triangle as simply having three points. Could someone please explain this to me...I know it might seem basic stuff, but I really want to get this before I move on.
Anybody??

Drawing a triangle in OpenGL uses three points. Are the contents of the SimpleObject.txt file wrong, as it contains four points?
Advertisement
number of verts = 4
vert 1: -1.0 1.0 -1.0
vert 2: 1.0 1.0 -1.0
vert 3: 1.0 1.0 1.0
vert 4: -1.0 1.0 1.0
number of triangles = 2
triangle 1: 1 4 3
triangle 2: 1 3 2

where
1 4 3
1 3 2

are the vert 1, vert 2, vert 3, vert 4 above
so vert 1 and vert 3 are shared by the two triangles.
(i guess)

hope you understand now.
Ahh, thank you, that does seem to make sense. I''ll put that information into practice and see if I can make my own objects now.

Thanks for the reply.

WWW.SPANNERWORX.CO.UK - Coming soon.

This topic is closed to new replies.

Advertisement