Panda3D
 All Classes Functions Variables Enumerations
eggSwitchCondition.cxx
00001 // Filename: eggSwitchCondition.cxx
00002 // Created by:  drose (08Feb99)
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 "eggSwitchCondition.h"
00016 
00017 #include "indent.h"
00018 
00019 TypeHandle EggSwitchCondition::_type_handle;
00020 TypeHandle EggSwitchConditionDistance::_type_handle;
00021 
00022 
00023 ////////////////////////////////////////////////////////////////////
00024 //     Function: EggSwitchConditionDistance::Constructor
00025 //       Access: Public
00026 //  Description:
00027 ////////////////////////////////////////////////////////////////////
00028 EggSwitchConditionDistance::
00029 EggSwitchConditionDistance(double switch_in, double switch_out,
00030                            const LPoint3d &center, double fade) {
00031   _switch_in = switch_in;
00032   _switch_out = switch_out;
00033   _center = center;
00034   _fade = fade;
00035 }
00036 
00037 
00038 ////////////////////////////////////////////////////////////////////
00039 //     Function: EggSwitchConditionDistance::make_copy
00040 //       Access: Public, Virtual
00041 //  Description:
00042 ////////////////////////////////////////////////////////////////////
00043 EggSwitchCondition *EggSwitchConditionDistance::
00044 make_copy() const {
00045   return new EggSwitchConditionDistance(*this);
00046 }
00047 
00048 
00049 ////////////////////////////////////////////////////////////////////
00050 //     Function: EggSwitchConditionDistance::write
00051 //       Access: Public, Virtual
00052 //  Description:
00053 ////////////////////////////////////////////////////////////////////
00054 void EggSwitchConditionDistance::
00055 write(ostream &out, int indent_level) const {
00056   indent(out, indent_level) << "<SwitchCondition> {\n";
00057   indent(out, indent_level+2)
00058     << "<Distance> { " << _switch_in << " " << _switch_out;
00059 
00060   if (_fade != 0.0) {
00061     out << " " << _fade;
00062   }
00063 
00064   out << " <Vertex> { " << _center << " } }\n";
00065   indent(out, indent_level) << "}\n";
00066 }
00067 
00068 
00069 ////////////////////////////////////////////////////////////////////
00070 //     Function: EggSwitchConditionDistance::transform
00071 //       Access: Public, Virtual
00072 //  Description: Applies the indicated transformation matrix to the
00073 //               switch condition parameters.
00074 ////////////////////////////////////////////////////////////////////
00075 void EggSwitchConditionDistance::
00076 transform(const LMatrix4d &mat) {
00077   _center = _center * mat;
00078 
00079   LVector3d in = LVector3d(_switch_in, 0.0, 0.0) * mat;
00080   LVector3d out = LVector3d(_switch_out, 0.0, 0.0) * mat;
00081 
00082   _switch_in = in.length();
00083   _switch_out = out.length();
00084 }
 All Classes Functions Variables Enumerations