void AppWindow::move2() {
	
	GsArray <GsVec> cntrlpoint;
	cntrlpoint.size(3);


	for (int i = 0; i < cntrlpoint.size(); i++) {
		//figure out contorl points
		cntrlpoint[i] = GsVec((i - 2), ((i - 2)*(i - 2)*(i - 2)) / 5, 0);
		std::cout << "herp -> " << cntrlpoint[i].x << " " << cntrlpoint[i].y << " " << cntrlpoint[i].z << std::endl;
	};
	evaluate_bezier(cntrlpoint.size() * 5, currentanimu, cntrlpoint);
	
	for (int i = 0; i < currentanimu.size(); i++) {
		std::cout << "derp -> " << currentanimu[i].x << " " << currentanimu[i].y << " " << currentanimu[i].z << std::endl;
	}



	animutime = 0;
	spaceships = currentanimu[0].z;
	spacexx = currentanimu[0].x;
	spaceyy = currentanimu[0].y;

}
void AppWindow::mranorbit() {
	GsArray <GsVec> cntrlpoint;
	cntrlpoint.size(30);
	float radx, randy;
	radx = 0.0;
	randy = 0.0;
	radx = rand() % 1 + .5;
	randy = rand() % 1 + .5;

	for (int i = 0; i < cntrlpoint.size(); i++) {
		//figure out contorl points
		cntrlpoint[i] = GsVec(sin(i)*radx, 0.0 + randy, cos(i)*randy);

		std::cout << "herp -> " << cntrlpoint[i].x << " " << cntrlpoint[i].y << " " << cntrlpoint[i].z << std::endl;
	};
	evaluate_bezier(cntrlpoint.size() * 4, currentanimu, cntrlpoint);

	for (int i = 0; i < currentanimu.size(); i++) {
		std::cout << "derp -> " << currentanimu[i].x << " " << currentanimu[i].y << " " << currentanimu[i].z << std::endl;
	}



	animutime = 0;
	m1 = currentanimu[0].z;
	m2 = currentanimu[0].x;
	m3 = currentanimu[0].y;
}
void SeLct::get_path_corners ( GsArray<GsVec2>& points, GsArray<char>& topdown )
 {
   points.size(0);
   topdown.size(0);
   if ( !_fpath ) return;
   for ( int i=0; i<_fpath->size(); i++ )
    { points.push() = _fpath->get(i);
      topdown.push() = _fpath->get(i).side;
    }
 }
void SeLct::get_funnel_corners ( GsArray<GsVec2>& points, GsArray<char>& sides, FunnelDeque* funnel )
 {
   char s;
   points.size(0);
   sides.size(0);
   if ( !funnel ) funnel=_fdeque;
   if ( !funnel ) return;
   for ( int i=0; i<funnel->size(); i++ )
    { points.push() = (*funnel)[i];
      s = (*funnel)[i].side;
      sides.push() = s;
      if ( (*funnel)[i].apex ) sides.top() = GS_UPPER(s);
    }
 }
Exemplo n.º 5
0
// build may be called everytime the object changes (not the case for this axis object):
void SoCurve::build(GsArray<GsVec> curve, GsColor c)
{
	int i;
	//const float d = r / 20.0f;

	P.size(0); C.size(0); // set size to zero
	//P.reserve(18); C.reserve(18); // reserve some space to avoid re-allocations below

	P = curve;
	for (int i = 0; i < curve.size(); i++) {
		C.push(c);
	}

	// send data to OpenGL buffers:
	glBindVertexArray(va[0]);
	glEnableVertexAttribArray(0);
	glEnableVertexAttribArray(1);

	glBindBuffer(GL_ARRAY_BUFFER, buf[0]);
	glBufferData(GL_ARRAY_BUFFER, 3 * sizeof(float)*P.size(), P.pt(), GL_STATIC_DRAW);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);

	glBindBuffer(GL_ARRAY_BUFFER, buf[1]);
	glBufferData(GL_ARRAY_BUFFER, 4 * sizeof(gsbyte)*C.size(), C.pt(), GL_STATIC_DRAW);
	glVertexAttribPointer(1, 4, GL_UNSIGNED_BYTE, GL_FALSE, 0, 0);

	glBindVertexArray(0); // break the existing vertex array object binding.

						  // save size so that we can free our buffers and later draw the OpenGL arrays:
	_numpoints = P.size();

	// free non-needed memory:
	P.capacity(0); C.capacity(0);
}
void AppWindow::orbit() {
	GsArray <GsVec> cntrlpoint;
	cntrlpoint.size(15);


	for (int i = 0; i < cntrlpoint.size(); i++) {
		//figure out contorl points
		cntrlpoint[i] = GsVec(3.0*sin(i), 0.0, 3.0*cos(i));
		std::cout << "herp -> " << cntrlpoint[i].x << " " << cntrlpoint[i].y << " " << cntrlpoint[i].z << std::endl;
	};
	evaluate_bezier(cntrlpoint.size() * 4, currentanimu, cntrlpoint);

	for (int i = 0; i < currentanimu.size(); i++) {
		std::cout << "derp -> " << currentanimu[i].x << " " << currentanimu[i].y << " " << currentanimu[i].z << std::endl;
	}



	animutime = 0;
	jx = currentanimu[0].z;
	jy = currentanimu[0].x;
	jz = currentanimu[0].y;
}