00001 #ifndef POINTS_H
00002 #define POINTS_H
00003 #include "SelectableThing.h"
00004 #include "matrices.h"
00005 #include "Point.h"
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00018
00021 class Point : public SelectableThing
00022 {
00023 public :
00026 Vec _Perturbation;
00029 bool IsAPoint(){return true;};
00032 bool IsAPatch(){return false;};
00035 Point* GetPoint(){return this;};
00038 BaryPatch* GetPatch(){return NULL;};
00039
00046 void draw(ManipulatedFrame* MF)
00047 {
00048
00049
00050
00051 if(_IsSelected)
00052
00053
00054
00055 {
00056 glColor3f(_Color[0], _Color[1], _Color[2]);
00057
00058
00059 _Perturbation = MF->inverseCoordinatesOf(_ThingLocalFrame.position())-_ThingGlobalFrame.position();
00060 }
00061 else
00062
00063
00064
00065
00066 {
00067 glColor3f(_Color[1], _Color[2], _Color[0]);
00068
00069 _ThingLocalFrame.setPosition(MF->coordinatesOf(_ThingGlobalFrame.position()+_Perturbation));
00070 }
00071 glPushAttrib(GL_ENABLE_BIT);
00072 glDisable(GL_LIGHTING);
00073 glPushName(_ThingName);
00074 glPushMatrix();
00075 glMultMatrixd(_ThingGlobalFrame.matrix());
00076 glutSolidSphere(0.004,3,2);
00077 glTranslatef(_Perturbation.x,_Perturbation.y,_Perturbation.z);
00078 glutSolidSphere(0.004,3,2);
00079 glPopMatrix();
00080 glPopName();
00081
00082 float X0,Y0,Z0;
00083 _ThingGlobalFrame.getPosition(X0,Y0,Z0);
00084 Vec P = MF->inverseCoordinatesOf(_ThingLocalFrame.position());
00085 glBegin(GL_LINES);
00086 glVertex3f(X0,Y0,Z0);
00087 glVertex3f(P.x,P.y,P.z);
00088 glEnd();
00089 glPopAttrib();
00090 };
00092 virtual void UpdateNameTag(){_NameTag = "Point " + QString::number(_ThingName);};
00093
00095 Point(int ThingName,Vec Position,Vec Perturbation): SelectableThing(ThingName)
00096 {
00097 _Color = Vec(1.0,0.2,0.2);
00098 _ThingGlobalFrame.setPosition(Position);
00099 _Perturbation=Perturbation;
00100 }
00102 ~Point(){};
00104 void inline SnapToGrid(float GridSpace, ManipulatedFrame* MF)
00105 {
00106
00107 Vec Pos = _ThingGlobalFrame.position();
00108 _ThingGlobalFrame.setPosition(Round(Pos[0]/GridSpace)*GridSpace,Round(Pos[1]/GridSpace)*GridSpace,Round(Pos[2]/GridSpace)*GridSpace);
00109 _ThingLocalFrame.setPosition(MF->coordinatesOf(_ThingGlobalFrame.position()));
00110 };
00111 };
00112 #endif