Panda3D
eggSwitchCondition.cxx
1 // Filename: eggSwitchCondition.cxx
2 // Created by: drose (08Feb99)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #include "eggSwitchCondition.h"
16 
17 #include "indent.h"
18 
19 TypeHandle EggSwitchCondition::_type_handle;
20 TypeHandle EggSwitchConditionDistance::_type_handle;
21 
22 
23 ////////////////////////////////////////////////////////////////////
24 // Function: EggSwitchConditionDistance::Constructor
25 // Access: Public
26 // Description:
27 ////////////////////////////////////////////////////////////////////
28 EggSwitchConditionDistance::
29 EggSwitchConditionDistance(double switch_in, double switch_out,
30  const LPoint3d &center, double fade) {
31  _switch_in = switch_in;
32  _switch_out = switch_out;
33  _center = center;
34  _fade = fade;
35 }
36 
37 
38 ////////////////////////////////////////////////////////////////////
39 // Function: EggSwitchConditionDistance::make_copy
40 // Access: Public, Virtual
41 // Description:
42 ////////////////////////////////////////////////////////////////////
43 EggSwitchCondition *EggSwitchConditionDistance::
44 make_copy() const {
45  return new EggSwitchConditionDistance(*this);
46 }
47 
48 
49 ////////////////////////////////////////////////////////////////////
50 // Function: EggSwitchConditionDistance::write
51 // Access: Public, Virtual
52 // Description:
53 ////////////////////////////////////////////////////////////////////
54 void EggSwitchConditionDistance::
55 write(ostream &out, int indent_level) const {
56  indent(out, indent_level) << "<SwitchCondition> {\n";
57  indent(out, indent_level+2)
58  << "<Distance> { " << _switch_in << " " << _switch_out;
59 
60  if (_fade != 0.0) {
61  out << " " << _fade;
62  }
63 
64  out << " <Vertex> { " << _center << " } }\n";
65  indent(out, indent_level) << "}\n";
66 }
67 
68 
69 ////////////////////////////////////////////////////////////////////
70 // Function: EggSwitchConditionDistance::transform
71 // Access: Public, Virtual
72 // Description: Applies the indicated transformation matrix to the
73 // switch condition parameters.
74 ////////////////////////////////////////////////////////////////////
76 transform(const LMatrix4d &mat) {
77  _center = _center * mat;
78 
79  LVector3d in = LVector3d(_switch_in, 0.0, 0.0) * mat;
80  LVector3d out = LVector3d(_switch_out, 0.0, 0.0) * mat;
81 
82  _switch_in = in.length();
83  _switch_out = out.length();
84 }
This is a 4-by-4 transform matrix.
Definition: lmatrix.h:4716
double length() const
Returns the length of the vector, by the Pythagorean theorem.
Definition: lvecBase3.h:2132
virtual void transform(const LMatrix4d &mat)
Applies the indicated transformation matrix to the switch condition parameters.
This is a three-component vector distance (as opposed to a three-component point, which represents a ...
Definition: lvector3.h:760
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
Definition: lpoint3.h:544
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
This corresponds to a <SwitchCondition> entry within a group.
A SwitchCondition that switches the levels-of-detail based on distance from the camera&#39;s eyepoint...