Panda3D

maxEgg.h

00001 /*
00002   MaxEgg.h 
00003   Created by Steven "Sauce" Osman, 01/??/03
00004   Modified and maintained by Ken Strickland, (02/01/03)-(05/15/03)
00005   Modified and maintained by Corey Revilla, (05/22/03)-present
00006   Carnegie Mellon University, Entetainment Technology Center
00007 
00008   This file contains a 3dsMax exporter derived from discreet's own SceneExport 
00009   plug-in class; this exporter is basically a wrapper around the MaxToEgg
00010   Panda-converter class, and just sets up the interface and environment
00011   in which the MaxToEgg class can be "run" as if it were a standalone app.
00012 */
00013 #ifndef __MaxEgg__H
00014 #define __MaxEgg__H
00015 
00016 #include "pandatoolbase.h"
00017 #include <sys/types.h>
00018 #include <sys/stat.h>
00019 #include <fcntl.h>
00020 #include <crtdbg.h>
00021 #include "errno.h"
00022 #include "Max.h"
00023 #include "eggGroup.h"
00024 #include "eggTable.h"
00025 #include "eggXfmSAnim.h"
00026 #include "eggData.h"
00027 #include "referenceCount.h"
00028 #include "pointerTo.h"
00029 #include "namable.h"
00030 #include "modstack.h"
00031 
00032 #include <iostream>
00033 #include <fstream>
00034 #include <vector>
00035 
00036 #include "windef.h"
00037 #include "windows.h"
00038 
00039 #include "Max.h"
00040 #include "iparamb2.h"
00041 #include "iparamm2.h"
00042 #include "istdplug.h"
00043 #include "iskin.h"
00044 #include "maxResource.h"
00045 #include "stdmat.h"
00046 #include "phyexp.h"
00047 #include "surf_api.h"
00048 #include "bipexp.h"
00049 
00050 #include "eggCoordinateSystem.h"
00051 #include "eggGroup.h"
00052 #include "eggPolygon.h"
00053 #include "eggTextureCollection.h"
00054 #include "eggTexture.h"
00055 #include "eggVertex.h"
00056 #include "eggVertexPool.h"
00057 #include "eggNurbsCurve.h"
00058 #include "pandatoolbase.h"
00059 #include "somethingToEgg.h"
00060 #include "somethingToEggConverter.h"
00061 #include "eggXfmSAnim.h"
00062 #include "pathStore.h"
00063 
00064 #include "maxNodeDesc.h"
00065 #include "maxNodeTree.h"
00066 #include "maxOptionsDialog.h"
00067 #include "maxToEggConverter.h"
00068 
00069 #define MaxEggPlugin_CLASS_ID   Class_ID(0x7ac0d6b7, 0x55731ef6)
00070 
00071 #pragma conform(forScope, off)
00072 
00073 /* Externed Globals
00074  */
00075 extern HINSTANCE hInstance;
00076 
00077 /* Global Functions
00078  */
00079 extern TCHAR *GetString(int id);
00080 
00081 /* This class defines the 3D Studio Max exporter itself.  It is basically a
00082    shell that is invoked by 3D Studio Max's export API.  It then sets up 
00083    MaxToEgg instance and attempts to "fool it" into thinking that it is
00084    actually being invoked as a standalone program.  The thought behind this
00085    is that some day MaxToEgg may well be a standalone program, provided that
00086    a suitable interface to Max files can be connected from a standalone
00087    program instead of a plugin.
00088 */
00089 
00090 #if MAX_VERSION_MAJOR < 9
00091   #define DefaultRemapDir NoRemap
00092 #endif
00093 
00094 class MaxEggPlugin : public HelperObject 
00095 {
00096   MaxOptionsDialog **eggList;
00097   int numEggs;
00098   int maxEggs;
00099 
00100  public:
00101   bool autoOverwrite;
00102   bool pview;
00103   bool logOutput;
00104   
00105   // Class vars
00106   static Mesh mesh;           // This plugin generates no geometry, this mesh is not passed on to 3D Studio.
00107   static short meshBuilt;
00108   static HWND hMaxEggParams;
00109   static IObjParam *iObjParams;
00110 
00111   //Constructor/Destructor
00112   MaxEggPlugin();
00113   virtual ~MaxEggPlugin();
00114 
00115   //Other class Methods
00116   void DoExport();
00117   void UpdateUI();
00118   void SaveCheckState();
00119   void BuildMesh();
00120 
00121   void AddEgg(MaxOptionsDialog *newEgg);
00122   void RemoveEgg(int i);
00123   MaxOptionsDialog *GetEgg(int i) { return (i >= 0 && i < numEggs) ? eggList[i] : NULL; }
00124 
00125   // Required implimented virtual methods:
00126   // inherited virtual methods for Reference-management
00127   RefResult NotifyRefChanged( Interval changeInt, RefTargetHandle hTarget, PartID& partID, RefMessage message );
00128   void GetMat(TimeValue t, INode* inod, ViewExp *vpt, Matrix3& mat);
00129 
00130   // From BaseObject
00131   int HitTest(TimeValue t, INode* inode, int type, int crossing, int flags, IPoint2 *p, ViewExp *vpt);
00132   int Display(TimeValue t, INode* inode, ViewExp *vpt, int flags);
00133   CreateMouseCallBack* GetCreateMouseCallBack();
00134   void BeginEditParams( IObjParam *ip, ULONG flags,Animatable *prev);
00135   void EndEditParams( IObjParam *ip, ULONG flags,Animatable *next);
00136   TCHAR *GetObjectName() { return GetString(IDS_LIBDESCRIPTION); }
00137 
00138   // From Object
00139   ObjectState Eval(TimeValue time);
00140   void InitNodeName(TSTR& s) { s = GetString(IDS_CLASS_NAME); }
00141   Interval ObjectValidity(TimeValue time);
00142   void Invalidate();
00143   int DoOwnSelectHilite() { return 1; }
00144 
00145   // From GeomObject
00146   int IntersectRay(TimeValue t, Ray& r, PN_stdfloat& at) { return 0; }
00147   void GetWorldBoundBox(TimeValue t, INode *mat, ViewExp *vpt, Box3& box );
00148   void GetLocalBoundBox(TimeValue t, INode *mat, ViewExp *vpt, Box3& box );
00149   void GetDeformBBox(TimeValue t, Box3& box, Matrix3 *tm, BOOL useSel );
00150 
00151   // Animatable methods
00152   void DeleteThis() { delete this; }
00153   Class_ID ClassID() { return MaxEggPlugin_CLASS_ID; }
00154   void GetClassName(TSTR& s) { s = TSTR(GetString(IDS_CLASS_NAME)); }
00155   TSTR SubAnimName(int i) { return TSTR(GetString(IDS_CLASS_NAME)); }
00156   
00157   // From ref
00158   RefTargetHandle Clone(RemapDir& remap = DefaultRemapDir());
00159 
00160   // IO
00161   IOResult Save(ISave *isave);
00162   IOResult Load(ILoad *iload);
00163 };
00164 
00165 
00166 #endif // __MaxEgg__H
 All Classes Functions Variables Enumerations