00001 #ifndef __FTPoint__ 00002 #define __FTPoint__ 00003 00004 #include <ft2build.h> 00005 #include FT_FREETYPE_H 00006 #include FT_GLYPH_H 00007 00008 #include "FTGL.h" 00009 00010 /** 00011 * FTPoint class is a basic 3 dimensional point or vector. 00012 */ 00013 class FTGL_EXPORT FTPoint 00014 { 00015 public: 00016 /** 00017 * Default constructor. Point is set to zero. 00018 */ 00019 FTPoint() 00020 { 00021 values[0] = 0; 00022 values[1] = 0; 00023 values[2] = 0; 00024 } 00025 00026 /** 00027 * Constructor. 00028 * 00029 * @param x First component 00030 * @param y Second component 00031 * @param z Third component 00032 */ 00033 FTPoint( const FTGL_DOUBLE x, const FTGL_DOUBLE y, const FTGL_DOUBLE z) 00034 { 00035 values[0] = x; 00036 values[1] = y; 00037 values[2] = z; 00038 } 00039 00040 /** 00041 * Constructor. This converts an FT_Vector to an FT_Point 00042 * 00043 * @param ft_vector A freetype vector 00044 */ 00045 FTPoint( const FT_Vector& ft_vector) 00046 { 00047 values[0] = ft_vector.x; 00048 values[1] = ft_vector.y; 00049 values[2] = 0; 00050 } 00051 00052 /** 00053 * Operator += In Place Addition. 00054 * 00055 * @param point 00056 * @return this plus point. 00057 */ 00058 FTPoint& operator += ( const FTPoint& point) 00059 { 00060 values[0] += point.values[0]; 00061 values[1] += point.values[1]; 00062 values[2] += point.values[2]; 00063 00064 return *this; 00065 } 00066 00067 /** 00068 * Operator + 00069 * 00070 * @param point 00071 * @return this plus point. 00072 */ 00073 FTPoint operator + ( const FTPoint& point) 00074 { 00075 FTPoint temp; 00076 temp.values[0] = values[0] + point.values[0]; 00077 temp.values[1] = values[1] + point.values[1]; 00078 temp.values[2] = values[2] + point.values[2]; 00079 00080 return temp; 00081 } 00082 00083 00084 /** 00085 * Operator * 00086 * 00087 * @param multiplier 00088 * @return <code>this</code> multiplied by <code>multiplier</code>. 00089 */ 00090 FTPoint operator * ( double multiplier) 00091 { 00092 FTPoint temp; 00093 temp.values[0] = values[0] * multiplier; 00094 temp.values[1] = values[1] * multiplier; 00095 temp.values[2] = values[2] * multiplier; 00096 00097 return temp; 00098 } 00099 00100 00101 /** 00102 * Operator * 00103 * 00104 * @param point 00105 * @param multiplier 00106 * @return <code>multiplier</code> multiplied by <code>point</code>. 00107 */ 00108 friend FTPoint operator*( double multiplier, FTPoint& point); 00109 00110 00111 /** 00112 * Operator == Tests for eqaulity 00113 * 00114 * @param a 00115 * @param b 00116 * @return true if a & b are equal 00117 */ 00118 friend bool operator == ( const FTPoint &a, const FTPoint &b); 00119 00120 /** 00121 * Operator != Tests for non equality 00122 * 00123 * @param a 00124 * @param b 00125 * @return true if a & b are not equal 00126 */ 00127 friend bool operator != ( const FTPoint &a, const FTPoint &b); 00128 00129 00130 /** 00131 * Cast to FTGL_DOUBLE* 00132 */ 00133 operator const FTGL_DOUBLE*() const 00134 { 00135 return values; 00136 } 00137 00138 00139 /** 00140 * Setters 00141 */ 00142 void X( FTGL_DOUBLE x) { values[0] = x;}; 00143 void Y( FTGL_DOUBLE y) { values[1] = y;}; 00144 void Z( FTGL_DOUBLE z) { values[2] = z;}; 00145 00146 00147 /** 00148 * Getters 00149 */ 00150 FTGL_DOUBLE X() const { return values[0];}; 00151 FTGL_DOUBLE Y() const { return values[1];}; 00152 FTGL_DOUBLE Z() const { return values[2];}; 00153 00154 private: 00155 /** 00156 * The point data 00157 */ 00158 FTGL_DOUBLE values[3]; 00159 }; 00160 00161 #endif // __FTPoint__ 00162