simpshp.h

Go to the documentation of this file.
00001 //**************************************************************************/
00002 // Copyright (c) 1998-2006 Autodesk, Inc.
00003 // All rights reserved.
00004 // 
00005 // These coded instructions, statements, and computer programs contain
00006 // unpublished proprietary information written by Autodesk, Inc., and are
00007 // protected by Federal copyright law. They may not be disclosed to third
00008 // parties or copied or duplicated in any form, in whole or in part, without
00009 // the prior written consent of Autodesk, Inc.
00010 //**************************************************************************/
00011 // FILE:        simpshp.h
00012 // DESCRIPTION: Defines a simple shape object class to make
00013 //              procedural shape primitives easier to create
00014 // AUTHOR:      Tom Hudson
00015 // HISTORY:     created 30 October 1995
00016 //**************************************************************************/
00017 #pragma once
00018 
00019 #include "object.h"
00020 #include "GraphicsConstants.h"
00021 
00022 // Parameter block reference indices
00023 // IMPORTANT: Reference #0 is ShapeObject's parameter block!  (Starting with MAXr4)
00024 #define SHAPEOBJPBLOCK 0    // ShapeObject's parameter block
00025 
00026 #pragma warning(push)
00027 #pragma warning(disable:4239 4100)
00028 
00069 class SimpleShape: public ShapeObject
00070 {              
00071     public:
00072         IParamBlock* pblock;
00073 
00074         static IObjParam* ip;
00075         static HWND hGenParams;
00076         static BOOL dlgRenderable;
00077         static float dlgThickness;
00078         static int dlgSides;
00079         static float dlgAngle;
00080         static BOOL dlgGenUVs;
00081         static ISpinnerControl *thickSpin;
00082 
00083         // Shape cache
00084         PolyShape shape;
00085         Interval ivalid;
00086 
00087         // Flag to suspend snapping -- Used during creation
00088         BOOL suspendSnap;
00089 
00090         CoreExport void UpdateShape(TimeValue t);
00091 
00092         static SimpleShape* editOb;
00093 
00095         CoreExport SimpleShape();
00098         CoreExport ~SimpleShape();
00099 
00100         void ShapeInvalid() { ivalid.SetEmpty(); }
00101 
00102         //  inherited virtual methods:
00103 
00104         // From BaseObject
00105         CoreExport int HitTest(TimeValue t, INode* inode, int type, int crossing, int flags, IPoint2 *p, ViewExp *vpt);
00106         CoreExport void Snap(TimeValue t, INode* inode, SnapInfo *snap, IPoint2 *p, ViewExp *vpt);
00107         CoreExport int Display(TimeValue t, INode* inode, ViewExp *vpt, int flags);
00108         CoreExport virtual void BeginEditParams( IObjParam *ip, ULONG flags,Animatable *prev);
00109         CoreExport virtual void EndEditParams( IObjParam *ip, ULONG flags,Animatable *next);
00110         // Return an upcasted version of the parameter block.
00111         IParamArray* GetParamBlock() {return (IParamArray*)pblock;}
00112         CoreExport int GetParamBlockIndex(int id);
00113 
00114         // From Object
00115         CoreExport ObjectState Eval(TimeValue time);
00116         CoreExport Interval ObjectValidity(TimeValue t);
00117         CoreExport int CanConvertToType(Class_ID obtype);
00118         CoreExport Object* ConvertToType(TimeValue t, Class_ID obtype);
00119         CoreExport void BuildMesh(TimeValue t, Mesh &mesh);
00120                 
00121         // From ShapeObject
00122         CoreExport ObjectHandle CreateTriObjRep(TimeValue t);  // for rendering, also for deformation       
00123         CoreExport void GetWorldBoundBox(TimeValue t, INode* inode, ViewExp* vpt, Box3& box );
00124         CoreExport void GetLocalBoundBox(TimeValue t, INode* inode, ViewExp* vxt, Box3& box );
00125         CoreExport void GetDeformBBox(TimeValue t, Box3& box, Matrix3 *tm, BOOL useSel );
00126         CoreExport int NumberOfVertices(TimeValue t, int curve);
00127         CoreExport int NumberOfCurves();
00128         CoreExport BOOL CurveClosed(TimeValue t, int curve);
00129         CoreExport ShapeHierarchy &OrganizeCurves(TimeValue t, ShapeHierarchy *hier=NULL);  // Ready for lofting, extrusion, etc.
00130         CoreExport void MakePolyShape(TimeValue t, PolyShape &shape, int steps = PSHAPE_BUILTIN_STEPS, BOOL optimize = FALSE);
00131         CoreExport int MakeCap(TimeValue t, MeshCapInfo &capInfo, int capType); // Makes a cap out of the shape
00132         CoreExport int MakeCap(TimeValue t, PatchCapInfo &capInfo);
00133 
00134         int NumRefs() { return 1 + ShapeObject::NumRefs(); }
00135         CoreExport RefTargetHandle GetReference(int i);
00136 protected:
00137         CoreExport virtual void SetReference(int i, RefTargetHandle rtarg);     
00138 public:
00139         CoreExport RefResult NotifyRefChanged(Interval changeInt,RefTargetHandle hTarget, 
00140            PartID& partID, RefMessage message);
00141 
00150         CoreExport void ReadyGeneralParameters();
00162         CoreExport void SimpleShapeClone( SimpleShape *sshpSource );
00163 
00164         int NumSubs() { return 1 + ShapeObject::NumSubs(); }  
00165         CoreExport Animatable* SubAnim(int i);
00166         CoreExport MSTR SubAnimName(int i);     
00167 
00168         // Animatable methods
00169         CoreExport void DeleteThis();
00170         CoreExport void FreeCaches(); 
00171 
00172         // IO
00173         CoreExport IOResult Save(ISave *isave);
00174         CoreExport IOResult Load(ILoad *iload);
00175 
00176         CoreExport void SetGenUVs(BOOL sw);
00177         CoreExport void SetRenderable(BOOL sw);
00178         LRESULT CALLBACK TrackViewWinProc( HWND hwnd,  UINT message, 
00179                 WPARAM wParam,   LPARAM lParam ){return(0);}
00180 
00181         void GetClassName(MSTR& s) {s = GetObjectName();}
00182         void InitNodeName(MSTR& s) {s = GetObjectName();}
00183 
00184         // Clients of SimpleShape need to implement these methods:
00185     
00186         virtual Class_ID ClassID() = 0;
00194         virtual void BuildShape(TimeValue t,PolyShape& ashape) = 0;
00195         
00196         virtual RefTargetHandle Clone(RemapDir& remap) = 0;
00197         
00198         virtual CreateMouseCallBack* GetCreateMouseCallBack() = 0;
00208         virtual BOOL ValidForDisplay(TimeValue t) = 0;
00234         virtual void InvalidateUI() {}
00244         virtual ParamDimension *GetParameterDim(int pbIndex) {return defaultDim;}
00252         virtual MSTR GetParameterName(int pbIndex) {return MSTR(_M("Parameter"));}
00253 
00254         // Unlike SimpleSplines, you're probably procedural, so implementing these
00255         // is a must!
00270         virtual Point3 InterpCurve3D(TimeValue t, int curve, float param, int ptype=PARAM_SIMPLE) = 0;
00285         virtual Point3 TangentCurve3D(TimeValue t, int curve, float param, int ptype=PARAM_SIMPLE) = 0;
00292         virtual float LengthOfCurve(TimeValue t, int curve) = 0;
00293         
00294         // Here are some optional methods.
00295         // You should _really_ implement these, because they just do the bare-minimum job
00296         // (Chopping your curve up into manageable pieces makes things look better)
00305         virtual int NumberOfPieces(TimeValue t, int curve) { return 1; }
00325         virtual Point3 InterpPiece3D(TimeValue t, int curve, int piece, float param, int ptype=PARAM_SIMPLE) { return InterpCurve3D(t, curve, param, ptype); }
00345         virtual Point3 TangentPiece3D(TimeValue t, int curve, int piece, float param, int ptype=PARAM_SIMPLE) { return TangentCurve3D(t, curve, param, ptype); }
00357         CoreExport virtual MtlID GetMatID(TimeValue t, int curve, int piece);
00358     };              
00359 
00360 #pragma warning(pop)