Panda3D
maxEgg.h
1 /*
2  MaxEgg.h
3  Created by Steven "Sauce" Osman, 01/??/03
4  Modified and maintained by Ken Strickland, (02/01/03)-(05/15/03)
5  Modified and maintained by Corey Revilla, (05/22/03)-present
6  Carnegie Mellon University, Entetainment Technology Center
7 
8  This file contains a 3dsMax exporter derived from discreet's own SceneExport
9  plug-in class; this exporter is basically a wrapper around the MaxToEgg
10  Panda-converter class, and just sets up the interface and environment
11  in which the MaxToEgg class can be "run" as if it were a standalone app.
12 */
13 #ifndef __MaxEgg__H
14 #define __MaxEgg__H
15 
16 #include "pandatoolbase.h"
17 #include <sys/types.h>
18 #include <sys/stat.h>
19 #include <fcntl.h>
20 #include <crtdbg.h>
21 #include "errno.h"
22 #include "Max.h"
23 #include "eggGroup.h"
24 #include "eggTable.h"
25 #include "eggXfmSAnim.h"
26 #include "eggData.h"
27 #include "referenceCount.h"
28 #include "pointerTo.h"
29 #include "namable.h"
30 #include "modstack.h"
31 
32 #include <iostream>
33 #include <fstream>
34 #include <vector>
35 
36 #define WIN32_LEAN_AND_MEAN
37 #include "windef.h"
38 #include "windows.h"
39 
40 #include "Max.h"
41 #include "iparamb2.h"
42 #include "iparamm2.h"
43 #include "istdplug.h"
44 #include "iskin.h"
45 #include "maxResource.h"
46 #include "stdmat.h"
47 #include "phyexp.h"
48 #include "surf_api.h"
49 #include "bipexp.h"
50 
51 #include "eggCoordinateSystem.h"
52 #include "eggGroup.h"
53 #include "eggPolygon.h"
54 #include "eggTextureCollection.h"
55 #include "eggTexture.h"
56 #include "eggVertex.h"
57 #include "eggVertexPool.h"
58 #include "eggNurbsCurve.h"
59 #include "pandatoolbase.h"
60 #include "eggXfmSAnim.h"
61 #include "pathStore.h"
62 
63 #include "maxNodeDesc.h"
64 #include "maxNodeTree.h"
65 #include "maxOptionsDialog.h"
66 #include "maxToEggConverter.h"
67 
68 #define MaxEggPlugin_CLASS_ID Class_ID(0x7ac0d6b7, 0x55731ef6)
69 
70 #pragma conform(forScope, off)
71 
72 /* Externed Globals
73  */
74 extern HINSTANCE hInstance;
75 
76 /* Global Functions
77  */
78 extern TCHAR *GetString(int id);
79 
80 /* This class defines the 3D Studio Max exporter itself. It is basically a
81  shell that is invoked by 3D Studio Max's export API. It then sets up
82  MaxToEgg instance and attempts to "fool it" into thinking that it is
83  actually being invoked as a standalone program. The thought behind this
84  is that some day MaxToEgg may well be a standalone program, provided that
85  a suitable interface to Max files can be connected from a standalone
86  program instead of a plugin.
87 */
88 
89 #if MAX_VERSION_MAJOR < 9
90  #define DefaultRemapDir NoRemap
91 #endif
92 
93 class MaxEggPlugin : public HelperObject
94 {
95  MaxOptionsDialog **eggList;
96  int numEggs;
97  int maxEggs;
98 
99  public:
100  bool autoOverwrite;
101  bool pview;
102  bool logOutput;
103 
104  // Class vars
105  static Mesh mesh; // This plugin generates no geometry, this mesh is not passed on to 3D Studio.
106  static short meshBuilt;
107  static HWND hMaxEggParams;
108  static IObjParam *iObjParams;
109 
110  //Constructor/Destructor
111  MaxEggPlugin();
112  virtual ~MaxEggPlugin();
113 
114  //Other class Methods
115  void DoExport();
116  void UpdateUI();
117  void SaveCheckState();
118  void BuildMesh();
119 
120  void AddEgg(MaxOptionsDialog *newEgg);
121  void RemoveEgg(int i);
122  MaxOptionsDialog *GetEgg(int i) { return (i >= 0 && i < numEggs) ? eggList[i] : NULL; }
123 
124  // Required implimented virtual methods:
125  // inherited virtual methods for Reference-management
126  RefResult NotifyRefChanged( Interval changeInt, RefTargetHandle hTarget, PartID& partID, RefMessage message );
127  void GetMat(TimeValue t, INode* inod, ViewExp *vpt, Matrix3& mat);
128 
129  // From BaseObject
130  int HitTest(TimeValue t, INode* inode, int type, int crossing, int flags, IPoint2 *p, ViewExp *vpt);
131  int Display(TimeValue t, INode* inode, ViewExp *vpt, int flags);
132  CreateMouseCallBack* GetCreateMouseCallBack();
133  void BeginEditParams( IObjParam *ip, ULONG flags,Animatable *prev);
134  void EndEditParams( IObjParam *ip, ULONG flags,Animatable *next);
135 #if MAX_VERSION_MAJOR < 15
136  TCHAR *GetObjectName() { return GetString(IDS_LIBDESCRIPTION); }
137 #else
138  const TCHAR *GetObjectName() { return GetString(IDS_LIBDESCRIPTION); }
139 #endif
140 
141  // From Object
142  ObjectState Eval(TimeValue time);
143  void InitNodeName(TSTR& s) { s = GetString(IDS_CLASS_NAME); }
144  Interval ObjectValidity(TimeValue time);
145  void Invalidate();
146  int DoOwnSelectHilite() { return 1; }
147 
148  // From GeomObject
149  int IntersectRay(TimeValue t, Ray& r, PN_stdfloat& at) { return 0; }
150  void GetWorldBoundBox(TimeValue t, INode *mat, ViewExp *vpt, Box3& box );
151  void GetLocalBoundBox(TimeValue t, INode *mat, ViewExp *vpt, Box3& box );
152  void GetDeformBBox(TimeValue t, Box3& box, Matrix3 *tm, BOOL useSel );
153 
154  // Animatable methods
155  void DeleteThis() { delete this; }
156  Class_ID ClassID() { return MaxEggPlugin_CLASS_ID; }
157  void GetClassName(TSTR& s) { s = TSTR(GetString(IDS_CLASS_NAME)); }
158  TSTR SubAnimName(int i) { return TSTR(GetString(IDS_CLASS_NAME)); }
159 
160  // From ref
161  RefTargetHandle Clone(RemapDir& remap = DefaultRemapDir());
162 
163  // IO
164  IOResult Save(ISave *isave);
165  IOResult Load(ILoad *iload);
166 };
167 
168 
169 #endif // __MaxEgg__H