source: golgotha/src/maxtool/sdk_inc/nurbsobj.h @ 80

Last change on this file since 80 was 80, checked in by Sam Hocevar, 12 years ago
  • Adding the Golgotha source code. Not sure what's going to be interesting in there, but since it's all public domain, there's certainly stuff to pick up.
  • Property svn:keywords set to Id
File size: 5.9 KB
Line 
1/**********************************************************************
2 *<
3        FILE: nurbsobj.h
4
5        DESCRIPTION:  Defines NURBS Mesh Object
6
7        CREATED BY: Steve Anderson, based on nurbsobj by Tom Hudson
8
9        HISTORY: created January 4 1996.
10
11 *>     Copyright (c) 1996, All Rights Reserved.
12 **********************************************************************/
13
14#ifndef __NURBSOBJ__
15
16#define __NURBSOBJ__
17
18#include "meshlib.h"
19#include "nurbslib.h"
20#include "snap.h"
21
22#define NURBSOBJ_CLASS_ID       0x4135
23
24extern CoreExport Class_ID nurbsObjectClassID;
25
26// For welding intersections of face & edge tesselations:
27#define NMESHWELD 1e-04f
28
29typedef Tab<float> FloatTab;
30
31// MeshingFaces, MeshingEdges, and MeshingVerts are for my own convenience
32// in converting NurbsMeshes to Meshes.  Don't worry about them if you don't
33// care about how the meshing occurs.
34
35class NurbsMeshingFace {
36public:
37        int medg[4];    // Four boundary lines: u=0, v=0, u=1, v=1.
38        int gnum[2];    // g[0] represents columns, g[1] rows.
39        int *gedx[2];   // Indices of intersections of boundary with grid lines
40        int vstart;             // Records start vertex of face in final mesh.
41
42        NurbsMeshingFace ();
43        ~NurbsMeshingFace ();
44        void Setup (NurbsFace & fac);
45        void AddGridIntersection (int g, int level, int pnt, float endval);
46        int CountVerts ();
47};
48
49class NurbsMeshingEdge {
50public:
51        int start, end;         // Meshing verts
52        int face1, face2, edge1, edge2;
53        FloatTab tvals;         // One t-value per required vertex, including first & last
54        int vstart;                     // Start of edge-vertices in final mesh.
55        BOOL degenerate;
56
57        NurbsMeshingEdge();
58        ~NurbsMeshingEdge() {}
59};
60
61typedef IntTab NurbsMeshingVert;        // (List of incident meshingEdges.)
62
63// NurbsObject: the nexus of Nurbsiness.
64// about what you'd expect.  All rendering, etc resorts to meshing.
65
66class NurbsObject: public GeomObject {
67                Interval geomValid;
68                Interval topoValid;
69                DWORD validBits; // for the remaining constant channels
70                void CopyValidity(NurbsObject *fromOb, ChannelMask channels);
71
72                // Meshing stuff:
73                NurbsMeshingFace *mFaces;
74                NurbsMeshingEdge *mEdges;
75                NurbsMeshingVert *mVerts;
76                int mFnum, mEnum, mVnum;
77
78                void SetupMeshingStructs ();
79                void FindMeshingEdges ();
80                void FindTVectors ();
81                int SortOutMeshingVerts ();
82                void SetEdgeVertConnection (int e, int end, int v);
83               
84        protected:
85                //  inherited virtual methods for Reference-management
86                RefResult NotifyRefChanged(Interval changeInt, RefTargetHandle hTarget, PartID& partID, RefMessage message );
87        public:
88                NurbsMesh nmesh;
89
90                int meshSteps;
91                BOOL adaptive;
92                Mesh mesh;
93                BOOL meshValid;
94                BOOL showMesh;
95                BOOL showLattice;
96
97                CoreExport NurbsObject();
98                CoreExport ~NurbsObject();
99
100                // Inherited virtual methods:
101
102                // From BaseObject
103                CoreExport int HitTest(TimeValue t, INode* inode, int type, int crossing, int flags, IPoint2 *p, ViewExp *vpt);
104                CoreExport int Display(TimeValue t, INode* inode, ViewExp *vpt, int flags);
105                CoreExport void Snap(TimeValue t, INode* inode, SnapInfo *snap, IPoint2 *p, ViewExp *vpt);
106                CoreExport CreateMouseCallBack* GetCreateMouseCallBack();
107                CoreExport RefTargetHandle Clone(RemapDir& remap = NoRemap());
108
109                // From Object                   
110                CoreExport ObjectState Eval(TimeValue time);
111                CoreExport Interval ObjectValidity(TimeValue t);
112
113                // get and set the validity interval for the nth channel
114                CoreExport Interval ChannelValidity(TimeValue t, int nchan);
115                CoreExport void SetChannelValidity(int i, Interval v);
116                CoreExport void InvalidateChannels(ChannelMask channels);
117
118                // Deformable object procs     
119                int IsDeformable()                                              { return 1; } 
120                int NumPoints()                                                 { return nmesh.getNumVerts(); }
121                Point3 GetPoint(int i)                                  { return nmesh.getVert(i).p; }
122                void SetPoint(int i, const Point3& p)   { nmesh.setVert(i,p); }
123               
124                void PointsWereChanged()                                { return; }
125                CoreExport void GetDeformBBox(TimeValue t, Box3& box, Matrix3 *tm=NULL,BOOL useSel=FALSE );
126                CoreExport void Deform(Deformer *defProc, int useSel);
127
128                CoreExport int CanConvertToType(Class_ID obtype);
129                CoreExport Object* ConvertToType(TimeValue t, Class_ID obtype);
130                CoreExport void FreeChannels(ChannelMask chan);
131                CoreExport Object *MakeShallowCopy(ChannelMask channels);
132                CoreExport void ShallowCopy(Object* fromOb, ChannelMask channels);
133                CoreExport void NewAndCopyChannels(ChannelMask channels);
134
135                CoreExport DWORD GetSubselState();
136
137                // From GeomObject
138                CoreExport int IntersectRay(TimeValue t, Ray& r, float& at);
139                CoreExport ObjectHandle CreateTriObjRep(TimeValue t);  // for rendering, also for deformation           
140                CoreExport void GetWorldBoundBox(TimeValue t, INode *inode, ViewExp* vpt, Box3& box );
141                CoreExport void GetLocalBoundBox(TimeValue t, INode *inode, ViewExp* vpt, Box3& box );
142                CoreExport int IsInstanceDependent();   // Not view-dependent (yet)
143                CoreExport Mesh* GetRenderMesh(TimeValue t, INode *inode, View& view, BOOL& needDelete);
144
145                NurbsMesh& GetNurbsMesh() { return nmesh; }
146                Mesh& GetMesh() { PrepareMesh(); return mesh; }
147
148                // Animatable methods
149
150                void DeleteThis() { delete this; }
151                void FreeCaches() { return; }
152                Class_ID ClassID() { return Class_ID(NURBSOBJ_CLASS_ID,0); }
153                void GetClassName(TSTR& s) { s = TSTR(_T("NurbsObject")); }
154                void NotifyMe (Animatable *subAnim, int message) {}
155                int IsKeyable() { return 0;}
156                int Update(TimeValue t) { return 0; }
157                BOOL BypassTreeView() { return TRUE; }
158
159                // IO
160                CoreExport IOResult Save(ISave *isave);
161                CoreExport IOResult Load(ILoad *iload);
162
163                // NurbsObject-specific methods
164                CoreExport void PrepareMesh();
165                CoreExport void SetMeshSteps(int steps);
166                CoreExport void SetAdaptive(BOOL sw);
167                CoreExport void InvalidateMesh();
168        };
169
170CoreExport ClassDesc* GetNurbsObjDescriptor();
171
172#endif // __NURBSOBJ__
Note: See TracBrowser for help on using the repository browser.