Browse Source

Add `setGrid...` methods and fix `setTexCoords` for `GridWarpSurface`

master
Krisjanis Rijnieks 9 years ago
parent
commit
0ccdbe6839
  1. 0
      src/Commands/AddGridRowCmd.cpp
  2. 14
      src/Surfaces/GridWarpSurface.cpp
  3. 3
      src/Surfaces/GridWarpSurface.h

0
src/Commands/AddGridRowCmd.cpp

14
src/Surfaces/GridWarpSurface.cpp

@ -43,6 +43,16 @@ int GridWarpSurface::getGridCols(){
return _gridCols;
}
int GridWarpSurface::setGridRows(int r){
_gridRows = r;
createGridMesh();
}
int GridWarpSurface::setGridCols(int c){
_gridCols = c;
createGridMesh();
}
bool GridWarpSurface::hitTest(ofVec2f p){
ofPolyline pl;
int vertsPerCol = _gridRows + 1;
@ -153,7 +163,7 @@ 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){
for(int i = 0; i < t.size(); ++i){
mesh.setTexCoord(i, t[i]);
}
}
@ -209,6 +219,8 @@ void GridWarpSurface::createGridMesh(){
mesh.addTexCoord(ofVec2f(xc, yc));
}
}
}

3
src/Surfaces/GridWarpSurface.h

@ -18,6 +18,8 @@ class GridWarpSurface : public BaseSurface {
int getType();
int getGridRows();
int getGridCols();
int setGridRows(int r);
int setGridCols(int c);
bool hitTest(ofVec2f p);
@ -31,7 +33,6 @@ class GridWarpSurface : public BaseSurface {
vector <ofVec3f> & getVertices();
vector <ofVec2f> & getTexCoords();
private:
int _gridCols;
int _gridRows;

Loading…
Cancel
Save