Browse Source

Fix saving and loading `GridWarpSurface`s

Had to add rows and cols parameters in xml
master
Krisjanis Rijnieks 9 years ago
parent
commit
29bc46732e
  1. 23
      src/Application/SettingsLoader.cpp
  2. 4
      src/Surfaces/GridWarpSurface.h

23
src/Application/SettingsLoader.cpp

@ -167,6 +167,15 @@ bool SettingsLoader::save(SurfaceStack & surfaces, string fileName){
xmlSettings->pushTag("properties");
xmlSettings->addValue("perspectiveWarping", qs->getPerspectiveWarping());
xmlSettings->popTag(); // properties
}else if(surface->getType() == SurfaceType::GRID_WARP_SURFACE){
GridWarpSurface * gws = (GridWarpSurface *)surface;
if(!xmlSettings->tagExists("properties")){
xmlSettings->addTag("properties");
}
xmlSettings->pushTag("properties");
xmlSettings->addValue("gridCols", gws->getGridCols());
xmlSettings->addValue("gridRows", gws->getGridRows());
xmlSettings->popTag();
}
xmlSettings->popTag(); // surface
@ -375,10 +384,24 @@ BaseSurface * SettingsLoader::getGridWarpSurface(ofxXmlSettings * xmlSettings){
xmlSettings->popTag(); // texCoords
}
// Read properties
// Only perspective warping for now
int gridCols = 0;
int gridRows = 0;
if(xmlSettings->tagExists("properties")){
xmlSettings->pushTag("properties");
gridCols = xmlSettings->getValue("gridCols", 0);
gridRows = xmlSettings->getValue("gridRows", 0);
xmlSettings->popTag(); // properties
}
// Create and add quad surface
BaseSurface * gridWarpSurface =
SurfaceFactory::instance()->createSurface(
SurfaceType::GRID_WARP_SURFACE);
((GridWarpSurface *)gridWarpSurface)->setGridCols(gridCols);
((GridWarpSurface *)gridWarpSurface)->setGridRows(gridRows);
((GridWarpSurface *)gridWarpSurface)->createGridMesh();
gridWarpSurface->setVertices(vertices);
gridWarpSurface->setTexCoords(texCoords);

4
src/Surfaces/GridWarpSurface.h

@ -32,12 +32,12 @@ class GridWarpSurface : public BaseSurface {
void setTexCoords(vector<ofVec2f> t);
vector <ofVec3f> & getVertices();
vector <ofVec2f> & getTexCoords();
void createGridMesh();
private:
int _gridCols;
int _gridRows;
void createGridMesh();
};
} // namespace piMapper

Loading…
Cancel
Save