Browse Source

Implement `setTexCoord` and `setTexCoords` in `GridWarpSurface`

master
Krisjanis Rijnieks 9 years ago
parent
commit
855b56cb8f
  1. 18
      src/Surfaces/GridWarpSurface.cpp
  2. 2
      src/Surfaces/GridWarpSurface.h

18
src/Surfaces/GridWarpSurface.cpp

@ -125,6 +125,24 @@ void GridWarpSurface::setVertices(vector<ofVec2f> v){
}
}
void GridWarpSurface::setTexCoord(int index, ofVec2f t){
if(index >= mesh.getVertices().size()){
ofLog() << "Texture coordinate with this index does not exist: " << index << endl;
return;
}
mesh.setTexCoord(index, t);
}
void GridWarpSurface::setTexCoords(vector<ofVec2f> t){
if(t.size() != mesh.getVertices().size()){
throw runtime_error("Wrong number of texture coordinates");
}
for(int i = 0; i < 3; ++i){
mesh.setTexCoord(i, t[i]);
}
}
vector <ofVec3f> & GridWarpSurface::getVertices(){
return mesh.getVertices();
}

2
src/Surfaces/GridWarpSurface.h

@ -24,6 +24,8 @@ class GridWarpSurface : public BaseSurface {
void setVertex(int index, ofVec2f p);
void setVertices(vector<ofVec2f> v);
void setTexCoord(int index, ofVec2f t);
void setTexCoords(vector<ofVec2f> t);
vector <ofVec3f> & getVertices();
vector <ofVec2f> & getTexCoords();

Loading…
Cancel
Save