00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #pragma once
00018
00019 #include "meshlib.h"
00020 #include "mnmath.h"
00021 #include "snap.h"
00022 #include "object.h"
00023 #include "maxtess.h"
00024
00025 #ifdef POLY_LIB_EXPORTING
00026 #define PolyLibExport __declspec( dllexport )
00027 #else
00028 #define PolyLibExport __declspec( dllimport )
00029 #endif
00030
00031 #define POLY_MULTI_PROCESSING TRUE
00032
00033 extern PolyLibExport Class_ID polyObjectClassID;
00034
00035 #pragma warning(push)
00036 #pragma warning(disable:4239 4100)
00037
00081 class PolyObject: public GeomObject {
00082 private:
00083
00084 TessApprox mDispApprox;
00085 bool mSubDivideDisplacement;
00086 bool mDisableDisplacement;
00087 bool mSplitMesh;
00088
00089 protected:
00090 Interval geomValid;
00091 Interval topoValid;
00092 Interval texmapValid;
00093 Interval selectValid;
00094 Interval vcolorValid;
00095 DWORD validBits;
00096 PolyLibExport void CopyValidity(PolyObject *fromOb, ChannelMask channels);
00097
00098 PolyLibExport RefResult NotifyRefChanged(Interval changeInt, RefTargetHandle hTarget, PartID& partID, RefMessage message );
00099 public:
00100 MNMesh mm;
00101
00102 PolyLibExport PolyObject();
00103 PolyLibExport ~PolyObject();
00104
00105
00106
00107
00108 PolyLibExport virtual bool RequiresSupportForLegacyDisplayMode() const;
00109 PolyLibExport virtual bool UpdateDisplay(
00110 unsigned long renderItemCategories,
00111 const MaxSDK::Graphics::MaterialRequiredStreams& materialRequiredStreams,
00112 TimeValue t);
00113
00114
00115 PolyLibExport int HitTest(TimeValue t, INode* inode, int type, int crossing, int flags, IPoint2 *p, ViewExp *vpt);
00116 PolyLibExport int Display(TimeValue t, INode* inode, ViewExp *vpt, int flags);
00117 PolyLibExport void Snap(TimeValue t, INode* inode, SnapInfo *snap, IPoint2 *p, ViewExp *vpt);
00118 PolyLibExport CreateMouseCallBack* GetCreateMouseCallBack() { return NULL; }
00119
00120 PolyLibExport RefTargetHandle Clone(RemapDir& remap);
00121
00122
00123
00124 PolyLibExport ObjectState Eval(TimeValue time);
00125 PolyLibExport Interval ObjectValidity(TimeValue t);
00126 PolyLibExport BOOL HasUVW();
00127 PolyLibExport BOOL HasUVW(int mapChannel);
00128 PolyLibExport Object *CollapseObject();
00129
00130 PolyLibExport Interval ChannelValidity (TimeValue t, int nchan);
00131 PolyLibExport Interval PartValidity (DWORD partIDs);
00132 PolyLibExport void SetChannelValidity (int i, Interval v);
00133 PolyLibExport void SetPartValidity (DWORD partIDs, Interval v);
00134 PolyLibExport void InvalidateChannels (ChannelMask channels);
00135
00136
00137 PolyLibExport Interval ConvertValidity(TimeValue t);
00138
00139
00140 int IsDeformable() { return 1; }
00141 PolyLibExport int NumPoints();
00142 PolyLibExport Point3 GetPoint(int i);
00143 PolyLibExport void SetPoint(int i, const Point3& p);
00144 PolyLibExport void PointsWereChanged();
00145 PolyLibExport void Deform (Deformer *defProc, int useSel=0);
00146
00147
00148
00149
00150
00155 BOOL IsPointSelected (int i) {
00156 if ((i<0) || (i>=mm.numv)) return false;
00157 return mm.v[i].FlagMatch (MN_DEAD|MN_SEL, MN_SEL);
00158 }
00164 float PointSelection (int i) {
00165 if ((i<0) || (i>=mm.numv)) return 0.0f;
00166 if (mm.v[i].GetFlag (MN_DEAD)) return 0.0f;
00167 if (mm.v[i].GetFlag (MN_SEL)) return 1.0f;
00168 float *vssel = mm.getVSelectionWeights();
00169 if (vssel) return vssel[i];
00170 else return 0.0f;
00171 }
00172
00186 BOOL PolygonCount(TimeValue t, int& numFaces, int& numVerts) {
00187 numFaces = 0;
00188 numVerts = 0;
00189 for (int i=0; i<mm.numf; i++) if (!mm.f[i].GetFlag (MN_DEAD)) numFaces++;
00190 for (int i=0; i<mm.numv; i++) if (!mm.v[i].GetFlag (MN_DEAD)) numVerts++;
00191 return TRUE;
00192 }
00193
00194
00195 int IsMappable() { return 1; }
00196 int NumMapChannels () { return MAX_MESHMAPS; }
00197 int NumMapsUsed () { return mm.numm; }
00198 PolyLibExport void ApplyUVWMap(int type, float utile, float vtile, float wtile,
00199 int uflip, int vflip, int wflip, int cap,const Matrix3 &tm,int channel=1);
00200
00201 PolyLibExport void GetDeformBBox(TimeValue t, Box3& box, Matrix3 *tm=NULL,BOOL useSel=FALSE );
00202
00203 PolyLibExport int CanConvertToType(Class_ID obtype);
00204 PolyLibExport Object* ConvertToType(TimeValue t, Class_ID obtype);
00205 PolyLibExport void FreeChannels(ChannelMask chan);
00206 PolyLibExport Object *MakeShallowCopy(ChannelMask channels);
00207 PolyLibExport void ShallowCopy(Object* fromOb, ChannelMask channels);
00208 PolyLibExport void NewAndCopyChannels(ChannelMask channels);
00209
00213 PolyLibExport DWORD GetSubselState();
00220 PolyLibExport void SetSubSelState(DWORD s);
00221
00224 PolyLibExport BOOL CheckObjectIntegrity();
00225
00226
00227 PolyLibExport int IntersectRay(TimeValue t, Ray& ray, float& at, Point3& norm);
00228 PolyLibExport ObjectHandle CreateTriObjRep(TimeValue t);
00229 PolyLibExport void GetWorldBoundBox(TimeValue t, INode *inode, ViewExp* vpt, Box3& box );
00230 PolyLibExport void GetLocalBoundBox(TimeValue t, INode *inode, ViewExp* vpt, Box3& box );
00231 PolyLibExport Mesh* GetRenderMesh(TimeValue t, INode *inode, View &view, BOOL& needDelete);
00232
00233 PolyLibExport void TopologyChanged();
00234
00236 MNMesh& GetMesh() { return mm; }
00237
00238
00239
00240 PolyLibExport void DeleteThis();
00241 void FreeCaches() {mm.InvalidateGeomCache(); mm.InvalidateTopoCache(false); }
00242 Class_ID ClassID() { return Class_ID(POLYOBJ_CLASS_ID,0); }
00243 void GetClassName(MSTR& s) { s = MSTR(_M("PolyMeshObject")); }
00244 void NotifyMe(Animatable* subAnim, int message) { UNUSED_PARAM(subAnim); UNUSED_PARAM(message);}
00245 int IsKeyable() { return 0;}
00246 int Update(TimeValue t) { UNUSED_PARAM(t); return 0; }
00247
00248
00249 MCHAR *GetObjectName() { return _M("PolyMesh"); }
00250 PolyLibExport void RescaleWorldUnits(float f);
00251
00252
00253 PolyLibExport IOResult Save(ISave *isave);
00254 PolyLibExport IOResult Load(ILoad *iload);
00255
00256
00257
00258
00262 PolyLibExport BOOL CanDoDisplacementMapping();
00268 PolyLibExport void SetDisplacementApproxToPreset(int preset);
00269
00270
00276 void SetDisplacementDisable (bool disable) { mDisableDisplacement = disable; }
00282 void SetDisplacementParameters (TessApprox & params) { mDispApprox = params; }
00287 void SetDisplacementSplit (bool split) { mSplitMesh = split; }
00292 void SetDisplacement (bool displace) { mSubDivideDisplacement = displace; }
00293
00296 bool GetDisplacementDisable () const { return mDisableDisplacement; }
00299 TessApprox GetDisplacementParameters () const { return mDispApprox; }
00302 bool GetDisplacementSplit () const { return mSplitMesh; }
00304 bool GetDisplacement () const { return mSubDivideDisplacement; }
00305
00310 TessApprox &DispParams() { return mDispApprox; }
00311
00313
00316 PolyLibExport void ReduceDisplayCaches();
00317
00324 PolyLibExport bool NeedGWCacheRebuilt(GraphicsWindow *gw, Material *ma, int numMat);
00325
00333 PolyLibExport void BuildGWCache(GraphicsWindow *gw, Material *ma, int numMat,BOOL threaded);
00334
00335
00336 };
00337
00338 #pragma warning(pop)
00339
00340
00342 PolyLibExport ClassDesc* GetPolyObjDescriptor();
00343
00344
00345
00346
00347
00356 PolyLibExport void RegisterEditPolyObjDesc(ClassDesc* desc);
00358 PolyLibExport ClassDesc* GetEditPolyObjDesc();
00359
00360
00361
00364 PolyLibExport PolyObject *CreateEditablePolyObject();
00365
00366
00367 PolyLibExport void ConvertPolyToPatch (MNMesh & from, PatchMesh & to, DWORD flags=0);
00368 PolyLibExport void ConvertPatchToPoly (PatchMesh & from, MNMesh & to, DWORD flags=0);
00369