4 Replies - 3428 Views - Last Post: 09 October 2013 - 05:44 AM

#1 AIintern  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 53
  • Joined: 06-June 12

Face list of a cube?

Posted 03 October 2013 - 04:08 PM

Hello, I was wondering if someone could explain to me how a face list works.

Here is an example for a cube

#vertices
v -1.000000 -1.000000 1.000000
v 1.000000 -1.000000 1.000000
v -1.000000 1.000000 1.000000
v 1.000000 1.000000 1.000000
v -1.000000 1.000000 -1.000000
v 1.000000 1.000000 -1.000000
v -1.000000 -1.000000 -1.000000
v 1.000000 -1.000000 -1.000000

#faces
f 1 2 3
f 3 2 4
f 3 4 5
f 5 4 6
f 5 6 7
f 7 6 8
f 7 8 1
f 1 8 2
f 2 8 4
f 4 8 6
f 7 1 5
f 5 1 3

can someone please break this down for me?

Is This A Good Question/Topic? 0
  • +

Replies To: Face list of a cube?

#2 BetaWar  Icon User is offline

  • #include "soul.h"
  • member icon

Reputation: 1137
  • View blog
  • Posts: 7,099
  • Joined: 07-September 06

Re: Face list of a cube?

Posted 03 October 2013 - 04:17 PM

It appears that they are starting off with defining all of the points (for the corners), and then listing all of the faces, as 3 of the vertices previously defined (so each face is 2 triangles).

I expect that, if you plotted the above information out on a piece of graph paper, or in a 3d graphics program, you could come up with a cube where each of the faces consist of 2 triangles (12 faces in total).
Was This Post Helpful? 0
  • +
  • -

#3 AIintern  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 53
  • Joined: 06-June 12

Re: Face list of a cube?

Posted 03 October 2013 - 07:21 PM

Thank you! I understand it better now, but how do they come up with the order, and how do you know what vertices to start at, and how do you know if to go clock wise or counter clockwise?
Was This Post Helpful? 0
  • +
  • -

#4 BetaWar  Icon User is offline

  • #include "soul.h"
  • member icon

Reputation: 1137
  • View blog
  • Posts: 7,099
  • Joined: 07-September 06

Re: Face list of a cube?

Posted 08 October 2013 - 02:39 PM

The order is probably just the same order they were in when originally creating the object. So, it will be based on what a program thinks is a good order.

The vertices are ordered from 1 to n (12 8 (I can count) in this case) and the faces tell you which vertex to go to next. So that's how you know where to do.

Clockwise/counter-clockwise doesn't matter. They should both draw the same shape... assuming I am understanding that portion of the question.
Was This Post Helpful? 0
  • +
  • -

#5 baavgai  Icon User is online

  • Dreaming Coder
  • member icon

Reputation: 5770
  • View blog
  • Posts: 12,582
  • Joined: 16-October 07

Re: Face list of a cube?

Posted 09 October 2013 - 05:44 AM

I thought a picture might help.

Sorry, not the best picture. But it should give an idea. I thought about spinning it...


Anyway, faces are labled in my simple wire frame, in the center of the triangle. The triangles defined by the faces are in green. The light grey lines point to the vertices that define the face.

Note, in some systems the order of the vertices are important, as this defines the "face normal." Direct3D does this, for sure.


For the curious, the source use to generate (OpenGL, I had it to hand):
Spoiler

Attached image(s)

  • Attached Image

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1