mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 02:15:43 -04:00
add fltInfo
This commit is contained in:
parent
4d22a1d7ef
commit
f2dca60c21
@ -28,6 +28,20 @@
|
|||||||
|
|
||||||
#end bin_target
|
#end bin_target
|
||||||
|
|
||||||
|
#begin bin_target
|
||||||
|
#define TARGET flt-info
|
||||||
|
#define LOCAL_LIBS \
|
||||||
|
progbase flt
|
||||||
|
#define OTHER_LIBS \
|
||||||
|
linmath:c panda:m \
|
||||||
|
express:c pandaexpress:m \
|
||||||
|
dtoolutil:c dtoolbase:c dconfig:c dtoolconfig:m dtool:m pystub
|
||||||
|
|
||||||
|
#define SOURCES \
|
||||||
|
fltInfo.cxx fltInfo.h
|
||||||
|
|
||||||
|
#end bin_target
|
||||||
|
|
||||||
#begin bin_target
|
#begin bin_target
|
||||||
#define TARGET flt2egg
|
#define TARGET flt2egg
|
||||||
#define LOCAL_LIBS flt fltegg eggbase progbase
|
#define LOCAL_LIBS flt fltegg eggbase progbase
|
||||||
|
110
pandatool/src/fltprogs/fltInfo.cxx
Normal file
110
pandatool/src/fltprogs/fltInfo.cxx
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
// Filename: fltInfo.cxx
|
||||||
|
// Created by: drose (05Sep01)
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// PANDA 3D SOFTWARE
|
||||||
|
// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
|
||||||
|
//
|
||||||
|
// All use of this software is subject to the terms of the Panda 3d
|
||||||
|
// Software license. You should have received a copy of this license
|
||||||
|
// along with this source code; you will also find a current copy of
|
||||||
|
// the license at http://www.panda3d.org/license.txt .
|
||||||
|
//
|
||||||
|
// To contact the maintainers of this program write to
|
||||||
|
// panda3d@yahoogroups.com .
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "fltInfo.h"
|
||||||
|
|
||||||
|
#include "fltHeader.h"
|
||||||
|
#include "indent.h"
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: FltInfo::Constructor
|
||||||
|
// Access: Public
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
FltInfo::
|
||||||
|
FltInfo() {
|
||||||
|
set_program_description
|
||||||
|
("This program reads a MultiGen OpenFlight (.flt) file and reports "
|
||||||
|
"some interesting things about its contents.");
|
||||||
|
|
||||||
|
clear_runlines();
|
||||||
|
add_runline("[opts] input.flt");
|
||||||
|
|
||||||
|
add_option
|
||||||
|
("ls", "", 0,
|
||||||
|
"List the hierarchy in the flt file.",
|
||||||
|
&FltInfo::dispatch_none, &_list_hierarchy);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: FltInfo::run
|
||||||
|
// Access: Public
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void FltInfo::
|
||||||
|
run() {
|
||||||
|
PT(FltHeader) header = new FltHeader;
|
||||||
|
|
||||||
|
nout << "Reading " << _input_filename << "\n";
|
||||||
|
FltError result = header->read_flt(_input_filename);
|
||||||
|
if (result != FE_ok) {
|
||||||
|
nout << "Unable to read: " << result << "\n";
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (header->check_version()) {
|
||||||
|
nout << "Version is " << header->get_flt_version() / 100.0 << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_list_hierarchy) {
|
||||||
|
list_hierarchy(header, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: FltInfo::list_hierarchy
|
||||||
|
// Access: Protected
|
||||||
|
// Description: Recursively lists the flt file's hierarchy in a
|
||||||
|
// meaningful way.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void FltInfo::
|
||||||
|
list_hierarchy(FltRecord *record, int indent_level) {
|
||||||
|
// Maybe in the future we can do something fancier here.
|
||||||
|
record->write(cout, indent_level);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: FltInfo::handle_args
|
||||||
|
// Access: Protected, Virtual
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
bool FltInfo::
|
||||||
|
handle_args(ProgramBase::Args &args) {
|
||||||
|
if (args.empty()) {
|
||||||
|
nout << "You must specify the .flt file to read on the command line.\n";
|
||||||
|
return false;
|
||||||
|
|
||||||
|
} else if (args.size() != 1) {
|
||||||
|
nout << "You must specify only one .flt file to read on the command line.\n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
_input_filename = args[0];
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int main(int argc, char *argv[]) {
|
||||||
|
FltInfo prog;
|
||||||
|
prog.parse_command_line(argc, argv);
|
||||||
|
prog.run();
|
||||||
|
return 0;
|
||||||
|
}
|
49
pandatool/src/fltprogs/fltInfo.h
Normal file
49
pandatool/src/fltprogs/fltInfo.h
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
// Filename: fltInfo.h
|
||||||
|
// Created by: drose (05Sep01)
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// PANDA 3D SOFTWARE
|
||||||
|
// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
|
||||||
|
//
|
||||||
|
// All use of this software is subject to the terms of the Panda 3d
|
||||||
|
// Software license. You should have received a copy of this license
|
||||||
|
// along with this source code; you will also find a current copy of
|
||||||
|
// the license at http://www.panda3d.org/license.txt .
|
||||||
|
//
|
||||||
|
// To contact the maintainers of this program write to
|
||||||
|
// panda3d@yahoogroups.com .
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef FLTINFO_H
|
||||||
|
#define FLTINFO_H
|
||||||
|
|
||||||
|
#include "pandatoolbase.h"
|
||||||
|
|
||||||
|
#include "programBase.h"
|
||||||
|
|
||||||
|
class FltRecord;
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Class : FltInfo
|
||||||
|
// Description : A program to read a flt file and report interesting
|
||||||
|
// things about it.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
class FltInfo : public ProgramBase {
|
||||||
|
public:
|
||||||
|
FltInfo();
|
||||||
|
|
||||||
|
void run();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual bool handle_args(Args &args);
|
||||||
|
|
||||||
|
void list_hierarchy(FltRecord *record, int indent_level);
|
||||||
|
|
||||||
|
Filename _input_filename;
|
||||||
|
bool _list_hierarchy;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user