Browse Source

Add setVertex method to striangle surface to be able to move its corners

master
Krisjanis Rijnieks 11 years ago
parent
commit
0427680c29
  1. 5
      example/src/ofApp.cpp
  2. 1
      src/ofxBaseSurface.h
  3. 10
      src/ofxTriangleSurface.cpp
  4. 1
      src/ofxTriangleSurface.h

5
example/src/ofApp.cpp

@ -12,6 +12,11 @@ void ofApp::setup()
void ofApp::update()
{
ofBackground(0);
ofVec2f p;
p.x = ofRandomWidth();
p.y = ofRandomHeight();
triangleSurface.setVertex(0, p);
}
void ofApp::draw()

1
src/ofxBaseSurface.h

@ -9,6 +9,7 @@ public:
ofxBaseSurface();
virtual void setup(){};
virtual void draw(){};
virtual void setVertex(int index, ofVec2f p){};
protected:
ofMesh mesh;

10
src/ofxTriangleSurface.cpp

@ -50,4 +50,14 @@ void ofxTriangleSurface::draw()
texture->bind();
mesh.draw();
texture->unbind();
}
void ofxTriangleSurface::setVertex(int index, ofVec2f p)
{
if ( index > 2 ) {
ofLog() << "Vertex with this index does not exist: " << index << endl;
return;
}
mesh.setVertex(index, p);
}

1
src/ofxTriangleSurface.h

@ -13,6 +13,7 @@ public:
void setup();
void setup( ofVec2f p1, ofVec2f p2, ofVec2f p3, ofVec2f t1, ofVec2f t2, ofVec2f t3, ofTexture* texturePtr );
void draw();
void setVertex( int index, ofVec2f p );
};
#endif
Loading…
Cancel
Save