Browse Source

Add texture editing joints depending on surface type

master
Krisjanis Rijnieks 9 years ago
parent
commit
7bbeb572ea
  1. 30
      src/UserInterface/TextureEditor.cpp
  2. 2
      src/UserInterface/TextureEditor.h

30
src/UserInterface/TextureEditor.cpp

@ -154,10 +154,36 @@ void TextureEditor::createJoints(){
vector <ofVec2f> & texCoords = surface->getTexCoords();
ofVec2f textureSize = ofVec2f(surface->getSource()->getTexture()->getWidth(),
surface->getSource()->getTexture()->getHeight());
// Select joints depending on the surface type
vector <ofVec2f> 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;
}
}

2
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 {

Loading…
Cancel
Save