void Mesh::updateMesh(){
	cout<<"Number of Triangle "<<triangles.size()<<endl;
	cout<<"Number of Nodes "<<nodes.size()<<endl;

	computeForcesOnNodes();
	updateVelocityOfAllNodes();
	updatePositionOfAllNodes();
	updateTriangles();
	//calculate new velocity of the nodes.
	//update the position of the nodes.
	//check all the nodes and all the triangles. if a node ovelap with triangle, compute a set
	//perform contraction pass. remove edges if too short.
	//split overlapping elements of the s.
	//with each split, again contract.
	//
	//check the triangles. check nodes are present in another triangle. remove them.
	//check for changes in length, merge nodes if length too short.
	//check for big sides. Divide edge if length too big.
	//check
}
Пример #2
0
void PlaneSet::renderBegin(RenderContext* renderContext)
{
  updateTriangles(renderContext->scene->getBoundingBox());
  invalidateDisplaylist();
  TriangleSet::renderBegin(renderContext);
}
Пример #3
0
AABox& PlaneSet::getBoundingBox(RenderContext* renderContext)
{
  updateTriangles(renderContext->scene->getBoundingBox());
  return TriangleSet::getBoundingBox(renderContext); 
}
Пример #4
0
void testApp::update() {	
	kinect.update();
	if(!panel.getValueB("pause") && kinect.isFrameNew())	{
		zCutoff = panel.getValueF("zCutoff");
		
		float fovWidth = panel.getValueF("fovWidth");
		float fovHeight = panel.getValueF("fovHeight");
		int left = Xres * (1 - fovWidth) / 2;
		int top = Yres * (1 - fovHeight) / 2;
		int right = left + Xres * fovWidth;
		int bottom = top + Yres * fovHeight;
		roiStart = Point2d(left, top);
		roiEnd = Point2d(right, bottom);
		
		ofVec3f nw = ConvertProjectiveToRealWorld(roiStart.x, roiStart.y, zCutoff);
		ofVec3f se = ConvertProjectiveToRealWorld(roiEnd.x - 1, roiEnd.y - 1, zCutoff);
		float width = (se - nw).x;
		float height = (se - nw).y;
		globalScale = panel.getValueF("stlSize") / MAX(width, height);
		
		backOffset = panel.getValueF("backOffset") / globalScale;
		
		cutoffKinect();
		
		if(panel.getValueB("useSmoothing")) {
			smoothKinect();
		}
		
		if(panel.getValueB("useWatermark")) {
			startTimer();
			injectWatermark();
			injectWatermarkTime = stopTimer();
		}
		
		startTimer();
		updateSurface();
		updateSurfaceTime = stopTimer();
		
		bool exportStl = panel.getValueB("exportStl");
		bool useRandomExport = panel.getValueB("useRandomExport");
		
		startTimer();
		if((exportStl && useRandomExport) || panel.getValueB("useRandom")) {
			updateTrianglesRandom();
		} else if(panel.getValueB("useSimplify")) {
			updateTrianglesSimplify();
		} else {
			updateTriangles();
		}
		calculateNormals(triangles, normals);
		updateTrianglesTime = stopTimer();
		
		startTimer();
		updateBack();
		updateBackTime = stopTimer();
		
		startTimer();
		postProcess();
		postProcessTime = stopTimer();
		
		if(exportStl) {
			string pocoTime = Poco::DateTimeFormatter::format(Poco::LocalDateTime(), "%Y-%m-%d at %H.%M.%S");
			
			ofxSTLExporter exporter;
			exporter.beginModel("Kinect Export");
			addTriangles(exporter, triangles, normals);
			addTriangles(exporter, backTriangles, backNormals);
			exporter.saveModel("Kinect Export " + pocoTime + ".stl");
			
#ifdef USE_REPLICATORG
			if(printer.isConnected()) {
				printer.printToFile("/home/matt/MakerBot/repg_workspace/ReplicatorG/examples/Snake.stl", "/home/matt/Desktop/snake.s3g");
			}
#endif
			
			panel.setValueB("exportStl", false);
		}
	}
	
	float diffuse = panel.getValueF("diffuseAmount");
	redLight.setDiffuseColor(ofColor(diffuse / 2, diffuse / 2, 0));
	greenLight.setDiffuseColor(ofColor(0, diffuse / 2, diffuse / 2));
	blueLight.setDiffuseColor(ofColor(diffuse / 2, 0, diffuse / 2));
	
	float ambient = 255 - diffuse;
	redLight.setAmbientColor(ofColor(ambient / 2, ambient / 2, 0));
	greenLight.setAmbientColor(ofColor(0, ambient / 2, ambient / 2));
	blueLight.setAmbientColor(ofColor(ambient / 2, 0, ambient / 2));
	
	float lightY = ofGetHeight() / 2 + panel.getValueF("lightY");
	float lightZ = panel.getValueF("lightZ");
	float lightDistance = panel.getValueF("lightDistance");
	float lightRotation = panel.getValueF("lightRotation");
	redLight.setPosition(ofGetWidth() / 2 + cos(lightRotation + 0 * TWO_PI / 3) * lightDistance,
											 lightY + sin(lightRotation + 0 * TWO_PI / 3) * lightDistance,
											 lightZ);
	greenLight.setPosition(ofGetWidth() / 2 + cos(lightRotation + 1 * TWO_PI / 3) * lightDistance,
												 lightY + sin(lightRotation + 1 * TWO_PI / 3) * lightDistance,
												 lightZ);
	blueLight.setPosition(ofGetWidth() / 2 + cos(lightRotation + 2 * TWO_PI / 3) * lightDistance,
												lightY + sin(lightRotation + 2 * TWO_PI / 3) * lightDistance,
												lightZ);
}