diff --git a/dtool/Config.pp b/dtool/Config.pp index 57c63cb96b..43aaf36f18 100644 --- a/dtool/Config.pp +++ b/dtool/Config.pp @@ -358,6 +358,7 @@ // Is Maya installed? This matters only to programs in PANDATOOL. #define MAYA_LOCATION /usr/aw/maya3.0 +#defer MAYA_LIBS $[if $[WINDOWS_PLATFORM],Foundation.lib OpenMaya.lib] #defer HAVE_MAYA $[isdir $[MAYA_LOCATION]] diff --git a/dtool/pptempl/Global.pp b/dtool/pptempl/Global.pp index 7846185906..8804594c46 100644 --- a/dtool/pptempl/Global.pp +++ b/dtool/pptempl/Global.pp @@ -213,7 +213,8 @@ #if $[and $[HAVE_MAYA],$[MAYA_LOCATION]] #define maya_ipath $[MAYA_LOCATION]/include #define maya_lpath $[MAYA_LOCATION]/lib - #define maya_ld $[MAYA_LOCATION]/bin/mayald + #define maya_ld $[wildcard $[MAYA_LOCATION]/bin/mayald] + #define maya_libs $[MAYA_LIBS] #endif #if $[HAVE_IPC] diff --git a/pandatool/src/maya/Sources.pp b/pandatool/src/maya/Sources.pp index bb243d1cca..a8cf6581f6 100644 --- a/pandatool/src/maya/Sources.pp +++ b/pandatool/src/maya/Sources.pp @@ -1,5 +1,16 @@ #define DIRECTORY_IF_MAYA yes +#define binary_name maya2egg + +#if $[UNIX_PLATFORM] + // On Unix, we need maya2egg to be a script that sets the + // LD_LIBRARY_PATH variable and then invokes the application. On + // Windows, this path seems to get built into the executable so + // there's no need. (Don't know why they didn't decide to compile + // it in also on Unix.) + +#set binary_name maya2egg_bin + #begin sed_bin_target #define TARGET maya2egg @@ -8,14 +19,19 @@ #end sed_bin_target +#endif // $[UNIX_PLATFORM] + #begin bin_target #define USE_MAYA yes - #define TARGET maya2egg_bin + #define TARGET $[binary_name] #define LOCAL_LIBS \ eggbase progbase #define OTHER_LIBS \ - egg:c linmath:c putil:c express:c panda:m \ - dtoolutil:c dtoolbase:c dconfig:c dtool:m + egg:c pandaegg:m \ + linmath:c putil:c panda:m \ + express:c pandaexpress:m \ + dtoolutil:c dtoolbase:c dconfig:c dtoolconfig:m dtool:m pystub + #define UNIX_SYS_LIBS \ m diff --git a/pandatool/src/maya/global_parameters.h b/pandatool/src/maya/global_parameters.h index 023b8ee6f1..941f6a61f0 100644 --- a/pandatool/src/maya/global_parameters.h +++ b/pandatool/src/maya/global_parameters.h @@ -19,7 +19,7 @@ #ifndef GLOBAL_PARAMETERS_H #define GLOBAL_PARAMETERS_H -#include +#include "pandatoolbase.h" extern int verbose; extern bool polygon_output; diff --git a/pandatool/src/maya/mayaFile.cxx b/pandatool/src/maya/mayaFile.cxx index 6022037ed5..782e4fa362 100644 --- a/pandatool/src/maya/mayaFile.cxx +++ b/pandatool/src/maya/mayaFile.cxx @@ -19,15 +19,17 @@ #include "mayaFile.h" #include "mayaShader.h" #include "global_parameters.h" +#include "maya_funcs.h" -#include -#include -#include -#include -#include -#include -#include +#include "eggData.h" +#include "eggGroup.h" +#include "eggVertex.h" +#include "eggVertexPool.h" +#include "eggNurbsSurface.h" +#include "eggNurbsCurve.h" +#include "eggPolygon.h" +#include "pre_maya_include.h" #include #include #include @@ -55,6 +57,7 @@ #include #include #include +#include "post_maya_include.h" MayaFile:: MayaFile() { @@ -727,10 +730,10 @@ make_polyset(const MDagPath &dag_path, MFnMesh mesh, // Determine the shader for this particular polygon. int index = pi.index(); - assert(index >= 0 && index < poly_shader_indices.length()); + assert(index >= 0 && index < (int)poly_shader_indices.length()); int shader_index = poly_shader_indices[index]; if (shader_index != -1) { - assert(shader_index >= 0 && shader_index < shaders.length()); + assert(shader_index >= 0 && shader_index < (int)shaders.length()); MObject engine = shaders[shader_index]; MayaShader *shader = _shaders.find_shader_for_shading_engine(engine); diff --git a/pandatool/src/maya/mayaFile.h b/pandatool/src/maya/mayaFile.h index 70975a288d..ba7013ca25 100644 --- a/pandatool/src/maya/mayaFile.h +++ b/pandatool/src/maya/mayaFile.h @@ -19,11 +19,9 @@ #ifndef MAYAFILE_H #define MAYAFILE_H -#include - +#include "pandatoolbase.h" #include "mayaShaders.h" - -#include +#include "eggTextureCollection.h" class EggData; class EggGroup; diff --git a/pandatool/src/maya/mayaShader.cxx b/pandatool/src/maya/mayaShader.cxx index 90f22d7657..48c7231a53 100644 --- a/pandatool/src/maya/mayaShader.cxx +++ b/pandatool/src/maya/mayaShader.cxx @@ -21,10 +21,11 @@ #include "mayaFile.h" #include "global_parameters.h" -#include -#include -#include +#include "eggPrimitive.h" +#include "eggTexture.h" +#include "eggTextureCollection.h" +#include "pre_maya_include.h" #include #include #include @@ -32,6 +33,7 @@ #include #include #include +#include "post_maya_include.h" MayaShader:: MayaShader(MObject engine) { diff --git a/pandatool/src/maya/mayaShader.h b/pandatool/src/maya/mayaShader.h index d5d3caa372..1beaceefa5 100644 --- a/pandatool/src/maya/mayaShader.h +++ b/pandatool/src/maya/mayaShader.h @@ -19,12 +19,10 @@ #ifndef MAYASHADER_H #define MAYASHADER_H -#include +#include "pandatoolbase.h" -#include -#include - -#include +#include "luse.h" +#include "lmatrix.h" class MObject; class MayaFile; diff --git a/pandatool/src/maya/mayaShaders.cxx b/pandatool/src/maya/mayaShaders.cxx index 8db754845f..3be3f93690 100644 --- a/pandatool/src/maya/mayaShaders.cxx +++ b/pandatool/src/maya/mayaShaders.cxx @@ -19,13 +19,16 @@ #include "mayaShaders.h" #include "mayaShader.h" #include "global_parameters.h" +#include "maya_funcs.h" +#include "pre_maya_include.h" #include #include #include #include #include #include +#include "post_maya_include.h" MayaShader *MayaShaders:: find_shader_for_node(MObject node) { diff --git a/pandatool/src/maya/mayaShaders.h b/pandatool/src/maya/mayaShaders.h index 66f2326c7c..9bc780cbf5 100644 --- a/pandatool/src/maya/mayaShaders.h +++ b/pandatool/src/maya/mayaShaders.h @@ -19,10 +19,9 @@ #ifndef MAYASHADERS_H #define MAYASHADERS_H -#include +#include "pandatoolbase.h" #include "pmap.h" -#include class MayaShader; class MObject; diff --git a/pandatool/src/maya/mayaToEgg.cxx b/pandatool/src/maya/mayaToEgg.cxx index 3db3c477cf..83c8f8204a 100644 --- a/pandatool/src/maya/mayaToEgg.cxx +++ b/pandatool/src/maya/mayaToEgg.cxx @@ -19,7 +19,9 @@ #include "mayaToEgg.h" #include "global_parameters.h" +#include "pre_maya_include.h" #include +#include "post_maya_include.h" //////////////////////////////////////////////////////////////////// // Function: MayaToEgg::Constructor diff --git a/pandatool/src/maya/mayaToEgg.h b/pandatool/src/maya/mayaToEgg.h index 37198b4f3e..d791307970 100644 --- a/pandatool/src/maya/mayaToEgg.h +++ b/pandatool/src/maya/mayaToEgg.h @@ -19,11 +19,9 @@ #ifndef MAYATOEGG_H #define MAYATOEGG_H -#include - +#include "pandatoolbase.h" #include "mayaFile.h" - -#include +#include "somethingToEgg.h" //////////////////////////////////////////////////////////////////// // Class : MayaToEgg diff --git a/pandatool/src/maya/maya_funcs.I b/pandatool/src/maya/maya_funcs.I index c52e61b048..d8d2ef367f 100644 --- a/pandatool/src/maya/maya_funcs.I +++ b/pandatool/src/maya/maya_funcs.I @@ -16,12 +16,6 @@ // //////////////////////////////////////////////////////////////////// -#include -#include -#include -#include -#include - template bool get_maya_attribute(MObject &node, const string &attribute_name, diff --git a/pandatool/src/maya/maya_funcs.cxx b/pandatool/src/maya/maya_funcs.cxx index 24ea898c17..e464403461 100644 --- a/pandatool/src/maya/maya_funcs.cxx +++ b/pandatool/src/maya/maya_funcs.cxx @@ -18,12 +18,14 @@ #include "maya_funcs.h" +#include "pre_maya_include.h" #include #include #include #include #include #include +#include "post_maya_include.h" bool get_bool_attribute(MObject &node, const string &attribute_name, diff --git a/pandatool/src/maya/maya_funcs.h b/pandatool/src/maya/maya_funcs.h index 808a08aa38..20a011e070 100644 --- a/pandatool/src/maya/maya_funcs.h +++ b/pandatool/src/maya/maya_funcs.h @@ -19,11 +19,18 @@ #ifndef MAYA_FUNCS_H #define MAYA_FUNCS_H -#include +#include "pandatoolbase.h" +#include "luse.h" -#include - -#include +#include "pre_maya_include.h" +#include +#include +#include +#include +#include +#include +#include +#include "post_maya_include.h" class MObject; @@ -55,6 +62,17 @@ get_string_attribute(MObject &node, const string &attribute_name, void describe_maya_attribute(MObject &node, const string &attribute_name); +// Also, we must define some output functions for Maya objects, since +// we can't use those built into Maya (which forward-defines the +// ostream type incorrectly). +INLINE ostream &operator << (ostream &out, const MString &str) { + return out << str.asChar(); +} +INLINE ostream &operator << (ostream &out, const MVector &vec) { + return out << vec.x << " " << vec.y << " " << vec.z; +} + + #include "maya_funcs.I" #endif diff --git a/pandatool/src/maya/post_maya_include.h b/pandatool/src/maya/post_maya_include.h new file mode 100644 index 0000000000..d31fa23a69 --- /dev/null +++ b/pandatool/src/maya/post_maya_include.h @@ -0,0 +1,24 @@ +// Filename: post_maya_include.h +// Created by: drose (11Apr02) +// +//////////////////////////////////////////////////////////////////// +// +// 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 . +// +//////////////////////////////////////////////////////////////////// + +// This header file works in conjunction with pre_maya_include.h; it +// cleans up some of the definitions that it left open. + +// Remove the symbols defined from pre_maya_include.h. +#undef ostream +#undef istream diff --git a/pandatool/src/maya/pre_maya_include.h b/pandatool/src/maya/pre_maya_include.h new file mode 100644 index 0000000000..bcc5d76abb --- /dev/null +++ b/pandatool/src/maya/pre_maya_include.h @@ -0,0 +1,35 @@ +// Filename: pre_maya_include.h +// Created by: drose (11Apr02) +// +//////////////////////////////////////////////////////////////////// +// +// 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 . +// +//////////////////////////////////////////////////////////////////// + +// This header file defines a few things that are necessary to define +// before including any Maya headers, just to work around some of +// Maya's assumptions about the compiler. It must not try to protect +// itself from multiple inclusion with #ifdef .. #endif, since it must +// be used each time it is included. + +// Maya will try to typedef bool unless this symbol is defined. +#ifndef _BOOL +#define _BOOL 1 +#endif + +// Maya tries to make a forward declaration for class ostream, but +// this is not necessarily a class! Curses. We can't use any of the +// built-in Maya stream operators, and we have to protect ourselves +// from them. +#define ostream maya_ostream +#define istream maya_istream