Panda3D

eggSliderData.cxx

00001 // Filename: eggSliderData.cxx
00002 // Created by:  drose (26Feb01)
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 "eggSliderData.h"
00016 #include "eggVertexPointer.h"
00017 #include "eggScalarTablePointer.h"
00018 #include "eggSliderPointer.h"
00019 #include "dcast.h"
00020 #include "eggPrimitive.h"
00021 #include "eggVertex.h"
00022 #include "eggSAnimData.h"
00023 #include "indent.h"
00024 
00025 TypeHandle EggSliderData::_type_handle;
00026 
00027 ////////////////////////////////////////////////////////////////////
00028 //     Function: EggSliderData::Constructor
00029 //       Access: Public
00030 //  Description:
00031 ////////////////////////////////////////////////////////////////////
00032 EggSliderData::
00033 EggSliderData(EggCharacterCollection *collection,
00034               EggCharacterData *char_data) :
00035   EggComponentData(collection, char_data)
00036 {
00037 }
00038 
00039 ////////////////////////////////////////////////////////////////////
00040 //     Function: EggSliderData::get_frame
00041 //       Access: Public
00042 //  Description: Returns the value corresponding to this slider
00043 //               position in the nth frame in the indicated model.
00044 ////////////////////////////////////////////////////////////////////
00045 double EggSliderData::
00046 get_frame(int model_index, int n) const {
00047   EggBackPointer *back = get_model(model_index);
00048   if (back == (EggBackPointer *)NULL) {
00049     return 0.0;
00050   }
00051 
00052   EggSliderPointer *slider;
00053   DCAST_INTO_R(slider, back, 0.0);
00054 
00055   return slider->get_frame(n);
00056 }
00057 
00058 ////////////////////////////////////////////////////////////////////
00059 //     Function: EggSliderData::add_back_pointer
00060 //       Access: Public, Virtual
00061 //  Description: Adds the indicated vertex, primitive, or morph table
00062 //               to the data.
00063 ////////////////////////////////////////////////////////////////////
00064 void EggSliderData::
00065 add_back_pointer(int model_index, EggObject *egg_object) {
00066   if (egg_object->is_of_type(EggPrimitive::get_class_type())) {
00067     // A primitive!
00068     EggBackPointer *back = get_model(model_index);
00069     if (back == (EggBackPointer *)NULL) {
00070       back = new EggVertexPointer(egg_object);
00071       set_model(model_index, back);
00072     }
00073 
00074   } else if (egg_object->is_of_type(EggVertex::get_class_type())) {
00075     // A vertex!
00076     EggBackPointer *back = get_model(model_index);
00077     if (back == (EggBackPointer *)NULL) {
00078       back = new EggVertexPointer(egg_object);
00079       set_model(model_index, back);
00080     }
00081 
00082   } else if (egg_object->is_of_type(EggSAnimData::get_class_type())) {
00083     // A slider animation table!  Woo hoo!
00084     EggBackPointer *back = get_model(model_index);
00085     if (back == (EggBackPointer *)NULL) {
00086       back = new EggScalarTablePointer(egg_object);
00087       set_model(model_index, back);
00088     }
00089 
00090   } else {
00091     nout << "Invalid object added to slider for back pointer.\n";
00092   }
00093 }
00094 
00095 ////////////////////////////////////////////////////////////////////
00096 //     Function: EggSliderData::write
00097 //       Access: Public, Virtual
00098 //  Description:
00099 ////////////////////////////////////////////////////////////////////
00100 void EggSliderData::
00101 write(ostream &out, int indent_level) const {
00102   indent(out, indent_level)
00103     << "Slider " << get_name()
00104     << " (models:";
00105   int num_models = get_num_models();
00106   for (int model_index = 0; model_index < num_models; model_index++) {
00107     if (has_model(model_index)) {
00108       out << " " << model_index;
00109     }
00110   }
00111   out << ")\n";
00112 }
 All Classes Functions Variables Enumerations