diff --git a/src/UserInterface/TextureEditor.cpp b/src/UserInterface/TextureEditor.cpp index 9b7c919..9bb7bfc 100644 --- a/src/UserInterface/TextureEditor.cpp +++ b/src/UserInterface/TextureEditor.cpp @@ -154,10 +154,36 @@ void TextureEditor::createJoints(){ vector & texCoords = surface->getTexCoords(); ofVec2f textureSize = ofVec2f(surface->getSource()->getTexture()->getWidth(), surface->getSource()->getTexture()->getHeight()); + + // Select joints depending on the surface type + vector tc; + + if(surface->getType() == SurfaceType::TRIANGLE_SURFACE){ + tc = texCoords; + }else if(surface->getType() == SurfaceType::QUAD_SURFACE){ + tc = texCoords; + }else if(surface->getType() == SurfaceType::GRID_WARP_SURFACE){ + GridWarpSurface * s = (GridWarpSurface *)surface; + + int rows = s->getGridRows(); + int cols = s->getGridCols(); + int vertsPerRow = cols + 1; + int vertsPerCol = rows + 1; + + int a = 0; + int b = cols; + int c = (rows * vertsPerCol) + (vertsPerRow - 1); + int d = (rows * vertsPerCol); + + tc.push_back(texCoords[a]); + tc.push_back(texCoords[b]); + tc.push_back(texCoords[c]); + tc.push_back(texCoords[d]); + } - for(int i = 0; i < texCoords.size(); i++){ + for(int i = 0; i < tc.size(); i++){ joints.push_back(new CircleJoint()); - joints.back()->position = texCoords[i] * textureSize; + joints.back()->position = tc[i] * textureSize; } } diff --git a/src/UserInterface/TextureEditor.h b/src/UserInterface/TextureEditor.h index 6fc3098..2220b55 100644 --- a/src/UserInterface/TextureEditor.h +++ b/src/UserInterface/TextureEditor.h @@ -3,7 +3,9 @@ #include "ofEvents.h" #include "BaseSurface.h" +#include "GridWarpSurface.h" #include "CircleJoint.h" +#include "SurfaceType.h" namespace ofx { namespace piMapper {