예제 #1
0
void ofxEnveloper::drawInterpolation()
{
    drawInterpolatorSmooth(mInterpolator, mNumSteps, 20,  2) ;
}
예제 #2
0
파일: testApp.cpp 프로젝트: Giladx/msalibs
//--------------------------------------------------------------
void testApp::draw() {
	glPushMatrix();
	glTranslatef(ofGetWidth()/2, 0, 0);		// move to center of screen horizontally (so we can rotate)
	
	if(rotateView) {
		currentRot += 0.2;
		glRotatef(currentRot, 0, 1, 0);		// rotate view
	} else {
		currentRot = 0;
	}
	
	
	int numSteps = floor(mouseX / (float)ofGetWidth() * 1000);
	if(numSteps<10) numSteps = 10;
	float spacing = 1.0/numSteps;	
	
	// draw spline2D
	glColor3f(1, 1, 1);
	drawInterpolatorRaw(spline2D);
	
	// draw interpolated spline2D
	glColor3f(0, 0, 1);
	drawInterpolatorSmooth(spline2D, numSteps);
	
	// draw raw spline3D
	glColor3f(1, 1, 1);
	drawInterpolatorRaw(spline3D);
	
	// draw interpolated spline3D
	glColor3f(0.2f, 0.2f, 0.2f);
	drawInterpolatorSmooth(spline3D, numSteps);
	
	
	
	// draw sphere moving along 3D path
	MSA::Vec3f spherePos = spline3D.sampleAt(spherePosPerc);
	glPushMatrix();
	glColor3f(1, 1, 0);
	glTranslatef(spherePos.x, spherePos.y, spherePos.z);
	glutSolidSphere(20, 5, 5);
	glPopMatrix();
	
	// move sphere
	// if it reaches the edges, bounce back
	spherePosPerc += sphereSpeed;
	if(spherePosPerc > 1) {
		spherePosPerc = 1;
		sphereSpeed *= -1;
	} else if(spherePosPerc < 0) {
		spherePosPerc = 0;
		sphereSpeed *= -1;
	}
	

	glPopMatrix();

	ofSetColor(0);
	string uiLin = interpolationType == MSA::kInterpolationLinear ? "* " : "  ";
	string uiCub = interpolationType == MSA::kInterpolationCubic ? "* " : "  ";
	string uiDist = spline3D.getUseLength() ? "* " : "  ";
	ofDrawBitmapString( ofToString(ofGetFrameRate(), 2) + "\n"
					   + "numSteps (resampling resolution - mouseX to change): " + ofToString(numSteps) + "\n"
					   + "mouse click around the area to draw a 3D spline (length = " + ofToString(spline3D.getLength()) + "\n"
					   + "\n"
					   + uiLin + "'1' to use linear interpolation\n"
					   + uiCub + "'2' to use cubic (catmull rom) interpolation\n"
					   + "\n"
					   + uiDist + "'d' to toggle 'using Length in interpolation'\n"
					   + "\n"
					   + "'c' to clear 3D spline\n"
					   , 20, 20);
	
}