Browse Source

support maya on windows

David Rose 24 years ago
parent
commit
678d14ce4b

+ 1 - 0
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]]
 
 

+ 2 - 1
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]

+ 19 - 3
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
 

+ 1 - 1
pandatool/src/maya/global_parameters.h

@@ -19,7 +19,7 @@
 #ifndef GLOBAL_PARAMETERS_H
 #define GLOBAL_PARAMETERS_H
 
-#include <pandatoolbase.h>
+#include "pandatoolbase.h"
 
 extern int verbose;
 extern bool polygon_output;

+ 12 - 9
pandatool/src/maya/mayaFile.cxx

@@ -19,15 +19,17 @@
 #include "mayaFile.h"
 #include "mayaShader.h"
 #include "global_parameters.h"
+#include "maya_funcs.h"
 
-#include <eggData.h>
-#include <eggGroup.h>
-#include <eggVertex.h>
-#include <eggVertexPool.h>
-#include <eggNurbsSurface.h>
-#include <eggNurbsCurve.h>
-#include <eggPolygon.h>
+#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 <maya/MArgList.h>
 #include <maya/MColor.h>
 #include <maya/MDagPath.h>
@@ -55,6 +57,7 @@
 #include <maya/MTransformationMatrix.h>
 #include <maya/MVector.h>
 #include <maya/MTesselationParams.h>
+#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);

+ 2 - 4
pandatool/src/maya/mayaFile.h

@@ -19,11 +19,9 @@
 #ifndef MAYAFILE_H
 #define MAYAFILE_H
 
-#include <pandatoolbase.h>
-
+#include "pandatoolbase.h"
 #include "mayaShaders.h"
-
-#include <eggTextureCollection.h>
+#include "eggTextureCollection.h"
 
 class EggData;
 class EggGroup;

+ 5 - 3
pandatool/src/maya/mayaShader.cxx

@@ -21,10 +21,11 @@
 #include "mayaFile.h"
 #include "global_parameters.h"
 
-#include <eggPrimitive.h>
-#include <eggTexture.h>
-#include <eggTextureCollection.h>
+#include "eggPrimitive.h"
+#include "eggTexture.h"
+#include "eggTextureCollection.h"
 
+#include "pre_maya_include.h"
 #include <maya/MFnDependencyNode.h>
 #include <maya/MFnLambertShader.h>
 #include <maya/MPlug.h>
@@ -32,6 +33,7 @@
 #include <maya/MColor.h>
 #include <maya/MObject.h>
 #include <maya/MStatus.h>
+#include "post_maya_include.h"
 
 MayaShader::
 MayaShader(MObject engine) {

+ 3 - 5
pandatool/src/maya/mayaShader.h

@@ -19,12 +19,10 @@
 #ifndef MAYASHADER_H
 #define MAYASHADER_H
 
-#include <pandatoolbase.h>
+#include "pandatoolbase.h"
 
-#include <luse.h>
-#include <lmatrix.h>
-
-#include <string>
+#include "luse.h"
+#include "lmatrix.h"
 
 class MObject;
 class MayaFile;

+ 3 - 0
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 <maya/MStatus.h>
 #include <maya/MObject.h>
 #include <maya/MFnDependencyNode.h>
 #include <maya/MPlug.h>
 #include <maya/MPlugArray.h>
 #include <maya/MFn.h>
+#include "post_maya_include.h"
 
 MayaShader *MayaShaders::
 find_shader_for_node(MObject node) {

+ 1 - 2
pandatool/src/maya/mayaShaders.h

@@ -19,10 +19,9 @@
 #ifndef MAYASHADERS_H
 #define MAYASHADERS_H
 
-#include <pandatoolbase.h>
+#include "pandatoolbase.h"
 
 #include "pmap.h"
-#include <string>
 
 class MayaShader;
 class MObject;

+ 2 - 0
pandatool/src/maya/mayaToEgg.cxx

@@ -19,7 +19,9 @@
 #include "mayaToEgg.h"
 #include "global_parameters.h"
 
+#include "pre_maya_include.h"
 #include <maya/MGlobal.h>
+#include "post_maya_include.h"
 
 ////////////////////////////////////////////////////////////////////
 //     Function: MayaToEgg::Constructor

+ 2 - 4
pandatool/src/maya/mayaToEgg.h

@@ -19,11 +19,9 @@
 #ifndef MAYATOEGG_H
 #define MAYATOEGG_H
 
-#include <pandatoolbase.h>
-
+#include "pandatoolbase.h"
 #include "mayaFile.h"
-
-#include <somethingToEgg.h>
+#include "somethingToEgg.h"
 
 ////////////////////////////////////////////////////////////////////
 //       Class : MayaToEgg

+ 0 - 6
pandatool/src/maya/maya_funcs.I

@@ -16,12 +16,6 @@
 //
 ////////////////////////////////////////////////////////////////////
 
-#include <maya/MFnAttribute.h>
-#include <maya/MPlug.h>
-#include <maya/MStatus.h>
-#include <maya/MFnDependencyNode.h>
-#include <maya/MObject.h>
-
 template<class ValueType>
 bool
 get_maya_attribute(MObject &node, const string &attribute_name,

+ 2 - 0
pandatool/src/maya/maya_funcs.cxx

@@ -18,12 +18,14 @@
 
 #include "maya_funcs.h"
 
+#include "pre_maya_include.h"
 #include <maya/MObject.h>
 #include <maya/MAngle.h>
 #include <maya/MFnDependencyNode.h>
 #include <maya/MStatus.h>
 #include <maya/MFnStringData.h>
 #include <maya/MFnNumericData.h>
+#include "post_maya_include.h"
 
 bool
 get_bool_attribute(MObject &node, const string &attribute_name,

+ 22 - 4
pandatool/src/maya/maya_funcs.h

@@ -19,11 +19,18 @@
 #ifndef MAYA_FUNCS_H
 #define MAYA_FUNCS_H
 
-#include <pandatoolbase.h>
+#include "pandatoolbase.h"
+#include "luse.h"
 
-#include <luse.h>
-
-#include <string>
+#include "pre_maya_include.h"
+#include <maya/MFnAttribute.h>
+#include <maya/MPlug.h>
+#include <maya/MStatus.h>
+#include <maya/MFnDependencyNode.h>
+#include <maya/MObject.h>
+#include <maya/MString.h>
+#include <maya/MVector.h>
+#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

+ 24 - 0
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
+// [email protected] .
+//
+////////////////////////////////////////////////////////////////////
+
+// 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

+ 35 - 0
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
+// [email protected] .
+//
+////////////////////////////////////////////////////////////////////
+
+// 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