Go to the documentation of this file.00001 #ifndef _OF_TYPES
00002 #define _OF_TYPES
00003
00004 #include "ofConstants.h"
00005
00006
00007
00008
00009 class ofPoint {
00010 public:
00011 virtual ~ofPoint(){}
00012
00013 ofPoint( float _x=0.0f, float _y=0.0f, float _z=0.0f ) {
00014 x = _x;
00015 y = _y;
00016 z = _z;
00017 }
00018
00019 ofPoint( const ofPoint & pnt){
00020 x = pnt.x;
00021 y = pnt.y;
00022 z = pnt.z;
00023 }
00024
00025 void set(float _x, float _y, float _z = 0){
00026 x = _x;
00027 y = _y;
00028 z = _z;
00029 }
00030
00031
00032
00033
00034
00035 ofPoint operator-() const {
00036 return ofPoint( -x, -y, -z );
00037 }
00038
00039
00040 bool operator==( const ofPoint& pnt ) {
00041 return (x == pnt.x) && (y == pnt.y) && (z == pnt.z);
00042 }
00043
00044
00045 bool operator!=( const ofPoint& pnt ) {
00046 return (x != pnt.x) || (y != pnt.y) || (z != pnt.z);
00047 }
00048
00049
00050 ofPoint & operator=( const ofPoint& pnt ){
00051 x = pnt.x;
00052 y = pnt.y;
00053 z = pnt.z;
00054 return *this;
00055 }
00056
00057 ofPoint & operator=( const float& val ){
00058 x = val;
00059 y = val;
00060 z = val;
00061 return *this;
00062 }
00063
00064
00065 ofPoint operator+( const ofPoint& pnt ) const {
00066 return ofPoint( x+pnt.x, y+pnt.y, z+pnt.z );
00067 }
00068
00069 ofPoint operator+( const float& val ) const {
00070 return ofPoint( x+val, y+val, z+val );
00071 }
00072
00073 ofPoint & operator+=( const ofPoint& pnt ) {
00074 x+=pnt.x;
00075 y+=pnt.y;
00076 z+=pnt.z;
00077 return *this;
00078 }
00079
00080 ofPoint & operator+=( const float & val ) {
00081 x+=val;
00082 y+=val;
00083 z+=val;
00084 return *this;
00085 }
00086
00087
00088 ofPoint operator-(const ofPoint& pnt) const {
00089 return ofPoint( x-pnt.x, y-pnt.y, z-pnt.z );
00090 }
00091
00092 ofPoint operator-(const float& val) const {
00093 return ofPoint( x-val, y-val, z-val);
00094 }
00095
00096 ofPoint & operator-=( const ofPoint& pnt ) {
00097 x -= pnt.x;
00098 y -= pnt.y;
00099 z -= pnt.z;
00100 return *this;
00101 }
00102
00103 ofPoint & operator-=( const float & val ) {
00104 x -= val;
00105 y -= val;
00106 z -= val;
00107 return *this;
00108 }
00109
00110
00111 ofPoint operator*( const ofPoint& pnt ) const {
00112 return ofPoint( x*pnt.x, y*pnt.y, z*pnt.z );
00113 }
00114
00115 ofPoint operator*(const float& val) const {
00116 return ofPoint( x*val, y*val, z*val);
00117 }
00118
00119 ofPoint & operator*=( const ofPoint& pnt ) {
00120 x*=pnt.x;
00121 y*=pnt.y;
00122 z*=pnt.z;
00123 return *this;
00124 }
00125
00126 ofPoint & operator*=( const float & val ) {
00127 x*=val;
00128 y*=val;
00129 z*=val;
00130 return *this;
00131 }
00132
00133
00134
00135 ofPoint operator/( const ofPoint& pnt ) const {
00136 return ofPoint( pnt.x!=0 ? x/pnt.x : x , pnt.y!=0 ? y/pnt.y : y, pnt.z!=0 ? z/pnt.z : z );
00137 }
00138
00139 ofPoint operator/( const float &val ) const {
00140 if( val != 0){
00141 return ofPoint( x/val, y/val, z/val );
00142 }
00143 return ofPoint(x, y, z );
00144 }
00145
00146 ofPoint& operator/=( const ofPoint& pnt ) {
00147 pnt.x!=0 ? x/=pnt.x : x;
00148 pnt.y!=0 ? y/=pnt.y : y;
00149 pnt.z!=0 ? z/=pnt.z : z;
00150
00151 return *this;
00152 }
00153
00154 ofPoint& operator/=( const float &val ) {
00155 if( val != 0 ){
00156 x /= val;
00157 y /= val;
00158 z /= val;
00159 }
00160
00161 return *this;
00162 }
00163
00164
00165
00166 union {
00167 struct {
00168 float x;
00169 float y;
00170 float z;
00171 };
00172 float v[3];
00173 };
00174
00175 };
00176
00177
00178
00179
00180
00181 class ofRectangle {
00182 public:
00183 ofRectangle(){ x = y = width = height = 0; };
00184 ofRectangle(float _x, float _y, float _w, float _h){
00185 x = _x;
00186 y = _y;
00187 width = _w;
00188 height = _h;
00189 }
00190 virtual ~ofRectangle(){}
00191
00192 float x;
00193 float y;
00194 float width;
00195 float height;
00196
00197 };
00198
00199
00200
00201
00202
00203
00204
00205 class ofColor{
00206 public:
00207 ofColor(){
00208 r = 255;
00209 g = 255;
00210 b = 255;
00211 a = 255;
00212 }
00213 virtual ~ofColor(){}
00214 float r, g, b, a;
00215 };
00216
00217
00218
00219
00220
00221 class ofStyle{
00222 public:
00223 ofStyle(){
00224 bFill = true;
00225 blending = false;
00226 smoothing = false;
00227 circleResolution = 20;
00228 lineWidth = 1.0;
00229 polyMode = OF_POLY_WINDING_ODD;
00230 rectMode = OF_RECTMODE_CORNER;
00231 }
00232
00233 virtual ~ofStyle(){}
00234
00235 ofColor color;
00236 int polyMode;
00237 int rectMode;
00238 bool bFill;
00239 bool blending;
00240 bool smoothing;
00241 int circleResolution;
00242 float lineWidth;
00243 };
00244
00245
00246
00247
00248
00249
00250 class ofBaseDraws{
00251 public:
00252 virtual ~ofBaseDraws(){}
00253 virtual void draw(float x,float y)=0;
00254 virtual void draw(float x,float y,float w, float h)=0;
00255 virtual float getHeight()=0;
00256 virtual float getWidth()=0;
00257
00258 virtual void setAnchorPercent(float xPct, float yPct){};
00259 virtual void setAnchorPoint(int x, int y){};
00260 virtual void resetAnchor(){};
00261
00262 };
00263
00264
00265
00266
00267
00268 class ofBaseUpdates{
00269 public:
00270 virtual ~ofBaseUpdates(){}
00271 virtual void update()=0;
00272 };
00273
00274
00275
00276
00277
00278 class ofTexture;
00279
00280 class ofBaseHasTexture{
00281 public:
00282 virtual ~ofBaseHasTexture(){}
00283 virtual ofTexture & getTextureReference()=0;
00284 };
00285
00286
00287
00288
00289 class ofBaseHasPixels{
00290 public:
00291 virtual ~ofBaseHasPixels(){}
00292 virtual unsigned char * getPixels()=0;
00293 };
00294
00295
00296
00297
00298 class ofBaseVideo: public ofBaseDraws, public ofBaseUpdates, public ofBaseHasTexture, public ofBaseHasPixels{
00299 public:
00300 virtual ~ofBaseVideo(){}
00301 virtual unsigned char * getPixels()=0;
00302 virtual void close()=0;
00303 };
00304 #endif