Point.h

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                 // achtung
00049                 // position remains constant
00050                 // perturbation is manipulated
00051                 if(_IsSelected)
00052                         // I am moving with the selection
00053                         // my position relatively to the selection remains constant
00054                         // my perturbation in the world is changing
00055                 {
00056                         glColor3f(_Color[0], _Color[1], _Color[2]);
00057                         // Local -> Global
00058                         //_ThingGlobalFrame.setPosition(MF->inverseCoordinatesOf(_ThingLocalFrame.position()));
00059                         _Perturbation = MF->inverseCoordinatesOf(_ThingLocalFrame.position())-_ThingGlobalFrame.position();
00060                 }
00061                 else 
00062                         // I am not moving with the selection
00063                         // my position relatively to the selection is changing
00064                         // my position in the world remains constant
00065                         // my perturbation is expressed in the world coord system
00066                 {
00067                         glColor3f(_Color[1], _Color[2], _Color[0]);
00068                         // Global -> Local
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); // the position sphere
00077                 glTranslatef(_Perturbation.x,_Perturbation.y,_Perturbation.z);
00078                 glutSolidSphere(0.004,3,2); // the perturbation sphere
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                 // move global coords, update local
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

Generated on Thu Sep 28 09:38:08 2006 by  doxygen 1.4.7