mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-01 09:23:03 -04:00
Now with more comments and extra cruft removed
This commit is contained in:
parent
367cb1a1ff
commit
fa179419bb
@ -1,5 +1,5 @@
|
|||||||
// Filename: mayaToEgg.cxx
|
// Filename: mayaToEgg.cxx
|
||||||
// Created by: drose (15Feb00)
|
// Adapted by: cbrunner (09Nov09)
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
@ -13,10 +13,6 @@
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include "mayaToEgg_client.h"
|
#include "mayaToEgg_client.h"
|
||||||
#include "mayaToEggConverter.h"
|
|
||||||
#include "config_mayaegg.h"
|
|
||||||
#include "config_maya.h" // for maya_cat
|
|
||||||
#include "globPattern.h"
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include "pystub.h"
|
#include "pystub.h"
|
||||||
#endif
|
#endif
|
||||||
@ -26,305 +22,17 @@
|
|||||||
// Access: Public
|
// Access: Public
|
||||||
// Description:
|
// Description:
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
MayaToEgg::
|
MayaToEggClient::
|
||||||
MayaToEgg() :
|
MayaToEggClient() :
|
||||||
SomethingToEgg("Maya", ".mb")
|
SomethingToEgg("Maya", ".mb")
|
||||||
{
|
{
|
||||||
add_path_replace_options();
|
qManager = new QueuedConnectionManager();
|
||||||
add_path_store_options();
|
qReader = new QueuedConnectionReader(manager, 0);
|
||||||
add_animation_options();
|
qWriter = new ConnectionWriter(manager, 0);
|
||||||
add_units_options();
|
// We assume the server is local and on port 4242
|
||||||
add_normals_options();
|
|
||||||
add_transform_options();
|
|
||||||
|
|
||||||
set_program_description
|
|
||||||
("This program converts Maya model files to egg. Static and animatable "
|
|
||||||
"models can be converted, with polygon or NURBS output. Animation tables "
|
|
||||||
"can also be generated to apply to an animatable model.");
|
|
||||||
|
|
||||||
add_option
|
|
||||||
("p", "", 0,
|
|
||||||
"Generate polygon output only. Tesselate all NURBS surfaces to "
|
|
||||||
"polygons via the built-in Maya tesselator. The tesselation will "
|
|
||||||
"be based on the tolerance factor given by -ptol.",
|
|
||||||
&MayaToEgg::dispatch_none, &_polygon_output);
|
|
||||||
|
|
||||||
add_option
|
|
||||||
("ptol", "tolerance", 0,
|
|
||||||
"Specify the fit tolerance for Maya polygon tesselation. The smaller "
|
|
||||||
"the number, the more polygons will be generated. The default is "
|
|
||||||
"0.01.",
|
|
||||||
&MayaToEgg::dispatch_double, NULL, &_polygon_tolerance);
|
|
||||||
|
|
||||||
add_option
|
|
||||||
("bface", "", 0,
|
|
||||||
"Respect the Maya \"double sided\" rendering flag to indicate whether "
|
|
||||||
"polygons should be double-sided or single-sided. Since this flag "
|
|
||||||
"is set to double-sided by default in Maya, it is often better to "
|
|
||||||
"ignore this flag (unless your modelers are diligent in turning it "
|
|
||||||
"off where it is not desired). If this flag is not specified, the "
|
|
||||||
"default is to treat all polygons as single-sided, unless an "
|
|
||||||
"egg object type of \"double-sided\" is set.",
|
|
||||||
&MayaToEgg::dispatch_none, &_respect_maya_double_sided);
|
|
||||||
|
|
||||||
add_option
|
|
||||||
("suppress-vcolor", "", 0,
|
|
||||||
"Ignore vertex color for geometry that has a texture applied. "
|
|
||||||
"(This is the way Maya normally renders internally.) The egg flag "
|
|
||||||
"'vertex-color' may be applied to a particular model to override "
|
|
||||||
"this setting locally.",
|
|
||||||
&MayaToEgg::dispatch_none, &_suppress_vertex_color);
|
|
||||||
|
|
||||||
add_option
|
|
||||||
("keep-uvs", "", 0,
|
|
||||||
"Convert all UV sets on all vertices, even those that do not appear "
|
|
||||||
"to be referenced by any textures.",
|
|
||||||
&MayaToEgg::dispatch_none, &_keep_all_uvsets);
|
|
||||||
|
|
||||||
add_option
|
|
||||||
("round-uvs", "", 0,
|
|
||||||
"round up uv coordinates to the nearest 1/100th. i.e. -0.001 becomes"
|
|
||||||
"0.0; 0.444 becomes 0.44; 0.778 becomes 0.78.",
|
|
||||||
&MayaToEgg::dispatch_none, &_round_uvs);
|
|
||||||
|
|
||||||
add_option
|
|
||||||
("trans", "type", 0,
|
|
||||||
"Specifies which transforms in the Maya file should be converted to "
|
|
||||||
"transforms in the egg file. The option may be one of all, model, "
|
|
||||||
"dcs, or none. The default is model, which means only transforms on "
|
|
||||||
"nodes that have the model flag or the dcs flag are preserved.",
|
|
||||||
&MayaToEgg::dispatch_transform_type, NULL, &_transform_type);
|
|
||||||
|
|
||||||
add_option
|
|
||||||
("subroot", "name", 0,
|
|
||||||
"Specifies that only a subroot of the geometry in the Maya file should "
|
|
||||||
"be converted; specifically, the geometry under the node or nodes whose "
|
|
||||||
"name matches the parameter (which may include globbing characters "
|
|
||||||
"like * or ?). This parameter may be repeated multiple times to name "
|
|
||||||
"multiple roots. If it is omitted altogether, the entire file is "
|
|
||||||
"converted.",
|
|
||||||
&MayaToEgg::dispatch_vector_string, NULL, &_subroots);
|
|
||||||
|
|
||||||
add_option
|
|
||||||
("subset", "name", 0,
|
|
||||||
"Specifies that only a subset of the geometry in the Maya file should "
|
|
||||||
"be converted; specifically, the geometry under the node or nodes whose "
|
|
||||||
"name matches the parameter (which may include globbing characters "
|
|
||||||
"like * or ?). This parameter may be repeated multiple times to name "
|
|
||||||
"multiple roots. If it is omitted altogether, the entire file is "
|
|
||||||
"converted.",
|
|
||||||
&MayaToEgg::dispatch_vector_string, NULL, &_subsets);
|
|
||||||
|
|
||||||
add_option
|
|
||||||
("exclude", "name", 0,
|
|
||||||
"Specifies that a subset of the geometry in the Maya file should "
|
|
||||||
"not be converted; specifically, the geometry under the node or nodes whose "
|
|
||||||
"name matches the parameter (which may include globbing characters "
|
|
||||||
"like * or ?). This parameter may be repeated multiple times to name "
|
|
||||||
"multiple roots.",
|
|
||||||
&MayaToEgg::dispatch_vector_string, NULL, &_excludes);
|
|
||||||
|
|
||||||
add_option
|
|
||||||
("ignore-slider", "name", 0,
|
|
||||||
"Specifies the name of a slider (blend shape deformer) that maya2egg "
|
|
||||||
"should not process. The slider will not be touched during conversion "
|
|
||||||
"and it will not become a part of the animation. This "
|
|
||||||
"parameter may including globbing characters, and it may be repeated "
|
|
||||||
"as needed.",
|
|
||||||
&MayaToEgg::dispatch_vector_string, NULL, &_ignore_sliders);
|
|
||||||
|
|
||||||
add_option
|
|
||||||
("force-joint", "name", 0,
|
|
||||||
"Specifies the name of a DAG node that maya2egg "
|
|
||||||
"should treat as a joint, even if it does not appear to be a Maya joint "
|
|
||||||
"and does not appear to be animated.",
|
|
||||||
&MayaToEgg::dispatch_vector_string, NULL, &_force_joints);
|
|
||||||
|
|
||||||
add_option
|
|
||||||
("v", "", 0,
|
|
||||||
"Increase verbosity. More v's means more verbose.",
|
|
||||||
&MayaToEgg::dispatch_count, NULL, &_verbose);
|
|
||||||
|
|
||||||
// Unfortunately, the Maya API doesn't allow us to differentiate
|
|
||||||
// between relative and absolute pathnames--everything comes out as
|
|
||||||
// an absolute pathname, even if it is stored in the Maya file as a
|
|
||||||
// relative path. So we can't support -noabs.
|
|
||||||
remove_option("noabs");
|
|
||||||
|
|
||||||
_verbose = 0;
|
|
||||||
_polygon_tolerance = 0.01;
|
|
||||||
_transform_type = MayaToEggConverter::TT_model;
|
|
||||||
_got_tbnauto = true;
|
|
||||||
manager = new QueuedConnectionManager();
|
|
||||||
reader = new QueuedConnectionReader(manager, 0);
|
|
||||||
writer = new ConnectionWriter(manager, 0);
|
|
||||||
server.set_host("localhost", 4242);
|
server.set_host("localhost", 4242);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
// Function: MayaToEgg::run
|
|
||||||
// Access: Public
|
|
||||||
// Description:
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
void MayaToEgg::
|
|
||||||
run() {
|
|
||||||
// Set the verbose level by using Notify.
|
|
||||||
if (_verbose >= 3) {
|
|
||||||
maya_cat->set_severity(NS_spam);
|
|
||||||
mayaegg_cat->set_severity(NS_spam);
|
|
||||||
} else if (_verbose >= 2) {
|
|
||||||
maya_cat->set_severity(NS_debug);
|
|
||||||
mayaegg_cat->set_severity(NS_debug);
|
|
||||||
} else if (_verbose >= 1) {
|
|
||||||
maya_cat->set_severity(NS_info);
|
|
||||||
mayaegg_cat->set_severity(NS_info);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Let's convert the output file to a full path before we initialize
|
|
||||||
// Maya, since Maya now has a nasty habit of changing the current
|
|
||||||
// directory.
|
|
||||||
if (_got_output_filename) {
|
|
||||||
_output_filename.make_absolute();
|
|
||||||
}
|
|
||||||
|
|
||||||
nout << "Initializing Maya.\n";
|
|
||||||
MayaToEggConverter converter(_program_name);
|
|
||||||
if (!converter.open_api()) {
|
|
||||||
nout << "Unable to initialize Maya.\n";
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Copy in the command-line parameters.
|
|
||||||
converter._polygon_output = _polygon_output;
|
|
||||||
converter._polygon_tolerance = _polygon_tolerance;
|
|
||||||
converter._respect_maya_double_sided = _respect_maya_double_sided;
|
|
||||||
converter._always_show_vertex_color = !_suppress_vertex_color;
|
|
||||||
converter._keep_all_uvsets = _keep_all_uvsets;
|
|
||||||
converter._round_uvs = _round_uvs;
|
|
||||||
converter._transform_type = _transform_type;
|
|
||||||
|
|
||||||
vector_string::const_iterator si;
|
|
||||||
if (!_subroots.empty()) {
|
|
||||||
converter.clear_subroots();
|
|
||||||
for (si = _subroots.begin(); si != _subroots.end(); ++si) {
|
|
||||||
converter.add_subroot(GlobPattern(*si));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!_subsets.empty()) {
|
|
||||||
converter.clear_subsets();
|
|
||||||
for (si = _subsets.begin(); si != _subsets.end(); ++si) {
|
|
||||||
converter.add_subset(GlobPattern(*si));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!_excludes.empty()) {
|
|
||||||
converter.clear_excludes();
|
|
||||||
for (si = _excludes.begin(); si != _excludes.end(); ++si) {
|
|
||||||
converter.add_exclude(GlobPattern(*si));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!_ignore_sliders.empty()) {
|
|
||||||
converter.clear_ignore_sliders();
|
|
||||||
for (si = _ignore_sliders.begin(); si != _ignore_sliders.end(); ++si) {
|
|
||||||
converter.add_ignore_slider(GlobPattern(*si));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!_force_joints.empty()) {
|
|
||||||
converter.clear_force_joints();
|
|
||||||
for (si = _force_joints.begin(); si != _force_joints.end(); ++si) {
|
|
||||||
converter.add_force_joint(GlobPattern(*si));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Copy in the path and animation parameters.
|
|
||||||
apply_parameters(converter);
|
|
||||||
|
|
||||||
// Set the coordinate system to match Maya's.
|
|
||||||
if (!_got_coordinate_system) {
|
|
||||||
_coordinate_system = converter._maya->get_coordinate_system();
|
|
||||||
}
|
|
||||||
_data->set_coordinate_system(_coordinate_system);
|
|
||||||
|
|
||||||
converter.set_egg_data(_data);
|
|
||||||
|
|
||||||
if (!converter.convert_file(_input_filename)) {
|
|
||||||
nout << "Errors in conversion.\n";
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Use the standard Maya units, if the user didn't specify
|
|
||||||
// otherwise. This always returns centimeters, which is the way all
|
|
||||||
// Maya files are stored internally (and is the units returned by
|
|
||||||
// all of the API functions called here).
|
|
||||||
if (_input_units == DU_invalid) {
|
|
||||||
_input_units = converter.get_input_units();
|
|
||||||
}
|
|
||||||
|
|
||||||
write_egg_file();
|
|
||||||
nout << "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
// Function: MayaToEgg::dispatch_transform_type
|
|
||||||
// Access: Protected, Static
|
|
||||||
// Description: Dispatches a parameter that expects a
|
|
||||||
// MayaToEggConverter::TransformType option.
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
bool MayaToEgg::
|
|
||||||
dispatch_transform_type(const string &opt, const string &arg, void *var) {
|
|
||||||
MayaToEggConverter::TransformType *ip = (MayaToEggConverter::TransformType *)var;
|
|
||||||
(*ip) = MayaToEggConverter::string_transform_type(arg);
|
|
||||||
|
|
||||||
if ((*ip) == MayaToEggConverter::TT_invalid) {
|
|
||||||
nout << "Invalid type for -" << opt << ": " << arg << "\n"
|
|
||||||
<< "Valid types are all, model, dcs, and none.\n";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
// Function: MayaToEgg::poll
|
|
||||||
// Access: Public
|
|
||||||
// Description: Checks for any network activity and handles it, if
|
|
||||||
// appropriate, and then returns. This must be called
|
|
||||||
// periodically
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
void MayaToEgg::
|
|
||||||
poll() {
|
|
||||||
// Delete all the readers that we couldn't delete before.
|
|
||||||
while (!_lost_readers.empty()) {
|
|
||||||
QueuedConnectionReader *reader = _lost_readers.back();
|
|
||||||
_lost_readers.pop_back();
|
|
||||||
|
|
||||||
delete reader;
|
|
||||||
}
|
|
||||||
while (!_removed_readers.empty()) {
|
|
||||||
QueuedConnectionReader *reader = _removed_readers.back();
|
|
||||||
_removed_readers.pop_back();
|
|
||||||
delete reader;
|
|
||||||
}
|
|
||||||
|
|
||||||
// listener->poll();
|
|
||||||
|
|
||||||
Readers::const_iterator ri = _readers.begin();
|
|
||||||
while (ri != _readers.end()) {
|
|
||||||
// Preincrement the iterator, in case we remove it as a result of
|
|
||||||
// calling poll().
|
|
||||||
Readers::const_iterator rnext = ri;
|
|
||||||
++rnext;
|
|
||||||
QueuedConnectionReader *reader = (*ri).second;
|
|
||||||
|
|
||||||
reader->poll();
|
|
||||||
|
|
||||||
ri = rnext;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
// We don't want pystub on linux, since it gives problems with Maya's python.
|
// We don't want pystub on linux, since it gives problems with Maya's python.
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
@ -332,23 +40,17 @@ int main(int argc, char *argv[]) {
|
|||||||
pystub();
|
pystub();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
MayaToEgg prog;
|
MayaToEggClient prog;
|
||||||
// prog.parse_command_line(argc, argv);
|
// Open a connection to the server process
|
||||||
// prog.run();
|
|
||||||
|
|
||||||
// TODO:
|
|
||||||
// - Open a socket and wait for communications
|
|
||||||
// - When communication is received, send along argc and argv to
|
|
||||||
// prog.parase_command_line and prog.run()
|
|
||||||
// [ see commented out section above ]
|
|
||||||
// - Go back to waiting
|
|
||||||
PT(Connection) con = prog.manager->open_TCP_client_connection(prog.server,0);
|
PT(Connection) con = prog.manager->open_TCP_client_connection(prog.server,0);
|
||||||
if (con.is_null()) {
|
if (con.is_null()) {
|
||||||
nout << "port opened fail";
|
nout << "port opened fail";
|
||||||
}
|
}
|
||||||
|
|
||||||
prog.reader->add_connection(con);
|
// Add this connection to the readers list
|
||||||
|
prog.qReader->add_connection(con);
|
||||||
|
|
||||||
|
// Get the current working directory and make sure it's a string
|
||||||
Filename cwd = ExecutionEnvironment::get_cwd();
|
Filename cwd = ExecutionEnvironment::get_cwd();
|
||||||
string s_cwd = (string)cwd.to_os_specific();
|
string s_cwd = (string)cwd.to_os_specific();
|
||||||
nout << "CWD: " << s_cwd << "\n";
|
nout << "CWD: " << s_cwd << "\n";
|
||||||
@ -356,15 +58,20 @@ int main(int argc, char *argv[]) {
|
|||||||
nout << "building datagram\n";
|
nout << "building datagram\n";
|
||||||
NetDatagram datagram;
|
NetDatagram datagram;
|
||||||
|
|
||||||
|
// First part of the datagram is the argc
|
||||||
datagram.add_uint8(argc);
|
datagram.add_uint8(argc);
|
||||||
|
|
||||||
|
// Add the rest of the arguments as strings to the datagram
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < argc; i++) {
|
for (i = 0; i < argc; i++) {
|
||||||
datagram.add_string(argv[i]);
|
datagram.add_string(argv[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Lastly, add the current working dir as a string to the datagram
|
||||||
datagram.add_string(s_cwd);
|
datagram.add_string(s_cwd);
|
||||||
nout << "sending datagram\n";
|
nout << "sending datagram\n";
|
||||||
|
|
||||||
|
// Send it and close the connection
|
||||||
prog.writer->send(datagram, con);
|
prog.writer->send(datagram, con);
|
||||||
prog.manager->close_connection(con);
|
prog.manager->close_connection(con);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Filename: mayaToEgg.h
|
// Filename: mayaToEgg_client.h
|
||||||
// Created by: drose (15Feb00)
|
// Adapted by: cbrunner (09Nov09)
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
@ -12,53 +12,26 @@
|
|||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#ifndef MAYATOEGG_H
|
#ifndef MAYATOEGGCLIENT_H
|
||||||
#define MAYATOEGG_H
|
#define MAYATOEGGCLIENT_H
|
||||||
|
|
||||||
#include "pandatoolbase.h"
|
|
||||||
#include "somethingToEgg.h"
|
#include "somethingToEgg.h"
|
||||||
#include "mayaToEggConverter.h"
|
|
||||||
#include "queuedConnectionManager.h"
|
#include "queuedConnectionManager.h"
|
||||||
#include "queuedConnectionReader.h"
|
#include "queuedConnectionReader.h"
|
||||||
#include "connectionWriter.h"
|
#include "connectionWriter.h"
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Class : MayaToEgg
|
// Class : MayaToEggClient
|
||||||
// Description :
|
// Description :
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
class MayaToEgg : public SomethingToEgg {
|
class MayaToEggClient : public SomethingToEgg {
|
||||||
public:
|
public:
|
||||||
MayaToEgg();
|
MayaToEggClient();
|
||||||
|
|
||||||
void run();
|
|
||||||
void poll();
|
|
||||||
QueuedConnectionManager *manager;
|
QueuedConnectionManager *manager;
|
||||||
QueuedConnectionReader *reader;
|
QueuedConnectionReader *reader;
|
||||||
ConnectionWriter *writer;
|
ConnectionWriter *writer;
|
||||||
NetAddress server;
|
NetAddress server;
|
||||||
|
|
||||||
protected:
|
|
||||||
static bool dispatch_transform_type(const string &opt, const string &arg, void *var);
|
|
||||||
|
|
||||||
int _verbose;
|
|
||||||
bool _polygon_output;
|
|
||||||
double _polygon_tolerance;
|
|
||||||
bool _respect_maya_double_sided;
|
|
||||||
bool _suppress_vertex_color;
|
|
||||||
bool _keep_all_uvsets;
|
|
||||||
bool _round_uvs;
|
|
||||||
MayaToEggConverter::TransformType _transform_type;
|
|
||||||
vector_string _subroots;
|
|
||||||
vector_string _subsets;
|
|
||||||
vector_string _excludes;
|
|
||||||
vector_string _ignore_sliders;
|
|
||||||
vector_string _force_joints;
|
|
||||||
|
|
||||||
typedef pmap<PT(Connection), QueuedConnectionReader *> Readers;
|
|
||||||
Readers _readers;
|
|
||||||
typedef pvector<QueuedConnectionReader *> LostReaders;
|
|
||||||
LostReaders _lost_readers;
|
|
||||||
LostReaders _removed_readers;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Filename: mayaToEgg.cxx
|
// Filename: mayaToEgg_server.cxx
|
||||||
// Created by: drose (15Feb00)
|
// Adapted by: cbrunner (09Nov09)
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
@ -25,12 +25,12 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: MayaToEgg::Constructor
|
// Function: MayaToEggServer::Constructor
|
||||||
// Access: Public
|
// Access: Public
|
||||||
// Description:
|
// Description:
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
MayaToEgg::
|
MayaToEggServer::
|
||||||
MayaToEgg() :
|
MayaToEggServer() :
|
||||||
SomethingToEgg("Maya", ".mb")
|
SomethingToEgg("Maya", ".mb")
|
||||||
{
|
{
|
||||||
add_path_replace_options();
|
add_path_replace_options();
|
||||||
@ -50,14 +50,14 @@ MayaToEgg() :
|
|||||||
"Generate polygon output only. Tesselate all NURBS surfaces to "
|
"Generate polygon output only. Tesselate all NURBS surfaces to "
|
||||||
"polygons via the built-in Maya tesselator. The tesselation will "
|
"polygons via the built-in Maya tesselator. The tesselation will "
|
||||||
"be based on the tolerance factor given by -ptol.",
|
"be based on the tolerance factor given by -ptol.",
|
||||||
&MayaToEgg::dispatch_none, &_polygon_output);
|
&MayaToEggServer::dispatch_none, &_polygon_output);
|
||||||
|
|
||||||
add_option
|
add_option
|
||||||
("ptol", "tolerance", 0,
|
("ptol", "tolerance", 0,
|
||||||
"Specify the fit tolerance for Maya polygon tesselation. The smaller "
|
"Specify the fit tolerance for Maya polygon tesselation. The smaller "
|
||||||
"the number, the more polygons will be generated. The default is "
|
"the number, the more polygons will be generated. The default is "
|
||||||
"0.01.",
|
"0.01.",
|
||||||
&MayaToEgg::dispatch_double, NULL, &_polygon_tolerance);
|
&MayaToEggServer::dispatch_double, NULL, &_polygon_tolerance);
|
||||||
|
|
||||||
add_option
|
add_option
|
||||||
("bface", "", 0,
|
("bface", "", 0,
|
||||||
@ -68,7 +68,7 @@ MayaToEgg() :
|
|||||||
"off where it is not desired). If this flag is not specified, the "
|
"off where it is not desired). If this flag is not specified, the "
|
||||||
"default is to treat all polygons as single-sided, unless an "
|
"default is to treat all polygons as single-sided, unless an "
|
||||||
"egg object type of \"double-sided\" is set.",
|
"egg object type of \"double-sided\" is set.",
|
||||||
&MayaToEgg::dispatch_none, &_respect_maya_double_sided);
|
&MayaToEggServer::dispatch_none, &_respect_maya_double_sided);
|
||||||
|
|
||||||
add_option
|
add_option
|
||||||
("suppress-vcolor", "", 0,
|
("suppress-vcolor", "", 0,
|
||||||
@ -76,19 +76,19 @@ MayaToEgg() :
|
|||||||
"(This is the way Maya normally renders internally.) The egg flag "
|
"(This is the way Maya normally renders internally.) The egg flag "
|
||||||
"'vertex-color' may be applied to a particular model to override "
|
"'vertex-color' may be applied to a particular model to override "
|
||||||
"this setting locally.",
|
"this setting locally.",
|
||||||
&MayaToEgg::dispatch_none, &_suppress_vertex_color);
|
&MayaToEggServer::dispatch_none, &_suppress_vertex_color);
|
||||||
|
|
||||||
add_option
|
add_option
|
||||||
("keep-uvs", "", 0,
|
("keep-uvs", "", 0,
|
||||||
"Convert all UV sets on all vertices, even those that do not appear "
|
"Convert all UV sets on all vertices, even those that do not appear "
|
||||||
"to be referenced by any textures.",
|
"to be referenced by any textures.",
|
||||||
&MayaToEgg::dispatch_none, &_keep_all_uvsets);
|
&MayaToEggServer::dispatch_none, &_keep_all_uvsets);
|
||||||
|
|
||||||
add_option
|
add_option
|
||||||
("round-uvs", "", 0,
|
("round-uvs", "", 0,
|
||||||
"round up uv coordinates to the nearest 1/100th. i.e. -0.001 becomes"
|
"round up uv coordinates to the nearest 1/100th. i.e. -0.001 becomes"
|
||||||
"0.0; 0.444 becomes 0.44; 0.778 becomes 0.78.",
|
"0.0; 0.444 becomes 0.44; 0.778 becomes 0.78.",
|
||||||
&MayaToEgg::dispatch_none, &_round_uvs);
|
&MayaToEggServer::dispatch_none, &_round_uvs);
|
||||||
|
|
||||||
add_option
|
add_option
|
||||||
("trans", "type", 0,
|
("trans", "type", 0,
|
||||||
@ -96,7 +96,7 @@ MayaToEgg() :
|
|||||||
"transforms in the egg file. The option may be one of all, model, "
|
"transforms in the egg file. The option may be one of all, model, "
|
||||||
"dcs, or none. The default is model, which means only transforms on "
|
"dcs, or none. The default is model, which means only transforms on "
|
||||||
"nodes that have the model flag or the dcs flag are preserved.",
|
"nodes that have the model flag or the dcs flag are preserved.",
|
||||||
&MayaToEgg::dispatch_transform_type, NULL, &_transform_type);
|
&MayaToEggServer::dispatch_transform_type, NULL, &_transform_type);
|
||||||
|
|
||||||
add_option
|
add_option
|
||||||
("subroot", "name", 0,
|
("subroot", "name", 0,
|
||||||
@ -106,7 +106,7 @@ MayaToEgg() :
|
|||||||
"like * or ?). This parameter may be repeated multiple times to name "
|
"like * or ?). This parameter may be repeated multiple times to name "
|
||||||
"multiple roots. If it is omitted altogether, the entire file is "
|
"multiple roots. If it is omitted altogether, the entire file is "
|
||||||
"converted.",
|
"converted.",
|
||||||
&MayaToEgg::dispatch_vector_string, NULL, &_subroots);
|
&MayaToEggServer::dispatch_vector_string, NULL, &_subroots);
|
||||||
|
|
||||||
add_option
|
add_option
|
||||||
("subset", "name", 0,
|
("subset", "name", 0,
|
||||||
@ -116,7 +116,7 @@ MayaToEgg() :
|
|||||||
"like * or ?). This parameter may be repeated multiple times to name "
|
"like * or ?). This parameter may be repeated multiple times to name "
|
||||||
"multiple roots. If it is omitted altogether, the entire file is "
|
"multiple roots. If it is omitted altogether, the entire file is "
|
||||||
"converted.",
|
"converted.",
|
||||||
&MayaToEgg::dispatch_vector_string, NULL, &_subsets);
|
&MayaToEggServer::dispatch_vector_string, NULL, &_subsets);
|
||||||
|
|
||||||
add_option
|
add_option
|
||||||
("exclude", "name", 0,
|
("exclude", "name", 0,
|
||||||
@ -125,7 +125,7 @@ MayaToEgg() :
|
|||||||
"name matches the parameter (which may include globbing characters "
|
"name matches the parameter (which may include globbing characters "
|
||||||
"like * or ?). This parameter may be repeated multiple times to name "
|
"like * or ?). This parameter may be repeated multiple times to name "
|
||||||
"multiple roots.",
|
"multiple roots.",
|
||||||
&MayaToEgg::dispatch_vector_string, NULL, &_excludes);
|
&MayaToEggServer::dispatch_vector_string, NULL, &_excludes);
|
||||||
|
|
||||||
add_option
|
add_option
|
||||||
("ignore-slider", "name", 0,
|
("ignore-slider", "name", 0,
|
||||||
@ -134,19 +134,19 @@ MayaToEgg() :
|
|||||||
"and it will not become a part of the animation. This "
|
"and it will not become a part of the animation. This "
|
||||||
"parameter may including globbing characters, and it may be repeated "
|
"parameter may including globbing characters, and it may be repeated "
|
||||||
"as needed.",
|
"as needed.",
|
||||||
&MayaToEgg::dispatch_vector_string, NULL, &_ignore_sliders);
|
&MayaToEggServer::dispatch_vector_string, NULL, &_ignore_sliders);
|
||||||
|
|
||||||
add_option
|
add_option
|
||||||
("force-joint", "name", 0,
|
("force-joint", "name", 0,
|
||||||
"Specifies the name of a DAG node that maya2egg "
|
"Specifies the name of a DAG node that maya2egg "
|
||||||
"should treat as a joint, even if it does not appear to be a Maya joint "
|
"should treat as a joint, even if it does not appear to be a Maya joint "
|
||||||
"and does not appear to be animated.",
|
"and does not appear to be animated.",
|
||||||
&MayaToEgg::dispatch_vector_string, NULL, &_force_joints);
|
&MayaToEggServer::dispatch_vector_string, NULL, &_force_joints);
|
||||||
|
|
||||||
add_option
|
add_option
|
||||||
("v", "", 0,
|
("v", "", 0,
|
||||||
"Increase verbosity. More v's means more verbose.",
|
"Increase verbosity. More v's means more verbose.",
|
||||||
&MayaToEgg::dispatch_count, NULL, &_verbose);
|
&MayaToEggServer::dispatch_count, NULL, &_verbose);
|
||||||
|
|
||||||
// Unfortunately, the Maya API doesn't allow us to differentiate
|
// Unfortunately, the Maya API doesn't allow us to differentiate
|
||||||
// between relative and absolute pathnames--everything comes out as
|
// between relative and absolute pathnames--everything comes out as
|
||||||
@ -164,17 +164,17 @@ MayaToEgg() :
|
|||||||
dummy = new MayaToEggConverter();
|
dummy = new MayaToEggConverter();
|
||||||
nout << "Initializing Maya...\n";
|
nout << "Initializing Maya...\n";
|
||||||
if (!dummy->open_api()) {
|
if (!dummy->open_api()) {
|
||||||
nout << "Unable to initialize May.\n";
|
nout << "Unable to initialize Maya.\n";
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: MayaToEgg::Destructor
|
// Function: MayaToEggServer::Destructor
|
||||||
// Access: Public
|
// Access: Public
|
||||||
// Description:
|
// Description:
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
MayaToEgg::
|
MayaToEggServer::
|
||||||
~MayaToEgg() {
|
~MayaToEggServer() {
|
||||||
delete qManager;
|
delete qManager;
|
||||||
delete qReader;
|
delete qReader;
|
||||||
delete qListener;
|
delete qListener;
|
||||||
@ -182,11 +182,11 @@ MayaToEgg::
|
|||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: MayaToEgg::run
|
// Function: MayaToEggServer::run
|
||||||
// Access: Public
|
// Access: Public
|
||||||
// Description:
|
// Description:
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void MayaToEgg::
|
void MayaToEggServer::
|
||||||
run() {
|
run() {
|
||||||
// Set the verbose level by using Notify.
|
// Set the verbose level by using Notify.
|
||||||
if (_verbose >= 3) {
|
if (_verbose >= 3) {
|
||||||
@ -291,12 +291,12 @@ run() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: MayaToEgg::dispatch_transform_type
|
// Function: MayaToEggServer::dispatch_transform_type
|
||||||
// Access: Protected, Static
|
// Access: Protected, Static
|
||||||
// Description: Dispatches a parameter that expects a
|
// Description: Dispatches a parameter that expects a
|
||||||
// MayaToEggConverter::TransformType option.
|
// MayaToEggConverter::TransformType option.
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
bool MayaToEgg::
|
bool MayaToEggServer::
|
||||||
dispatch_transform_type(const string &opt, const string &arg, void *var) {
|
dispatch_transform_type(const string &opt, const string &arg, void *var) {
|
||||||
MayaToEggConverter::TransformType *ip = (MayaToEggConverter::TransformType *)var;
|
MayaToEggConverter::TransformType *ip = (MayaToEggConverter::TransformType *)var;
|
||||||
(*ip) = MayaToEggConverter::string_transform_type(arg);
|
(*ip) = MayaToEggConverter::string_transform_type(arg);
|
||||||
@ -311,13 +311,13 @@ dispatch_transform_type(const string &opt, const string &arg, void *var) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: MayaToEgg::poll
|
// Function: MayaToEggServer::poll
|
||||||
// Access: Public
|
// Access: Public
|
||||||
// Description: Checks for any network activity and handles it, if
|
// Description: Checks for any network activity and handles it, if
|
||||||
// appropriate, and then returns. This must be called
|
// appropriate, and then returns. This must be called
|
||||||
// periodically
|
// periodically
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void MayaToEgg::
|
void MayaToEggServer::
|
||||||
poll() {
|
poll() {
|
||||||
// Listen for new connections
|
// Listen for new connections
|
||||||
qListener->poll();
|
qListener->poll();
|
||||||
@ -412,7 +412,7 @@ int main(int argc, char *argv[]) {
|
|||||||
pystub();
|
pystub();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
MayaToEgg prog;
|
MayaToEggServer prog;
|
||||||
// Open a rendezvous port for receiving new connections from the client
|
// Open a rendezvous port for receiving new connections from the client
|
||||||
PT(Connection) rend = prog.qManager->open_TCP_server_rendezvous(4242, 50);
|
PT(Connection) rend = prog.qManager->open_TCP_server_rendezvous(4242, 50);
|
||||||
if (rend.is_null()) {
|
if (rend.is_null()) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Filename: mayaToEgg.h
|
// Filename: mayaToEgg_server.h
|
||||||
// Created by: drose (15Feb00)
|
// Adapted by: cbrunner (09Nov09)
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
@ -12,8 +12,8 @@
|
|||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#ifndef MAYATOEGG_H
|
#ifndef MAYATOEGGSERVER_H
|
||||||
#define MAYATOEGG_H
|
#define MAYATOEGGSERVER_H
|
||||||
|
|
||||||
#include "pandatoolbase.h"
|
#include "pandatoolbase.h"
|
||||||
#include "somethingToEgg.h"
|
#include "somethingToEgg.h"
|
||||||
@ -23,13 +23,13 @@
|
|||||||
#include "queuedConnectionReader.h"
|
#include "queuedConnectionReader.h"
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Class : MayaToEgg
|
// Class : MayaToEggServer
|
||||||
// Description :
|
// Description :
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
class MayaToEgg : public SomethingToEgg {
|
class MayaToEggServer : public SomethingToEgg {
|
||||||
public:
|
public:
|
||||||
MayaToEgg();
|
MayaToEggServer();
|
||||||
~MayaToEgg();
|
~MayaToEggServer();
|
||||||
|
|
||||||
void run();
|
void run();
|
||||||
void poll();
|
void poll();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user