Browse Source

Improve texture mapping mode code

master
Krisjanis Rijnieks 9 years ago
parent
commit
0f0aa49e37
  1. 44
      src/Application/States/TextureMappingState.cpp
  2. 1
      src/Application/States/TextureMappingState.h
  3. 4
      src/Surfaces/SurfaceManagerGui.cpp

44
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
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;
}

1
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){}

4
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){

Loading…
Cancel
Save