00001 // Filename: xFileNormal.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 "xFileNormal.h" 00020 #include "eggVertex.h" 00021 #include "eggPrimitive.h" 00022 #include "config_xfile.h" 00023 00024 //////////////////////////////////////////////////////////////////// 00025 // Function: XFileNormal::Constructor 00026 // Access: Public 00027 // Description: 00028 //////////////////////////////////////////////////////////////////// 00029 XFileNormal:: 00030 XFileNormal() { 00031 _normal.set(0.0, 0.0, 0.0); 00032 _has_normal = false; 00033 } 00034 00035 //////////////////////////////////////////////////////////////////// 00036 // Function: XFileNormal::set_from_egg 00037 // Access: Public 00038 // Description: Sets the structure up from the indicated egg data. 00039 //////////////////////////////////////////////////////////////////// 00040 void XFileNormal:: 00041 set_from_egg(EggVertex *egg_vertex, EggPrimitive *egg_prim) { 00042 if (egg_vertex->has_normal() || egg_prim->has_normal()) { 00043 Normald norm; 00044 if (egg_vertex->has_normal()) { 00045 norm = egg_vertex->get_normal(); 00046 } else { 00047 norm = egg_prim->get_normal(); 00048 } 00049 00050 if (xfile_one_mesh) { 00051 // If this is going into one big mesh, we must ensure every 00052 // vertex is in world coordinates. 00053 norm = norm * egg_prim->get_vertex_frame(); 00054 } else { 00055 // Otherwise, we ensure the vertex is in local coordinates. 00056 norm = norm * egg_prim->get_vertex_to_node(); 00057 } 00058 00059 _normal = LCAST(float, norm); 00060 _has_normal = true; 00061 } 00062 } 00063 00064 //////////////////////////////////////////////////////////////////// 00065 // Function: XFileNormal::compare_to 00066 // Access: Public 00067 // Description: 00068 //////////////////////////////////////////////////////////////////// 00069 int XFileNormal:: 00070 compare_to(const XFileNormal &other) const { 00071 int ct; 00072 ct = _normal.compare_to(other._normal); 00073 return ct; 00074 }