73 changed files with 4869 additions and 4658 deletions
@ -1,17 +1,18 @@ |
|||||
#include "PresentationState.h" |
#include "PresentationState.h" |
||||
|
|
||||
namespace ofx { |
namespace ofx { |
||||
namespace piMapper { |
namespace piMapper { |
||||
|
|
||||
PresentationState * PresentationState::_instance = 0; |
PresentationState * PresentationState::_instance = 0; |
||||
|
|
||||
PresentationState * PresentationState::instance() { |
PresentationState * PresentationState::instance(){ |
||||
if (_instance == 0) { |
if(_instance == 0){ |
||||
_instance = new ofx::piMapper::PresentationState(); |
_instance = new ofx::piMapper::PresentationState(); |
||||
} |
} |
||||
return _instance; |
return _instance; |
||||
} |
} |
||||
|
|
||||
void PresentationState::draw(Application * app) {} |
void PresentationState::draw(Application * app){} |
||||
} |
|
||||
} |
} // namespace piMapper
|
||||
|
} // namespace ofx
|
@ -1,46 +1,47 @@ |
|||||
#include "ProjectionMappingState.h" |
#include "ProjectionMappingState.h" |
||||
|
|
||||
namespace ofx { |
namespace ofx { |
||||
namespace piMapper { |
namespace piMapper { |
||||
|
|
||||
ProjectionMappingState * ProjectionMappingState::_instance = 0; |
ProjectionMappingState * ProjectionMappingState::_instance = 0; |
||||
|
|
||||
ProjectionMappingState * ProjectionMappingState::instance() { |
ProjectionMappingState * ProjectionMappingState::instance(){ |
||||
if (_instance == 0) { |
if(_instance == 0){ |
||||
_instance = new ofx::piMapper::ProjectionMappingState(); |
_instance = new ofx::piMapper::ProjectionMappingState(); |
||||
} |
} |
||||
return _instance; |
return _instance; |
||||
} |
} |
||||
|
|
||||
void ProjectionMappingState::draw(Application * app) {} |
void ProjectionMappingState::draw(Application * app){} |
||||
|
|
||||
void ProjectionMappingState::onKeyPressed(Application * app, ofKeyEventArgs & args) { |
void ProjectionMappingState::onKeyPressed(Application * app, ofKeyEventArgs & args){ |
||||
switch (args.key) { |
switch(args.key){ |
||||
|
|
||||
case 't': |
case 't': |
||||
app->getOfxPiMapper()->getCmdManager().exec( |
app->getOfxPiMapper()->getCmdManager().exec( |
||||
new AddSurfaceCmd( |
new AddSurfaceCmd( |
||||
app->getOfxPiMapper(), |
app->getOfxPiMapper(), |
||||
SurfaceType::TRIANGLE_SURFACE) |
SurfaceType::TRIANGLE_SURFACE) |
||||
); |
); |
||||
break; |
break; |
||||
|
|
||||
case 'q': |
case 'q': |
||||
app->getOfxPiMapper()->getCmdManager().exec( |
app->getOfxPiMapper()->getCmdManager().exec( |
||||
new AddSurfaceCmd( |
new AddSurfaceCmd( |
||||
app->getOfxPiMapper(), |
app->getOfxPiMapper(), |
||||
SurfaceType::QUAD_SURFACE) |
SurfaceType::QUAD_SURFACE) |
||||
); |
); |
||||
break; |
break; |
||||
|
|
||||
case OF_KEY_BACKSPACE: |
case OF_KEY_BACKSPACE: |
||||
app->getOfxPiMapper()->getCmdManager().exec( |
app->getOfxPiMapper()->getCmdManager().exec( |
||||
new RmSurfaceCmd(app->getOfxPiMapper())); |
new RmSurfaceCmd(app->getOfxPiMapper())); |
||||
break; |
break; |
||||
|
|
||||
default: |
default: |
||||
break; |
break; |
||||
} |
} |
||||
} |
} |
||||
} |
|
||||
} |
} // namespace piMapper
|
||||
|
} // namespace ofx
|
@ -1,17 +1,18 @@ |
|||||
#include "SourceSelectionState.h" |
#include "SourceSelectionState.h" |
||||
|
|
||||
namespace ofx { |
namespace ofx { |
||||
namespace piMapper { |
namespace piMapper { |
||||
|
|
||||
SourceSelectionState * SourceSelectionState::_instance = 0; |
SourceSelectionState * SourceSelectionState::_instance = 0; |
||||
|
|
||||
SourceSelectionState * SourceSelectionState::instance() { |
SourceSelectionState * SourceSelectionState::instance(){ |
||||
if (_instance == 0) { |
if(_instance == 0){ |
||||
_instance = new ofx::piMapper::SourceSelectionState(); |
_instance = new ofx::piMapper::SourceSelectionState(); |
||||
} |
} |
||||
return _instance; |
return _instance; |
||||
} |
} |
||||
|
|
||||
void SourceSelectionState::draw(Application * app) {} |
void SourceSelectionState::draw(Application * app){} |
||||
} |
|
||||
} |
} // namespace piMapper
|
||||
|
} // namespace ofx
|
@ -1,17 +1,18 @@ |
|||||
#include "TextureMappingState.h" |
#include "TextureMappingState.h" |
||||
|
|
||||
namespace ofx { |
namespace ofx { |
||||
namespace piMapper { |
namespace piMapper { |
||||
|
|
||||
TextureMappingState * TextureMappingState::_instance = 0; |
TextureMappingState * TextureMappingState::_instance = 0; |
||||
|
|
||||
TextureMappingState * TextureMappingState::instance() { |
TextureMappingState * TextureMappingState::instance(){ |
||||
if (_instance == 0) { |
if(_instance == 0){ |
||||
_instance = new ofx::piMapper::TextureMappingState(); |
_instance = new ofx::piMapper::TextureMappingState(); |
||||
} |
} |
||||
return _instance; |
return _instance; |
||||
} |
} |
||||
|
|
||||
void TextureMappingState::draw(Application * app) {} |
void TextureMappingState::draw(Application * app){} |
||||
} |
|
||||
} |
} // namespace piMapper
|
||||
|
} // namespace ofx
|
@ -1,61 +1,61 @@ |
|||||
#include "AddSurfaceCmd.h" |
#include "AddSurfaceCmd.h" |
||||
|
|
||||
namespace ofx{ |
namespace ofx { |
||||
namespace piMapper{ |
namespace piMapper { |
||||
|
|
||||
AddSurfaceCmd::AddSurfaceCmd(ofxPiMapper * app, int surfaceType){ |
AddSurfaceCmd::AddSurfaceCmd(ofxPiMapper * app, int surfaceType){ |
||||
_app = app; |
_app = app; |
||||
_surfaceType = surfaceType; |
_surfaceType = surfaceType; |
||||
} |
} |
||||
|
|
||||
void AddSurfaceCmd::exec(){ |
void AddSurfaceCmd::exec(){ |
||||
if (_surfaceType == SurfaceType::TRIANGLE_SURFACE) { |
if(_surfaceType == SurfaceType::TRIANGLE_SURFACE){ |
||||
addTriangleSurface(); |
addTriangleSurface(); |
||||
} else if (_surfaceType == SurfaceType::QUAD_SURFACE) { |
}else if(_surfaceType == SurfaceType::QUAD_SURFACE){ |
||||
addQuadSurface(); |
addQuadSurface(); |
||||
} |
} |
||||
} |
} |
||||
|
|
||||
void AddSurfaceCmd::undo(){ |
void AddSurfaceCmd::undo(){ |
||||
ofLogNotice("AddSurfaceCmd", "undo"); |
ofLogNotice("AddSurfaceCmd", "undo"); |
||||
_app->getSurfaceManager().removeSurface(); |
_app->getSurfaceManager().removeSurface(); |
||||
} |
} |
||||
|
|
||||
void AddSurfaceCmd::addTriangleSurface() { |
void AddSurfaceCmd::addTriangleSurface(){ |
||||
int surfaceType = ofx::piMapper::SurfaceType::TRIANGLE_SURFACE; |
int surfaceType = ofx::piMapper::SurfaceType::TRIANGLE_SURFACE; |
||||
|
|
||||
vector<ofVec2f> vertices; |
vector <ofVec2f> vertices; |
||||
float margin = 50.0f; |
float margin = 50.0f; |
||||
vertices.push_back(ofVec2f((float)ofGetWidth() / 2.0f, margin)); |
vertices.push_back(ofVec2f((float)ofGetWidth() / 2.0f, margin)); |
||||
vertices.push_back(ofVec2f((float)ofGetWidth() - margin, (float)ofGetHeight() - margin)); |
vertices.push_back(ofVec2f((float)ofGetWidth() - margin, (float)ofGetHeight() - margin)); |
||||
vertices.push_back(ofVec2f(margin, (float)ofGetHeight() - margin)); |
vertices.push_back(ofVec2f(margin, (float)ofGetHeight() - margin)); |
||||
|
|
||||
vector<ofVec2f> texCoords; |
vector <ofVec2f> texCoords; |
||||
texCoords.push_back(ofVec2f(0.5f, 0.0f)); |
texCoords.push_back(ofVec2f(0.5f, 0.0f)); |
||||
texCoords.push_back(ofVec2f(1.0f, 1.0f)); |
texCoords.push_back(ofVec2f(1.0f, 1.0f)); |
||||
texCoords.push_back(ofVec2f(0.0f, 1.0f)); |
texCoords.push_back(ofVec2f(0.0f, 1.0f)); |
||||
_app->getSurfaceManager().addSurface(surfaceType, vertices, texCoords); |
_app->getSurfaceManager().addSurface(surfaceType, vertices, texCoords); |
||||
} |
} |
||||
|
|
||||
void AddSurfaceCmd::addQuadSurface() { |
void AddSurfaceCmd::addQuadSurface(){ |
||||
int surfaceType = ofx::piMapper::SurfaceType::QUAD_SURFACE; |
int surfaceType = ofx::piMapper::SurfaceType::QUAD_SURFACE; |
||||
|
|
||||
vector<ofVec2f> vertices; |
vector <ofVec2f> vertices; |
||||
float margin = 50.0f; |
float margin = 50.0f; |
||||
vertices.push_back(ofVec2f(margin, margin)); |
vertices.push_back(ofVec2f(margin, margin)); |
||||
vertices.push_back(ofVec2f((float)ofGetWidth() - margin, margin)); |
vertices.push_back(ofVec2f((float)ofGetWidth() - margin, margin)); |
||||
vertices.push_back(ofVec2f((float)ofGetWidth() - margin, (float)ofGetHeight() - margin)); |
vertices.push_back(ofVec2f((float)ofGetWidth() - margin, (float)ofGetHeight() - margin)); |
||||
vertices.push_back(ofVec2f(margin, (float)ofGetHeight() - margin)); |
vertices.push_back(ofVec2f(margin, (float)ofGetHeight() - margin)); |
||||
|
|
||||
vector<ofVec2f> texCoords; |
vector <ofVec2f> texCoords; |
||||
texCoords.push_back(ofVec2f(ofVec2f(0.0f, 0.0f))); |
texCoords.push_back(ofVec2f(ofVec2f(0.0f, 0.0f))); |
||||
texCoords.push_back(ofVec2f(ofVec2f(1.0f, 0.0f))); |
texCoords.push_back(ofVec2f(ofVec2f(1.0f, 0.0f))); |
||||
texCoords.push_back(ofVec2f(ofVec2f(1.0f, 1.0f))); |
texCoords.push_back(ofVec2f(ofVec2f(1.0f, 1.0f))); |
||||
texCoords.push_back(ofVec2f(ofVec2f(0.0f, 1.0f))); |
texCoords.push_back(ofVec2f(ofVec2f(0.0f, 1.0f))); |
||||
|
|
||||
_app->getSurfaceManager().addSurface(surfaceType, vertices, texCoords); |
_app->getSurfaceManager().addSurface(surfaceType, vertices, texCoords); |
||||
} |
} |
||||
|
|
||||
} // namespace piMapper
|
} // namespace piMapper
|
||||
} // namespace ofx
|
} // namespace ofx
|
||||
|
|
||||
|
@ -1,28 +1,28 @@ |
|||||
#include "CmdManager.h" |
#include "CmdManager.h" |
||||
|
|
||||
namespace ofx{ |
namespace ofx { |
||||
namespace piMapper{ |
namespace piMapper { |
||||
|
|
||||
void CmdManager::exec(BaseCmd * cmd){ |
void CmdManager::exec(BaseCmd * cmd){ |
||||
cmd->exec(); |
cmd->exec(); |
||||
if (cmd->isUndoable()){ |
if(cmd->isUndoable()){ |
||||
cmdStack.push_back(static_cast<BaseUndoCmd *>(cmd)); |
cmdStack.push_back(static_cast <BaseUndoCmd *>(cmd)); |
||||
} |
} |
||||
} |
} |
||||
|
|
||||
void CmdManager::undo(){ |
void CmdManager::undo(){ |
||||
ofLogNotice("CmdManager", "undo"); |
ofLogNotice("CmdManager", "undo"); |
||||
if (cmdStack.size() > 0){ |
if(cmdStack.size() > 0){ |
||||
BaseUndoCmd * cmd = cmdStack.back(); |
BaseUndoCmd * cmd = cmdStack.back(); |
||||
cmd->undo(); |
cmd->undo(); |
||||
|
|
||||
// Delete last command now, change this when implementing redo.
|
// Delete last command now, change this when implementing redo.
|
||||
delete cmdStack.back(); |
delete cmdStack.back(); |
||||
cmdStack.pop_back(); |
cmdStack.pop_back(); |
||||
} else { |
}else{ |
||||
ofLogNotice("CmdManager", "Nothing to undo"); |
ofLogNotice("CmdManager", "Nothing to undo"); |
||||
} |
} |
||||
} |
} |
||||
|
|
||||
} // namespace piMapper
|
} // namespace piMapper
|
||||
} // namespace ofx
|
} // namespace ofx
|
@ -1,27 +1,27 @@ |
|||||
#include "MvAllTexCoordsCmd.h" |
#include "MvAllTexCoordsCmd.h" |
||||
|
|
||||
namespace ofx{ |
namespace ofx { |
||||
namespace piMapper{ |
namespace piMapper { |
||||
|
|
||||
MvAllTexCoordsCmd::MvAllTexCoordsCmd(BaseSurface * surface, TextureEditor * texEditor){ |
|
||||
_surface = surface; |
|
||||
_texEditor = texEditor; |
|
||||
} |
|
||||
|
|
||||
void MvAllTexCoordsCmd::exec(){ |
MvAllTexCoordsCmd::MvAllTexCoordsCmd(BaseSurface * surface, TextureEditor * texEditor){ |
||||
ofLogNotice("MvAllTexCoordsCmd", "exec"); |
_surface = surface; |
||||
_texCoords = _surface->getTexCoords(); |
_texEditor = texEditor; |
||||
} |
} |
||||
|
|
||||
void MvAllTexCoordsCmd::undo(){ |
void MvAllTexCoordsCmd::exec(){ |
||||
ofLogNotice("MvAllTexCoordsCmd", "undo"); |
ofLogNotice("MvAllTexCoordsCmd", "exec"); |
||||
ofVec2f dist = _texCoords[0] - _surface->getTexCoords()[0]; |
_texCoords = _surface->getTexCoords(); |
||||
dist.x = _surface->getSource()->getTexture()->getWidth() * dist.x; |
} |
||||
dist.y = _surface->getSource()->getTexture()->getHeight() * dist.y; |
|
||||
_texEditor->moveTexCoords(dist); |
void MvAllTexCoordsCmd::undo(){ |
||||
_surface = 0; |
ofLogNotice("MvAllTexCoordsCmd", "undo"); |
||||
} |
ofVec2f dist = _texCoords[0] - _surface->getTexCoords()[0]; |
||||
|
dist.x = _surface->getSource()->getTexture()->getWidth() * dist.x; |
||||
} // namespace piMapper
|
dist.y = _surface->getSource()->getTexture()->getHeight() * dist.y; |
||||
|
_texEditor->moveTexCoords(dist); |
||||
|
_surface = 0; |
||||
|
} |
||||
|
|
||||
|
} // namespace piMapper
|
||||
} // namespace ofx
|
} // namespace ofx
|
||||
|
|
||||
|
@ -1,30 +1,29 @@ |
|||||
#include "MvSurfaceCmd.h" |
#include "MvSurfaceCmd.h" |
||||
|
|
||||
namespace ofx{ |
namespace ofx { |
||||
namespace piMapper{ |
namespace piMapper { |
||||
|
|
||||
MvSurfaceCmd::MvSurfaceCmd( |
|
||||
BaseSurface * surface, |
|
||||
ProjectionEditor * projectionEditor){ |
|
||||
|
|
||||
_surface = surface; |
|
||||
_projectionEditor = projectionEditor; |
|
||||
} |
|
||||
|
|
||||
void MvSurfaceCmd::exec(){ |
MvSurfaceCmd::MvSurfaceCmd(BaseSurface * surface, |
||||
ofLogNotice("MvSurfaceCmd", "exec"); |
ProjectionEditor * projectionEditor){ |
||||
_previousVertices = _surface->getVertices(); |
|
||||
_surface->setMoved(false); |
_surface = surface; |
||||
} |
_projectionEditor = projectionEditor; |
||||
|
} |
||||
void MvSurfaceCmd::undo(){ |
|
||||
ofLogNotice("MvSurfaceCmd", "undo"); |
void MvSurfaceCmd::exec(){ |
||||
_surface->moveBy(_previousVertices[0] - _surface->getVertices()[0]); |
ofLogNotice("MvSurfaceCmd", "exec"); |
||||
_projectionEditor->updateJoints(); |
_previousVertices = _surface->getVertices(); |
||||
_previousVertices.clear(); |
_surface->setMoved(false); |
||||
_surface = 0; |
} |
||||
} |
|
||||
|
void MvSurfaceCmd::undo(){ |
||||
} // namespace piMapper
|
ofLogNotice("MvSurfaceCmd", "undo"); |
||||
|
_surface->moveBy(_previousVertices[0] - _surface->getVertices()[0]); |
||||
|
_projectionEditor->updateJoints(); |
||||
|
_previousVertices.clear(); |
||||
|
_surface = 0; |
||||
|
} |
||||
|
|
||||
|
} // namespace piMapper
|
||||
} // namespace ofx
|
} // namespace ofx
|
||||
|
|
||||
|
@ -1,31 +1,30 @@ |
|||||
#include "MvSurfaceVertCmd.h" |
#include "MvSurfaceVertCmd.h" |
||||
|
|
||||
namespace ofx{ |
namespace ofx { |
||||
namespace piMapper{ |
namespace piMapper { |
||||
|
|
||||
MvSurfaceVertCmd::MvSurfaceVertCmd( |
|
||||
int vertIndex, |
|
||||
BaseSurface * surface, |
|
||||
ProjectionEditor * projectionEditor){ |
|
||||
|
|
||||
_vertIndex = vertIndex; |
|
||||
_surface = surface; |
|
||||
_projectionEditor = projectionEditor; |
|
||||
} |
|
||||
|
|
||||
void MvSurfaceVertCmd::exec(){ |
MvSurfaceVertCmd::MvSurfaceVertCmd(int vertIndex, |
||||
ofLogNotice("MvSurfaceVertCommand", "exec"); |
BaseSurface * surface, |
||||
_prevVertPos = _surface->getVertices()[_vertIndex]; |
ProjectionEditor * projectionEditor){ |
||||
} |
|
||||
|
_vertIndex = vertIndex; |
||||
void MvSurfaceVertCmd::undo(){ |
_surface = surface; |
||||
ofLogNotice("MvSurfaceVertCommand", "undo"); |
_projectionEditor = projectionEditor; |
||||
_surface->setVertex(_vertIndex, _prevVertPos); |
} |
||||
_projectionEditor->updateJoints(); |
|
||||
_projectionEditor = 0; |
void MvSurfaceVertCmd::exec(){ |
||||
_surface = 0; |
ofLogNotice("MvSurfaceVertCommand", "exec"); |
||||
} |
_prevVertPos = _surface->getVertices()[_vertIndex]; |
||||
|
} |
||||
} // namespace piMapper
|
|
||||
|
void MvSurfaceVertCmd::undo(){ |
||||
|
ofLogNotice("MvSurfaceVertCommand", "undo"); |
||||
|
_surface->setVertex(_vertIndex, _prevVertPos); |
||||
|
_projectionEditor->updateJoints(); |
||||
|
_projectionEditor = 0; |
||||
|
_surface = 0; |
||||
|
} |
||||
|
|
||||
|
} // namespace piMapper
|
||||
} // namespace ofx
|
} // namespace ofx
|
||||
|
|
||||
|
@ -1,26 +1,26 @@ |
|||||
#include "MvTexCoordCmd.h" |
#include "MvTexCoordCmd.h" |
||||
|
|
||||
namespace ofx{ |
namespace ofx { |
||||
namespace piMapper{ |
namespace piMapper { |
||||
|
|
||||
MvTexCoordCmd::MvTexCoordCmd(int jointIndex, TextureEditor * texEditor){ |
|
||||
_jointIndex = jointIndex; |
|
||||
_texEditor = texEditor; |
|
||||
} |
|
||||
|
|
||||
void MvTexCoordCmd::exec(){ |
MvTexCoordCmd::MvTexCoordCmd(int jointIndex, TextureEditor * texEditor){ |
||||
ofLogNotice("MvTexCoordCmd", "exec"); |
_jointIndex = jointIndex; |
||||
_jointPosition = _texEditor->getJoints()[_jointIndex]->position; |
_texEditor = texEditor; |
||||
} |
} |
||||
|
|
||||
void MvTexCoordCmd::undo(){ |
void MvTexCoordCmd::exec(){ |
||||
ofLogNotice("MvTexCoordCmd", "undo"); |
ofLogNotice("MvTexCoordCmd", "exec"); |
||||
_texEditor->unselectAllJoints(); |
_jointPosition = _texEditor->getJoints()[_jointIndex]->position; |
||||
_texEditor->getJoints()[_jointIndex]->select(); |
} |
||||
_texEditor->getJoints()[_jointIndex]->position = _jointPosition; |
|
||||
_texEditor = 0; |
void MvTexCoordCmd::undo(){ |
||||
} |
ofLogNotice("MvTexCoordCmd", "undo"); |
||||
|
_texEditor->unselectAllJoints(); |
||||
} // namespace piMapper
|
_texEditor->getJoints()[_jointIndex]->select(); |
||||
|
_texEditor->getJoints()[_jointIndex]->position = _jointPosition; |
||||
|
_texEditor = 0; |
||||
|
} |
||||
|
|
||||
|
} // namespace piMapper
|
||||
} // namespace ofx
|
} // namespace ofx
|
||||
|
|
||||
|
@ -1,30 +1,30 @@ |
|||||
#include "RmSurfaceCmd.h" |
#include "RmSurfaceCmd.h" |
||||
|
|
||||
namespace ofx{ |
namespace ofx { |
||||
namespace piMapper{ |
namespace piMapper { |
||||
|
|
||||
RmSurfaceCmd::RmSurfaceCmd(ofxPiMapper * app){ |
|
||||
_app = app; |
|
||||
_surface = 0; |
|
||||
} |
|
||||
|
|
||||
void RmSurfaceCmd::exec(){ |
RmSurfaceCmd::RmSurfaceCmd(ofxPiMapper * app){ |
||||
// Store the surface, this implies that the surfaceManager's
|
_app = app; |
||||
// removeSelectedSurface does not destroy the surface.
|
_surface = 0; |
||||
_surface = _app->surfaceManager.getSelectedSurface(); |
} |
||||
_app->surfaceManager.removeSelectedSurface(); |
|
||||
} |
void RmSurfaceCmd::exec(){ |
||||
|
// Store the surface, this implies that the surfaceManager's
|
||||
void RmSurfaceCmd::undo(){ |
// removeSelectedSurface does not destroy the surface.
|
||||
ofLogNotice("RmSurfaceCmd", "undo"); |
_surface = _app->surfaceManager.getSelectedSurface(); |
||||
if (_surface == 0) { |
_app->surfaceManager.removeSelectedSurface(); |
||||
ofLogError("RmSurfaceCmd", "No surface stored"); |
} |
||||
} |
|
||||
_app->surfaceManager.addSurface(_surface); |
void RmSurfaceCmd::undo(){ |
||||
_app->surfaceManager.selectSurface(_surface); |
ofLogNotice("RmSurfaceCmd", "undo"); |
||||
_surface = 0; |
if(_surface == 0){ |
||||
} |
ofLogError("RmSurfaceCmd", "No surface stored"); |
||||
|
} |
||||
} // namespace piMapper
|
_app->surfaceManager.addSurface(_surface); |
||||
|
_app->surfaceManager.selectSurface(_surface); |
||||
|
_surface = 0; |
||||
|
} |
||||
|
|
||||
|
} // namespace piMapper
|
||||
} // namespace ofx
|
} // namespace ofx
|
||||
|
|
||||
|
@ -1,34 +1,33 @@ |
|||||
#include "SelSurfaceCmd.h" |
#include "SelSurfaceCmd.h" |
||||
|
|
||||
namespace ofx{ |
namespace ofx { |
||||
namespace piMapper{ |
namespace piMapper { |
||||
|
|
||||
SelSurfaceCmd::SelSurfaceCmd( |
|
||||
SurfaceManager * surfaceManager, |
|
||||
BaseSurface * surfaceToSelect, |
|
||||
ProjectionEditor * projectionEditor){ |
|
||||
|
|
||||
_surfaceManager = surfaceManager; |
|
||||
_surfaceToSelect = surfaceToSelect; |
|
||||
_projectionEditor = projectionEditor; |
|
||||
} |
|
||||
|
|
||||
void SelSurfaceCmd::exec(){ |
SelSurfaceCmd::SelSurfaceCmd(SurfaceManager * surfaceManager, |
||||
_prevSelectedSurface = _surfaceManager->getSelectedSurface(); |
BaseSurface * surfaceToSelect, |
||||
_projectionEditor->clearJoints(); |
ProjectionEditor * projectionEditor){ |
||||
_surfaceManager->selectSurface(_surfaceToSelect); |
|
||||
_projectionEditor->createJoints(); |
_surfaceManager = surfaceManager; |
||||
} |
_surfaceToSelect = surfaceToSelect; |
||||
|
_projectionEditor = projectionEditor; |
||||
void SelSurfaceCmd::undo(){ |
} |
||||
ofLogNotice("SelSurfaceCmd", "undo"); |
|
||||
_projectionEditor->clearJoints(); |
void SelSurfaceCmd::exec(){ |
||||
_surfaceManager->selectSurface(_prevSelectedSurface); |
_prevSelectedSurface = _surfaceManager->getSelectedSurface(); |
||||
_projectionEditor->createJoints(); |
_projectionEditor->clearJoints(); |
||||
_surfaceToSelect = 0; |
_surfaceManager->selectSurface(_surfaceToSelect); |
||||
_prevSelectedSurface = 0; |
_projectionEditor->createJoints(); |
||||
} |
} |
||||
|
|
||||
} // namespace piMapper
|
void SelSurfaceCmd::undo(){ |
||||
|
ofLogNotice("SelSurfaceCmd", "undo"); |
||||
|
_projectionEditor->clearJoints(); |
||||
|
_surfaceManager->selectSurface(_prevSelectedSurface); |
||||
|
_projectionEditor->createJoints(); |
||||
|
_surfaceToSelect = 0; |
||||
|
_prevSelectedSurface = 0; |
||||
|
} |
||||
|
|
||||
|
} // namespace piMapper
|
||||
} // namespace ofx
|
} // namespace ofx
|
||||
|
|
||||
|
@ -1,42 +1,40 @@ |
|||||
#include "SetApplicationStateCmd.h" |
#include "SetApplicationStateCmd.h" |
||||
|
|
||||
namespace ofx { |
namespace ofx { |
||||
namespace piMapper { |
namespace piMapper { |
||||
|
|
||||
SetApplicationStateCmd::SetApplicationStateCmd( |
SetApplicationStateCmd::SetApplicationStateCmd(Application * app, |
||||
Application * app, |
ApplicationBaseState * st, |
||||
ApplicationBaseState * st, |
SurfaceManagerGui * gui, |
||||
|
int mode){ |
||||
SurfaceManagerGui * gui, |
|
||||
int mode) { |
_application = app; |
||||
|
_prevApplicationState = 0; |
||||
_application = app; |
_applicationState = st; |
||||
_prevApplicationState = 0; |
|
||||
_applicationState = st; |
// TODO: To be removed
|
||||
|
_gui = gui; |
||||
// TODO: To be removed
|
_prevGuiMode = -1; |
||||
_gui = gui; |
_mode = mode; |
||||
_prevGuiMode = -1; |
} |
||||
_mode = mode; |
|
||||
} |
void SetApplicationStateCmd::exec(){ |
||||
|
_prevApplicationState = _application->getState(); |
||||
void SetApplicationStateCmd::exec() { |
_application->setState(_applicationState); |
||||
_prevApplicationState = _application->getState(); |
|
||||
_application->setState(_applicationState); |
// TODO: To be removed.
|
||||
|
_prevGuiMode = _gui->getMode(); |
||||
// TODO: To be removed.
|
_gui->setMode(_mode); |
||||
_prevGuiMode = _gui->getMode(); |
} |
||||
_gui->setMode(_mode); |
|
||||
} |
void SetApplicationStateCmd::undo(){ |
||||
|
ofLogNotice("SetApplicationStateCmd", "undo"); |
||||
void SetApplicationStateCmd::undo() { |
_application->setState(_prevApplicationState); |
||||
ofLogNotice("SetApplicationStateCmd", "undo"); |
|
||||
_application->setState(_prevApplicationState); |
// TODO: To be removed.
|
||||
|
_gui->setMode(_prevGuiMode); |
||||
// TODO: To be removed.
|
} |
||||
_gui->setMode(_prevGuiMode); |
|
||||
} |
} // namespace piMapper
|
||||
|
|
||||
} // namespace piMapper
|
|
||||
} // namespace ofx
|
} // namespace ofx
|
||||
|
|
||||
|
@ -1,57 +1,57 @@ |
|||||
#include "SetSourceCmd.h" |
#include "SetSourceCmd.h" |
||||
|
|
||||
namespace ofx{ |
namespace ofx { |
||||
namespace piMapper{ |
namespace piMapper { |
||||
|
|
||||
SetSourceCmd::SetSourceCmd(int sourceType, |
SetSourceCmd::SetSourceCmd(int sourceType, |
||||
string sourceId, |
string sourceId, |
||||
BaseSurface * surface, |
BaseSurface * surface, |
||||
SourcesEditor * sourcesEditor){ |
SourcesEditor * sourcesEditor){ |
||||
|
|
||||
_sourceType = sourceType; |
_sourceType = sourceType; |
||||
_sourceId = sourceId; |
_sourceId = sourceId; |
||||
_surface = surface; |
_surface = surface; |
||||
_sourcesEditor = sourcesEditor; |
_sourcesEditor = sourcesEditor; |
||||
} |
} |
||||
|
|
||||
void SetSourceCmd::exec(){ |
void SetSourceCmd::exec(){ |
||||
ofLogNotice("SetSourceCmd", "exec"); |
ofLogNotice("SetSourceCmd", "exec"); |
||||
|
|
||||
_oldSourceType = _surface->getSource()->getType(); |
_oldSourceType = _surface->getSource()->getType(); |
||||
if (_surface->getSource()->isLoadable()) { |
if(_surface->getSource()->isLoadable()){ |
||||
_oldSourceId = _surface->getSource()->getPath(); |
_oldSourceId = _surface->getSource()->getPath(); |
||||
} else { |
}else{ |
||||
_oldSourceId = _surface->getSource()->getName(); |
_oldSourceId = _surface->getSource()->getName(); |
||||
} |
} |
||||
|
|
||||
if (_sourceType == SourceType::SOURCE_TYPE_IMAGE) { |
if(_sourceType == SourceType::SOURCE_TYPE_IMAGE){ |
||||
_sourcesEditor->setImageSource(_sourceId); |
_sourcesEditor->setImageSource(_sourceId); |
||||
} else if (_sourceType == SourceType::SOURCE_TYPE_VIDEO) { |
}else if(_sourceType == SourceType::SOURCE_TYPE_VIDEO){ |
||||
_sourcesEditor->setVideoSource(_sourceId); |
_sourcesEditor->setVideoSource(_sourceId); |
||||
} else if (_sourceType == SourceType::SOURCE_TYPE_FBO) { |
}else if(_sourceType == SourceType::SOURCE_TYPE_FBO){ |
||||
_sourcesEditor->setFboSource(_sourceId); |
_sourcesEditor->setFboSource(_sourceId); |
||||
} else if (_sourceType == SourceType::SOURCE_TYPE_NONE) { |
}else if(_sourceType == SourceType::SOURCE_TYPE_NONE){ |
||||
_sourcesEditor->clearSource(); |
_sourcesEditor->clearSource(); |
||||
} |
} |
||||
} |
} |
||||
|
|
||||
void SetSourceCmd::undo(){ |
void SetSourceCmd::undo(){ |
||||
ofLogNotice("SetSourceCmd", "undo"); |
ofLogNotice("SetSourceCmd", "undo"); |
||||
|
|
||||
if (_oldSourceType == SourceType::SOURCE_TYPE_IMAGE) { |
if(_oldSourceType == SourceType::SOURCE_TYPE_IMAGE){ |
||||
_sourcesEditor->setImageSource(_oldSourceId); |
_sourcesEditor->setImageSource(_oldSourceId); |
||||
} else if (_oldSourceType == SourceType::SOURCE_TYPE_VIDEO) { |
}else if(_oldSourceType == SourceType::SOURCE_TYPE_VIDEO){ |
||||
_sourcesEditor->setVideoSource(_oldSourceId); |
_sourcesEditor->setVideoSource(_oldSourceId); |
||||
} else if (_oldSourceType == SourceType::SOURCE_TYPE_FBO) { |
}else if(_oldSourceType == SourceType::SOURCE_TYPE_FBO){ |
||||
_sourcesEditor->setFboSource(_oldSourceId); |
_sourcesEditor->setFboSource(_oldSourceId); |
||||
} else if (_oldSourceType == SourceType::SOURCE_TYPE_NONE) { |
}else if(_oldSourceType == SourceType::SOURCE_TYPE_NONE){ |
||||
_sourcesEditor->clearSource(); |
_sourcesEditor->clearSource(); |
||||
} |
} |
||||
|
|
||||
_surface = 0; |
_surface = 0; |
||||
_sourcesEditor = 0; |
_sourcesEditor = 0; |
||||
} |
} |
||||
|
|
||||
} // namespace piMapper
|
} // namespace piMapper
|
||||
} // namespace ofx
|
} // namespace ofx
|
||||
|
|
||||
|
@ -1,59 +1,61 @@ |
|||||
#include "BaseSource.h" |
#include "BaseSource.h" |
||||
|
|
||||
namespace ofx { |
namespace ofx { |
||||
namespace piMapper { |
namespace piMapper { |
||||
BaseSource::BaseSource() { |
|
||||
//cout << "BaseSource" << endl;
|
BaseSource::BaseSource(){ |
||||
init(); |
//cout << "BaseSource" << endl;
|
||||
} |
init(); |
||||
|
} |
||||
BaseSource::BaseSource(ofTexture* newTexture) { |
|
||||
init(); |
BaseSource::BaseSource(ofTexture * newTexture){ |
||||
texture = newTexture; |
init(); |
||||
} |
texture = newTexture; |
||||
|
} |
||||
BaseSource::~BaseSource() {} |
|
||||
|
BaseSource::~BaseSource(){} |
||||
ofTexture* BaseSource::getTexture() { |
|
||||
return texture; |
ofTexture * BaseSource::getTexture(){ |
||||
} |
return texture; |
||||
|
} |
||||
std::string& BaseSource::getName() { |
|
||||
return name; |
std::string & BaseSource::getName(){ |
||||
} |
return name; |
||||
|
} |
||||
bool BaseSource::isLoadable() { |
|
||||
return loadable; |
bool BaseSource::isLoadable(){ |
||||
} |
return loadable; |
||||
|
} |
||||
bool BaseSource::isLoaded() { |
|
||||
return loaded; |
bool BaseSource::isLoaded(){ |
||||
} |
return loaded; |
||||
|
} |
||||
int BaseSource::getType() { |
|
||||
return type; |
int BaseSource::getType(){ |
||||
} |
return type; |
||||
|
} |
||||
std::string& BaseSource::getPath() { |
|
||||
return path; |
std::string & BaseSource::getPath(){ |
||||
} |
return path; |
||||
|
} |
||||
void BaseSource::init() { |
|
||||
texture = NULL; |
void BaseSource::init(){ |
||||
name = ""; |
texture = NULL; |
||||
path = ""; |
name = ""; |
||||
loadable = false; |
path = ""; |
||||
loaded = false; |
loadable = false; |
||||
type = SourceType::SOURCE_TYPE_NONE; |
loaded = false; |
||||
referenceCount = 1; // We have one instance on init
|
type = SourceType::SOURCE_TYPE_NONE; |
||||
} |
referenceCount = 1; // We have one instance on init
|
||||
|
} |
||||
void BaseSource::setNameFromPath(std::string& fullPath) { |
|
||||
std::vector<string> pathParts; |
void BaseSource::setNameFromPath(std::string & fullPath){ |
||||
//cout << "fullPath: " << fullPath << endl;
|
std::vector <string> pathParts; |
||||
pathParts = ofSplitString(fullPath, "/"); // Maybe on win "/" is "\", have to test
|
//cout << "fullPath: " << fullPath << endl;
|
||||
//cout << "lastPathPart: " << pathParts[pathParts.size() - 1] << endl;
|
pathParts = ofSplitString(fullPath, "/"); // Maybe on win "/" is "\", have to test
|
||||
name = pathParts[pathParts.size() - 1]; |
//cout << "lastPathPart: " << pathParts[pathParts.size() - 1] << endl;
|
||||
} |
name = pathParts[pathParts.size() - 1]; |
||||
} |
} |
||||
} |
|
||||
|
} // namespace piMapper
|
||||
|
} // namespace ofx
|
@ -1,115 +1,115 @@ |
|||||
#include "FboSource.h" |
#include "FboSource.h" |
||||
|
|
||||
namespace ofx { |
namespace ofx { |
||||
namespace piMapper { |
namespace piMapper { |
||||
|
|
||||
FboSource::FboSource() : fbo(NULL) { |
FboSource::FboSource() : fbo(NULL){ |
||||
name = PIMAPPER_FBO_SOURCE_DEF_NAME; |
name = PIMAPPER_FBO_SOURCE_DEF_NAME; |
||||
loadable = false; |
loadable = false; |
||||
loaded = false; |
loaded = false; |
||||
type = SourceType::SOURCE_TYPE_FBO; |
type = SourceType::SOURCE_TYPE_FBO; |
||||
ofAddListener(ofEvents().setup, this, |
ofAddListener(ofEvents().setup, this, |
||||
&FboSource::onAppSetup, OF_EVENT_ORDER_BEFORE_APP); |
&FboSource::onAppSetup, OF_EVENT_ORDER_BEFORE_APP); |
||||
} |
} |
||||
|
|
||||
FboSource::~FboSource() { |
FboSource::~FboSource(){ |
||||
removeAppListeners(); |
removeAppListeners(); |
||||
clear(); |
clear(); |
||||
} |
} |
||||
|
|
||||
void FboSource::addAppListeners() { |
void FboSource::addAppListeners(){ |
||||
ofLogNotice("FboSource") << "Adding app listeners"; |
ofLogNotice("FboSource") << "Adding app listeners"; |
||||
ofAddListener(ofEvents().update, this, |
ofAddListener(ofEvents().update, this, |
||||
&FboSource::onAppUpdate, OF_EVENT_ORDER_BEFORE_APP); |
&FboSource::onAppUpdate, OF_EVENT_ORDER_BEFORE_APP); |
||||
ofAddListener(ofEvents().draw, this, |
ofAddListener(ofEvents().draw, this, |
||||
&FboSource::onAppDraw, OF_EVENT_ORDER_BEFORE_APP); |
&FboSource::onAppDraw, OF_EVENT_ORDER_BEFORE_APP); |
||||
ofAddListener(ofEvents().exit, this, |
ofAddListener(ofEvents().exit, this, |
||||
&FboSource::onAppExit, OF_EVENT_ORDER_AFTER_APP); |
&FboSource::onAppExit, OF_EVENT_ORDER_AFTER_APP); |
||||
} |
} |
||||
|
|
||||
void FboSource::removeAppListeners() { |
void FboSource::removeAppListeners(){ |
||||
ofLogNotice("FboSource") << "Removing app listeners"; |
ofLogNotice("FboSource") << "Removing app listeners"; |
||||
ofRemoveListener(ofEvents().update, this, |
ofRemoveListener(ofEvents().update, this, |
||||
&FboSource::onAppUpdate, OF_EVENT_ORDER_BEFORE_APP); |
&FboSource::onAppUpdate, OF_EVENT_ORDER_BEFORE_APP); |
||||
ofRemoveListener(ofEvents().draw, this, |
ofRemoveListener(ofEvents().draw, this, |
||||
&FboSource::onAppDraw, OF_EVENT_ORDER_BEFORE_APP); |
&FboSource::onAppDraw, OF_EVENT_ORDER_BEFORE_APP); |
||||
ofRemoveListener(ofEvents().exit, this, |
ofRemoveListener(ofEvents().exit, this, |
||||
&FboSource::onAppExit, OF_EVENT_ORDER_AFTER_APP); |
&FboSource::onAppExit, OF_EVENT_ORDER_AFTER_APP); |
||||
} |
} |
||||
|
|
||||
void FboSource::onAppSetup(ofEventArgs &args) { |
void FboSource::onAppSetup(ofEventArgs & args){ |
||||
ofRemoveListener(ofEvents().setup, this, |
ofRemoveListener(ofEvents().setup, this, |
||||
&FboSource::onAppSetup, OF_EVENT_ORDER_BEFORE_APP); |
&FboSource::onAppSetup, OF_EVENT_ORDER_BEFORE_APP); |
||||
setup(); |
setup(); |
||||
|
|
||||
// Check if FBO was allocated in user defined setup
|
// Check if FBO was allocated in user defined setup
|
||||
// If not, show warning and alocate to avoid panic
|
// If not, show warning and alocate to avoid panic
|
||||
if (!fbo->isAllocated()) { |
if(!fbo->isAllocated()){ |
||||
ofLogWarning("FboSource::onAppSetup") << |
ofLogWarning("FboSource::onAppSetup") |
||||
"FBO not allocated, allocating with default values"; |
<< "FBO not allocated, allocating with default values"; |
||||
allocate(PIMAPPER_FBO_SOURCE_DEF_WIDTH, |
allocate(PIMAPPER_FBO_SOURCE_DEF_WIDTH, |
||||
PIMAPPER_FBO_SOURCE_DEF_HEIGHT); |
PIMAPPER_FBO_SOURCE_DEF_HEIGHT); |
||||
} |
} |
||||
} |
} |
||||
|
|
||||
void FboSource::onAppUpdate(ofEventArgs &args) { |
void FboSource::onAppUpdate(ofEventArgs & args){ |
||||
if (fbo == NULL || !fbo->isAllocated()) { |
if(fbo == NULL || !fbo->isAllocated()){ |
||||
ofLogWarning("FboSource") << "FBO not allocated"; |
ofLogWarning("FboSource") << "FBO not allocated"; |
||||
return; |
return; |
||||
} |
} |
||||
update(); |
update(); |
||||
} |
} |
||||
|
|
||||
void FboSource::onAppDraw(ofEventArgs &args) { |
void FboSource::onAppDraw(ofEventArgs & args){ |
||||
if (fbo == NULL || !fbo->isAllocated()) { |
if(fbo == NULL || !fbo->isAllocated()){ |
||||
ofLogWarning("FboSource") << "FBO not allocated"; |
ofLogWarning("FboSource") << "FBO not allocated"; |
||||
return; |
return; |
||||
} |
} |
||||
fbo->begin(); |
fbo->begin(); |
||||
draw(); |
draw(); |
||||
fbo->end(); |
fbo->end(); |
||||
} |
} |
||||
|
|
||||
void FboSource::onAppExit(ofEventArgs &args) { |
void FboSource::onAppExit(ofEventArgs & args){ |
||||
exit(); |
exit(); |
||||
} |
} |
||||
|
|
||||
void FboSource::allocate(int width, int height) { |
void FboSource::allocate(int width, int height){ |
||||
clear(); |
clear(); |
||||
fbo = new ofFbo(); |
fbo = new ofFbo(); |
||||
fbo->allocate(width, height); |
fbo->allocate(width, height); |
||||
|
|
||||
// Clear FBO
|
// Clear FBO
|
||||
fbo->begin(); |
fbo->begin(); |
||||
ofClear(0); |
ofClear(0); |
||||
fbo->end(); |
fbo->end(); |
||||
|
|
||||
texture = &(fbo->getTextureReference()); |
texture = &(fbo->getTextureReference()); |
||||
} |
} |
||||
|
|
||||
void FboSource::clear() { |
void FboSource::clear(){ |
||||
texture = NULL; |
texture = NULL; |
||||
if (fbo != NULL) { |
if(fbo != NULL){ |
||||
delete fbo; |
delete fbo; |
||||
fbo = NULL; |
fbo = NULL; |
||||
} |
} |
||||
} |
} |
||||
|
|
||||
int FboSource::getWidth() { |
int FboSource::getWidth(){ |
||||
if (fbo->isAllocated()) { |
if(fbo->isAllocated()){ |
||||
return fbo->getWidth(); |
return fbo->getWidth(); |
||||
} else { |
}else{ |
||||
return 0; |
return 0; |
||||
} |
} |
||||
} |
} |
||||
|
|
||||
int FboSource::getHeight() { |
int FboSource::getHeight(){ |
||||
if (fbo->isAllocated()) { |
if(fbo->isAllocated()){ |
||||
return fbo->getHeight(); |
return fbo->getHeight(); |
||||
} else { |
}else{ |
||||
return 0; |
return 0; |
||||
} |
} |
||||
} |
} |
||||
|
|
||||
} // namespace piMapper
|
} // namespace piMapper
|
||||
} // namespace ofx
|
} // namespace ofx
|
@ -1,39 +1,40 @@ |
|||||
#include "ImageSource.h" |
#include "ImageSource.h" |
||||
|
|
||||
namespace ofx { |
namespace ofx { |
||||
namespace piMapper { |
namespace piMapper { |
||||
ImageSource::ImageSource() { |
|
||||
//cout << "ImageSource" << endl;
|
ImageSource::ImageSource(){ |
||||
loadable = true; |
//cout << "ImageSource" << endl;
|
||||
loaded = false; |
loadable = true; |
||||
type = SourceType::SOURCE_TYPE_IMAGE; |
loaded = false; |
||||
} |
type = SourceType::SOURCE_TYPE_IMAGE; |
||||
|
} |
||||
ImageSource::~ImageSource() {} |
|
||||
|
ImageSource::~ImageSource(){} |
||||
void ImageSource::loadImage(std::string& filePath) { |
|
||||
path = filePath; |
void ImageSource::loadImage(std::string & filePath){ |
||||
//cout << "loading image: " << filePath << endl;
|
path = filePath; |
||||
setNameFromPath(filePath); |
//cout << "loading image: " << filePath << endl;
|
||||
//cout << "path: " << path << endl;
|
setNameFromPath(filePath); |
||||
image = new ofImage(); |
//cout << "path: " << path << endl;
|
||||
if (!image->loadImage(filePath)) { |
image = new ofImage(); |
||||
ofLogWarning("ImageSource") << "Could not load image"; |
if(!image->loadImage(filePath)){ |
||||
//std::exit(EXIT_FAILURE);
|
ofLogWarning("ImageSource") << "Could not load image"; |
||||
} |
//std::exit(EXIT_FAILURE);
|
||||
texture = &image->getTextureReference(); |
} |
||||
loaded = true; |
texture = &image->getTextureReference(); |
||||
} |
loaded = true; |
||||
|
} |
||||
void ImageSource::clear() { |
|
||||
texture = NULL; |
void ImageSource::clear(){ |
||||
image->clear(); |
texture = NULL; |
||||
delete image; |
image->clear(); |
||||
image = NULL; |
delete image; |
||||
//path = "";
|
image = NULL; |
||||
//name = "";
|
//path = "";
|
||||
loaded = false; |
//name = "";
|
||||
} |
loaded = false; |
||||
|
} |
||||
} |
|
||||
} |
} // namespace piMapper
|
||||
|
} // namespace ofx
|
@ -1,70 +1,71 @@ |
|||||
#include "VideoSource.h" |
#include "VideoSource.h" |
||||
|
|
||||
namespace ofx { |
namespace ofx { |
||||
namespace piMapper { |
namespace piMapper { |
||||
|
|
||||
bool VideoSource::enableAudio = false; |
bool VideoSource::enableAudio = false; |
||||
|
|
||||
VideoSource::VideoSource() { |
VideoSource::VideoSource(){ |
||||
loadable = true; |
loadable = true; |
||||
loaded = false; |
loaded = false; |
||||
type = SourceType::SOURCE_TYPE_VIDEO; |
type = SourceType::SOURCE_TYPE_VIDEO; |
||||
#ifdef TARGET_RASPBERRY_PI |
#ifdef TARGET_RASPBERRY_PI |
||||
omxPlayer = NULL; |
omxPlayer = NULL; |
||||
#else |
#else |
||||
videoPlayer = NULL; |
videoPlayer = NULL; |
||||
#endif |
#endif |
||||
} |
} |
||||
|
|
||||
VideoSource::~VideoSource() {} |
VideoSource::~VideoSource(){} |
||||
|
|
||||
void VideoSource::loadVideo(std::string & filePath) { |
void VideoSource::loadVideo(std::string & filePath){ |
||||
path = filePath; |
path = filePath; |
||||
setNameFromPath(filePath); |
setNameFromPath(filePath); |
||||
#ifdef TARGET_RASPBERRY_PI |
#ifdef TARGET_RASPBERRY_PI |
||||
ofxOMXPlayerSettings settings; |
ofxOMXPlayerSettings settings; |
||||
settings.videoPath = filePath; |
settings.videoPath = filePath; |
||||
settings.useHDMIForAudio = true; |
settings.useHDMIForAudio = true; |
||||
settings.enableTexture = true; |
settings.enableTexture = true; |
||||
settings.enableLooping = true; |
settings.enableLooping = true; |
||||
settings.enableAudio = VideoSource::enableAudio; |
settings.enableAudio = VideoSource::enableAudio; |
||||
omxPlayer = new ofxOMXPlayer(); |
omxPlayer = new ofxOMXPlayer(); |
||||
omxPlayer->setup(settings); |
omxPlayer->setup(settings); |
||||
texture = &(omxPlayer->getTextureReference()); |
texture = &(omxPlayer->getTextureReference()); |
||||
#else |
#else |
||||
videoPlayer = new ofVideoPlayer(); |
videoPlayer = new ofVideoPlayer(); |
||||
videoPlayer->load(filePath); |
videoPlayer->load(filePath); |
||||
videoPlayer->setLoopState(OF_LOOP_NORMAL); |
videoPlayer->setLoopState(OF_LOOP_NORMAL); |
||||
videoPlayer->setVolume(VideoSource::enableAudio ? 1.0f : 0.0f); |
videoPlayer->setVolume(VideoSource::enableAudio ? 1.0f : 0.0f); |
||||
videoPlayer->play(); |
videoPlayer->play(); |
||||
texture = &(videoPlayer->getTexture()); |
texture = &(videoPlayer->getTexture()); |
||||
ofAddListener(ofEvents().update, this, &VideoSource::update); |
ofAddListener(ofEvents().update, this, &VideoSource::update); |
||||
#endif |
#endif |
||||
loaded = true; |
loaded = true; |
||||
} |
} |
||||
|
|
||||
void VideoSource::clear() { |
void VideoSource::clear(){ |
||||
texture = NULL; |
texture = NULL; |
||||
#ifdef TARGET_RASPBERRY_PI |
#ifdef TARGET_RASPBERRY_PI |
||||
omxPlayer->close(); |
omxPlayer->close(); |
||||
delete omxPlayer; |
delete omxPlayer; |
||||
omxPlayer = NULL; |
omxPlayer = NULL; |
||||
#else |
#else |
||||
ofRemoveListener(ofEvents().update, this, &VideoSource::update); |
ofRemoveListener(ofEvents().update, this, &VideoSource::update); |
||||
videoPlayer->stop(); |
videoPlayer->stop(); |
||||
videoPlayer->close(); |
videoPlayer->close(); |
||||
delete videoPlayer; |
delete videoPlayer; |
||||
videoPlayer = NULL; |
videoPlayer = NULL; |
||||
#endif |
#endif |
||||
loaded = false; |
loaded = false; |
||||
} |
} |
||||
|
|
||||
#ifndef TARGET_RASPBERRY_PI |
#ifndef TARGET_RASPBERRY_PI |
||||
void VideoSource::update(ofEventArgs & args) { |
void VideoSource::update(ofEventArgs & args){ |
||||
if (videoPlayer != NULL) { |
if(videoPlayer != NULL){ |
||||
videoPlayer->update(); |
videoPlayer->update(); |
||||
} |
} |
||||
} |
} |
||||
#endif |
#endif |
||||
} // namespace piMapper
|
|
||||
|
} // namespace piMapper
|
||||
} // namespace ofx
|
} // namespace ofx
|
@ -1,94 +1,100 @@ |
|||||
#include "BaseSurface.h" |
#include "BaseSurface.h" |
||||
|
|
||||
namespace ofx { |
namespace ofx { |
||||
namespace piMapper { |
namespace piMapper { |
||||
|
|
||||
BaseSurface::BaseSurface() { |
BaseSurface::BaseSurface(){ |
||||
_moved = false; |
_moved = false; |
||||
ofEnableNormalizedTexCoords(); |
ofEnableNormalizedTexCoords(); |
||||
createDefaultTexture(); |
createDefaultTexture(); |
||||
} |
} |
||||
|
|
||||
BaseSurface::~BaseSurface() { |
BaseSurface::~BaseSurface(){ |
||||
delete defaultSource; |
delete defaultSource; |
||||
defaultSource = NULL; |
defaultSource = NULL; |
||||
defaultTexture.clear(); |
defaultTexture.clear(); |
||||
} |
} |
||||
|
|
||||
void BaseSurface::createDefaultTexture() { |
void BaseSurface::createDefaultTexture(){ |
||||
ofPixels pixels; |
ofPixels pixels; |
||||
pixels.allocate(500, 500, 1); |
pixels.allocate(500, 500, 1); |
||||
for (int i = 0; i < pixels.size(); i++) { |
for(int i = 0; i < pixels.size(); i++){ |
||||
pixels[i] = 255; |
pixels[i] = 255; |
||||
} |
} |
||||
int squareSize = 10; // size of each test pattern square
|
int squareSize = 10; // size of each test pattern square
|
||||
bool sy = false; |
bool sy = false; |
||||
for (int y = 0; y < pixels.getWidth(); y += squareSize) { |
for(int y = 0; y < pixels.getWidth(); y += squareSize){ |
||||
bool sx = false; |
bool sx = false; |
||||
for (int x = 0; x < pixels.getHeight(); x += squareSize) { |
for(int x = 0; x < pixels.getHeight(); x += squareSize){ |
||||
for (int yi = 0; yi < squareSize; yi++) { |
for(int yi = 0; yi < squareSize; yi++){ |
||||
for (int xi = 0; xi < squareSize; xi++) { |
for(int xi = 0; xi < squareSize; xi++){ |
||||
if (sx && sy) |
if(sx && sy){ |
||||
pixels[(y + yi) * pixels.getWidth() + x + xi] = 255; |
pixels[(y + yi) * pixels.getWidth() + x + xi] = 255; |
||||
else if (sx && !sy) |
}else if(sx && !sy){ |
||||
pixels[(y + yi) * pixels.getWidth() + x + xi] = 0; |
pixels[(y + yi) * pixels.getWidth() + x + xi] = 0; |
||||
else if (!sx && sy) |
}else if(!sx && sy){ |
||||
pixels[(y + yi) * pixels.getWidth() + x + xi] = 0; |
pixels[(y + yi) * pixels.getWidth() + x + xi] = 0; |
||||
else |
}else{ |
||||
pixels[(y + yi) * pixels.getWidth() + x + xi] = 255; |
pixels[(y + yi) * pixels.getWidth() + x + xi] = 255; |
||||
} |
} |
||||
} |
} |
||||
sx = !sx; |
} |
||||
} |
sx = !sx; |
||||
sy = !sy; |
} |
||||
} |
sy = !sy; |
||||
|
} |
||||
// load pixels into texture
|
|
||||
defaultTexture.loadData(pixels); |
// load pixels into texture
|
||||
// Create new source to be the default
|
defaultTexture.loadData(pixels); |
||||
defaultSource = new BaseSource(&defaultTexture); |
// Create new source to be the default
|
||||
source = defaultSource; |
defaultSource = new BaseSource(&defaultTexture); |
||||
} |
source = defaultSource; |
||||
|
} |
||||
void BaseSurface::drawTexture(ofVec2f position) { |
|
||||
if (source->getTexture() == NULL) { |
void BaseSurface::drawTexture(ofVec2f position){ |
||||
ofLogWarning("BaseSurface") << "Source texture empty. Not drawing."; |
if(source->getTexture() == NULL){ |
||||
return; |
ofLogWarning("BaseSurface") << "Source texture empty. Not drawing."; |
||||
} |
return; |
||||
|
} |
||||
ofMesh texMesh; |
|
||||
texMesh.addVertex(position); |
ofMesh texMesh; |
||||
texMesh.addVertex(position + ofVec2f(source->getTexture()->getWidth(), 0.0f)); |
texMesh.addVertex(position); |
||||
texMesh.addVertex(position + |
texMesh.addVertex(position + ofVec2f(source->getTexture()->getWidth(), 0.0f)); |
||||
ofVec2f(source->getTexture()->getWidth(), source->getTexture()->getHeight())); |
texMesh.addVertex(position |
||||
texMesh.addVertex(position + ofVec2f(0.0f, source->getTexture()->getHeight())); |
+ ofVec2f(source->getTexture()->getWidth(), source->getTexture()->getHeight())); |
||||
texMesh.addTriangle(0, 2, 3); |
texMesh.addVertex(position + ofVec2f(0.0f, source->getTexture()->getHeight())); |
||||
texMesh.addTriangle(0, 1, 2); |
texMesh.addTriangle(0, 2, 3); |
||||
texMesh.addTexCoord(ofVec2f(0.0f, 0.0f)); |
texMesh.addTriangle(0, 1, 2); |
||||
texMesh.addTexCoord(ofVec2f(1.0f, 0.0f)); |
texMesh.addTexCoord(ofVec2f(0.0f, 0.0f)); |
||||
texMesh.addTexCoord(ofVec2f(1.0f, 1.0f)); |
texMesh.addTexCoord(ofVec2f(1.0f, 0.0f)); |
||||
texMesh.addTexCoord(ofVec2f(0.0f, 1.0f)); |
texMesh.addTexCoord(ofVec2f(1.0f, 1.0f)); |
||||
source->getTexture()->bind(); |
texMesh.addTexCoord(ofVec2f(0.0f, 1.0f)); |
||||
texMesh.draw(); |
source->getTexture()->bind(); |
||||
source->getTexture()->unbind(); |
texMesh.draw(); |
||||
} |
source->getTexture()->unbind(); |
||||
|
} |
||||
//void BaseSurface::setTexture(ofTexture* texturePtr) { texture = texturePtr; }
|
|
||||
void BaseSurface::setSource(BaseSource* newSource) { |
//void BaseSurface::setTexture(ofTexture* texturePtr) { texture = texturePtr; }
|
||||
source = newSource; |
void BaseSurface::setSource(BaseSource * newSource){ |
||||
} |
source = newSource; |
||||
|
} |
||||
//ofTexture* BaseSurface::getTexture() { return texture; }
|
|
||||
BaseSource* BaseSurface::getSource() { |
//ofTexture* BaseSurface::getTexture() { return texture; }
|
||||
return source; |
BaseSource * BaseSurface::getSource(){ |
||||
} |
return source; |
||||
|
} |
||||
//ofTexture* BaseSurface::getDefaultTexture() { return &defaultTexture; }
|
|
||||
BaseSource* BaseSurface::getDefaultSource() { |
//ofTexture* BaseSurface::getDefaultTexture() { return &defaultTexture; }
|
||||
return defaultSource; |
BaseSource * BaseSurface::getDefaultSource(){ |
||||
} |
return defaultSource; |
||||
|
} |
||||
void BaseSurface::setMoved(bool moved){ _moved = moved; } |
|
||||
bool BaseSurface::getMoved(){ return _moved; } |
void BaseSurface::setMoved(bool moved){ |
||||
} |
_moved = moved; |
||||
} |
} |
||||
|
bool BaseSurface::getMoved(){ |
||||
|
return _moved; |
||||
|
} |
||||
|
|
||||
|
} // namespace piMapper
|
||||
|
} // namespace ofx
|
@ -1,311 +1,322 @@ |
|||||
#include "SurfaceManagerGui.h" |
#include "SurfaceManagerGui.h" |
||||
|
|
||||
namespace ofx { |
namespace ofx { |
||||
namespace piMapper { |
namespace piMapper { |
||||
SurfaceManagerGui::SurfaceManagerGui() { |
|
||||
surfaceManager = NULL; |
SurfaceManagerGui::SurfaceManagerGui(){ |
||||
guiMode = GuiMode::NONE; |
surfaceManager = NULL; |
||||
bDrag = false; |
guiMode = GuiMode::NONE; |
||||
registerMouseEvents(); |
bDrag = false; |
||||
ofHideCursor(); |
registerMouseEvents(); |
||||
_cmdManager = 0; |
ofHideCursor(); |
||||
} |
_cmdManager = 0; |
||||
|
} |
||||
SurfaceManagerGui::~SurfaceManagerGui() { |
|
||||
unregisterMouseEvents(); |
SurfaceManagerGui::~SurfaceManagerGui(){ |
||||
surfaceManager = NULL; |
unregisterMouseEvents(); |
||||
_cmdManager = 0; |
surfaceManager = NULL; |
||||
} |
_cmdManager = 0; |
||||
|
} |
||||
void SurfaceManagerGui::registerMouseEvents() { |
|
||||
ofAddListener(ofEvents().mousePressed, this, |
void SurfaceManagerGui::registerMouseEvents(){ |
||||
&SurfaceManagerGui::mousePressed); |
ofAddListener(ofEvents().mousePressed, this, |
||||
ofAddListener(ofEvents().mouseReleased, this, |
&SurfaceManagerGui::mousePressed); |
||||
&SurfaceManagerGui::mouseReleased); |
ofAddListener(ofEvents().mouseReleased, this, |
||||
ofAddListener(ofEvents().mouseDragged, this, |
&SurfaceManagerGui::mouseReleased); |
||||
&SurfaceManagerGui::mouseDragged); |
ofAddListener(ofEvents().mouseDragged, this, |
||||
} |
&SurfaceManagerGui::mouseDragged); |
||||
|
} |
||||
void SurfaceManagerGui::unregisterMouseEvents() { |
|
||||
ofRemoveListener(ofEvents().mousePressed, this, |
void SurfaceManagerGui::unregisterMouseEvents(){ |
||||
&SurfaceManagerGui::mousePressed); |
ofRemoveListener(ofEvents().mousePressed, this, |
||||
ofRemoveListener(ofEvents().mouseReleased, this, |
&SurfaceManagerGui::mousePressed); |
||||
&SurfaceManagerGui::mouseReleased); |
ofRemoveListener(ofEvents().mouseReleased, this, |
||||
ofRemoveListener(ofEvents().mouseDragged, this, |
&SurfaceManagerGui::mouseReleased); |
||||
&SurfaceManagerGui::mouseDragged); |
ofRemoveListener(ofEvents().mouseDragged, this, |
||||
} |
&SurfaceManagerGui::mouseDragged); |
||||
|
} |
||||
void SurfaceManagerGui::draw() { |
|
||||
if (surfaceManager == NULL) return; |
void SurfaceManagerGui::draw(){ |
||||
|
if(surfaceManager == NULL){ |
||||
if (guiMode == GuiMode::NONE) { |
return; |
||||
surfaceManager->draw(); |
} |
||||
} else if (guiMode == GuiMode::TEXTURE_MAPPING) { |
|
||||
// draw the texture of the selected surface
|
if(guiMode == GuiMode::NONE){ |
||||
if (surfaceManager->getSelectedSurface() != NULL) { |
surfaceManager->draw(); |
||||
// Reset default color to white first
|
}else if(guiMode == GuiMode::TEXTURE_MAPPING){ |
||||
ofSetColor(255, 255, 255, 255); |
// draw the texture of the selected surface
|
||||
surfaceManager->getSelectedSurface()->drawTexture(ofVec2f(0, 0)); |
if(surfaceManager->getSelectedSurface() != NULL){ |
||||
} |
// Reset default color to white first
|
||||
|
ofSetColor(255, 255, 255, 255); |
||||
// draw surfaces with opacity
|
surfaceManager->getSelectedSurface()->drawTexture(ofVec2f(0, 0)); |
||||
ofPushStyle(); |
} |
||||
ofSetColor(255, 255, 255, 200); |
|
||||
surfaceManager->draw(); |
// draw surfaces with opacity
|
||||
ofPopStyle(); |
ofPushStyle(); |
||||
|
ofSetColor(255, 255, 255, 200); |
||||
// highlight selected surface
|
surfaceManager->draw(); |
||||
drawSelectedSurfaceHighlight(); |
ofPopStyle(); |
||||
|
|
||||
// hilight selected surface texture
|
// highlight selected surface
|
||||
drawSelectedSurfaceTextureHighlight(); |
drawSelectedSurfaceHighlight(); |
||||
|
|
||||
// draw texture editing GUI on top
|
// hilight selected surface texture
|
||||
textureEditor.draw(); |
drawSelectedSurfaceTextureHighlight(); |
||||
|
|
||||
} else if (guiMode == GuiMode::PROJECTION_MAPPING) { |
// draw texture editing GUI on top
|
||||
// draw projection surfaces first
|
textureEditor.draw(); |
||||
surfaceManager->draw(); |
|
||||
|
}else if(guiMode == GuiMode::PROJECTION_MAPPING){ |
||||
// highlight selected surface
|
// draw projection surfaces first
|
||||
drawSelectedSurfaceHighlight(); |
surfaceManager->draw(); |
||||
|
|
||||
// draw projection mapping editing gui
|
// highlight selected surface
|
||||
projectionEditor.draw(); |
drawSelectedSurfaceHighlight(); |
||||
|
|
||||
} else if (guiMode == GuiMode::SOURCE_SELECTION) { |
// draw projection mapping editing gui
|
||||
// draw projection surfaces first
|
projectionEditor.draw(); |
||||
surfaceManager->draw(); |
|
||||
|
}else if(guiMode == GuiMode::SOURCE_SELECTION){ |
||||
// highlight selected surface
|
// draw projection surfaces first
|
||||
drawSelectedSurfaceHighlight(); |
surfaceManager->draw(); |
||||
|
|
||||
sourcesEditor.draw(); |
// highlight selected surface
|
||||
} |
drawSelectedSurfaceHighlight(); |
||||
} |
|
||||
|
sourcesEditor.draw(); |
||||
void SurfaceManagerGui::mousePressed(ofMouseEventArgs& args) { |
} |
||||
if (guiMode == GuiMode::NONE) { |
} |
||||
return; |
|
||||
} else if (guiMode == GuiMode::TEXTURE_MAPPING) { |
void SurfaceManagerGui::mousePressed(ofMouseEventArgs & args){ |
||||
bool bSurfaceSelected = false; |
if(guiMode == GuiMode::NONE){ |
||||
CircleJoint* hitJoint = |
return; |
||||
textureEditor.hitTestJoints(ofVec2f(args.x, args.y)); |
}else if(guiMode == GuiMode::TEXTURE_MAPPING){ |
||||
if (hitJoint != NULL) { |
bool bSurfaceSelected = false; |
||||
textureEditor.unselectAllJoints(); |
CircleJoint * hitJoint = |
||||
|
textureEditor.hitTestJoints(ofVec2f(args.x, args.y)); |
||||
hitJoint->select(); |
if(hitJoint != NULL){ |
||||
hitJoint->startDrag(); |
textureEditor.unselectAllJoints(); |
||||
bSurfaceSelected = true; |
|
||||
|
hitJoint->select(); |
||||
int jointIndex = -1; |
hitJoint->startDrag(); |
||||
for (int i = 0; i < textureEditor.getJoints().size(); i++) { |
bSurfaceSelected = true; |
||||
if (textureEditor.getJoints()[i] == hitJoint) { |
|
||||
jointIndex = i; |
int jointIndex = -1; |
||||
break; |
for(int i = 0; i < textureEditor.getJoints().size(); i++){ |
||||
} |
if(textureEditor.getJoints()[i] == hitJoint){ |
||||
} |
jointIndex = i; |
||||
|
break; |
||||
if (jointIndex != -1) { |
} |
||||
_cmdManager->exec(new MvTexCoordCmd(jointIndex, &textureEditor)); |
} |
||||
} |
|
||||
|
if(jointIndex != -1){ |
||||
} else { |
_cmdManager->exec(new MvTexCoordCmd(jointIndex, &textureEditor)); |
||||
textureEditor.unselectAllJoints(); |
} |
||||
} |
|
||||
|
}else{ |
||||
if (surfaceManager->getSelectedSurface() != NULL && !bSurfaceSelected) { |
textureEditor.unselectAllJoints(); |
||||
// hittest texture area to see if we are hitting the texture surface
|
} |
||||
if (surfaceManager->getSelectedSurface()->getTextureHitArea().inside( |
|
||||
args.x, args.y)) { |
if(surfaceManager->getSelectedSurface() != NULL && !bSurfaceSelected){ |
||||
|
// hittest texture area to see if we are hitting the texture surface
|
||||
// TODO: move these to a separate routine
|
if(surfaceManager->getSelectedSurface()->getTextureHitArea().inside( |
||||
clickPosition = ofVec2f(args.x, args.y); |
args.x, args.y)){ |
||||
startDrag(); |
|
||||
|
// TODO: move these to a separate routine
|
||||
_cmdManager->exec(new MvAllTexCoordsCmd( |
clickPosition = ofVec2f(args.x, args.y); |
||||
surfaceManager->getSelectedSurface(), |
startDrag(); |
||||
&textureEditor)); |
|
||||
|
_cmdManager->exec(new MvAllTexCoordsCmd( |
||||
} |
surfaceManager->getSelectedSurface(), |
||||
} |
&textureEditor)); |
||||
|
|
||||
} else if (guiMode == GuiMode::PROJECTION_MAPPING) { |
} |
||||
bool bSurfaceSelected = false; |
} |
||||
|
|
||||
CircleJoint* hitJoint = |
}else if(guiMode == GuiMode::PROJECTION_MAPPING){ |
||||
projectionEditor.hitTestJoints(ofVec2f(args.x, args.y)); |
bool bSurfaceSelected = false; |
||||
if (hitJoint != NULL) { |
|
||||
projectionEditor.unselectAllJoints(); |
CircleJoint * hitJoint = |
||||
hitJoint->select(); |
projectionEditor.hitTestJoints(ofVec2f(args.x, args.y)); |
||||
hitJoint->startDrag(); |
if(hitJoint != NULL){ |
||||
int jointVertIndex = 0; |
projectionEditor.unselectAllJoints(); |
||||
for (int i = 0; i < projectionEditor.getJoints()->size(); i++) { |
hitJoint->select(); |
||||
if ((*projectionEditor.getJoints())[i] == hitJoint) { |
hitJoint->startDrag(); |
||||
jointVertIndex = i; |
int jointVertIndex = 0; |
||||
break; |
for(int i = 0; i < projectionEditor.getJoints()->size(); i++){ |
||||
} |
if((*projectionEditor.getJoints())[i] == hitJoint){ |
||||
} |
jointVertIndex = i; |
||||
_cmdManager->exec(new MvSurfaceVertCmd( |
break; |
||||
jointVertIndex, |
} |
||||
surfaceManager->getSelectedSurface(), |
} |
||||
&projectionEditor)); |
_cmdManager->exec(new MvSurfaceVertCmd( |
||||
bSurfaceSelected = true; |
jointVertIndex, |
||||
} |
surfaceManager->getSelectedSurface(), |
||||
|
&projectionEditor)); |
||||
// attempt to select surface, loop from end to beginning
|
bSurfaceSelected = true; |
||||
if (!bSurfaceSelected) { |
} |
||||
for (int i = surfaceManager->size() - 1; i >= 0; i--) { |
|
||||
if (surfaceManager->getSurface(i)->hitTest(ofVec2f(args.x, args.y))) { |
// attempt to select surface, loop from end to beginning
|
||||
|
if(!bSurfaceSelected){ |
||||
// Do not repeat this command if attempting to select an
|
for(int i = surfaceManager->size() - 1; i >= 0; i--){ |
||||
// already selected surface.
|
if(surfaceManager->getSurface(i)->hitTest(ofVec2f(args.x, args.y))){ |
||||
if (surfaceManager->getSelectedSurface() != surfaceManager->getSurface(i)){ |
|
||||
_cmdManager->exec(new SelSurfaceCmd( |
// Do not repeat this command if attempting to select an
|
||||
surfaceManager, |
// already selected surface.
|
||||
surfaceManager->getSurface(i), |
if(surfaceManager->getSelectedSurface() != surfaceManager->getSurface(i)){ |
||||
&projectionEditor)); |
_cmdManager->exec(new SelSurfaceCmd( |
||||
} |
surfaceManager, |
||||
|
surfaceManager->getSurface(i), |
||||
bSurfaceSelected = true; |
&projectionEditor)); |
||||
break; |
} |
||||
} |
|
||||
} |
bSurfaceSelected = true; |
||||
} |
break; |
||||
|
} |
||||
if (bSurfaceSelected && hitJoint == NULL) { |
} |
||||
|
} |
||||
// if not hitting the joints, start drag only if
|
|
||||
// we have a selected surface
|
if(bSurfaceSelected && hitJoint == NULL){ |
||||
clickPosition = ofVec2f(args.x, args.y); |
|
||||
startDrag(); |
// if not hitting the joints, start drag only if
|
||||
|
// we have a selected surface
|
||||
_cmdManager->exec( |
clickPosition = ofVec2f(args.x, args.y); |
||||
new MvSurfaceCmd( |
startDrag(); |
||||
surfaceManager->getSelectedSurface(), |
|
||||
&projectionEditor)); |
_cmdManager->exec( |
||||
} |
new MvSurfaceCmd( |
||||
|
surfaceManager->getSelectedSurface(), |
||||
if (!bSurfaceSelected) { |
&projectionEditor)); |
||||
// unselect if no surface selected
|
} |
||||
projectionEditor.clearJoints(); |
|
||||
surfaceManager->deselectSurface(); |
if(!bSurfaceSelected){ |
||||
} |
// unselect if no surface selected
|
||||
} else if (guiMode == GuiMode::SOURCE_SELECTION) { |
projectionEditor.clearJoints(); |
||||
} |
surfaceManager->deselectSurface(); |
||||
} |
} |
||||
|
}else if(guiMode == GuiMode::SOURCE_SELECTION){} |
||||
void SurfaceManagerGui::mouseReleased(ofMouseEventArgs& args) { |
} |
||||
stopDrag(); |
|
||||
projectionEditor.stopDragJoints(); |
void SurfaceManagerGui::mouseReleased(ofMouseEventArgs & args){ |
||||
textureEditor.stopDragJoints(); |
stopDrag(); |
||||
|
projectionEditor.stopDragJoints(); |
||||
// Check if surface has moved
|
textureEditor.stopDragJoints(); |
||||
if (surfaceManager->getSelectedSurface()){ |
|
||||
if (!surfaceManager->getSelectedSurface()->getMoved()) { |
// Check if surface has moved
|
||||
_cmdManager->undo(); |
if(surfaceManager->getSelectedSurface()){ |
||||
} |
if(!surfaceManager->getSelectedSurface()->getMoved()){ |
||||
} |
_cmdManager->undo(); |
||||
|
} |
||||
} |
} |
||||
|
|
||||
void SurfaceManagerGui::mouseDragged(ofMouseEventArgs& args) { |
} |
||||
if (bDrag) { |
|
||||
ofVec2f mousePosition = ofVec2f(args.x, args.y); |
void SurfaceManagerGui::mouseDragged(ofMouseEventArgs & args){ |
||||
ofVec2f distance = mousePosition - clickPosition; |
if(bDrag){ |
||||
|
ofVec2f mousePosition = ofVec2f(args.x, args.y); |
||||
if (guiMode == GuiMode::PROJECTION_MAPPING) { |
ofVec2f distance = mousePosition - clickPosition; |
||||
// add this distance to all vertices in surface
|
|
||||
projectionEditor.moveSelectedSurface(distance); |
if(guiMode == GuiMode::PROJECTION_MAPPING){ |
||||
} else if (guiMode == GuiMode::TEXTURE_MAPPING) { |
// add this distance to all vertices in surface
|
||||
textureEditor.moveTexCoords(distance); |
projectionEditor.moveSelectedSurface(distance); |
||||
} |
}else if(guiMode == GuiMode::TEXTURE_MAPPING){ |
||||
clickPosition = mousePosition; |
textureEditor.moveTexCoords(distance); |
||||
} |
} |
||||
} |
clickPosition = mousePosition; |
||||
|
} |
||||
void SurfaceManagerGui::setSurfaceManager(SurfaceManager* newSurfaceManager) { |
} |
||||
surfaceManager = newSurfaceManager; |
|
||||
projectionEditor.setSurfaceManager(surfaceManager); |
void SurfaceManagerGui::setSurfaceManager(SurfaceManager * newSurfaceManager){ |
||||
sourcesEditor.setSurfaceManager(surfaceManager); |
surfaceManager = newSurfaceManager; |
||||
} |
projectionEditor.setSurfaceManager(surfaceManager); |
||||
|
sourcesEditor.setSurfaceManager(surfaceManager); |
||||
// Set external media server so we can access it from wherever we need
|
} |
||||
void SurfaceManagerGui::setMediaServer(MediaServer* newMediaServer) { |
|
||||
mediaServer = newMediaServer; |
// Set external media server so we can access it from wherever we need
|
||||
// Set the media server of the sources editor here
|
void SurfaceManagerGui::setMediaServer(MediaServer * newMediaServer){ |
||||
sourcesEditor.setMediaServer(mediaServer); |
mediaServer = newMediaServer; |
||||
} |
// Set the media server of the sources editor here
|
||||
|
sourcesEditor.setMediaServer(mediaServer); |
||||
void SurfaceManagerGui::setCmdManager(CmdManager * cmdManager){ |
} |
||||
_cmdManager = cmdManager; |
|
||||
sourcesEditor.setCmdManager(_cmdManager); |
void SurfaceManagerGui::setCmdManager(CmdManager * cmdManager){ |
||||
} |
_cmdManager = cmdManager; |
||||
|
sourcesEditor.setCmdManager(_cmdManager); |
||||
void SurfaceManagerGui::setMode(int newGuiMode) { |
} |
||||
if (newGuiMode != GuiMode::NONE && newGuiMode != GuiMode::TEXTURE_MAPPING && |
|
||||
newGuiMode != GuiMode::PROJECTION_MAPPING && |
void SurfaceManagerGui::setMode(int newGuiMode){ |
||||
newGuiMode != GuiMode::SOURCE_SELECTION) { |
if(newGuiMode != GuiMode::NONE && newGuiMode != GuiMode::TEXTURE_MAPPING && |
||||
throw std::runtime_error("Trying to set invalid mode."); |
newGuiMode != GuiMode::PROJECTION_MAPPING && |
||||
} |
newGuiMode != GuiMode::SOURCE_SELECTION){ |
||||
|
throw std::runtime_error("Trying to set invalid mode."); |
||||
if (newGuiMode == GuiMode::NONE) { |
} |
||||
ofHideCursor(); |
|
||||
} else { |
if(newGuiMode == GuiMode::NONE){ |
||||
ofShowCursor(); |
ofHideCursor(); |
||||
} |
}else{ |
||||
|
ofShowCursor(); |
||||
guiMode = newGuiMode; |
} |
||||
|
|
||||
if (guiMode == GuiMode::SOURCE_SELECTION) { |
guiMode = newGuiMode; |
||||
sourcesEditor.enable(); |
|
||||
//string sourceName = surfaceManager->getSelectedSurfaceSourceName();
|
if(guiMode == GuiMode::SOURCE_SELECTION){ |
||||
//sourcesEditor.selectImageSourceRadioButton(sourceName);
|
sourcesEditor.enable(); |
||||
} else { |
//string sourceName = surfaceManager->getSelectedSurfaceSourceName();
|
||||
sourcesEditor.disable(); |
//sourcesEditor.selectImageSourceRadioButton(sourceName);
|
||||
} |
}else{ |
||||
|
sourcesEditor.disable(); |
||||
if (guiMode == GuiMode::TEXTURE_MAPPING) { |
} |
||||
textureEditor.enable(); |
|
||||
// refresh texture editor surface reference
|
if(guiMode == GuiMode::TEXTURE_MAPPING){ |
||||
textureEditor.setSurface(surfaceManager->getSelectedSurface()); |
textureEditor.enable(); |
||||
} else { |
// refresh texture editor surface reference
|
||||
textureEditor.disable(); |
textureEditor.setSurface(surfaceManager->getSelectedSurface()); |
||||
} |
}else{ |
||||
|
textureEditor.disable(); |
||||
if (guiMode == GuiMode::PROJECTION_MAPPING) { |
} |
||||
projectionEditor.enable(); |
|
||||
} else { |
if(guiMode == GuiMode::PROJECTION_MAPPING){ |
||||
projectionEditor.disable(); |
projectionEditor.enable(); |
||||
} |
}else{ |
||||
} |
projectionEditor.disable(); |
||||
|
} |
||||
int SurfaceManagerGui::getMode(){ |
} |
||||
return guiMode; |
|
||||
} |
int SurfaceManagerGui::getMode(){ |
||||
|
return guiMode; |
||||
void SurfaceManagerGui::drawSelectedSurfaceHighlight() { |
} |
||||
if (surfaceManager->getSelectedSurface() == NULL) return; |
|
||||
ofPolyline line = surfaceManager->getSelectedSurface()->getHitArea(); |
void SurfaceManagerGui::drawSelectedSurfaceHighlight(){ |
||||
ofPushStyle(); |
if(surfaceManager->getSelectedSurface() == NULL){ |
||||
ofSetLineWidth(1); |
return; |
||||
ofSetColor(255, 255, 255, 255); |
} |
||||
line.draw(); |
ofPolyline line = surfaceManager->getSelectedSurface()->getHitArea(); |
||||
ofPopStyle(); |
ofPushStyle(); |
||||
} |
ofSetLineWidth(1); |
||||
|
ofSetColor(255, 255, 255, 255); |
||||
void SurfaceManagerGui::drawSelectedSurfaceTextureHighlight() { |
line.draw(); |
||||
if (surfaceManager->getSelectedSurface() == NULL) return; |
ofPopStyle(); |
||||
ofPolyline line = surfaceManager->getSelectedSurface()->getTextureHitArea(); |
} |
||||
ofPushStyle(); |
|
||||
ofSetLineWidth(1); |
void SurfaceManagerGui::drawSelectedSurfaceTextureHighlight(){ |
||||
ofSetColor(255, 255, 0, 255); |
if(surfaceManager->getSelectedSurface() == NULL){ |
||||
line.draw(); |
return; |
||||
ofPopStyle(); |
} |
||||
} |
ofPolyline line = surfaceManager->getSelectedSurface()->getTextureHitArea(); |
||||
|
ofPushStyle(); |
||||
void SurfaceManagerGui::startDrag() { bDrag = true; } |
ofSetLineWidth(1); |
||||
|
ofSetColor(255, 255, 0, 255); |
||||
void SurfaceManagerGui::stopDrag() { bDrag = false; } |
line.draw(); |
||||
} |
ofPopStyle(); |
||||
} |
} |
||||
|
|
||||
|
void SurfaceManagerGui::startDrag(){ |
||||
|
bDrag = true; |
||||
|
} |
||||
|
|
||||
|
void SurfaceManagerGui::stopDrag(){ |
||||
|
bDrag = false; |
||||
|
} |
||||
|
|
||||
|
} // namespace piMapper
|
||||
|
} // namespace ofx
|
@ -1,9 +1,13 @@ |
|||||
#pragma once |
#pragma once |
||||
|
|
||||
namespace ofx { |
namespace ofx { |
||||
namespace piMapper { |
namespace piMapper { |
||||
struct SurfaceType { |
|
||||
enum { TRIANGLE_SURFACE, QUAD_SURFACE }; |
struct SurfaceType { |
||||
}; |
enum { |
||||
} |
TRIANGLE_SURFACE, QUAD_SURFACE |
||||
} |
}; |
||||
|
}; |
||||
|
|
||||
|
} // namespace piMapper
|
||||
|
} // namespace ofx
|
@ -1,270 +1,289 @@ |
|||||
#include "ProjectionEditor.h" |
#include "ProjectionEditor.h" |
||||
|
|
||||
namespace ofx { |
namespace ofx { |
||||
namespace piMapper { |
namespace piMapper { |
||||
ProjectionEditor::ProjectionEditor() { |
|
||||
surfaceManager = NULL; |
ProjectionEditor::ProjectionEditor(){ |
||||
bShiftKeyDown = false; |
surfaceManager = NULL; |
||||
fSnapDistance = 10.0f; |
bShiftKeyDown = false; |
||||
enable(); |
fSnapDistance = 10.0f; |
||||
} |
enable(); |
||||
|
} |
||||
ProjectionEditor::~ProjectionEditor() { |
|
||||
clearJoints(); |
ProjectionEditor::~ProjectionEditor(){ |
||||
surfaceManager = NULL; |
clearJoints(); |
||||
disable(); |
surfaceManager = NULL; |
||||
} |
disable(); |
||||
|
} |
||||
void ProjectionEditor::registerAppEvents() { |
|
||||
ofAddListener(ofEvents().update, this, &ProjectionEditor::update); |
void ProjectionEditor::registerAppEvents(){ |
||||
ofAddListener(ofEvents().messageEvent, this, &ProjectionEditor::gotMessage); |
ofAddListener(ofEvents().update, this, &ProjectionEditor::update); |
||||
} |
ofAddListener(ofEvents().messageEvent, this, &ProjectionEditor::gotMessage); |
||||
|
} |
||||
void ProjectionEditor::unregisterAppEvents() { |
|
||||
ofRemoveListener(ofEvents().update, this, &ProjectionEditor::update); |
void ProjectionEditor::unregisterAppEvents(){ |
||||
ofRemoveListener(ofEvents().messageEvent, this, |
ofRemoveListener(ofEvents().update, this, &ProjectionEditor::update); |
||||
&ProjectionEditor::gotMessage); |
ofRemoveListener(ofEvents().messageEvent, this, |
||||
} |
&ProjectionEditor::gotMessage); |
||||
|
} |
||||
void ProjectionEditor::registerMouseEvents() { |
|
||||
ofAddListener(ofEvents().mouseDragged, this, &ProjectionEditor::mouseDragged); |
void ProjectionEditor::registerMouseEvents(){ |
||||
} |
ofAddListener(ofEvents().mouseDragged, this, &ProjectionEditor::mouseDragged); |
||||
|
} |
||||
void ProjectionEditor::unregisterMouseEvents() { |
|
||||
ofRemoveListener(ofEvents().mouseDragged, this, |
void ProjectionEditor::unregisterMouseEvents(){ |
||||
&ProjectionEditor::mouseDragged); |
ofRemoveListener(ofEvents().mouseDragged, this, |
||||
} |
&ProjectionEditor::mouseDragged); |
||||
|
} |
||||
void ProjectionEditor::registerKeyEvents() { |
|
||||
ofAddListener(ofEvents().keyPressed, this, &ProjectionEditor::keyPressed); |
void ProjectionEditor::registerKeyEvents(){ |
||||
ofAddListener(ofEvents().keyReleased, this, &ProjectionEditor::keyReleased); |
ofAddListener(ofEvents().keyPressed, this, &ProjectionEditor::keyPressed); |
||||
} |
ofAddListener(ofEvents().keyReleased, this, &ProjectionEditor::keyReleased); |
||||
|
} |
||||
void ProjectionEditor::unregisterKeyEvents() { |
|
||||
ofRemoveListener(ofEvents().keyPressed, this, &ProjectionEditor::keyPressed); |
void ProjectionEditor::unregisterKeyEvents(){ |
||||
ofRemoveListener(ofEvents().keyReleased, this, |
ofRemoveListener(ofEvents().keyPressed, this, &ProjectionEditor::keyPressed); |
||||
&ProjectionEditor::keyReleased); |
ofRemoveListener(ofEvents().keyReleased, this, |
||||
} |
&ProjectionEditor::keyReleased); |
||||
|
} |
||||
void ProjectionEditor::enable() { |
|
||||
registerAppEvents(); |
void ProjectionEditor::enable(){ |
||||
registerMouseEvents(); |
registerAppEvents(); |
||||
registerKeyEvents(); |
registerMouseEvents(); |
||||
} |
registerKeyEvents(); |
||||
|
} |
||||
void ProjectionEditor::disable() { |
|
||||
unregisterAppEvents(); |
void ProjectionEditor::disable(){ |
||||
unregisterMouseEvents(); |
unregisterAppEvents(); |
||||
unregisterKeyEvents(); |
unregisterMouseEvents(); |
||||
} |
unregisterKeyEvents(); |
||||
|
} |
||||
void ProjectionEditor::update(ofEventArgs& args) { |
|
||||
// update surface if one of the joints is being dragged
|
void ProjectionEditor::update(ofEventArgs & args){ |
||||
for (int i = 0; i < joints.size(); i++) { |
// update surface if one of the joints is being dragged
|
||||
if (joints[i]->isDragged() || joints[i]->isSelected()) { |
for(int i = 0; i < joints.size(); i++){ |
||||
if (surfaceManager->getSelectedSurface() != NULL) { |
if(joints[i]->isDragged() || joints[i]->isSelected()){ |
||||
// update vertex to new location
|
if(surfaceManager->getSelectedSurface() != NULL){ |
||||
surfaceManager->getSelectedSurface()->setVertex(i, joints[i]->position); |
// update vertex to new location
|
||||
} else { |
surfaceManager->getSelectedSurface()->setVertex(i, joints[i]->position); |
||||
// clear joints if there is no surface selected
|
}else{ |
||||
// as the remove selected surface in the surface manager
|
// clear joints if there is no surface selected
|
||||
// is not supposed to access joints here
|
// as the remove selected surface in the surface manager
|
||||
joints.clear(); |
// is not supposed to access joints here
|
||||
} |
joints.clear(); |
||||
break; |
} |
||||
} |
break; |
||||
} |
} |
||||
} |
} |
||||
|
} |
||||
void ProjectionEditor::draw() { |
|
||||
if (surfaceManager == NULL) return; |
void ProjectionEditor::draw(){ |
||||
if (surfaceManager->getSelectedSurface() == NULL) return; |
if(surfaceManager == NULL){ |
||||
if (joints.size() <= 0) createJoints(); |
return; |
||||
drawJoints(); |
} |
||||
} |
if(surfaceManager->getSelectedSurface() == NULL){ |
||||
|
return; |
||||
void ProjectionEditor::mouseDragged(ofMouseEventArgs& args) { |
} |
||||
ofVec2f mousePosition = ofVec2f(args.x, args.y); |
if(joints.size() <= 0){ |
||||
|
createJoints(); |
||||
// Collect all vertices of the projection surfaces
|
} |
||||
vector<ofVec3f*> allVertices; |
drawJoints(); |
||||
for (int i = 0; i < surfaceManager->size(); i++) { |
} |
||||
BaseSurface* surface = surfaceManager->getSurface(i); |
|
||||
if (surface == surfaceManager->getSelectedSurface()) { |
void ProjectionEditor::mouseDragged(ofMouseEventArgs & args){ |
||||
continue; // Don't add vertices of selected surface
|
ofVec2f mousePosition = ofVec2f(args.x, args.y); |
||||
} |
|
||||
for (int j = 0; j < surface->getVertices().size(); j++) { |
// Collect all vertices of the projection surfaces
|
||||
allVertices.push_back(&surface->getVertices()[j]); |
vector <ofVec3f *> allVertices; |
||||
} |
for(int i = 0; i < surfaceManager->size(); i++){ |
||||
} |
BaseSurface * surface = surfaceManager->getSurface(i); |
||||
|
if(surface == surfaceManager->getSelectedSurface()){ |
||||
// Snap currently dragged joint to nearest vertex
|
continue; // Don't add vertices of selected surface
|
||||
for (int i = 0; i < joints.size(); i++) { |
} |
||||
if (joints[i]->isDragged()) { |
for(int j = 0; j < surface->getVertices().size(); j++){ |
||||
// Snap it!
|
allVertices.push_back(&surface->getVertices()[j]); |
||||
for (int j = 0; j < allVertices.size(); j++) { |
} |
||||
float distance = mousePosition.distance(*allVertices[j]); |
} |
||||
// cout << "distance: " << distance << endl;
|
|
||||
if (distance < fSnapDistance) { |
// Snap currently dragged joint to nearest vertex
|
||||
joints[i]->position = *allVertices[j]; |
for(int i = 0; i < joints.size(); i++){ |
||||
ofVec2f clickDistance = joints[i]->position - ofVec2f(args.x, args.y); |
if(joints[i]->isDragged()){ |
||||
joints[i]->setClickDistance(clickDistance); |
// Snap it!
|
||||
break; |
for(int j = 0; j < allVertices.size(); j++){ |
||||
} |
float distance = mousePosition.distance(*allVertices[j]); |
||||
} |
// cout << "distance: " << distance << endl;
|
||||
} |
if(distance < fSnapDistance){ |
||||
} |
joints[i]->position = *allVertices[j]; |
||||
} |
ofVec2f clickDistance = joints[i]->position - ofVec2f(args.x, args.y); |
||||
|
joints[i]->setClickDistance(clickDistance); |
||||
void ProjectionEditor::keyPressed(ofKeyEventArgs& args) { |
break; |
||||
int key = args.key; |
} |
||||
float moveStep; |
} |
||||
|
} |
||||
if (bShiftKeyDown) |
} |
||||
moveStep = 10.0f; |
} |
||||
else |
|
||||
moveStep = 0.5f; |
void ProjectionEditor::keyPressed(ofKeyEventArgs & args){ |
||||
|
int key = args.key; |
||||
switch (key) { |
float moveStep; |
||||
case OF_KEY_LEFT: |
|
||||
moveSelection(ofVec2f(-moveStep, 0.0f)); |
if(bShiftKeyDown){ |
||||
break; |
moveStep = 10.0f; |
||||
case OF_KEY_RIGHT: |
}else{ |
||||
moveSelection(ofVec2f(moveStep, 0.0f)); |
moveStep = 0.5f; |
||||
break; |
} |
||||
case OF_KEY_UP: |
|
||||
moveSelection(ofVec2f(0.0f, -moveStep)); |
switch(key){ |
||||
break; |
case OF_KEY_LEFT: |
||||
case OF_KEY_DOWN: |
moveSelection(ofVec2f(-moveStep, 0.0f)); |
||||
moveSelection(ofVec2f(0.0f, moveStep)); |
break; |
||||
break; |
|
||||
case OF_KEY_SHIFT: |
case OF_KEY_RIGHT: |
||||
bShiftKeyDown = true; |
moveSelection(ofVec2f(moveStep, 0.0f)); |
||||
break; |
break; |
||||
} |
|
||||
} |
case OF_KEY_UP: |
||||
|
moveSelection(ofVec2f(0.0f, -moveStep)); |
||||
void ProjectionEditor::keyReleased(ofKeyEventArgs& args) { |
break; |
||||
int key = args.key; |
|
||||
switch (key) { |
case OF_KEY_DOWN: |
||||
case OF_KEY_SHIFT: |
moveSelection(ofVec2f(0.0f, moveStep)); |
||||
bShiftKeyDown = false; |
break; |
||||
break; |
|
||||
} |
case OF_KEY_SHIFT: |
||||
} |
bShiftKeyDown = true; |
||||
|
break; |
||||
void ProjectionEditor::gotMessage(ofMessage& msg) { |
} |
||||
if (msg.message == "surfaceSelected") { |
} |
||||
// refresh gui
|
|
||||
clearJoints(); |
void ProjectionEditor::keyReleased(ofKeyEventArgs & args){ |
||||
createJoints(); |
int key = args.key; |
||||
} |
switch(key){ |
||||
} |
case OF_KEY_SHIFT: |
||||
|
bShiftKeyDown = false; |
||||
void ProjectionEditor::setSurfaceManager(SurfaceManager* newSurfaceManager) { |
break; |
||||
surfaceManager = newSurfaceManager; |
} |
||||
} |
} |
||||
|
|
||||
void ProjectionEditor::clearJoints() { |
void ProjectionEditor::gotMessage(ofMessage & msg){ |
||||
while (joints.size()) { |
if(msg.message == "surfaceSelected"){ |
||||
delete joints.back(); |
// refresh gui
|
||||
joints.pop_back(); |
clearJoints(); |
||||
} |
createJoints(); |
||||
} |
} |
||||
|
} |
||||
void ProjectionEditor::createJoints() { |
|
||||
if (surfaceManager == NULL) return; |
void ProjectionEditor::setSurfaceManager(SurfaceManager * newSurfaceManager){ |
||||
clearJoints(); |
surfaceManager = newSurfaceManager; |
||||
|
} |
||||
if (surfaceManager->getSelectedSurface() == NULL) { |
|
||||
ofLog(OF_LOG_WARNING, "Trying to create joints while no surface selected."); |
void ProjectionEditor::clearJoints(){ |
||||
return; |
while(joints.size()){ |
||||
} |
delete joints.back(); |
||||
|
joints.pop_back(); |
||||
vector<ofVec3f>& vertices = |
} |
||||
surfaceManager->getSelectedSurface()->getVertices(); |
} |
||||
|
|
||||
for (int i = 0; i < vertices.size(); i++) { |
void ProjectionEditor::createJoints(){ |
||||
joints.push_back(new CircleJoint()); |
if(surfaceManager == NULL){ |
||||
joints.back()->position = ofVec2f(vertices[i].x, vertices[i].y); |
return; |
||||
} |
} |
||||
} |
clearJoints(); |
||||
|
|
||||
void ProjectionEditor::updateJoints() { |
if(surfaceManager->getSelectedSurface() == NULL){ |
||||
if (surfaceManager->getSelectedSurface()) { |
ofLog(OF_LOG_WARNING, "Trying to create joints while no surface selected."); |
||||
vector<ofVec3f>& vertices = |
return; |
||||
surfaceManager->getSelectedSurface()->getVertices(); |
} |
||||
for (int i = 0; i < vertices.size(); i++) { |
|
||||
joints[i]->position = ofVec2f(vertices[i].x, vertices[i].y); |
vector <ofVec3f> & vertices = |
||||
} |
surfaceManager->getSelectedSurface()->getVertices(); |
||||
} |
|
||||
|
for(int i = 0; i < vertices.size(); i++){ |
||||
} |
joints.push_back(new CircleJoint()); |
||||
|
joints.back()->position = ofVec2f(vertices[i].x, vertices[i].y); |
||||
void ProjectionEditor::unselectAllJoints() { |
} |
||||
for (int i = 0; i < joints.size(); i++) { |
} |
||||
joints[i]->unselect(); |
|
||||
} |
void ProjectionEditor::updateJoints(){ |
||||
} |
if(surfaceManager->getSelectedSurface()){ |
||||
|
vector <ofVec3f> & vertices = |
||||
void ProjectionEditor::moveSelectedSurface(ofVec2f by) { |
surfaceManager->getSelectedSurface()->getVertices(); |
||||
if (surfaceManager == NULL) return; |
for(int i = 0; i < vertices.size(); i++){ |
||||
if (surfaceManager->getSelectedSurface() == NULL) return; |
joints[i]->position = ofVec2f(vertices[i].x, vertices[i].y); |
||||
surfaceManager->getSelectedSurface()->moveBy(by); |
} |
||||
/*vector<ofVec3f>& vertices =
|
} |
||||
surfaceManager->getSelectedSurface()->getVertices(); |
|
||||
for (int i=0; i<vertices.size(); i++) { |
} |
||||
vertices[i] += by; |
|
||||
}*/ |
void ProjectionEditor::unselectAllJoints(){ |
||||
updateJoints(); |
for(int i = 0; i < joints.size(); i++){ |
||||
} |
joints[i]->unselect(); |
||||
|
} |
||||
void ProjectionEditor::stopDragJoints() { |
} |
||||
for (int i = 0; i < joints.size(); i++) { |
|
||||
joints[i]->stopDrag(); |
void ProjectionEditor::moveSelectedSurface(ofVec2f by){ |
||||
} |
if(surfaceManager == NULL){ |
||||
} |
return; |
||||
|
} |
||||
void ProjectionEditor::moveSelection(ofVec2f by) { |
if(surfaceManager->getSelectedSurface() == NULL){ |
||||
// check if joints selected
|
return; |
||||
bool bJointSelected = false; |
} |
||||
BaseJoint* selectedJoint; |
surfaceManager->getSelectedSurface()->moveBy(by); |
||||
for (int i = 0; i < joints.size(); i++) { |
/*vector<ofVec3f>& vertices =
|
||||
if (joints[i]->isSelected()) { |
surfaceManager->getSelectedSurface()->getVertices(); |
||||
bJointSelected = true; |
for (int i=0; i<vertices.size(); i++) { |
||||
selectedJoint = joints[i]; |
vertices[i] += by; |
||||
break; |
}*/ |
||||
} |
updateJoints(); |
||||
} |
} |
||||
|
|
||||
if (bJointSelected) { |
void ProjectionEditor::stopDragJoints(){ |
||||
selectedJoint->position += by; |
for(int i = 0; i < joints.size(); i++){ |
||||
} else { |
joints[i]->stopDrag(); |
||||
moveSelectedSurface(by); |
} |
||||
} |
} |
||||
} |
|
||||
|
void ProjectionEditor::moveSelection(ofVec2f by){ |
||||
void ProjectionEditor::setSnapDistance(float newSnapDistance) { |
// check if joints selected
|
||||
fSnapDistance = newSnapDistance; |
bool bJointSelected = false; |
||||
} |
BaseJoint * selectedJoint; |
||||
|
for(int i = 0; i < joints.size(); i++){ |
||||
CircleJoint* ProjectionEditor::hitTestJoints(ofVec2f pos) { |
if(joints[i]->isSelected()){ |
||||
for (int i = 0; i < joints.size(); i++) { |
bJointSelected = true; |
||||
if (joints[i]->hitTest(pos)) { |
selectedJoint = joints[i]; |
||||
return joints[i]; |
break; |
||||
} |
} |
||||
} |
} |
||||
return NULL; |
|
||||
} |
if(bJointSelected){ |
||||
|
selectedJoint->position += by; |
||||
vector<CircleJoint *> * ProjectionEditor::getJoints(){ |
}else{ |
||||
return &joints; |
moveSelectedSurface(by); |
||||
} |
} |
||||
|
} |
||||
void ProjectionEditor::drawJoints() { |
|
||||
for (int i = 0; i < joints.size(); i++) { |
void ProjectionEditor::setSnapDistance(float newSnapDistance){ |
||||
joints[i]->draw(); |
fSnapDistance = newSnapDistance; |
||||
} |
} |
||||
} |
|
||||
} |
CircleJoint * ProjectionEditor::hitTestJoints(ofVec2f pos){ |
||||
} |
for(int i = 0; i < joints.size(); i++){ |
||||
|
if(joints[i]->hitTest(pos)){ |
||||
|
return joints[i]; |
||||
|
} |
||||
|
} |
||||
|
return NULL; |
||||
|
} |
||||
|
|
||||
|
vector <CircleJoint *> * ProjectionEditor::getJoints(){ |
||||
|
return &joints; |
||||
|
} |
||||
|
|
||||
|
void ProjectionEditor::drawJoints(){ |
||||
|
for(int i = 0; i < joints.size(); i++){ |
||||
|
joints[i]->draw(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} // namespace piMapper
|
||||
|
} // namespace ofx
|
@ -1,199 +1,201 @@ |
|||||
#include "RadioList.h" |
#include "RadioList.h" |
||||
|
|
||||
namespace ofx{ |
namespace ofx { |
||||
namespace piMapper{ |
namespace piMapper { |
||||
RadioList::RadioList(){ |
|
||||
storedTitle = ""; |
RadioList::RadioList(){ |
||||
storedSelectedItem = 0; |
storedTitle = ""; |
||||
} |
storedSelectedItem = 0; |
||||
|
} |
||||
RadioList::RadioList(vector<string> & labels, vector<string> & values){ |
|
||||
RadioList(); |
RadioList::RadioList(vector <string> & labels, vector <string> & values){ |
||||
setup(labels, values); |
RadioList(); |
||||
} |
setup(labels, values); |
||||
|
} |
||||
RadioList::RadioList(string title, vector<string> & labels, vector<string> & values){ |
|
||||
RadioList(); |
RadioList::RadioList(string title, vector <string> & labels, vector <string> & values){ |
||||
setup(title, labels, values); |
RadioList(); |
||||
} |
setup(title, labels, values); |
||||
|
} |
||||
RadioList::~RadioList(){ |
|
||||
clear(); |
RadioList::~RadioList(){ |
||||
} |
clear(); |
||||
|
} |
||||
void RadioList::setup(vector<string> & labels, vector<string> & values){ |
|
||||
|
void RadioList::setup(vector <string> & labels, vector <string> & values){ |
||||
// Copy incomming labels for later use
|
|
||||
storedLabels = labels; |
// Copy incomming labels for later use
|
||||
storedValues = values; |
storedLabels = labels; |
||||
|
storedValues = values; |
||||
// Create toggles with labels from the labels arg
|
|
||||
int i; |
// Create toggles with labels from the labels arg
|
||||
for(i = 0; i < labels.size(); i++){ |
int i; |
||||
ofxToggle * toggle = new ofxToggle(); |
for(i = 0; i < labels.size(); i++){ |
||||
toggle->setup(false); |
ofxToggle * toggle = new ofxToggle(); |
||||
toggle->setName(labels[i]); |
toggle->setup(false); |
||||
toggle->addListener(this, &RadioList::onToggleClicked); |
toggle->setName(labels[i]); |
||||
guiGroup.add(toggle); |
toggle->addListener(this, &RadioList::onToggleClicked); |
||||
#if OF_VERSION_MAJOR == 0 && (OF_VERSION_MINOR >= 8 && OF_VERSION_PATCH >= 2) || (OF_VERSION_MINOR >= 9 && OF_VERSION_PATCH >= 0) |
guiGroup.add(toggle); |
||||
toggle->registerMouseEvents(); |
#if OF_VERSION_MAJOR == 0 && (OF_VERSION_MINOR >= 8 && OF_VERSION_PATCH >= 2) || (OF_VERSION_MINOR >= 9 && OF_VERSION_PATCH >= 0) |
||||
#endif |
toggle->registerMouseEvents(); |
||||
} |
#endif |
||||
} |
} |
||||
|
} |
||||
void RadioList::setup(string title, vector<string> & labels, vector<string> & values){ |
|
||||
|
void RadioList::setup(string title, vector <string> & labels, vector <string> & values){ |
||||
// Store title for later use
|
|
||||
storedTitle = title; |
// Store title for later use
|
||||
guiGroup.setName(title); |
storedTitle = title; |
||||
setup(labels, values); |
guiGroup.setName(title); |
||||
} |
setup(labels, values); |
||||
|
} |
||||
void RadioList::draw(){ |
|
||||
guiGroup.draw(); |
void RadioList::draw(){ |
||||
} |
guiGroup.draw(); |
||||
|
} |
||||
void RadioList::setTitle(string title){ |
|
||||
storedTitle = title; |
void RadioList::setTitle(string title){ |
||||
guiGroup.setName(title); |
storedTitle = title; |
||||
} |
guiGroup.setName(title); |
||||
|
} |
||||
void RadioList::setPosition(ofPoint p){ |
|
||||
guiGroup.setPosition(p); |
void RadioList::setPosition(ofPoint p){ |
||||
} |
guiGroup.setPosition(p); |
||||
|
} |
||||
void RadioList::setPosition(float x, float y){ |
|
||||
guiGroup.setPosition(x, y); |
void RadioList::setPosition(float x, float y){ |
||||
} |
guiGroup.setPosition(x, y); |
||||
|
} |
||||
void RadioList::selectItem(int index){ |
|
||||
if(index >= guiGroup.getNumControls()){ |
void RadioList::selectItem(int index){ |
||||
return; |
if(index >= guiGroup.getNumControls()){ |
||||
} |
return; |
||||
|
} |
||||
unselectAll(); |
|
||||
|
unselectAll(); |
||||
ofxToggle * toggle = static_cast<ofxToggle *>(guiGroup.getControl(index)); |
|
||||
toggle->removeListener(this, &RadioList::onToggleClicked); |
ofxToggle * toggle = static_cast <ofxToggle *>(guiGroup.getControl(index)); |
||||
*toggle = true; // Select the specific radio button
|
toggle->removeListener(this, &RadioList::onToggleClicked); |
||||
toggle->addListener(this, &RadioList::onToggleClicked); |
*toggle = true; // Select the specific radio button
|
||||
//string name = toggle->getName();
|
toggle->addListener(this, &RadioList::onToggleClicked); |
||||
// Throw event with value that is image path instead of name
|
//string name = toggle->getName();
|
||||
string value = storedValues[index]; |
// Throw event with value that is image path instead of name
|
||||
ofNotifyEvent(onRadioSelected, value, this); |
string value = storedValues[index]; |
||||
storedSelectedItem = index; |
ofNotifyEvent(onRadioSelected, value, this); |
||||
} |
storedSelectedItem = index; |
||||
|
} |
||||
bool RadioList::selectItemByValue(std::string itemValue){ |
|
||||
if(itemValue == ""){ |
bool RadioList::selectItemByValue(std::string itemValue){ |
||||
ofLogNotice("RadioList") << "Item value empty"; |
if(itemValue == ""){ |
||||
return false; |
ofLogNotice("RadioList") << "Item value empty"; |
||||
} |
return false; |
||||
unselectAll(); |
} |
||||
int itemIndex = -1; |
unselectAll(); |
||||
for(int i = 0; i < storedValues.size(); i++){ |
int itemIndex = -1; |
||||
if(itemValue == storedValues[i]){ |
for(int i = 0; i < storedValues.size(); i++){ |
||||
itemIndex = i; |
if(itemValue == storedValues[i]){ |
||||
break; |
itemIndex = i; |
||||
} |
break; |
||||
} |
} |
||||
if(itemIndex >= 0){ |
} |
||||
ofxToggle * toggle = static_cast<ofxToggle *>(guiGroup.getControl(itemIndex)); |
if(itemIndex >= 0){ |
||||
toggle->removeListener(this, &RadioList::onToggleClicked); |
ofxToggle * toggle = static_cast <ofxToggle *>(guiGroup.getControl(itemIndex)); |
||||
*toggle = true; // Select the specific radio button
|
toggle->removeListener(this, &RadioList::onToggleClicked); |
||||
toggle->addListener(this, &RadioList::onToggleClicked); |
*toggle = true; // Select the specific radio button
|
||||
return true; |
toggle->addListener(this, &RadioList::onToggleClicked); |
||||
} |
return true; |
||||
ofLogNotice("RadioList") << "Item with value " << itemValue << " not found"; |
} |
||||
return false; |
ofLogNotice("RadioList") << "Item with value " << itemValue << " not found"; |
||||
} |
return false; |
||||
|
} |
||||
void RadioList::enable(){ |
|
||||
if(guiGroup.getNumControls() > 0){ |
void RadioList::enable(){ |
||||
clear(); |
if(guiGroup.getNumControls() > 0){ |
||||
} |
clear(); |
||||
|
} |
||||
// Rebuild everyting
|
|
||||
setup(storedTitle, storedLabels, storedValues); |
// Rebuild everyting
|
||||
|
setup(storedTitle, storedLabels, storedValues); |
||||
// Select the stored selected item without throwing an event
|
|
||||
ofxToggle * toggle = static_cast<ofxToggle *>(guiGroup.getControl(storedSelectedItem)); |
// Select the stored selected item without throwing an event
|
||||
toggle->removeListener(this, &RadioList::onToggleClicked); |
ofxToggle * toggle = static_cast <ofxToggle *>(guiGroup.getControl(storedSelectedItem)); |
||||
*toggle = true; |
toggle->removeListener(this, &RadioList::onToggleClicked); |
||||
toggle->addListener(this, &RadioList::onToggleClicked); |
*toggle = true; |
||||
|
toggle->addListener(this, &RadioList::onToggleClicked); |
||||
cout << "num items after enable: " << guiGroup.getNumControls() << endl; |
|
||||
} |
cout << "num items after enable: " << guiGroup.getNumControls() << endl; |
||||
|
} |
||||
void RadioList::disable(){ |
|
||||
// Just remove everything
|
void RadioList::disable(){ |
||||
clear(); |
// Just remove everything
|
||||
} |
clear(); |
||||
|
} |
||||
void RadioList::clear(){ |
|
||||
int i; |
void RadioList::clear(){ |
||||
for(i = 0; i < guiGroup.getNumControls(); i++){ |
int i; |
||||
ofxToggle * toggle = static_cast<ofxToggle *>(guiGroup.getControl(i)); |
for(i = 0; i < guiGroup.getNumControls(); i++){ |
||||
toggle->removeListener(this, &RadioList::onToggleClicked); |
ofxToggle * toggle = static_cast <ofxToggle *>(guiGroup.getControl(i)); |
||||
delete toggle; |
toggle->removeListener(this, &RadioList::onToggleClicked); |
||||
} |
delete toggle; |
||||
guiGroup.clear(); |
} |
||||
} |
guiGroup.clear(); |
||||
|
} |
||||
void RadioList::unselectAll(){ |
|
||||
int i; |
void RadioList::unselectAll(){ |
||||
for(i = 0; i < guiGroup.getNumControls(); i++){ |
int i; |
||||
ofxToggle * toggle = static_cast<ofxToggle *>(guiGroup.getControl(i)); |
for(i = 0; i < guiGroup.getNumControls(); i++){ |
||||
ofParameter<bool> * paramPtr = static_cast<ofParameter<bool> *>(&toggle->getParameter()); |
ofxToggle * toggle = static_cast <ofxToggle *>(guiGroup.getControl(i)); |
||||
toggle->removeListener(this, &RadioList::onToggleClicked); |
ofParameter <bool> * paramPtr = static_cast <ofParameter <bool> *>(&toggle->getParameter()); |
||||
*toggle = false; |
toggle->removeListener(this, &RadioList::onToggleClicked); |
||||
toggle->addListener(this, &RadioList::onToggleClicked); |
*toggle = false; |
||||
} |
toggle->addListener(this, &RadioList::onToggleClicked); |
||||
} |
} |
||||
|
} |
||||
ofPoint RadioList::getPosition(){ |
|
||||
return guiGroup.getPosition(); |
ofPoint RadioList::getPosition(){ |
||||
} |
return guiGroup.getPosition(); |
||||
|
} |
||||
float RadioList::getWidth(){ |
|
||||
return guiGroup.getWidth(); |
float RadioList::getWidth(){ |
||||
} |
return guiGroup.getWidth(); |
||||
|
} |
||||
float RadioList::getHeight(){ |
|
||||
return guiGroup.getHeight(); |
float RadioList::getHeight(){ |
||||
} |
return guiGroup.getHeight(); |
||||
|
} |
||||
string RadioList::getTitle(){ |
|
||||
return guiGroup.getName(); |
string RadioList::getTitle(){ |
||||
} |
return guiGroup.getName(); |
||||
|
} |
||||
string RadioList::getItemName(int index){ |
|
||||
if(index >= guiGroup.getNumControls()){ |
string RadioList::getItemName(int index){ |
||||
return ""; |
if(index >= guiGroup.getNumControls()){ |
||||
} |
return ""; |
||||
|
} |
||||
ofxToggle * toggle = static_cast<ofxToggle *>(guiGroup.getControl(index)); |
|
||||
return toggle->getName(); |
ofxToggle * toggle = static_cast <ofxToggle *>(guiGroup.getControl(index)); |
||||
} |
return toggle->getName(); |
||||
|
} |
||||
int RadioList::size(){ |
|
||||
return storedValues.size(); |
int RadioList::size(){ |
||||
} |
return storedValues.size(); |
||||
|
} |
||||
void RadioList::onToggleClicked(bool & toggleValue){ |
|
||||
unselectAll(); |
void RadioList::onToggleClicked(bool & toggleValue){ |
||||
|
unselectAll(); |
||||
// Search for the actual toggle triggering the event
|
|
||||
int i; |
// Search for the actual toggle triggering the event
|
||||
for(i = 0; i < guiGroup.getNumControls(); i++){ |
int i; |
||||
ofxToggle * toggle = static_cast<ofxToggle *>(guiGroup.getControl(i)); |
for(i = 0; i < guiGroup.getNumControls(); i++){ |
||||
ofParameter<bool> * paramPtr = static_cast<ofParameter<bool> *>(&toggle->getParameter()); |
ofxToggle * toggle = static_cast <ofxToggle *>(guiGroup.getControl(i)); |
||||
|
ofParameter <bool> * paramPtr = static_cast <ofParameter <bool> *>(&toggle->getParameter()); |
||||
if(&(paramPtr->get()) == &toggleValue){ |
|
||||
selectItem(i); |
if(&(paramPtr->get()) == &toggleValue){ |
||||
break; |
selectItem(i); |
||||
} |
break; |
||||
} |
} |
||||
} |
} |
||||
} // namespace piMapper
|
} |
||||
|
|
||||
|
} // namespace piMapper
|
||||
} // namespace ofx
|
} // namespace ofx
|
||||
|
@ -1,117 +1,117 @@ |
|||||
#include "ofxPiMapper.h" |
#include "ofxPiMapper.h" |
||||
|
|
||||
ofxPiMapper::ofxPiMapper() { |
ofxPiMapper::ofxPiMapper(){ |
||||
bShowInfo = false; |
bShowInfo = false; |
||||
isSetUp = false; |
isSetUp = false; |
||||
} |
} |
||||
|
|
||||
void ofxPiMapper::setup() { |
void ofxPiMapper::setup(){ |
||||
ofLogNotice("ofxPiMapper") << "Setting up..."; |
ofLogNotice("ofxPiMapper") << "Setting up..."; |
||||
|
|
||||
surfaceManager.setMediaServer(&mediaServer); |
surfaceManager.setMediaServer(&mediaServer); |
||||
gui.setMediaServer(&mediaServer); |
gui.setMediaServer(&mediaServer); |
||||
gui.setCmdManager(&cmdManager); |
gui.setCmdManager(&cmdManager); |
||||
|
|
||||
if (ofFile::doesFileExist(PIMAPPER_USER_SURFACES_XML_FILE)){ |
if(ofFile::doesFileExist(PIMAPPER_USER_SURFACES_XML_FILE)){ |
||||
ofLogNotice("ofxPiMapper") << "Loading user surfaces from " << PIMAPPER_USER_SURFACES_XML_FILE; |
ofLogNotice("ofxPiMapper") << "Loading user surfaces from " << PIMAPPER_USER_SURFACES_XML_FILE; |
||||
surfaceManager.loadXmlSettings(PIMAPPER_USER_SURFACES_XML_FILE); |
surfaceManager.loadXmlSettings(PIMAPPER_USER_SURFACES_XML_FILE); |
||||
} else { |
}else{ |
||||
ofLogNotice("ofxPiMapper") << "Loading default surfaces from " << PIMAPPER_DEF_SURFACES_XML_FILE; |
ofLogNotice("ofxPiMapper") << "Loading default surfaces from " << PIMAPPER_DEF_SURFACES_XML_FILE; |
||||
surfaceManager.loadXmlSettings(PIMAPPER_DEF_SURFACES_XML_FILE); |
surfaceManager.loadXmlSettings(PIMAPPER_DEF_SURFACES_XML_FILE); |
||||
} |
} |
||||
|
|
||||
gui.setSurfaceManager(&surfaceManager); |
gui.setSurfaceManager(&surfaceManager); |
||||
isSetUp = true; |
isSetUp = true; |
||||
ofLogNotice("ofxPiMapper") << "Done setting up"; |
ofLogNotice("ofxPiMapper") << "Done setting up"; |
||||
_application = new ofx::piMapper::Application(this); |
_application = new ofx::piMapper::Application(this); |
||||
} |
} |
||||
|
|
||||
void ofxPiMapper::draw() { |
void ofxPiMapper::draw(){ |
||||
if (!isSetUp) { |
if(!isSetUp){ |
||||
return; |
return; |
||||
} |
} |
||||
|
|
||||
gui.draw(); |
gui.draw(); |
||||
|
|
||||
if (bShowInfo){ |
if(bShowInfo){ |
||||
stringstream ss; |
stringstream ss; |
||||
ss << "There are 4 modes:\n\n"; |
ss << "There are 4 modes:\n\n"; |
||||
ss << " 1. Presentation mode\n"; |
ss << " 1. Presentation mode\n"; |
||||
ss << " 2. Texture mapping mode\n"; |
ss << " 2. Texture mapping mode\n"; |
||||
ss << " 3. Projection mapping mode\n"; |
ss << " 3. Projection mapping mode\n"; |
||||
ss << " 4. Source selection mode\n\n"; |
ss << " 4. Source selection mode\n\n"; |
||||
ss << "You can switch between the modes by using <1>, <2>, <3> and <4> " |
ss << "You can switch between the modes by using <1>, <2>, <3> and <4> " |
||||
"keys on the keyboard.\n\n"; |
"keys on the keyboard.\n\n"; |
||||
ss << "Press <t> to add new triangle surface\n"; |
ss << "Press <t> to add new triangle surface\n"; |
||||
ss << "Press <q> to add new quad surface\n"; |
ss << "Press <q> to add new quad surface\n"; |
||||
ss << "Press <s> to save the composition\n"; |
ss << "Press <s> to save the composition\n"; |
||||
ss << "Press <f> to toggle fullscreen\n"; |
ss << "Press <f> to toggle fullscreen\n"; |
||||
ss << "Press <i> to hide this message"; |
ss << "Press <i> to hide this message"; |
||||
ofDrawBitmapStringHighlight(ss.str(), 10, 20, |
ofDrawBitmapStringHighlight(ss.str(), 10, 20, |
||||
ofColor(0, 0, 0, 100), |
ofColor(0, 0, 0, 100), |
||||
ofColor(255, 255, 255, 200)); |
ofColor(255, 255, 255, 200)); |
||||
} |
} |
||||
|
|
||||
_application->draw(); |
_application->draw(); |
||||
} // draw
|
} // draw
|
||||
|
|
||||
void ofxPiMapper::registerFboSource(ofx::piMapper::FboSource & fboSource) { |
void ofxPiMapper::registerFboSource(ofx::piMapper::FboSource & fboSource){ |
||||
mediaServer.addFboSource(fboSource); |
mediaServer.addFboSource(fboSource); |
||||
} |
} |
||||
|
|
||||
void ofxPiMapper::addTriangleSurface() { |
void ofxPiMapper::addTriangleSurface(){ |
||||
int surfaceType = ofx::piMapper::SurfaceType::TRIANGLE_SURFACE; |
int surfaceType = ofx::piMapper::SurfaceType::TRIANGLE_SURFACE; |
||||
|
|
||||
vector<ofVec2f> vertices; |
vector <ofVec2f> vertices; |
||||
float margin = 50.0f; |
float margin = 50.0f; |
||||
vertices.push_back(ofVec2f((float)ofGetWidth() / 2.0f, margin)); |
vertices.push_back(ofVec2f((float)ofGetWidth() / 2.0f, margin)); |
||||
vertices.push_back(ofVec2f((float)ofGetWidth() - margin, (float)ofGetHeight() - margin)); |
vertices.push_back(ofVec2f((float)ofGetWidth() - margin, (float)ofGetHeight() - margin)); |
||||
vertices.push_back(ofVec2f(margin, (float)ofGetHeight() - margin)); |
vertices.push_back(ofVec2f(margin, (float)ofGetHeight() - margin)); |
||||
|
|
||||
vector<ofVec2f> texCoords; |
vector <ofVec2f> texCoords; |
||||
texCoords.push_back(ofVec2f(0.5f, 0.0f)); |
texCoords.push_back(ofVec2f(0.5f, 0.0f)); |
||||
texCoords.push_back(ofVec2f(1.0f, 1.0f)); |
texCoords.push_back(ofVec2f(1.0f, 1.0f)); |
||||
texCoords.push_back(ofVec2f(0.0f, 1.0f)); |
texCoords.push_back(ofVec2f(0.0f, 1.0f)); |
||||
surfaceManager.addSurface(surfaceType, vertices, texCoords); |
surfaceManager.addSurface(surfaceType, vertices, texCoords); |
||||
|
|
||||
// Select this surface right away
|
// Select this surface right away
|
||||
surfaceManager.selectSurface(surfaceManager.size() - 1); |
surfaceManager.selectSurface(surfaceManager.size() - 1); |
||||
} // addTriangleSurface
|
} // addTriangleSurface
|
||||
|
|
||||
void ofxPiMapper::addQuadSurface() { |
void ofxPiMapper::addQuadSurface(){ |
||||
int surfaceType = ofx::piMapper::SurfaceType::QUAD_SURFACE; |
int surfaceType = ofx::piMapper::SurfaceType::QUAD_SURFACE; |
||||
|
|
||||
vector<ofVec2f> vertices; |
vector <ofVec2f> vertices; |
||||
float margin = 50.0f; |
float margin = 50.0f; |
||||
vertices.push_back(ofVec2f(margin, margin)); |
vertices.push_back(ofVec2f(margin, margin)); |
||||
vertices.push_back(ofVec2f((float)ofGetWidth() - margin, margin)); |
vertices.push_back(ofVec2f((float)ofGetWidth() - margin, margin)); |
||||
vertices.push_back(ofVec2f((float)ofGetWidth() - margin, (float)ofGetHeight() - margin)); |
vertices.push_back(ofVec2f((float)ofGetWidth() - margin, (float)ofGetHeight() - margin)); |
||||
vertices.push_back(ofVec2f(margin, (float)ofGetHeight() - margin)); |
vertices.push_back(ofVec2f(margin, (float)ofGetHeight() - margin)); |
||||
|
|
||||
vector<ofVec2f> texCoords; |
vector <ofVec2f> texCoords; |
||||
texCoords.push_back(ofVec2f(ofVec2f(0.0f, 0.0f))); |
texCoords.push_back(ofVec2f(ofVec2f(0.0f, 0.0f))); |
||||
texCoords.push_back(ofVec2f(ofVec2f(1.0f, 0.0f))); |
texCoords.push_back(ofVec2f(ofVec2f(1.0f, 0.0f))); |
||||
texCoords.push_back(ofVec2f(ofVec2f(1.0f, 1.0f))); |
texCoords.push_back(ofVec2f(ofVec2f(1.0f, 1.0f))); |
||||
texCoords.push_back(ofVec2f(ofVec2f(0.0f, 1.0f))); |
texCoords.push_back(ofVec2f(ofVec2f(0.0f, 1.0f))); |
||||
|
|
||||
surfaceManager.addSurface(surfaceType, vertices, texCoords); |
surfaceManager.addSurface(surfaceType, vertices, texCoords); |
||||
|
|
||||
// select this surface right away
|
// select this surface right away
|
||||
surfaceManager.selectSurface(surfaceManager.size() - 1); |
surfaceManager.selectSurface(surfaceManager.size() - 1); |
||||
} // addQuadSurface
|
} // addQuadSurface
|
||||
|
|
||||
ofx::piMapper::CmdManager & ofxPiMapper::getCmdManager() { |
ofx::piMapper::CmdManager & ofxPiMapper::getCmdManager(){ |
||||
return cmdManager; |
return cmdManager; |
||||
} |
} |
||||
|
|
||||
ofx::piMapper::SurfaceManagerGui & ofxPiMapper::getGui() { |
ofx::piMapper::SurfaceManagerGui & ofxPiMapper::getGui(){ |
||||
return gui; |
return gui; |
||||
} |
} |
||||
|
|
||||
ofx::piMapper::MediaServer & ofxPiMapper::getMediaServer() { |
ofx::piMapper::MediaServer & ofxPiMapper::getMediaServer(){ |
||||
return mediaServer; |
return mediaServer; |
||||
} |
} |
||||
|
|
||||
ofx::piMapper::SurfaceManager & ofxPiMapper::getSurfaceManager() { |
ofx::piMapper::SurfaceManager & ofxPiMapper::getSurfaceManager(){ |
||||
return surfaceManager; |
return surfaceManager; |
||||
} |
} |
Loading…
Reference in new issue