Browse Source

add add_component_data

David Rose 22 years ago
parent
commit
81b91d8522
2 changed files with 38 additions and 0 deletions
  1. 36 0
      panda/src/egg/eggXfmSAnim.cxx
  2. 2 0
      panda/src/egg/eggXfmSAnim.h

+ 36 - 0
panda/src/egg/eggXfmSAnim.cxx

@@ -589,6 +589,42 @@ add_data(const LMatrix4d &mat) {
   return add_ok;
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: EggXfmSAnim::add_component_data
+//       Access: Public
+//  Description: Adds a new row to the named component (one of
+//               matrix_component_letters) of the table.
+////////////////////////////////////////////////////////////////////
+void EggXfmSAnim::
+add_component_data(const string &component_name, double value) {
+  EggNode *child = find_child(component_name);
+  EggSAnimData *sanim;
+  if (child == (EggNode *)NULL) {
+    // We don't have this component yet; create it.
+    sanim = new EggSAnimData(component_name);
+    add_child(sanim);
+
+  } else {
+    DCAST_INTO_V(sanim, child);
+  }
+
+  sanim->add_data(value);
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: EggXfmSAnim::add_component_data
+//       Access: Public
+//  Description: Adds a new row to the indicated component (0-12) of
+//               the table.
+////////////////////////////////////////////////////////////////////
+void EggXfmSAnim::
+add_component_data(int component, double value) {
+  nassertv(component >= 0 && component < num_matrix_components);
+
+  string name(1, matrix_component_letters[component]);
+  add_component_data(name, value);
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: EggXfmSAnim::r_transform
 //       Access: Protected, Virtual

+ 2 - 0
panda/src/egg/eggXfmSAnim.h

@@ -66,6 +66,8 @@ PUBLISHED:
 
   INLINE void clear_data();
   bool add_data(const LMatrix4d &mat);
+  void add_component_data(const string &component_name, double value);
+  void add_component_data(int component, double value);
 
   virtual void write(ostream &out, int indent_level) const;