mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-01 09:23:03 -04:00
bring egg2maya in to ppremake system
This commit is contained in:
parent
ebd2fd2f01
commit
cb5ee1cd82
@ -155,6 +155,19 @@ as_reader() {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: EggReader::pre_process_egg_file
|
||||||
|
// Access: Public, Virtual
|
||||||
|
// Description: Performs any processing of the egg file that is
|
||||||
|
// appropriate after reading it in.
|
||||||
|
//
|
||||||
|
// Normally, you should not need to call this function
|
||||||
|
// directly; it is called automatically at startup.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void EggReader::
|
||||||
|
pre_process_egg_file() {
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: EggReader::handle_args
|
// Function: EggReader::handle_args
|
||||||
// Access: Protected, Virtual
|
// Access: Protected, Virtual
|
||||||
@ -215,6 +228,8 @@ handle_args(ProgramBase::Args &args) {
|
|||||||
_data->merge(file_data);
|
_data->merge(file_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pre_process_egg_file();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,6 +39,7 @@ public:
|
|||||||
void add_delod_options(double default_delod = -1.0);
|
void add_delod_options(double default_delod = -1.0);
|
||||||
|
|
||||||
virtual EggReader *as_reader();
|
virtual EggReader *as_reader();
|
||||||
|
virtual void pre_process_egg_file();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool handle_args(Args &args);
|
virtual bool handle_args(Args &args);
|
||||||
|
@ -82,6 +82,68 @@ EggToSomething(const string &format_name,
|
|||||||
"one of 'y-up', 'z-up', 'y-up-left', or 'z-up-left'. The default "
|
"one of 'y-up', 'z-up', 'y-up-left', or 'z-up-left'. The default "
|
||||||
"is the same coordinate system as the input egg file. If this is "
|
"is the same coordinate system as the input egg file. If this is "
|
||||||
"different from the input egg file, a conversion will be performed.");
|
"different from the input egg file, a conversion will be performed.");
|
||||||
|
|
||||||
|
_input_units = DU_invalid;
|
||||||
|
_output_units = DU_invalid;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: EggToSomething::add_units_options
|
||||||
|
// Access: Public
|
||||||
|
// Description: Adds -ui and -uo as valid options for this program.
|
||||||
|
// If the user specifies -uo and -ui, or just -uo and
|
||||||
|
// the program specifies -ui by setting _input_units,
|
||||||
|
// the indicated units conversion will be automatically
|
||||||
|
// applied before writing out the egg file.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void EggToSomething::
|
||||||
|
add_units_options() {
|
||||||
|
add_option
|
||||||
|
("ui", "units", 40,
|
||||||
|
"Specify the units of the input egg file. If this is "
|
||||||
|
"specified, the vertices in the egg file will be scaled as "
|
||||||
|
"necessary to make the appropriate units conversion; otherwise, "
|
||||||
|
"the vertices will be left as they are.",
|
||||||
|
&EggToSomething::dispatch_units, NULL, &_input_units);
|
||||||
|
|
||||||
|
add_option
|
||||||
|
("uo", "units", 40,
|
||||||
|
"Specify the units of the resulting " + _format_name +
|
||||||
|
" file. Normally, the default units for the format are used.",
|
||||||
|
&EggToSomething::dispatch_units, NULL, &_output_units);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: EggToSomething::apply_units_scale
|
||||||
|
// Access: Protected
|
||||||
|
// Description: Applies the scale indicated by the input and output
|
||||||
|
// units to the indicated egg file. This is normally
|
||||||
|
// done automatically when the file is read in.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void EggToSomething::
|
||||||
|
apply_units_scale(EggData *data) {
|
||||||
|
if (_output_units != DU_invalid && _input_units != DU_invalid &&
|
||||||
|
_input_units != _output_units) {
|
||||||
|
nout << "Converting from " << format_long_unit(_input_units)
|
||||||
|
<< " to " << format_long_unit(_output_units) << "\n";
|
||||||
|
double scale = convert_units(_input_units, _output_units);
|
||||||
|
data->transform(LMatrix4d::scale_mat(scale));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: EggToSomething::pre_process_egg_file
|
||||||
|
// Access: Protected, Virtual
|
||||||
|
// Description: Performs any processing of the egg file that is
|
||||||
|
// appropriate after reading it in.
|
||||||
|
//
|
||||||
|
// Normally, you should not need to call this function
|
||||||
|
// directly; it is called automatically at startup.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void EggToSomething::
|
||||||
|
pre_process_egg_file() {
|
||||||
|
apply_units_scale(_data);
|
||||||
|
EggConverter::pre_process_egg_file();
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include "pandatoolbase.h"
|
#include "pandatoolbase.h"
|
||||||
|
|
||||||
#include "eggConverter.h"
|
#include "eggConverter.h"
|
||||||
|
#include "distanceUnit.h"
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Class : EggToSomething
|
// Class : EggToSomething
|
||||||
@ -36,8 +37,15 @@ public:
|
|||||||
bool allow_last_param = true,
|
bool allow_last_param = true,
|
||||||
bool allow_stdout = true);
|
bool allow_stdout = true);
|
||||||
|
|
||||||
|
void add_units_options();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
void apply_units_scale(EggData *data);
|
||||||
|
virtual void pre_process_egg_file();
|
||||||
virtual bool handle_args(Args &args);
|
virtual bool handle_args(Args &args);
|
||||||
|
|
||||||
|
DistanceUnit _input_units;
|
||||||
|
DistanceUnit _output_units;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#define SOURCES \
|
#define SOURCES \
|
||||||
config_mayaegg.cxx config_mayaegg.h \
|
config_mayaegg.cxx config_mayaegg.h \
|
||||||
mayaEggGroupUserData.cxx mayaEggGroupUserData.I mayaEggGroupUserData.h \
|
mayaEggGroupUserData.cxx mayaEggGroupUserData.I mayaEggGroupUserData.h \
|
||||||
|
mayaEggLoader.cxx mayaEggLoader.h \
|
||||||
mayaBlendDesc.cxx mayaBlendDesc.h \
|
mayaBlendDesc.cxx mayaBlendDesc.h \
|
||||||
mayaNodeDesc.cxx mayaNodeDesc.h \
|
mayaNodeDesc.cxx mayaNodeDesc.h \
|
||||||
mayaNodeTree.cxx mayaNodeTree.h \
|
mayaNodeTree.cxx mayaNodeTree.h \
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,7 @@
|
|||||||
#define BUILD_DIRECTORY $[HAVE_MAYA]
|
#define BUILD_DIRECTORY $[HAVE_MAYA]
|
||||||
|
|
||||||
#define maya2egg maya2egg
|
#define maya2egg maya2egg
|
||||||
|
#define egg2maya egg2maya
|
||||||
#define mayacopy mayacopy
|
#define mayacopy mayacopy
|
||||||
|
|
||||||
#if $[UNIX_PLATFORM]
|
#if $[UNIX_PLATFORM]
|
||||||
@ -11,6 +12,7 @@
|
|||||||
// it in also on Unix.)
|
// it in also on Unix.)
|
||||||
|
|
||||||
#set maya2egg maya2egg_bin
|
#set maya2egg maya2egg_bin
|
||||||
|
#set egg2maya egg2maya_bin
|
||||||
#set mayacopy mayacopy_bin
|
#set mayacopy mayacopy_bin
|
||||||
|
|
||||||
#begin sed_bin_target
|
#begin sed_bin_target
|
||||||
@ -21,6 +23,14 @@
|
|||||||
|
|
||||||
#end sed_bin_target
|
#end sed_bin_target
|
||||||
|
|
||||||
|
#begin sed_bin_target
|
||||||
|
#define TARGET egg2maya
|
||||||
|
|
||||||
|
#define SOURCE mayapath_script
|
||||||
|
#define COMMAND s:xxx:$[MAYA_LOCATION]:g;s:yyy:$[TARGET]:g;s+zzz+$[MAYA_LICENSE_FILE]+g;
|
||||||
|
|
||||||
|
#end sed_bin_target
|
||||||
|
|
||||||
#begin sed_bin_target
|
#begin sed_bin_target
|
||||||
#define TARGET mayacopy
|
#define TARGET mayacopy
|
||||||
|
|
||||||
@ -51,6 +61,26 @@
|
|||||||
|
|
||||||
#end bin_target
|
#end bin_target
|
||||||
|
|
||||||
|
#begin bin_target
|
||||||
|
#define USE_PACKAGES maya
|
||||||
|
#define TARGET $[egg2maya]
|
||||||
|
#define LOCAL_LIBS \
|
||||||
|
mayaegg maya eggbase progbase
|
||||||
|
#define OTHER_LIBS \
|
||||||
|
egg:c pandaegg:m \
|
||||||
|
linmath:c putil:c panda:m \
|
||||||
|
express:c pandaexpress:m \
|
||||||
|
interrogatedb:c dtoolutil:c dtoolbase:c prc:c dconfig:c dtoolconfig:m dtool:m pystub
|
||||||
|
|
||||||
|
// Irix requires this to be named explicitly.
|
||||||
|
#define UNIX_SYS_LIBS \
|
||||||
|
ExtensionLayer
|
||||||
|
|
||||||
|
#define SOURCES \
|
||||||
|
eggToMaya.cxx eggToMaya.h
|
||||||
|
|
||||||
|
#end bin_target
|
||||||
|
|
||||||
|
|
||||||
#begin bin_target
|
#begin bin_target
|
||||||
#define USE_PACKAGES maya
|
#define USE_PACKAGES maya
|
||||||
@ -112,6 +142,29 @@
|
|||||||
mayaSavePview.cxx mayaSavePview.h
|
mayaSavePview.cxx mayaSavePview.h
|
||||||
#end lib_target
|
#end lib_target
|
||||||
|
|
||||||
|
#begin lib_target
|
||||||
|
#define BUILD_TARGET $[not $[LINK_ALL_STATIC]]
|
||||||
|
#define USE_PACKAGES maya
|
||||||
|
#define TARGET mayaEggImport
|
||||||
|
#define LOCAL_LIBS mayaegg maya
|
||||||
|
#define OTHER_LIBS \
|
||||||
|
egg:c pandaegg:m \
|
||||||
|
framework:m \
|
||||||
|
linmath:c putil:c panda:m \
|
||||||
|
express:c pandaexpress:m \
|
||||||
|
interrogatedb:c dtoolutil:c dtoolbase:c prc:c dconfig:c dtoolconfig:m dtool:m pystub
|
||||||
|
|
||||||
|
#define BUILDING_DLL BUILDING_MISC
|
||||||
|
|
||||||
|
#if $[WINDOWS_PLATFORM]
|
||||||
|
#define dlllib mll
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define SOURCES \
|
||||||
|
mayaEggImport.cxx
|
||||||
|
|
||||||
|
#end lib_target
|
||||||
|
|
||||||
#begin lib_target
|
#begin lib_target
|
||||||
#define USE_PACKAGES maya
|
#define USE_PACKAGES maya
|
||||||
#define TARGET mayaloader
|
#define TARGET mayaloader
|
||||||
|
118
pandatool/src/mayaprogs/eggToMaya.cxx
Executable file
118
pandatool/src/mayaprogs/eggToMaya.cxx
Executable file
@ -0,0 +1,118 @@
|
|||||||
|
// Filename: eggToMaya.cxx
|
||||||
|
// Created by: drose (11Aug05)
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// PANDA 3D SOFTWARE
|
||||||
|
// Copyright (c) 2001 - 2004, 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://etc.cmu.edu/panda3d/docs/license/ .
|
||||||
|
//
|
||||||
|
// To contact the maintainers of this program write to
|
||||||
|
// panda3d-general@lists.sourceforge.net .
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "eggToMaya.h"
|
||||||
|
#include "mayaEggLoader.h"
|
||||||
|
#include "mayaApi.h"
|
||||||
|
|
||||||
|
// We must define this to prevent Maya from doubly-declaring its
|
||||||
|
// MApiVersion string in this file as well as in libmayaegg.
|
||||||
|
#define _MApiVersion
|
||||||
|
|
||||||
|
#include "pre_maya_include.h"
|
||||||
|
#include <maya/MString.h>
|
||||||
|
#include <maya/MFileIO.h>
|
||||||
|
#include "post_maya_include.h"
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: EggToMaya::Constructor
|
||||||
|
// Access: Public
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
EggToMaya::
|
||||||
|
EggToMaya() :
|
||||||
|
EggToSomething("Maya", ".mb", true, false)
|
||||||
|
{
|
||||||
|
add_units_options();
|
||||||
|
|
||||||
|
set_binary_output(true);
|
||||||
|
set_program_description
|
||||||
|
("egg2maya converts files from egg format to Maya .mb or .ma "
|
||||||
|
"format. At the moment, it contains support for basic geometry "
|
||||||
|
"(polygons with textures).");
|
||||||
|
|
||||||
|
add_option
|
||||||
|
("a", "", 0,
|
||||||
|
"Convert animation tables.",
|
||||||
|
&EggToMaya::dispatch_none, &_convert_anim);
|
||||||
|
|
||||||
|
add_option
|
||||||
|
("m", "", 0,
|
||||||
|
"Convert polygon models. You may specify both -a and -m at the same "
|
||||||
|
"time. If you specify neither, the default is -m.",
|
||||||
|
&EggToMaya::dispatch_none, &_convert_model);
|
||||||
|
|
||||||
|
// Maya files always store centimeters.
|
||||||
|
_output_units = DU_centimeters;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: EggToMaya::run
|
||||||
|
// Access: Public
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void EggToMaya::
|
||||||
|
run() {
|
||||||
|
if (!_convert_anim && !_convert_model) {
|
||||||
|
_convert_model = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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.
|
||||||
|
_output_filename.make_absolute();
|
||||||
|
|
||||||
|
nout << "Initializing Maya.\n";
|
||||||
|
PT(MayaApi) maya = MayaApi::open_api(_program_name);
|
||||||
|
if (!maya->is_valid()) {
|
||||||
|
nout << "Unable to initialize Maya.\n";
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
MStatus status;
|
||||||
|
status = MFileIO::newFile(true);
|
||||||
|
if (!status) {
|
||||||
|
status.perror("Could not initialize file");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now convert the data.
|
||||||
|
if (!MayaLoadEggData(_data, true, _convert_model, _convert_anim)) {
|
||||||
|
nout << "Unable to convert egg file.\n";
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// And write out the resulting Maya file.
|
||||||
|
string os_specific = _output_filename.to_os_generic();
|
||||||
|
const char *file_type = NULL;
|
||||||
|
if (_output_filename.get_extension() == "mb") {
|
||||||
|
file_type = "mayaBinary";
|
||||||
|
}
|
||||||
|
status = MFileIO::saveAs(os_specific.c_str(), file_type);
|
||||||
|
if (!status) {
|
||||||
|
status.perror("Could not save file");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char *argv[]) {
|
||||||
|
EggToMaya prog;
|
||||||
|
prog.parse_command_line(argc, argv);
|
||||||
|
prog.run();
|
||||||
|
return 0;
|
||||||
|
}
|
42
pandatool/src/mayaprogs/eggToMaya.h
Executable file
42
pandatool/src/mayaprogs/eggToMaya.h
Executable file
@ -0,0 +1,42 @@
|
|||||||
|
// Filename: eggToMaya.h
|
||||||
|
// Created by: drose (11Aug05)
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// PANDA 3D SOFTWARE
|
||||||
|
// Copyright (c) 2001 - 2004, 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://etc.cmu.edu/panda3d/docs/license/ .
|
||||||
|
//
|
||||||
|
// To contact the maintainers of this program write to
|
||||||
|
// panda3d-general@lists.sourceforge.net .
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef EGGTOMAYA_H
|
||||||
|
#define EGGTOMAYA_H
|
||||||
|
|
||||||
|
#include "pandatoolbase.h"
|
||||||
|
|
||||||
|
#include "eggToSomething.h"
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Class : EggToMaya
|
||||||
|
// Description : A program to read an egg file and write a maya file.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
class EggToMaya : public EggToSomething {
|
||||||
|
public:
|
||||||
|
EggToMaya();
|
||||||
|
|
||||||
|
void run();
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool _convert_anim;
|
||||||
|
bool _convert_model;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -31,6 +31,10 @@
|
|||||||
|
|
||||||
#include "dtoolbase.h"
|
#include "dtoolbase.h"
|
||||||
|
|
||||||
|
// We must define this to prevent Maya from doubly-declaring its
|
||||||
|
// MApiVersion string in this file as well as in libmayaegg.
|
||||||
|
#define _MApiVersion
|
||||||
|
|
||||||
#include "pre_maya_include.h"
|
#include "pre_maya_include.h"
|
||||||
#include <maya/MStatus.h>
|
#include <maya/MStatus.h>
|
||||||
#include <maya/MPxCommand.h>
|
#include <maya/MPxCommand.h>
|
Loading…
x
Reference in New Issue
Block a user