Panda3D
xFileFace.cxx
1 // Filename: xFileFace.cxx
2 // Created by: drose (19Jun01)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #include "xFileFace.h"
16 #include "xFileMesh.h"
17 #include "eggPolygon.h"
18 
19 ////////////////////////////////////////////////////////////////////
20 // Function: XFileFace::Constructor
21 // Access: Public
22 // Description:
23 ////////////////////////////////////////////////////////////////////
24 XFileFace::
25 XFileFace() {
26  _material_index = -1;
27 }
28 
29 ////////////////////////////////////////////////////////////////////
30 // Function: XFileFace::set_from_egg
31 // Access: Public
32 // Description: Sets the structure up from the indicated egg data.
33 ////////////////////////////////////////////////////////////////////
34 void XFileFace::
35 set_from_egg(XFileMesh *mesh, EggPolygon *egg_poly) {
36  // Walk through the polygon's vertices in reverse order, to change
37  // from Egg's counter-clockwise convention to DX's clockwise.
38  EggPolygon::reverse_iterator vi;
39  for (vi = egg_poly->rbegin(); vi != egg_poly->rend(); ++vi) {
40  EggVertex *egg_vertex = (*vi);
41  Vertex v;
42  v._vertex_index = mesh->add_vertex(egg_vertex, egg_poly);
43  v._normal_index = mesh->add_normal(egg_vertex, egg_poly);
44  _vertices.push_back(v);
45  }
46 
47  _material_index = mesh->add_material(egg_poly);
48 }
This is a collection of polygons; i.e.
Definition: xFileMesh.h:45
int add_vertex(EggVertex *egg_vertex, EggPrimitive *egg_prim)
Creates a new XFileVertex, if one does not already exist for the indicated vertex, and returns its index.
Definition: xFileMesh.cxx:115
int add_material(EggPrimitive *egg_prim)
Creates a new XFileMaterial, if one does not already exist for the indicated material, and returns its index.
Definition: xFileMesh.cxx:181
int add_normal(EggVertex *egg_vertex, EggPrimitive *egg_prim)
Creates a new XFileNormal, if one does not already exist for the indicated normal, and returns its index.
Definition: xFileMesh.cxx:150
Any one-, two-, three-, or four-component vertex, possibly with attributes such as a normal...
Definition: eggVertex.h:41
void set_from_egg(XFileMesh *mesh, EggPolygon *egg_poly)
Sets the structure up from the indicated egg data.
Definition: xFileFace.cxx:35
A single polygon.
Definition: eggPolygon.h:26