From 9bc4399b0a72f2f03ce7642852383b8bbfbfbf64 Mon Sep 17 00:00:00 2001 From: leo Date: Fri, 24 Nov 2000 23:24:09 +0000 Subject: Initial curved primitives support git-svn-id: http://svn.leocad.org/trunk@169 c7d43263-9d01-0410-8a33-9dba5d9f93d6 --- common/curve.h | 125 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100755 common/curve.h (limited to 'common/curve.h') diff --git a/common/curve.h b/common/curve.h new file mode 100755 index 0000000..874b828 --- /dev/null +++ b/common/curve.h @@ -0,0 +1,125 @@ +#ifndef _CURVE_H_ +#define _CURVE_H_ + +#include "object.h" +#include "opengl.h" +#include "array.h" + +class Curve; +class CurvePoint; +class PieceInfo; + +//#define LC_CURVE_POINT_HIDDEN 0x01 +#define LC_CURVE_POINT_SELECTED 0x02 +#define LC_CURVE_POINT_FOCUSED 0x04 +#define LC_CURVE_POINT_ARROW1_FOCUSED 0x08 +#define LC_CURVE_POINT_ARROW2_FOCUSED 0x10 +#define LC_CURVE_POINT_CONTINUOUS 0x20 + +typedef enum +{ + LC_CURVE_POINT_KEY_POSITION, + LC_CURVE_POINT_KEY_DIRECTION1, + LC_CURVE_POINT_KEY_DIRECTION2, + LC_CURVE_POINT_KEY_ANGLE, + LC_CURVE_POINT_KEY_COUNT +} LC_CURVE_POINT_KEY_TYPES; + +class CurvePoint : public Object +{ + public: + // constructors / destructor + CurvePoint (Curve *pParent); + CurvePoint (Curve *pParent, const float *pos, const float *dir); + virtual ~CurvePoint (); + + // object functions + bool FileLoad (File& file); + void FileSave (File& file) const; + void MinIntersectDist (LC_CLICKLINE* pLine); + void UpdatePosition (unsigned short nTime, bool bAnimation); + void Move (unsigned short nTime, bool bAnimation, bool bAddKey, float dx, float dy, float dz); + void Render (LC_RENDER_INFO* pInfo); + void Select (bool bSelecting, bool bFocus, bool bMultiple); + + // query functions + Curve* GetParent () const + { return m_pParent; } + const float* GetPosition () const + { return m_fPos; } + const float* GetDirection1 () const + { return m_fDir1; } + const float* GetDirection2 () const + { return m_fDir2; } + float GetAngle () const + { return m_fAngle; } + + protected: + void Initialize (); + + Curve* m_pParent; + static GLuint m_nArrowList; + static GLuint m_nSphereList; + + unsigned char m_nState; + + // temporary + float m_fPos[3]; + float m_fDir1[3]; + float m_fDir2[3]; + float m_fAngle; + + unsigned char m_nLastHit; // FIXME: create arrow objects, ugly hack for now +}; + +// ============================================================================= + +#define LC_CURVE_HIDDEN 0x01 +#define LC_CURVE_SELECTED 0x02 +#define LC_CURVE_FOCUSED 0x04 +#define LC_CURVE_LOOP 0x10 +#define LC_CURVE_FIXED_SIZE 0x20 + +// all the different types of curved objects +typedef enum +{ + LC_CURVE_TYPE_HOSE +} LC_CURVE_TYPE; + +class Curve : public Object +{ + public: + // constructors / destructor + Curve (); + Curve (PieceInfo *pInfo, const float *pos, unsigned char color); + virtual ~Curve (); + + // object functions + bool FileLoad (File& file); + void FileSave (File& file) const; + void MinIntersectDist (LC_CLICKLINE* pLine); + void UpdatePosition (unsigned short nTime, bool bAnimation); + void Move (unsigned short nTime, bool bAnimation, bool bAddKey, float dx, float dy, float dz); + void Render (LC_RENDER_INFO* pInfo); + void Select (bool bSelecting, bool bFocus, bool bMultiple); + + // implementation + void DeselectOtherPoints (CurvePoint *pSender, bool bFocusOnly); + + protected: + void Initialize (); + void TesselateHose (); + + LC_CURVE_TYPE m_nCurveType; + unsigned char m_nState; + unsigned char m_nColor; + float m_fLength; + + float m_fUp0[3]; + + GLuint m_nDisplayList; + + PtrArray m_Points; +}; + +#endif // _CURVE_H_ -- cgit v1.2.3