Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/testbed/test_eggWrite.cxx

Go to the documentation of this file.
00001 // Filename: test_eggWrite.cxx
00002 // Created by:  jason (16Jun00)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #include <renderRelation.h>
00020 #include <transformTransition.h>
00021 #include <namedNode.h>
00022 #include <geom.h>
00023 #include <geomNode.h>
00024 #include <pt_NamedNode.h>
00025 #include <nodeTransitionWrapper.h>
00026 #include <nodeAttributeWrapper.h>
00027 #include <allTransitionsWrapper.h>
00028 #include <allAttributesWrapper.h>
00029 #include <nullTransitionWrapper.h>
00030 #include <nullAttributeWrapper.h>
00031 #include <traverserVisitor.h>
00032 #include <dftraverser.h>
00033 #include <nullLevelState.h>
00034 #include <filename.h>
00035 #include <character.h>
00036 
00037 #include <indent.h>
00038 #include <ipc_file.h>
00039 #include <bamWriter.h>
00040 #include <bam.h>
00041 
00042 
00043 template<class TW>
00044 class PrintNodes : public TraverserVisitor<TW, NullLevelState> {
00045 public:
00046   PrintNodes() {
00047     _indent_level = 0;
00048   }
00049   bool reached_node(Node *node, AttributeWrapper &state, NullLevelState &)
00050   {
00051     indent(nout, _indent_level) << "Reached " << *node << ", state is " << state << "\n";
00052     //  if (node->is_of_type(GeomNode::get_class_type()))
00053 //      {
00054 //        GeomNode *geomNode = (GeomNode *)node;
00055 //        int num_geoms = geomNode->get_num_geoms();
00056 //        for (int i = 0; i < num_geoms; i++)
00057 //        {
00058 //      dDrawable *draw = geomNode->get_geom(i);
00059 //      Geom *geom = DCAST(Geom, draw);
00060 //      indent(nout, _indent_level+1) << *geom << ":\n";
00061 //      geom->output_verbose(nout);
00062 //        }
00063 //      }
00064     return true;
00065   }
00066   bool forward_arc(NodeRelation *, TransitionWrapper &, AttributeWrapper &, AttributeWrapper &, NullLevelState &)
00067   {
00068     _indent_level += 2;
00069     return true;
00070   }
00071   void backward_arc(NodeRelation *, TransitionWrapper &, AttributeWrapper &, AttributeWrapper &, const NullLevelState &)
00072   {
00073     _indent_level -= 2;
00074   }
00075   int _indent_level;
00076 };
00077 
00078 
00079 
00080 int main(int argc, char* argv[]) {
00081   if (argc < 2)
00082   {
00083     nout << "Need an egg file" << endl;
00084     exit(0);
00085   }
00086   Filename file(argv[1]);
00087   if (file.get_extension().compare("egg") != 0)
00088   {
00089     nout << "Need an egg file" << endl;
00090     exit(0);
00091   }
00092   datagram_file stream(file.get_basename_wo_extension()+string(".bam"));
00093   BamWriter manager(&stream);
00094 
00095   PT_NamedNode smiley = loader.load_sync(file);
00096 
00097   nout << "\n";
00098   PrintNodes<NodeTransitionWrapper> pn;
00099   df_traverse(smiley, pn,
00100               NodeAttributeWrapper(TransformTransition::get_class_type()),
00101               NullLevelState(),
00102               RenderRelation::get_class_type());
00103   nout << "\n";
00104 
00105   stream.open(file::FILE_WRITE, _bam_header);
00106   manager.init();
00107   manager.write_object(smiley);
00108   stream.close();
00109 
00110   return 0;
00111 }
00112 

Generated on Fri May 2 00:44:11 2003 for Panda by doxygen1.3