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