simpspl.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:        simpspl.h
00012 // DESCRIPTION: Defines a simple spline object class to make spline
00013 //              primitives easier to create
00014 // AUTHOR:      Tom Hudson
00015 // HISTORY:     created 3 October 1995
00016 //**************************************************************************/
00017 #pragma once
00018 
00019 #include "iparamm.h"
00020 #include "object.h"
00021 #include "GraphicsConstants.h"
00022 
00023 // Special dialog handling
00024 class SimpleSpline;
00025 
00026 class SimpleSplineDlgProc : public ParamMapUserDlgProc {
00027     private:
00028         SimpleSpline *spl;
00029     public:
00030         SimpleSplineDlgProc(SimpleSpline *s) { spl = s; }
00031         CoreExport INT_PTR DlgProc(TimeValue t,IParamMap *map,HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam);
00032         CoreExport void DeleteThis();
00033     };
00034 
00035 #pragma warning(push)
00036 #pragma warning(disable:4239)
00037 
00066 class SimpleSpline: public ShapeObject {               
00067     private:
00068     public:
00069         IParamBlock *ipblock;   // Interpolation parameter block (handled by SimpleSpline)
00070         IParamBlock *pblock;    // User's parameter block
00071 
00072         static IParamMap *ipmapParam;
00073         static int dlgSteps;
00074         static BOOL dlgOptimize;
00075         static BOOL dlgAdaptive;
00076 
00077         // Spline cache
00078         BezierShape shape;
00079         Interval ivalid;
00080 
00081         // Flag to suspend snapping -- Used during creation
00082         BOOL suspendSnap;
00083 
00084         CoreExport void UpdateShape(TimeValue t);
00085 
00086         static SimpleSpline *editOb;
00087 
00090         CoreExport SimpleSpline();
00093         CoreExport ~SimpleSpline();
00094 
00095         void ShapeInvalid() { ivalid.SetEmpty(); }
00096 
00097         //  inherited virtual methods:
00098 
00099         // From BaseObject
00100         CoreExport int HitTest(TimeValue t, INode* inode, int type, int crossing, int flags, IPoint2 *p, ViewExp *vpt);
00101         CoreExport void Snap(TimeValue t, INode* inode, SnapInfo *snap, IPoint2 *p, ViewExp *vpt);
00102         CoreExport int Display(TimeValue t, INode* inode, ViewExp *vpt, int flags);
00103         CoreExport virtual void BeginEditParams( IObjParam *ip, ULONG flags,Animatable *prev);
00125         CoreExport virtual void EndEditParams( IObjParam *ip, ULONG flags,Animatable *next);
00126         IParamArray* GetParamBlock() {return (IParamArray*)pblock;}
00127         CoreExport int GetParamBlockIndex(int id);
00128 
00129         // From Object
00130         CoreExport ObjectState Eval(TimeValue time);
00131         CoreExport Interval ObjectValidity(TimeValue t);
00132         CoreExport int CanConvertToType(Class_ID obtype);
00133         CoreExport Object* ConvertToType(TimeValue t, Class_ID obtype);
00134         CoreExport void GetCollapseTypes(Tab<Class_ID> &clist,Tab<MSTR*> &nlist);
00135 
00136         CoreExport void BuildMesh(TimeValue t, Mesh &mesh);
00137         
00138         // From ShapeObject
00139         CoreExport ObjectHandle CreateTriObjRep(TimeValue t);  // for rendering, also for deformation       
00140         CoreExport void GetWorldBoundBox(TimeValue t, INode* inode, ViewExp* vpt, Box3& box );
00141         CoreExport void GetLocalBoundBox(TimeValue t, INode* inode, ViewExp* vxt, Box3& box );
00142         CoreExport void GetDeformBBox(TimeValue t, Box3& box, Matrix3 *tm, BOOL useSel );
00143         CoreExport int NumberOfVertices(TimeValue t, int curve);
00144         CoreExport int NumberOfCurves();
00145         CoreExport BOOL CurveClosed(TimeValue t, int curve);
00146         CoreExport Point3 InterpCurve3D(TimeValue t, int curve, float param, int ptype=PARAM_SIMPLE);
00147         CoreExport Point3 TangentCurve3D(TimeValue t, int curve, float param, int ptype=PARAM_SIMPLE);
00148         CoreExport float LengthOfCurve(TimeValue t, int curve);
00149         CoreExport int NumberOfPieces(TimeValue t, int curve);
00150         CoreExport Point3 InterpPiece3D(TimeValue t, int curve, int piece, float param, int ptype=PARAM_SIMPLE);
00151         CoreExport Point3 TangentPiece3D(TimeValue t, int curve, int piece, float param, int ptype=PARAM_SIMPLE);
00152         CoreExport MtlID GetMatID(TimeValue t, int curve, int piece);
00153         BOOL CanMakeBezier() { return TRUE; }           // Return TRUE if can turn into a bezier representation
00154         CoreExport void MakeBezier(TimeValue t, BezierShape &shape);    // Create the bezier representation
00155         CoreExport ShapeHierarchy &OrganizeCurves(TimeValue t, ShapeHierarchy *hier=NULL);  // Ready for lofting, extrusion, etc.
00156         CoreExport void MakePolyShape(TimeValue t, PolyShape &shape, int steps = PSHAPE_BUILTIN_STEPS, BOOL optimize = FALSE);
00157         CoreExport int MakeCap(TimeValue t, MeshCapInfo &capInfo, int capType); // Makes a cap out of the shape
00158         CoreExport int MakeCap(TimeValue t, PatchCapInfo &capInfo);
00159 
00160         int NumRefs() { return 2 + ShapeObject::NumRefs();}
00161         CoreExport RefTargetHandle GetReference(int i);
00162 protected:
00163         CoreExport virtual void SetReference(int i, RefTargetHandle rtarg);     
00164 public:
00165         CoreExport RefResult NotifyRefChanged(Interval changeInt,RefTargetHandle hTarget, 
00166            PartID& partID, RefMessage message);
00167 
00168         CoreExport void ReadyInterpParameterBlock();
00169         void UnReadyInterpParameterBlock() { ipblock = NULL; }
00170 
00171         // When clients are cloning themselves, they should call this 
00172         // method on the clone to copy SimpleSpline's data.
00173         // NOTE: DEPRECATED! Use SimpleSplineClone(SimpleSpline *ssplSource, RemapDir& remap )
00174         CoreExport void SimpleSplineClone( SimpleSpline *ssplSource );
00175 
00176         // When clients are cloning themselves, they should call this 
00177         // method on the clone to copy SimpleSpline's data.
00178         CoreExport void SimpleSplineClone( SimpleSpline *ssplSource, RemapDir& remap );
00179 
00180         int NumSubs() { return 2 + ShapeObject::NumSubs(); }  
00181         CoreExport Animatable* SubAnim(int i);
00182         CoreExport MSTR SubAnimName(int i);     
00183 
00184         // Animatable methods
00185         CoreExport void DeleteThis();
00186         CoreExport void FreeCaches(); 
00187 
00188         // IO
00189         CoreExport IOResult Save(ISave *isave);
00190         CoreExport IOResult Load(ILoad *iload);
00191     #pragma warning(push)
00192     #pragma warning(disable:4100)
00193         LRESULT CALLBACK TrackViewWinProc( HWND hwnd,  UINT message, 
00194                 WPARAM wParam,   LPARAM lParam ){return(0);}
00195 
00201         void GetClassName(MSTR& s) {s = GetObjectName();}
00206         void InitNodeName(MSTR& s) {s = GetObjectName();}
00207 
00208         // Clients of SimpleSpline need to implement these methods:
00209     
00212         virtual Class_ID ClassID() = 0;
00220         virtual void BuildShape(TimeValue t,BezierShape& ashape) = 0;
00229         virtual RefTargetHandle Clone(RemapDir& remap) = 0;
00230         
00238         virtual CreateMouseCallBack* GetCreateMouseCallBack() = 0;
00245         virtual BOOL ValidForDisplay(TimeValue t) = 0;
00269         virtual void InvalidateUI() {}
00279         virtual ParamDimension *GetParameterDim(int pbIndex) {return defaultDim;}
00287         virtual MSTR GetParameterName(int pbIndex) {return MSTR(_M("Parameter"));}
00288         #pragma warning(pop)
00289 
00293         virtual BOOL DisplayVertTicksDuringCreation() { return TRUE; }
00294     };              
00295 #pragma warning(pop)
00296 
00297