Panda3D
|
00001 // Filename: xFileFace.cxx 00002 // Created by: drose (19Jun01) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #include "xFileFace.h" 00016 #include "xFileMesh.h" 00017 #include "eggPolygon.h" 00018 00019 //////////////////////////////////////////////////////////////////// 00020 // Function: XFileFace::Constructor 00021 // Access: Public 00022 // Description: 00023 //////////////////////////////////////////////////////////////////// 00024 XFileFace:: 00025 XFileFace() { 00026 _material_index = -1; 00027 } 00028 00029 //////////////////////////////////////////////////////////////////// 00030 // Function: XFileFace::set_from_egg 00031 // Access: Public 00032 // Description: Sets the structure up from the indicated egg data. 00033 //////////////////////////////////////////////////////////////////// 00034 void XFileFace:: 00035 set_from_egg(XFileMesh *mesh, EggPolygon *egg_poly) { 00036 // Walk through the polygon's vertices in reverse order, to change 00037 // from Egg's counter-clockwise convention to DX's clockwise. 00038 EggPolygon::reverse_iterator vi; 00039 for (vi = egg_poly->rbegin(); vi != egg_poly->rend(); ++vi) { 00040 EggVertex *egg_vertex = (*vi); 00041 Vertex v; 00042 v._vertex_index = mesh->add_vertex(egg_vertex, egg_poly); 00043 v._normal_index = mesh->add_normal(egg_vertex, egg_poly); 00044 _vertices.push_back(v); 00045 } 00046 00047 _material_index = mesh->add_material(egg_poly); 00048 }