diff --git a/src/Application/States/TextureMappingState.cpp b/src/Application/States/TextureMappingState.cpp index db47df7..f9fd4ff 100644 --- a/src/Application/States/TextureMappingState.cpp +++ b/src/Application/States/TextureMappingState.cpp @@ -20,43 +20,28 @@ TextureMappingState::TextureMappingState(){ } void TextureMappingState::draw(Application * app){ - if(_drawMode == 0){ - // Texture on the back - ofPushMatrix(); - ofTranslate(_canvasTranslate.x, _canvasTranslate.y); - app->getGui()->draw(); - - // Semi-transparent surfaces on the front + ofPushMatrix(); + ofTranslate(_canvasTranslate.x, _canvasTranslate.y); + + if(_drawMode == 0){ // Semi-transparent surfaces on front + drawTexture(app); ofPushStyle(); ofSetColor(255, 255, 255, 150); app->getSurfaceManager()->draw(); ofPopStyle(); - ofPopMatrix(); - }else if(_drawMode == 1){ - // Testure on the background - ofPushMatrix(); - ofTranslate(_canvasTranslate.x, _canvasTranslate.y); - app->getGui()->draw(); - - // Opaque surfaces on the front + }else if(_drawMode == 1){ // Opaque surfaces on front + drawTexture(app); ofPushStyle(); ofSetColor(255, 255, 255, 255); app->getSurfaceManager()->draw(); ofPopStyle(); - ofPopMatrix(); - }else if(_drawMode == 2){ - // Texture only - ofPushMatrix(); + }else if(_drawMode == 2){ // Draw texture only ofTranslate(_canvasTranslate.x, _canvasTranslate.y); - app->getGui()->draw(); - ofPopMatrix(); + drawTexture(app); }else{ _drawMode = 0; } - ofPushMatrix(); - ofTranslate(_canvasTranslate.x, _canvasTranslate.y); - if(_drawMode != 2){ Gui::instance()->getSurfaceHighlightWidget().setSurfaceManager(app->getSurfaceManager()); Gui::instance()->getSurfaceHighlightWidget().draw(); @@ -65,6 +50,9 @@ void TextureMappingState::draw(Application * app){ Gui::instance()->getTextureHighlightWidget().setSurfaceManager(app->getSurfaceManager()); Gui::instance()->getTextureHighlightWidget().draw(); + // TODO: Replace with a transform widget. + app->getGui()->getTextureEditor()->draw(); + ofPopMatrix(); } @@ -177,6 +165,20 @@ void TextureMappingState::onMouseDragged(Application * app, ofMouseEventArgs & a } } +void TextureMappingState::drawTexture(Application * app){ + if(app->getSurfaceManager()->getSelectedSurface() != 0){ + bool normalizedTexCoords = ofGetUsingNormalizedTexCoords(); + ofEnableNormalizedTexCoords(); + + ofSetColor(255, 255, 255, 255); + app->getSurfaceManager()->getSelectedSurface()->drawTexture(ofVec2f(0, 0)); + + if(!normalizedTexCoords){ + ofDisableNormalizedTexCoords(); + } + } +} + ofPoint TextureMappingState::getTranslation(){ return _canvasTranslate; } diff --git a/src/Application/States/TextureMappingState.h b/src/Application/States/TextureMappingState.h index 5f2348f..a8e70eb 100644 --- a/src/Application/States/TextureMappingState.h +++ b/src/Application/States/TextureMappingState.h @@ -27,6 +27,7 @@ class TextureMappingState : public ApplicationBaseState { void onMousePressed(Application * app, ofMouseEventArgs & args); void onMouseReleased(Application * app, ofMouseEventArgs & args); void onMouseDragged(Application * app, ofMouseEventArgs & args); + void drawTexture(Application * app); void onGuiEvent(Application * app, GuiEvent & e){} diff --git a/src/Surfaces/SurfaceManagerGui.cpp b/src/Surfaces/SurfaceManagerGui.cpp index ec0fea9..7da8215 100644 --- a/src/Surfaces/SurfaceManagerGui.cpp +++ b/src/Surfaces/SurfaceManagerGui.cpp @@ -43,6 +43,7 @@ void SurfaceManagerGui::draw(){ if(guiMode == GuiMode::TEXTURE_MAPPING){ // draw the texture of the selected surface + /* if(surfaceManager->getSelectedSurface() != 0){ bool normalizedTexCoords = ofGetUsingNormalizedTexCoords(); ofEnableNormalizedTexCoords(); @@ -55,9 +56,10 @@ void SurfaceManagerGui::draw(){ ofDisableNormalizedTexCoords(); } } + */ // draw texture editing GUI on top - textureEditor.draw(); + //textureEditor.draw(); }else if(guiMode == GuiMode::PROJECTION_MAPPING){ projectionEditor.draw(); }else if(guiMode == GuiMode::SOURCE_SELECTION){