From 0ccdbe6839cbcdb2c5079a2a7b2e68579ea896f5 Mon Sep 17 00:00:00 2001 From: Krisjanis Rijnieks Date: Sat, 30 Jan 2016 19:28:27 +0100 Subject: [PATCH] Add `setGrid...` methods and fix `setTexCoords` for `GridWarpSurface` --- src/Commands/AddGridRowCmd.cpp | 0 src/Surfaces/GridWarpSurface.cpp | 14 +++++++++++++- src/Surfaces/GridWarpSurface.h | 3 ++- 3 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 src/Commands/AddGridRowCmd.cpp diff --git a/src/Commands/AddGridRowCmd.cpp b/src/Commands/AddGridRowCmd.cpp new file mode 100644 index 0000000..e69de29 diff --git a/src/Surfaces/GridWarpSurface.cpp b/src/Surfaces/GridWarpSurface.cpp index de68fa3..04949d8 100644 --- a/src/Surfaces/GridWarpSurface.cpp +++ b/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 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)); } } + + } diff --git a/src/Surfaces/GridWarpSurface.h b/src/Surfaces/GridWarpSurface.h index d0dabaf..d80f2ec 100644 --- a/src/Surfaces/GridWarpSurface.h +++ b/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 & getVertices(); vector & getTexCoords(); - private: int _gridCols; int _gridRows;