Example #1
0
	Vec3 catmullRom(const Vec3& value1, const Vec3& value2, const Vec3& value3,
					const Vec3& value4, const float& amount)
	{
		return Vec3(catmullRom(value1.x, value2.x, value3.x, value4.x, amount),
					catmullRom(value1.y, value2.y, value3.y, value4.y, amount),
					catmullRom(value1.z, value2.z, value3.z, value4.z, amount));
	}
Example #2
0
Pnt3f* catmullPoint( float u, Pnt3f p1, Pnt3f p2, Pnt3f p3, Pnt3f p4 )
{
	return new Pnt3f(
		catmullRom(u, p1.x, p2.x, p3.x, p4.x),
		catmullRom(u, p1.y, p2.y, p3.y, p4.y),
		catmullRom(u, p1.z, p2.z, p3.z, p4.z));
}
Example #3
0
void SunApp::updateSpline(const vector<Vec2>& cp, u32 numPoints, MeshPtr& triangles)
{
  vector<Vec2> ip; // interpolated points
  vector<Vec2> nv; // tangent vectors
  
  catmullRom(cp, numPoints, ip);
  calculateNormals(ip, nv);
  
  // adjust triangle mesh, only writes to points
  f32 halfWidth = splineWidth / 2;
  u32 j=0;
  
  f32 falloff = halfWidth / numPoints;
  f32 hw = halfWidth;
  for(u32 i=0; i<numPoints; i+=1)
  {
    Vec2 p = ip[i];
    Vec2 n = nv[i];
    Vec2 halfdir = (n*hw);
    Vec2 leftPoint = p+halfdir;
    Vec2 rightPoint = p-halfdir;
    triangles->set(j, UT_position, leftPoint);
    triangles->set(j+1, UT_position, rightPoint);
    
    triangles->set(j, UT_texcoord0, Vec2(0,0));
    triangles->set(j+1, UT_texcoord0, Vec2(1,0));
//    DOUT("p "<< p << " n "<<n);
//    DOUT("left "<<leftPoint<<" right "<<rightPoint );
    j+=2;
    hw -= falloff;
  }
  
}
void Drawing::DrawingImpl::updateRoom()
{
	QElapsedTimer timer;

	triangulation = room->getTriangulation();

	path = room->generatePath();

	if (path.begin()->x > path.rbegin()->x) {
		std::reverse(path.begin(), path.end());
	}

	timer.start();

	pathPoints = catmullRom(path, 150);

	stats->lastCatmullRomCalculation = timer.elapsed();

	pathCollisions.clear();

	timer.start();

	for (std::vector< Coord2DTemplate<float> >::const_iterator it = pathPoints.begin(); it != pathPoints.end(); ++it) {
		if (!room->pointInside(it->x, it->y)) {
			pathCollisions.insert(*it);
		}
	}

	stats->lastPathCollisionCalculation = timer.elapsed();
}
 float eval(float x) const
 {
     switch (_type) {
     case Dirac:
         return 0.0f;
     case Box:
         return (x >= -0.5f && x <= 0.5f) ? 1.0f : 0.0f;
     case Tent:
         return 1.0f - std::abs(x);
     case Gaussian: {
         const float Alpha = 2.0f;
         return max(std::exp(-Alpha*x*x) - std::exp(-Alpha*4.0f), 0.0f);
     } case MitchellNetravali:
         return mitchellNetravali(std::abs(x));
     case CatmullRom:
         return catmullRom(std::abs(x));
     case Lanczos:
         return lanczos(std::abs(x));
     default:
         return 0.0f;
     }
 }
Example #6
0
	Vec1 catmullRom(const Vec1& value1, const Vec1& value2, const Vec1& value3,
					const Vec1& value4, const float& amount)
	{
		return Vec1(catmullRom(value1.x, value2.x, value3.x, value4.x, amount));
	}