Browse Source

Add moveSelectedSurface by method to projection editor

master
Krisjanis Rijnieks 11 years ago
parent
commit
e561579685
  1. 11
      src/ofxProjectionEditor.cpp
  2. 1
      src/ofxProjectionEditor.h
  3. 6
      src/ofxSurfaceManagerGui.cpp

11
src/ofxProjectionEditor.cpp

@ -59,6 +59,17 @@ void ofxProjectionEditor::updateJoints()
}
}
void ofxProjectionEditor::moveSelectedSurface(ofVec2f by)
{
if ( surfaceManager == NULL ) return;
if ( surfaceManager->getSelectedSurface() == NULL ) return;
vector<ofVec3f>& vertices = surfaceManager->getSelectedSurface()->getVertices();
for (int i=0; i<vertices.size(); i++) {
vertices[i] += by;
}
updateJoints();
}
bool ofxProjectionEditor::hitTestJoints(ofVec2f pos)
{
for ( int i=0; i<joints.size(); i++ ) {

1
src/ofxProjectionEditor.h

@ -15,6 +15,7 @@ public:
void clearJoints();
void createJoints();
void updateJoints();
void moveSelectedSurface(ofVec2f by);
bool hitTestJoints(ofVec2f pos);
private:

6
src/ofxSurfaceManagerGui.cpp

@ -114,11 +114,7 @@ void ofxSurfaceManagerGui::mouseDragged(ofMouseEventArgs &args)
ofVec2f mousePosition = ofVec2f(args.x, args.y);
ofVec2f distance = mousePosition - clickPosition;
// add this distance to all vertices in surface
vector<ofVec3f>& vertices = surfaceManager->getSelectedSurface()->getVertices();
for ( int i=0; i<vertices.size(); i++ ) {
vertices[i] += distance;
}
projectionEditor.updateJoints();
projectionEditor.moveSelectedSurface(distance);
clickPosition = mousePosition;
}
}

Loading…
Cancel
Save