Browse Source

Enable texture mapping draw mode switching with 9 and 0 keys

master
Krisjanis Rijnieks 9 years ago
parent
commit
c436eccb35
  1. 57
      src/Application/States/TextureMappingState.cpp
  2. 3
      src/Application/States/TextureMappingState.h

57
src/Application/States/TextureMappingState.cpp

@ -20,21 +20,47 @@ TextureMappingState::TextureMappingState(){
}
void TextureMappingState::draw(Application * app){
if(_drawMode == 0){
// Texture on the back
ofPushMatrix();
ofTranslate(_canvasTranslate.x, _canvasTranslate.y);
app->getGui()->draw();
ofPopMatrix();
// Semi-transparent surfaces on the front
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
ofPushStyle();
ofSetColor(255, 255, 255, 255);
app->getSurfaceManager()->draw();
ofPopStyle();
ofPopMatrix();
}else if(_drawMode == 2){
// Texture only
ofPushMatrix();
ofTranslate(_canvasTranslate.x, _canvasTranslate.y);
app->getGui()->draw();
ofPopMatrix();
}else{
_drawMode = 0;
}
ofPushMatrix();
ofTranslate(_canvasTranslate.x, _canvasTranslate.y);
if(_drawMode != 2){
Gui::instance()->getSurfaceHighlightWidget().setSurfaceManager(app->getSurfaceManager());
Gui::instance()->getSurfaceHighlightWidget().draw();
}
Gui::instance()->getTextureHighlightWidget().setSurfaceManager(app->getSurfaceManager());
Gui::instance()->getTextureHighlightWidget().draw();
@ -78,6 +104,15 @@ void TextureMappingState::onKeyPressed(Application * app, ofKeyEventArgs & args)
app->getCmdManager()->exec(new SelNextSurfaceCmd(app->getSurfaceManager()));
}
break;
case '0': // Next draw mode
app->getCmdManager()->exec(new SetTexMapDrawModeCmd( this, getNextDrawMode() ));
break;
case '9': // Prew draw mode
app->getCmdManager()->exec(new SetTexMapDrawModeCmd( this, getPrevDrawMode() ));
break;
}
}
@ -159,5 +194,25 @@ int TextureMappingState::getDrawMode(){
return _drawMode;
}
int TextureMappingState::getNextDrawMode(){
int nextDrawMode = _drawMode + 1;
if(nextDrawMode > 2){
nextDrawMode = 0;
}
return nextDrawMode;
}
int TextureMappingState::getPrevDrawMode(){
int prevDrawMode = _drawMode - 1;
if(prevDrawMode < 0){
prevDrawMode = 2;
}
return prevDrawMode;
}
} // namespace piMapper
} // namespace ofx

3
src/Application/States/TextureMappingState.h

@ -11,6 +11,7 @@
#include "SelNextSurfaceCmd.h"
#include "ToggleAnimatedSourceCmd.h"
#include "TranslateCanvasCmd.h"
#include "SetTexMapDrawModeCmd.h"
#include "Gui.h"
namespace ofx {
@ -34,6 +35,8 @@ class TextureMappingState : public ApplicationBaseState {
void setDrawMode(int m);
int getDrawMode();
int getNextDrawMode();
int getPrevDrawMode();
private:
static TextureMappingState * _instance;

Loading…
Cancel
Save