move pystub down to the executables

This commit is contained in:
David Rose 2006-10-18 13:08:08 +00:00
parent 2ac33f2119
commit e8f3232fef
49 changed files with 178 additions and 528 deletions

View File

@ -29,6 +29,7 @@
#include "pvector.h"
#include "bamCacheRecord.h"
#include "bamCacheIndex.h"
#include "pystub.h"
////////////////////////////////////////////////////////////////////
// Function: BamInfo::Constructor
@ -335,6 +336,9 @@ list_hierarchy(PandaNode *node, int indent_level) {
}
int main(int argc, char *argv[]) {
// A call to pystub() to force libpystub.so to be linked in.
pystub();
BamInfo prog;
prog.parse_command_line(argc, argv);
prog.run();

View File

@ -45,6 +45,7 @@
#include "eggMaterial.h"
#include "somethingToEggConverter.h"
#include "dcast.h"
#include "pystub.h"
////////////////////////////////////////////////////////////////////
@ -609,6 +610,9 @@ get_egg_texture(Texture *tex) {
int main(int argc, char *argv[]) {
// A call to pystub() to force libpystub.so to be linked in.
pystub();
BamToEgg prog;
prog.parse_command_line(argc, argv);
prog.run();

View File

@ -36,6 +36,7 @@
#include "load_prc_file.h"
#include "windowProperties.h"
#include "frameBufferProperties.h"
#include "pystub.h"
////////////////////////////////////////////////////////////////////
// Function: EggToBam::Constructor
@ -461,6 +462,9 @@ make_buffer() {
int main(int argc, char *argv[]) {
// A call to pystub() to force libpystub.so to be linked in.
pystub();
EggToBam prog;
prog.parse_command_line(argc, argv);
prog.run();

View File

@ -18,6 +18,7 @@
#include "testCopy.h"
#include "cvsSourceDirectory.h"
#include "pystub.h"
////////////////////////////////////////////////////////////////////
// Function: TestCopy::Constructor
@ -69,6 +70,9 @@ copy_file(const Filename &source, const Filename &dest,
int main(int argc, char *argv[]) {
// A call to pystub() to force libpystub.so to be linked in.
pystub();
TestCopy prog;
prog.parse_command_line(argc, argv);
prog.run();

View File

@ -17,6 +17,7 @@
////////////////////////////////////////////////////////////////////
#include "dxfPoints.h"
#include "pystub.h"
////////////////////////////////////////////////////////////////////
// Function: DXFPoints::Constructor
@ -95,6 +96,9 @@ handle_args(ProgramBase::Args &args) {
int main(int argc, char *argv[]) {
// A call to pystub() to force libpystub.so to be linked in.
pystub();
DXFPoints prog;
prog.parse_command_line(argc, argv);
prog.run();

View File

@ -19,6 +19,7 @@
#include "dxfToEgg.h"
#include "dxfToEggConverter.h"
#include "pystub.h"
////////////////////////////////////////////////////////////////////
// Function: DXFToEgg::Constructor
@ -75,6 +76,9 @@ run() {
int main(int argc, char *argv[]) {
// A call to pystub() to force libpystub.so to be linked in.
pystub();
DXFToEgg prog;
prog.parse_command_line(argc, argv);
prog.run();

View File

@ -19,6 +19,7 @@
#include "eggToDXF.h"
#include "eggPolygon.h"
#include "dcast.h"
#include "pystub.h"
////////////////////////////////////////////////////////////////////
// Function: EggToDXF::Constructor
@ -160,6 +161,9 @@ write_entities(ostream &out) {
int main(int argc, char *argv[]) {
// A call to pystub() to force libpystub.so to be linked in.
pystub();
EggToDXF prog;
prog.parse_command_line(argc, argv);
prog.run();

View File

@ -34,6 +34,7 @@
#include "eggVertex.h"
#include "string_utils.h"
#include "dcast.h"
#include "pystub.h"
#include <ctype.h>
@ -702,6 +703,9 @@ is_numeric(const string &str) {
}
int main(int argc, char *argv[]) {
// A call to pystub() to force libpystub.so to be linked in.
pystub();
EggMakeFont prog;
prog.parse_command_line(argc, argv);
prog.run();

View File

@ -33,6 +33,7 @@
#include "pset.h"
#include "compose_matrix.h"
#include "fftCompressor.h"
#include "pystub.h"
#include <algorithm>
@ -1347,6 +1348,9 @@ rename_primitives(EggGroupNode *egg_group, const string &name) {
}
int main(int argc, char *argv[]) {
// A call to pystub() to force libpystub.so to be linked in.
pystub();
EggOptchar prog;
prog.parse_command_line(argc, argv);
prog.run();

View File

@ -28,6 +28,7 @@
#include "pnotify.h"
#include "notifyCategory.h"
#include "notifySeverity.h"
#include "pystub.h"
#include <stdio.h>
@ -858,6 +859,9 @@ run() {
int
main(int argc, char *argv[]) {
// A call to pystub() to force libpystub.so to be linked in.
pystub();
EggPalettize prog;
prog.parse_command_line(argc, argv);
prog.run();

View File

@ -19,6 +19,7 @@
#include "eggQtess.h"
#include "qtessGlobals.h"
#include "dcast.h"
#include "pystub.h"
////////////////////////////////////////////////////////////////////
// Function: EggQtess::Constructor
@ -347,6 +348,9 @@ find_surfaces(EggNode *egg_node) {
}
int main(int argc, char *argv[]) {
// A call to pystub() to force libpystub.so to be linked in.
pystub();
EggQtess prog;
prog.parse_command_line(argc, argv);
prog.run();

View File

@ -22,6 +22,7 @@
#include "eggPrimitive.h"
#include "eggVertex.h"
#include "dcast.h"
#include "pystub.h"
////////////////////////////////////////////////////////////////////
// Function: EggCrop::Constructor
@ -132,6 +133,9 @@ strip_prims(EggGroupNode *group) {
int main(int argc, char *argv[]) {
// A call to pystub() to force libpystub.so to be linked in.
pystub();
EggCrop prog;
prog.parse_command_line(argc, argv);
prog.run();

View File

@ -19,6 +19,7 @@
#include "eggListTextures.h"
#include "eggTextureCollection.h"
#include "pnmImageHeader.h"
#include "pystub.h"
////////////////////////////////////////////////////////////////////
// Function: EggListTextures::Constructor
@ -66,6 +67,9 @@ run() {
int main(int argc, char *argv[]) {
// A call to pystub() to force libpystub.so to be linked in.
pystub();
EggListTextures prog;
prog.parse_command_line(argc, argv);
prog.run();

View File

@ -23,6 +23,7 @@
#include "eggPolygon.h"
#include "pointerTo.h"
#include "look_at.h"
#include "pystub.h"
////////////////////////////////////////////////////////////////////
// Function: EggMakeTube::Constructor
@ -281,6 +282,9 @@ add_polygon(EggVertex *a, EggVertex *b, EggVertex *c, EggVertex *d) {
int main(int argc, char *argv[]) {
// A call to pystub() to force libpystub.so to be linked in.
pystub();
EggMakeTube prog;
prog.parse_command_line(argc, argv);
prog.run();

View File

@ -17,6 +17,7 @@
////////////////////////////////////////////////////////////////////
#include "eggRename.h"
#include "pystub.h"
////////////////////////////////////////////////////////////////////
// Function: EggRename::Constructor
@ -59,6 +60,9 @@ run() {
int main(int argc, char *argv[]) {
// A call to pystub() to force libpystub.so to be linked in.
pystub();
EggRename prog;
prog.parse_command_line(argc, argv);
prog.run();

View File

@ -26,6 +26,7 @@
#include "eggJointPointer.h"
#include "eggTable.h"
#include "compose_matrix.h"
#include "pystub.h"
////////////////////////////////////////////////////////////////////
// Function: EggRetargetAnim::Constructor
@ -197,6 +198,9 @@ retarget_anim(EggCharacterData *char_data, EggJointData *joint_data,
int main(int argc, char *argv[]) {
// A call to pystub() to force libpystub.so to be linked in.
pystub();
EggRetargetAnim prog;
prog.parse_command_line(argc, argv);
prog.run();

View File

@ -24,6 +24,7 @@
#include "eggTexture.h"
#include "eggPolygon.h"
#include "pnmImageHeader.h"
#include "pystub.h"
#include <algorithm>
@ -418,6 +419,9 @@ run() {
int main(int argc, char *argv[]) {
// A call to pystub() to force libpystub.so to be linked in.
pystub();
EggTextureCards prog;
prog.parse_command_line(argc, argv);
prog.run();

View File

@ -26,6 +26,7 @@
#include "eggPolysetMaker.h"
#include "eggBin.h"
#include "string_utils.h"
#include "pystub.h"
////////////////////////////////////////////////////////////////////
// Function: EggToC::Constructor
@ -377,6 +378,9 @@ write_bin(EggBin *bin) {
int main(int argc, char *argv[]) {
// A call to pystub() to force libpystub.so to be linked in.
pystub();
EggToC prog;
prog.parse_command_line(argc, argv);
prog.run();

View File

@ -26,6 +26,7 @@
#include "eggJointPointer.h"
#include "eggTable.h"
#include "compose_matrix.h"
#include "pystub.h"
////////////////////////////////////////////////////////////////////
// Function: EggTopstrip::Constructor
@ -364,6 +365,9 @@ adjust_transform(LMatrix4d &mat) const {
int main(int argc, char *argv[]) {
// A call to pystub() to force libpystub.so to be linked in.
pystub();
EggTopstrip prog;
prog.parse_command_line(argc, argv);
prog.run();

View File

@ -18,6 +18,7 @@
#include "eggTrans.h"
#include "eggGroupUniquifier.h"
#include "pystub.h"
////////////////////////////////////////////////////////////////////
// Function: EggTrans::Constructor
@ -138,6 +139,9 @@ run() {
int main(int argc, char *argv[]) {
// A call to pystub() to force libpystub.so to be linked in.
pystub();
EggTrans prog;
prog.parse_command_line(argc, argv);
prog.run();

View File

@ -39,6 +39,7 @@
#include "dcast.h"
#include "string_utils.h"
#include "vector_string.h"
#include "pystub.h"
////////////////////////////////////////////////////////////////////
// Function: EggToFlt::Constructor
@ -696,6 +697,9 @@ get_flt_texture(EggTexture *egg_texture) {
int main(int argc, char *argv[]) {
// A call to pystub() to force libpystub.so to be linked in.
pystub();
EggToFlt prog;
prog.parse_command_line(argc, argv);
prog.run();

View File

@ -24,6 +24,7 @@
#include "fltExternalReference.h"
#include "fltError.h"
#include "dcast.h"
#include "pystub.h"
////////////////////////////////////////////////////////////////////
// Function: FltCopy::Constructor
@ -248,6 +249,9 @@ scan_flt(FltRecord *record, FltCopy::Refs &refs, FltCopy::Textures &textures) {
int main(int argc, char *argv[]) {
// A call to pystub() to force libpystub.so to be linked in.
pystub();
FltCopy prog;
prog.parse_command_line(argc, argv);
prog.run();

View File

@ -20,6 +20,7 @@
#include "fltHeader.h"
#include "indent.h"
#include "pystub.h"
////////////////////////////////////////////////////////////////////
// Function: FltInfo::Constructor
@ -103,6 +104,9 @@ handle_args(ProgramBase::Args &args) {
int main(int argc, char *argv[]) {
// A call to pystub() to force libpystub.so to be linked in.
pystub();
FltInfo prog;
prog.parse_command_line(argc, argv);
prog.run();

View File

@ -20,6 +20,7 @@
#include "fltToEggConverter.h"
#include "config_flt.h"
#include "pystub.h"
////////////////////////////////////////////////////////////////////
// Function: FltToEgg::Constructor
@ -106,6 +107,9 @@ run() {
int main(int argc, char *argv[]) {
// A call to pystub() to force libpystub.so to be linked in.
pystub();
init_libflt();
FltToEgg prog;
prog.parse_command_line(argc, argv);

View File

@ -19,6 +19,7 @@
#include "fltTrans.h"
#include "fltHeader.h"
#include "pystub.h"
////////////////////////////////////////////////////////////////////
// Function: FltTrans::Constructor
@ -136,6 +137,9 @@ handle_args(ProgramBase::Args &args) {
int main(int argc, char *argv[]) {
// A call to pystub() to force libpystub.so to be linked in.
pystub();
FltTrans prog;
prog.parse_command_line(argc, argv);
prog.run();

View File

@ -20,6 +20,7 @@
#include "gtkStats.h"
#include "gtkStatsServer.h"
#include "config_pstats.h"
#include "pystub.h"
GtkWidget *main_window;
static GtkStatsServer *server = NULL;
@ -57,6 +58,9 @@ timer(gpointer data) {
int
main(int argc, char *argv[]) {
// A call to pystub() to force libpystub.so to be linked in.
pystub();
gtk_init(&argc, &argv);
main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);

View File

@ -18,6 +18,7 @@
#include "imageInfo.h"
#include "pnmImageHeader.h"
#include "pystub.h"
////////////////////////////////////////////////////////////////////
// Function: ImageInfo::Constructor
@ -79,6 +80,9 @@ handle_args(ProgramBase::Args &args) {
int main(int argc, char *argv[]) {
// A call to pystub() to force libpystub.so to be linked in.
pystub();
ImageInfo prog;
prog.parse_command_line(argc, argv);
prog.run();

View File

@ -18,6 +18,7 @@
#include "imageResize.h"
#include "string_utils.h"
#include "pystub.h"
////////////////////////////////////////////////////////////////////
// Function: ImageResize::Constructor
@ -126,6 +127,9 @@ dispatch_size_request(const string &opt, const string &arg, void *var) {
int main(int argc, char *argv[]) {
// A call to pystub() to force libpystub.so to be linked in.
pystub();
ImageResize prog;
prog.parse_command_line(argc, argv);
prog.run();

View File

@ -18,6 +18,7 @@
#include "imageTrans.h"
#include "string_utils.h"
#include "pystub.h"
////////////////////////////////////////////////////////////////////
// Function: ImageTrans::Constructor
@ -182,6 +183,9 @@ extract_alpha() {
int main(int argc, char *argv[]) {
// A call to pystub() to force libpystub.so to be linked in.
pystub();
ImageTrans prog;
prog.parse_command_line(argc, argv);
prog.run();

View File

@ -19,9 +19,13 @@
#include "lwoInputFile.h"
#include "lwoChunk.h"
#include "config_lwo.h"
#include "pystub.h"
int
main(int argc, char *argv[]) {
// A call to pystub() to force libpystub.so to be linked in.
pystub();
init_liblwo();
if (argc != 2) {
nout << "test_lwo file.lwo\n";

View File

@ -21,6 +21,7 @@
#include "lwoInputFile.h"
#include "lwoChunk.h"
#include "config_lwo.h"
#include "pystub.h"
////////////////////////////////////////////////////////////////////
// Function: LwoScan::Constructor
@ -86,6 +87,9 @@ handle_args(ProgramBase::Args &args) {
int
main(int argc, char *argv[]) {
// A call to pystub() to force libpystub.so to be linked in.
pystub();
init_liblwo();
LwoScan prog;
prog.parse_command_line(argc, argv);

View File

@ -22,6 +22,7 @@
#include "lwoHeader.h"
#include "lwoInputFile.h"
#include "config_lwo.h"
#include "pystub.h"
////////////////////////////////////////////////////////////////////
// Function: LwoToEgg::Constructor
@ -87,6 +88,9 @@ run() {
int main(int argc, char *argv[]) {
// A call to pystub() to force libpystub.so to be linked in.
pystub();
init_liblwo();
LwoToEgg prog;
prog.parse_command_line(argc, argv);

View File

@ -19,6 +19,7 @@
#include "eggToMaya.h"
#include "mayaEggLoader.h"
#include "mayaApi.h"
#include "pystub.h"
// We must define this to prevent Maya from doubly-declaring its
// MApiVersion string in this file as well as in libmayaegg.
@ -111,6 +112,9 @@ run() {
}
int main(int argc, char *argv[]) {
// A call to pystub() to force libpystub.so to be linked in.
pystub();
EggToMaya prog;
prog.parse_command_line(argc, argv);
prog.run();

View File

@ -21,6 +21,7 @@
#include "cvsSourceDirectory.h"
#include "mayaShader.h"
#include "dcast.h"
#include "pystub.h"
#include "pre_maya_include.h"
#include <maya/MStringArray.h>
@ -437,6 +438,9 @@ collect_shader_for_node(const MDagPath &dag_path) {
int main(int argc, char *argv[]) {
// A call to pystub() to force libpystub.so to be linked in.
pystub();
MayaCopy prog;
prog.parse_command_line(argc, argv);
prog.run();

View File

@ -21,6 +21,7 @@
#include "config_mayaegg.h"
#include "config_maya.h" // for maya_cat
#include "globPattern.h"
#include "pystub.h"
////////////////////////////////////////////////////////////////////
// Function: MayaToEgg::Constructor
@ -255,6 +256,9 @@ dispatch_transform_type(const string &opt, const string &arg, void *var) {
}
int main(int argc, char *argv[]) {
// A call to pystub() to force libpystub.so to be linked in.
pystub();
MayaToEgg prog;
prog.parse_command_line(argc, argv);
prog.run();

View File

@ -18,6 +18,7 @@
#include "binToC.h"
#include "pystub.h"
// The number of bytes across the page to write.
static const int col_width = 11;
@ -152,6 +153,9 @@ handle_args(ProgramBase::Args &args) {
int main(int argc, char *argv[]) {
// A call to pystub() to force libpystub.so to be linked in.
pystub();
BinToC prog;
prog.parse_command_line(argc, argv);
prog.run();

View File

@ -8,12 +8,7 @@
pipeline:c event:c panda:m \
pandabase:c pnmimage:c linmath:c putil:c express:c \
interrogatedb:c prc:c dconfig:c dtoolconfig:m \
dtoolutil:c dtoolbase:c dtool:m \
pystub
// We link with pystub so we can include pystub.h here in
// programBase.cxx, so that every silly little executable in Pandatool
// doesn't have to include pystub.h.
dtoolutil:c dtoolbase:c dtool:m
#define COMBINED_SOURCES $[TARGET]_composite1.cxx

View File

@ -19,11 +19,6 @@
#include "programBase.h"
#include "wordWrapStream.h"
#include "pystub.h"
// Since programBase.cxx includes pystub.h, no program that links with
// progbase needs to do so. No Python code should attempt to link
// with libprogbase.so.
#include "pnmFileTypeRegistry.h"
#include "indent.h"
#include "dSearchPath.h"
@ -96,9 +91,6 @@ static ConfigVariableBool use_terminal_width
////////////////////////////////////////////////////////////////////
ProgramBase::
ProgramBase() {
// A call to pystub() to force libpystub.so to be linked in.
pystub();
// Set up Notify to write output to our own formatted stream.
Notify::ptr()->set_ostream_ptr(new WordWrapStream(this), true);

View File

@ -19,6 +19,7 @@
#include "programBase.h"
#include "pnotify.h"
#include "pystub.h"
class TestProgram : public ProgramBase {
public:
@ -62,6 +63,9 @@ TestProgram() {
int main(int argc, char *argv[]) {
// A call to pystub() to force libpystub.so to be linked in.
pystub();
TestProgram t;
t.parse_command_line(argc, argv);

View File

@ -20,6 +20,7 @@
#include "pnotify.h"
#include "multifile.h"
#include "pystub.h"
#include <algorithm>
@ -619,6 +620,9 @@ cvs_add_or_remove(const string &cvs_command, const vector_string &paths) {
int main(int argc, char *argv[]) {
// A call to pystub() to force libpystub.so to be linked in.
pystub();
SoftCVS prog;
prog.parse_command_line(argc, argv);
prog.run();

View File

@ -21,6 +21,7 @@
#include "pStatServer.h"
#include "config_pstats.h"
#include "pystub.h"
#include <signal.h>
@ -89,6 +90,9 @@ run() {
int main(int argc, char *argv[]) {
// A call to pystub() to force libpystub.so to be linked in.
pystub();
TextStats prog;
prog.parse_command_line(argc, argv);
prog.run();

View File

@ -1,436 +0,0 @@
// Filename: vrml2egg.C
// Created by: drose (24Jun99)
//
////////////////////////////////////////////////////////////////////
// Copyright (C) 1992,93,94,95,96,97 Walt Disney Imagineering, Inc.
//
// These coded instructions, statements, data structures and
// computer programs contain unpublished proprietary information of
// Walt Disney Imagineering and are protected by Federal copyright
// law. They may not be disclosed to third parties or copied or
// duplicated in any form, in whole or in part, without the prior
// written consent of Walt Disney Imagineering Inc.
////////////////////////////////////////////////////////////////////
#include "vrml2egg.h"
#include "parse_vrml.h"
#include "vrmlNode.h"
#include "appearance.h"
#include "indexedFaceSet.h"
#include "y.tab.h"
#include <assert.h>
#include <math.h>
static const double pi = 4.0 * atan(1.0);
////////////////////////////////////////////////////////////////////
// Function: MainProgram::Help
// Access: Public, Virtual
// Description: Displays the "what is this program" message, along
// with the usage message. Should be overridden in base
// classes to describe the current program.
////////////////////////////////////////////////////////////////////
void MainProgram::
Help() {
cerr <<
"\n"
"vrml2egg converts VRML 2.0 files (with the .wrl extension) to egg format.\n"
"A reasonable subset of the VRML standard is supported, including polygons,\n"
"colors, normals, textures, and hierarchy.\n";
Usage();
}
////////////////////////////////////////////////////////////////////
// Function: MainProgram::Usage
// Access: Public, Virtual
// Description: Displays the usage message.
////////////////////////////////////////////////////////////////////
void MainProgram::
Usage() {
cerr << "\nUsage:\n"
<< _commandName << " [opts] input.wrl\n\n"
<< "Options:\n";
ShowOpts();
cerr << "\n";
}
////////////////////////////////////////////////////////////////////
// Function: MainProgram::ShowOpts
// Access: Public, Virtual
// Description: Displays the valid options. Should be extended in
// base classes to show additional options relevant to
// the current program.
////////////////////////////////////////////////////////////////////
void MainProgram::
ShowOpts() {
EggBase::ShowOpts();
}
////////////////////////////////////////////////////////////////////
// Function: MainProgram::HandleGetopts
// Access: Public, Virtual
// Description:
////////////////////////////////////////////////////////////////////
boolean MainProgram::
HandleGetopts(char flag, char *optarg, int &optind,
int argc, char **argv) {
bool okflag = true;
switch (flag) {
default:
okflag = EggBase::HandleGetopts(flag, optarg, optind, argc, argv);
}
return okflag;
}
////////////////////////////////////////////////////////////////////
// Function: MainProgram::HandleArgs
// Access: Public
// Description: Called by EggBase::CommandLine() to do the right
// thing with the arguments after the switches.
////////////////////////////////////////////////////////////////////
boolean MainProgram::
HandleArgs(int &argc, char **&argv) {
if (argc != 2) {
cerr << "VRML file name required.\n";
return false;
}
_filename = argv[1];
return EggBase::HandleArgs(argc, argv);
}
////////////////////////////////////////////////////////////////////
// Function: MainProgram::vrml_group
// Access: Public
// Description: Creates an Egg group corresponding to the VRML group.
////////////////////////////////////////////////////////////////////
void MainProgram::
vrml_group(const VrmlNode *node, EggGroup *group,
const pfMatrix &net_transform) {
const MFArray *children = node->get_value("children")._mf;
MFArray::const_iterator ci;
for (ci = children->begin(); ci != children->end(); ++ci) {
vrml_node((*ci)._sfnode, group, net_transform);
}
}
////////////////////////////////////////////////////////////////////
// Function: MainProgram::vrml_transform
// Access: Public
// Description: Creates an Egg group with a transform corresponding
// to the VRML group.
////////////////////////////////////////////////////////////////////
void MainProgram::
vrml_transform(const VrmlNode *node, EggGroup *group,
const pfMatrix &net_transform) {
const double *scale = node->get_value("scale")._sfvec;
const double *rotation = node->get_value("rotation")._sfvec;
const double *translation = node->get_value("translation")._sfvec;
const double *center = node->get_value("center")._sfvec;
const double *o = node->get_value("scaleOrientation")._sfvec;
pfMatrix local_transform;
local_transform.makeIdent();
boolean any_transform = false;
if (scale[0] != 1.0 || scale[1] != 1.0 || scale[2] != 1.0) {
any_transform = true;
if (center[0] != 0.0 || center[1] != 0.0 || center[2] != 0.0) {
local_transform.postTrans(local_transform,
-center[0], -center[1], -center[2]);
if (o[3] != 0.0) {
local_transform.postRot(local_transform,
-o[3] * 180.0 / pi, o[0], o[1], o[2]);
local_transform.postScale(local_transform,
scale[0], scale[1], scale[2]);
local_transform.postRot(local_transform,
o[3] * 180.0 / pi, o[0], o[1], o[2]);
} else {
local_transform.postScale(local_transform,
scale[0], scale[1], scale[2]);
}
local_transform.postTrans(local_transform,
center[0], center[1], center[2]);
} else {
if (o[3] != 0.0) {
local_transform.postRot(local_transform,
-o[3] * 180.0 / pi, o[0], o[1], o[2]);
local_transform.postScale(local_transform,
scale[0], scale[1], scale[2]);
local_transform.postRot(local_transform,
o[3] * 180.0 / pi, o[0], o[1], o[2]);
} else {
local_transform.postScale(local_transform,
scale[0], scale[1], scale[2]);
}
}
}
if (rotation[3] != 0.0) {
any_transform = true;
if (center[0] != 0.0 || center[1] != 0.0 || center[2] != 0.0) {
local_transform.postTrans(local_transform,
-center[0], -center[1], -center[2]);
local_transform.postRot(local_transform,
rotation[3] * 180.0 / pi,
rotation[0], rotation[1], rotation[2]);
local_transform.postTrans(local_transform,
center[0], center[1], center[2]);
} else {
local_transform.postRot(local_transform,
rotation[3] * 180.0 / pi,
rotation[0], rotation[1], rotation[2]);
}
}
if (translation[0] != 0.0 ||
translation[1] != 0.0 ||
translation[2] != 0.0) {
any_transform = true;
local_transform.postTrans(local_transform,
translation[0],
translation[1],
translation[2]);
}
if (any_transform) {
group->transform = local_transform;
group->flags |= EF_TRANSFORM;
}
pfMatrix next_transform = local_transform * net_transform;
const MFArray *children = node->get_value("children")._mf;
MFArray::const_iterator ci;
for (ci = children->begin(); ci != children->end(); ++ci) {
vrml_node((*ci)._sfnode, group, next_transform);
}
}
////////////////////////////////////////////////////////////////////
// Function: MainProgram::vrml_shape
// Access: Public
// Description: Creates an Egg group corresponding a VRML shape.
// This will probably contain a vertex pool and a number
// of polygons.
////////////////////////////////////////////////////////////////////
void MainProgram::
vrml_shape(const VrmlNode *node, EggGroup *group,
const pfMatrix &net_transform) {
const VrmlNode *geometry = node->get_value("geometry")._sfnode._p;
double transparency = 0.0;
if (geometry != NULL) {
Appearance appearance
(node->get_value("appearance")._sfnode._p, _data);
if (strcmp(geometry->_type->getName(), "IndexedFaceSet") == 0) {
IndexedFaceSet ifs(geometry, appearance, _data);
ifs.convert_to_egg(group, net_transform);
} else {
cerr << "Ignoring " << geometry->_type->getName() << "\n";
}
}
}
////////////////////////////////////////////////////////////////////
// Function: MainProgram::vrml_grouping_node
// Access: Public
// Description: Begins initial processing of a grouping-type node;
// that is, any node (like Group, Transform, or Shape)
// that maps to a <Group> or <Instance> in egg. This
// create the group and does any instance-munging
// necessary, then calls the indicated method with the
// new parameters.
////////////////////////////////////////////////////////////////////
void MainProgram::
vrml_grouping_node(const SFNodeRef &vrml, EggGroup *egg,
const pfMatrix &net_transform,
void (MainProgram::*process_func)
(const VrmlNode *node, EggGroup *group,
const pfMatrix &net_transform)) {
const VrmlNode *node = vrml._p;
assert(node != NULL);
const char *name = vrml._name;
if (vrml._type == SFNodeRef::T_use) {
// If this is an instancing reference, just add the reference and
// return; no need for further processing on the node.
Instances::const_iterator fi = _instances.find(node);
assert(fi != _instances.end());
EggInstance *inst = _data.CreateInstance(egg);
inst->AddGroupRef((*fi).second);
return;
}
EggGroup *group;
pfMatrix next_transform;
if (node->_use_count > 0) {
// If this node is referenced one or more times later in the file,
// we must make it an instance node.
group = _data.CreateInstance(egg, name);
next_transform.makeIdent();
// And define the instance for future references.
_instances[node] = group;
} else {
group = _data.CreateGroup(egg, name);
next_transform = net_transform;
}
(this->*process_func)(node, group, next_transform);
}
////////////////////////////////////////////////////////////////////
// Function: MainProgram::vrml_node
// Access: Public
// Description: Processes a single VRML node, converting it to egg
// and adding it to the egg file, if appropriate, or
// doing whatever else should be done.
////////////////////////////////////////////////////////////////////
void MainProgram::
vrml_node(const SFNodeRef &vrml, EggGroup *egg,
const pfMatrix &net_transform) {
const VrmlNode *node = vrml._p;
if (node != NULL) {
// Now add it to the egg file at this point.
if (strcmp(node->_type->getName(), "Group") == 0) {
vrml_grouping_node(vrml, egg, net_transform, &vrml_group);
} else if (strcmp(node->_type->getName(), "Transform") == 0) {
vrml_grouping_node(vrml, egg, net_transform, &vrml_transform);
} else if (strcmp(node->_type->getName(), "Shape") == 0) {
vrml_grouping_node(vrml, egg, net_transform, &vrml_shape);
}
}
}
////////////////////////////////////////////////////////////////////
// Function: MainProgram::get_all_defs
// Access: Public
// Description: Makes a first pass through the VRML hierarchy,
// identifying all nodes marked with a DEF code, and
// also counting the times each one is referenced by
// USE. Later, we'll need this information: if a node
// is referenced at least once, we need to define it as
// an instance node.
////////////////////////////////////////////////////////////////////
void MainProgram::
get_all_defs(SFNodeRef &vrml, MainProgram::Nodes &nodes) {
Nodes::iterator ni;
switch (vrml._type) {
case SFNodeRef::T_def:
// If this is a node definition, add it to the map.
assert(vrml._name != NULL);
assert(vrml._p != NULL);
/*
This happens too often to bother yelling about it.
ni = nodes.find(vrml._name);
if (ni != nodes.end()) {
cerr << "Warning: node name " << vrml._name
<< " appears multiple times.\n";
}
*/
nodes[vrml._name] = vrml._p;
break;
case SFNodeRef::T_use:
// If it's a reference, resolve it.
assert(vrml._name != NULL);
ni = nodes.find(vrml._name);
if (ni == nodes.end()) {
cerr << "Unknown node reference: " << vrml._name << "\n";
} else {
// Increment the use count of the node.
(*ni).second->_use_count++;
// Store the pointer itself in the reference, so we don't have
// to do this again later.
vrml._p = (*ni).second;
}
return;
}
VrmlNode *node = vrml._p;
if (node != NULL) {
VrmlNode::Fields::iterator fi;
for (fi = node->_fields.begin(); fi != node->_fields.end(); ++fi) {
if ((*fi)._type->type == SFNODE) {
get_all_defs((*fi)._value._sfnode, nodes);
} else if ((*fi)._type->type == MFNODE) {
MFArray *children = (*fi)._value._mf;
MFArray::iterator ci;
for (ci = children->begin(); ci != children->end(); ++ci) {
get_all_defs((*ci)._sfnode, nodes);
}
}
}
}
}
////////////////////////////////////////////////////////////////////
// Function: MainProgram::DoIt
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
void MainProgram::
DoIt() {
VrmlScene *scene = parse_vrml(_filename.c_str());
if (scene != NULL) {
// First, resolve all the DEF/USE references, and count the number
// of times each node is USEd.
Nodes nodes;
VrmlScene::iterator si;
for (si = scene->begin(); si != scene->end(); ++si) {
get_all_defs((*si)._node, nodes);
}
// Now go through the hierarchy again, and this time actually
// build the egg structure.
pfMatrix ident;
ident.makeIdent();
VrmlScene::const_iterator csi;
for (csi = scene->begin(); csi != scene->end(); ++csi) {
vrml_node((*csi)._node, &_data.root_group, ident);
}
_data.UniquifyNames();
Output() << _data << "\n";
}
}
int
main(int argc, char *argv[]) {
pfInitArenas();
MainProgram prog;
if (prog.CommandLine(argc, argv)) {
prog.DoIt();
return 0;
}
return 1;
}

View File

@ -1,78 +0,0 @@
// Filename: vrml2egg.h
// Created by: drose (24Jun99)
//
////////////////////////////////////////////////////////////////////
// Copyright (C) 1992,93,94,95,96,97 Walt Disney Imagineering, Inc.
//
// These coded instructions, statements, data structures and
// computer programs contain unpublished proprietary information of
// Walt Disney Imagineering and are protected by Federal copyright
// law. They may not be disclosed to third parties or copied or
// duplicated in any form, in whole or in part, without the prior
// written consent of Walt Disney Imagineering Inc.
////////////////////////////////////////////////////////////////////
#ifndef VRML2EGG_H
#define VRML2EGG_H
#include <eggBase.h>
#include <mstring.h>
#include <map.h>
class VrmlNode;
struct SFNodeRef;
class EggGroup;
class pfMatrix;
////////////////////////////////////////////////////////////////////
// Class : MainProgram
// Description : The vrml2egg program class. This handles the user
// input and gets things going.
////////////////////////////////////////////////////////////////////
class MainProgram : public EggBase {
public:
MainProgram() : EggBase("") {
}
virtual void Help();
virtual void Usage();
virtual void ShowOpts();
virtual boolean
HandleGetopts(char flag, char *optarg, int &optind,
int argc, char **argv);
virtual boolean
HandleArgs(int &argc, char **&argv);
void vrml_group(const VrmlNode *node, EggGroup *group,
const pfMatrix &net_transform);
void vrml_transform(const VrmlNode *node, EggGroup *group,
const pfMatrix &net_transform);
void vrml_shape(const VrmlNode *node, EggGroup *group,
const pfMatrix &net_transform);
void vrml_grouping_node(const SFNodeRef &vrml, EggGroup *egg,
const pfMatrix &net_transform,
void (MainProgram::*process_func)
(const VrmlNode *node, EggGroup *group,
const pfMatrix &net_transform));
void vrml_node(const SFNodeRef &vrml,
EggGroup *egg, const pfMatrix &net_transform);
typedef map<String, VrmlNode *> Nodes;
void get_all_defs(SFNodeRef &vrml, Nodes &nodes);
void DoIt();
typedef map<const VrmlNode *, EggGroup *> Instances;
Instances _instances;
string _filename;
};
#endif

View File

@ -19,6 +19,7 @@
#include "vrmlToEgg.h"
#include "vrmlToEggConverter.h"
#include "pystub.h"
////////////////////////////////////////////////////////////////////
// Function: VRMLToEgg::Constructor
@ -73,6 +74,9 @@ run() {
int main(int argc, char *argv[]) {
// A call to pystub() to force libpystub.so to be linked in.
pystub();
VRMLToEgg prog;
prog.parse_command_line(argc, argv);
prog.run();

View File

@ -18,6 +18,7 @@
#include "vrmlTrans.h"
#include "parse_vrml.h"
#include "pystub.h"
////////////////////////////////////////////////////////////////////
// Function: VRMLTrans::Constructor
@ -97,6 +98,9 @@ handle_args(ProgramBase::Args &args) {
int main(int argc, char *argv[]) {
// A call to pystub() to force libpystub.so to be linked in.
pystub();
VRMLTrans prog;
prog.parse_command_line(argc, argv);
prog.run();

View File

@ -20,6 +20,7 @@
#include "winStatsServer.h"
#include "config_pstats.h"
#include "pystub.h"
#include <windows.h>

View File

@ -18,6 +18,7 @@
#include "eggToX.h"
#include "config_xfile.h"
#include "pystub.h"
////////////////////////////////////////////////////////////////////
// Function: EggToX::Constructor
@ -77,6 +78,9 @@ run() {
int main(int argc, char *argv[]) {
// A call to pystub() to force libpystub.so to be linked in.
pystub();
init_libxfile();
EggToX prog;
prog.parse_command_line(argc, argv);

View File

@ -19,6 +19,7 @@
#include "xFileToEgg.h"
#include "xFileToEggConverter.h"
#include "config_xfile.h"
#include "pystub.h"
////////////////////////////////////////////////////////////////////
// Function: XFileToEgg::Constructor
@ -122,6 +123,9 @@ run() {
int main(int argc, char *argv[]) {
// A call to pystub() to force libpystub.so to be linked in.
pystub();
init_libxfile();
XFileToEgg prog;
prog.parse_command_line(argc, argv);

View File

@ -18,6 +18,7 @@
#include "xFileTrans.h"
#include "xFile.h"
#include "pystub.h"
////////////////////////////////////////////////////////////////////
// Function: XFileTrans::Constructor
@ -99,6 +100,9 @@ handle_args(ProgramBase::Args &args) {
int main(int argc, char *argv[]) {
// A call to pystub() to force libpystub.so to be linked in.
pystub();
XFileTrans prog;
prog.parse_command_line(argc, argv);
prog.run();