Panda3D
eggSwitchCondition.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 eggSwitchCondition.cxx
10  * @author drose
11  * @date 1999-02-08
12  */
13 
14 #include "eggSwitchCondition.h"
15 
16 #include "indent.h"
17 
18 TypeHandle EggSwitchCondition::_type_handle;
19 TypeHandle EggSwitchConditionDistance::_type_handle;
20 
21 
22 /**
23  *
24  */
25 EggSwitchConditionDistance::
26 EggSwitchConditionDistance(double switch_in, double switch_out,
27  const LPoint3d &center, double fade) {
28  _switch_in = switch_in;
29  _switch_out = switch_out;
30  _center = center;
31  _fade = fade;
32 }
33 
34 
35 /**
36  *
37  */
38 EggSwitchCondition *EggSwitchConditionDistance::
39 make_copy() const {
40  return new EggSwitchConditionDistance(*this);
41 }
42 
43 
44 /**
45  *
46  */
47 void EggSwitchConditionDistance::
48 write(std::ostream &out, int indent_level) const {
49  indent(out, indent_level) << "<SwitchCondition> {\n";
50  indent(out, indent_level+2)
51  << "<Distance> { " << _switch_in << " " << _switch_out;
52 
53  if (_fade != 0.0) {
54  out << " " << _fade;
55  }
56 
57  out << " <Vertex> { " << _center << " } }\n";
58  indent(out, indent_level) << "}\n";
59 }
60 
61 
62 /**
63  * Applies the indicated transformation matrix to the switch condition
64  * parameters.
65  */
67 transform(const LMatrix4d &mat) {
68  _center = _center * mat;
69 
70  LVector3d in = LVector3d(_switch_in, 0.0, 0.0) * mat;
71  LVector3d out = LVector3d(_switch_out, 0.0, 0.0) * mat;
72 
73  _switch_in = in.length();
74  _switch_out = out.length();
75 }
virtual void transform(const LMatrix4d &mat)
Applies the indicated transformation matrix to the switch condition parameters.
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
Definition: indent.cxx:20
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
This corresponds to a <SwitchCondition> entry within a group.
A SwitchCondition that switches the levels-of-detail based on distance from the camera's eyepoint.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.