00001 // Filename: xFileFace.cxx 00002 // Created by: drose (19Jun01) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved 00008 // 00009 // All use of this software is subject to the terms of the Panda 3d 00010 // Software license. You should have received a copy of this license 00011 // along with this source code; you will also find a current copy of 00012 // the license at http://www.panda3d.org/license.txt . 00013 // 00014 // To contact the maintainers of this program write to 00015 // panda3d@yahoogroups.com . 00016 // 00017 //////////////////////////////////////////////////////////////////// 00018 00019 #include "xFileFace.h" 00020 #include "xFileMesh.h" 00021 #include "eggPolygon.h" 00022 00023 //////////////////////////////////////////////////////////////////// 00024 // Function: XFileFace::Constructor 00025 // Access: Public 00026 // Description: 00027 //////////////////////////////////////////////////////////////////// 00028 XFileFace:: 00029 XFileFace() { 00030 _material_index = -1; 00031 } 00032 00033 //////////////////////////////////////////////////////////////////// 00034 // Function: XFileFace::set_from_egg 00035 // Access: Public 00036 // Description: Sets the structure up from the indicated egg data. 00037 //////////////////////////////////////////////////////////////////// 00038 void XFileFace:: 00039 set_from_egg(XFileMesh *mesh, EggPolygon *egg_poly) { 00040 // Walk through the polygon's vertices in reverse order, to change 00041 // from Egg's counter-clockwise convention to DX's clockwise. 00042 EggPolygon::reverse_iterator vi; 00043 for (vi = egg_poly->rbegin(); vi != egg_poly->rend(); ++vi) { 00044 EggVertex *egg_vertex = (*vi); 00045 Vertex v; 00046 v._vertex_index = mesh->add_vertex(egg_vertex, egg_poly); 00047 v._normal_index = mesh->add_normal(egg_vertex, egg_poly); 00048 _vertices.push_back(v); 00049 } 00050 00051 _material_index = mesh->add_material(egg_poly); 00052 }