osnaphit.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:        osnaphit.h
00012 // DESCRIPTION: Defines the classes which are passed from the osnaps 
00013 //              to the manager.
00014 // AUTHOR:      John Hutchinson
00015 // HISTORY:     December 9, 1996
00016 //**************************************************************************/
00017 #pragma once
00018 #include "coreexp.h"
00019 #include "maxheap.h"
00020 #include "baseinterface.h"
00021 #include "point3.h"
00022 #include "ipoint3.h"
00023 #include "box2.h"
00024 #include "box3.h"
00025 
00026 // forward declarations
00027 class Osnap;
00028 class HitMesh;
00029 class OsnapMarker;
00030 class ViewExp;
00031 class INode;
00032 
00044 class OsnapHit : public BaseInterfaceServer
00045 {
00046     friend class OsnapManager;
00047     friend class Osnap;
00048     friend class TypedHit;
00049 public:
00061     CoreExport OsnapHit(Point3 p3, Osnap* s, int sub, HitMesh *m);
00062     CoreExport OsnapHit(Point3 pt);
00068     CoreExport OsnapHit(const OsnapHit& h);
00073     CoreExport virtual OsnapHit& operator=(const OsnapHit& h);
00076     CoreExport virtual ~OsnapHit();
00080     CoreExport virtual OsnapHit* clone();
00081 
00089     void setscreendata(IPoint3 screen3, int len);
00090 
00092     // Display Methods
00094 
00109     CoreExport virtual boolean display(ViewExp *vpt, TimeValue t, Point3 color,  \
00110         int markersize, boolean markers = TRUE, boolean hilite = TRUE);
00112     CoreExport void erase(ViewExp *vpt, TimeValue t) const; // the hit can erase itself
00124     CoreExport void GetViewportRect(TimeValue t, ViewExp* vpt, Rect* rect, int marksize) const;
00125 
00127     // Accessor Methods
00129 
00130     CoreExport Point3 GetHitpoint(){return hitpoint;};
00132     CoreExport Point3 GetWorldHitpoint(){return worldpoint;};
00135     CoreExport IPoint3 GetHitscreen(){return m_hitscreen;};
00137     CoreExport int GetSubsnap(){return subsnap;}
00138     CoreExport POINT GetCursor(){return m_cursor;}
00140     INode* GetNode(){return node;}
00145     void Dump()const;
00146 
00148     // Operator Methods
00150     //define comparators so we can sort a list of these
00158     CoreExport BOOL operator<(OsnapHit& hit);
00166     CoreExport BOOL operator>(OsnapHit& hit);
00167 
00168 public:
00170     void Update(TimeValue t);
00180     CoreExport Point3 ReEvaluate(TimeValue t);
00181     virtual bool IsWorldSpaceHit(){return false;}
00182 
00183 
00184 private: //data
00185     Point3 hitpoint; // the hit location in object space
00186     Point3 worldpoint; // the hit location in world space
00187     IPoint3 m_hitscreen; // the hit location in screen space
00188     POINT m_cursor;//the position of the cursor when this guy was recorded
00189     int m_len; //The distace from the cursor
00190     int m_z_depth; //The depth in z space
00191     BOOL m_complete; //indicates whether the screendata has been set
00192     Osnap*  snap; //the snap which made this hit
00193     int subsnap; //the subsnap index that made this hit
00194     OsnapMarker *m_pmarker; //a pointer to this snaps marker
00195 
00196     INode* node;// the node which got hit
00197     HitMesh *hitmesh;//a mesh used to hilite the topolgy we hit
00198 
00199     ViewExp *m_vpt;//the viewport which was active
00200 
00201     BOOL m_invisible;//this guy won't display itself
00202 };
00203 
00204 //a class to hold a list of object space points for highlighting the geometry
00219 class HitMesh: public MaxHeapOperators 
00220 {
00221 private:
00222     int m_numverts;
00223     Point3 *m_pverts;
00224     static long m_cref;
00225 public:
00228     CoreExport HitMesh();
00230     CoreExport ~HitMesh();
00236     CoreExport HitMesh(const HitMesh& h);
00244     CoreExport HitMesh(int n);
00249     Point3 operator[](int i){return m_pverts[i];}
00251     int getNumVerts(){return m_numverts;}
00257     CoreExport void setNumVerts(int n);     
00281     void setVert(int i, const Point3 &xyz){ m_pverts[i] = xyz; }    
00283     Point3& getVert(int i){return m_pverts[i];}
00287     Point3* getVertPtr(){return m_pverts;}
00288 };
00289 
00290 
00291 class TypedHit: public OsnapHit
00292 {
00293 public:
00294     TypedHit(Point3 pt);
00295     virtual boolean display(ViewExp *vpt, TimeValue t, Point3 color,  \
00296         int markersize, boolean markers = TRUE, boolean hilite = TRUE);
00297     virtual bool IsWorldSpaceHit(){return true;}
00298 };