Panda3D
xFileNormal.cxx
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file xFileNormal.cxx
10  * @author drose
11  * @date 2001-06-19
12  */
13 
14 #include "xFileNormal.h"
15 #include "eggVertex.h"
16 #include "eggPrimitive.h"
17 #include "config_xfile.h"
18 
19 /**
20  *
21  */
22 XFileNormal::
23 XFileNormal() {
24  _normal.set(0.0, 0.0, 0.0);
25  _has_normal = false;
26 }
27 
28 /**
29  * Sets the structure up from the indicated egg data.
30  */
31 void XFileNormal::
32 set_from_egg(EggVertex *egg_vertex, EggPrimitive *egg_prim) {
33  if (egg_vertex->has_normal() || egg_prim->has_normal()) {
34  LNormald norm;
35  if (egg_vertex->has_normal()) {
36  norm = egg_vertex->get_normal();
37  } else {
38  norm = egg_prim->get_normal();
39  }
40 
41  if (xfile_one_mesh) {
42  // If this is going into one big mesh, we must ensure every vertex is in
43  // world coordinates.
44  norm = norm * egg_prim->get_vertex_frame();
45  } else {
46  // Otherwise, we ensure the vertex is in local coordinates.
47  norm = norm * egg_prim->get_vertex_to_node();
48  }
49 
50  _normal = norm;
51  _has_normal = true;
52  }
53 }
54 
55 /**
56  *
57  */
58 int XFileNormal::
59 compare_to(const XFileNormal &other) const {
60  int ct;
61  ct = _normal.compare_to(other._normal);
62  return ct;
63 }
A base class for any of a number of kinds of geometry primitives: polygons, point lights,...
Definition: eggPrimitive.h:47
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
const LMatrix4d & get_vertex_frame() const
Returns the coordinate frame of the vertices referenced by primitives at or under this node.
Definition: eggNode.I:108
This represents a single normal associated with an XFileFace.
Definition: xFileNormal.h:28
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void set_from_egg(EggVertex *egg_vertex, EggPrimitive *egg_prim)
Sets the structure up from the indicated egg data.
Definition: xFileNormal.cxx:32
Any one-, two-, three-, or four-component vertex, possibly with attributes such as a normal.
Definition: eggVertex.h:39
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
const LMatrix4d & get_vertex_to_node() const
Returns the transformation matrix suitable for converting the vertices as read from the egg file into...
Definition: eggNode.I:166