void ofx2DTrackedMappingController::update() { vidGrabber.update(); ofPtr<ofx2DMappingObject> mo = available_shapes.at(0); ofPtr<ofx2DMappingShape> shape = std::dynamic_pointer_cast<ofx2DMappingShape>(mo); if(vidGrabber.isFrameNew() && available_shapes.size() > 0 && shape) { colorImage.setFromPixels(vidGrabber.getPixels()); grayImage = colorImage; grayImage.threshold(threshold); contourFinder.findContours(grayImage, 20, (camWidth*camHeight)/3, 10, true); getProjector(0)->removeAllShapes(); for (unsigned int i = 0; i < contourFinder.blobs.size(); i++){ ofxCvBlob blob = contourFinder.blobs[i]; if(!blob.hole){ getProjector(0)->copyShape(shape); vector<ofPoint> pts = blob.pts; shape->dst[0] = blob.boundingRect.getTopLeft() / ofPoint(camWidth, camHeight); shape->dst[1] = blob.boundingRect.getTopRight() / ofPoint(camWidth, camHeight); shape->dst[2] = blob.boundingRect.getBottomRight() / ofPoint(camWidth, camHeight); shape->dst[3] = blob.boundingRect.getBottomLeft() / ofPoint(camWidth, camHeight); shape->polyline.clear(); for(auto p: pts){ shape->polyline.addVertex(p / ofPoint(camWidth, camHeight)); } vector<ofPoint> simplified_pts; calcSimplificaiton(shape->polyline, simplified_pts); shape->polyline.clear(); for(auto p: simplified_pts){ shape->polyline.addVertex(p); } } } } //check if any object template wants to be copied to stage for(auto &e: getOptions()){ if(e->pleaseCopyMe.get()){ e->pleaseCopyMe.set(false); getProjector(0)->copyShape(e); } } for(uint i = 0; i < projectors.size(); i++) { projectors[i].update(); } updateFbo(0); updateAreaFbo(0); }
Face<ndim> *Face<ndim>::init(const Face<ndim> *base, iter_t vbegin, iter_t vend, bool flipped) { CARVE_ASSERT(vbegin < vend); vertices.reserve((size_t)std::distance(vbegin, vend)); if (flipped) { std::reverse_copy(vbegin, vend, std::back_inserter(vertices)); plane_eqn = -base->plane_eqn; } else { std::copy(vbegin, vend, std::back_inserter(vertices)); plane_eqn = base->plane_eqn; } edges.clear(); edges.resize(nVertices(), NULL); aabb.fit(vertices.begin(), vertices.end(), vec_adapt_vertex_ptr()); untag(); int da = carve::geom::largestAxis(plane_eqn.N); project = getProjector(plane_eqn.N.v[da] > 0, da); unproject = getUnprojector(plane_eqn.N.v[da] > 0, da); return this; }
void SceneVis::updateScene(int num) { getProjector(0)->getVisScene()->updateViewerPos(); }
osg::Group *SceneVis::getSceneGroup(int num) { osg::Group *sceneGroup = getProjector(num)->getVisScene()->getSceneGroup(); return sceneGroup; }