Exemplo n.º 1
0
void PrimitiveShader_PC::drawBatch(const Mat3 &transform, DrawMode mode, const Vec2 *p, size_t N)
{
    prepare(mode);
    pushPoints(transform, p, N);
}
Exemplo n.º 2
0
void PrimitiveShader_PC::drawBatch(DrawMode mode, const Point *p, size_t N)
{
    prepare(mode);
    pushPoints(p, N);
}
Exemplo n.º 3
0
 // N must be x3
 inline void pushTriangles(const Vec2 *points, size_t N)
 {
     pushPoints(points, N);
 }
void CatmullRomCurveEvaluator::evaluateCurve(const std::vector<Point>& ptvCtrlPts,
	std::vector<Point>& ptvEvaluatedCurvePts,
	const float& fAniLength,
	const bool& bWrap) const {

	ptvEvaluatedCurvePts.clear();
	int iCtrlPtCount = ptvCtrlPts.size();
	if (iCtrlPtCount < 3) return;
	vector<Point> pts;

	if (bWrap) {
		// first
		Point P0(ptvCtrlPts[iCtrlPtCount - 1].x - fAniLength, ptvCtrlPts[iCtrlPtCount - 1].y);
		Point P1 = ptvCtrlPts[0];
		Point P2 = ptvCtrlPts[1];
		Point P3 = ptvCtrlPts[2];
		convertPoints(pts, P0, P1, P2, P3);
		pushPoints(ptvEvaluatedCurvePts, pts);

		// last
		pts.clear();
		P0 = ptvCtrlPts[iCtrlPtCount - 3];
		P1 = ptvCtrlPts[iCtrlPtCount - 2];
		P2 = ptvCtrlPts[iCtrlPtCount - 1];
		P3.x = ptvCtrlPts[0].x + fAniLength;
		P3.y = ptvCtrlPts[0].y;
		convertPoints(pts, P0, P1, P2, P3);
		pushPoints(ptvEvaluatedCurvePts, pts);

		pts.clear();
		P0 = ptvCtrlPts[iCtrlPtCount - 2];
		P1 = ptvCtrlPts[iCtrlPtCount - 1];
		P2.x = ptvCtrlPts[0].x + fAniLength;
		P2.y = ptvCtrlPts[0].y;
		P3.x = ptvCtrlPts[1].x + fAniLength;
		P3.y = ptvCtrlPts[1].y;
		convertPoints(pts, P0, P1, P2, P3);
		pushPoints(ptvEvaluatedCurvePts, pts, fAniLength);

		// middle curve
		int i;
		for (i = 0; i + 3 < iCtrlPtCount; i++) {
			pts.clear();
			P0 = ptvCtrlPts[i];
			P1 = ptvCtrlPts[i + 1];
			P2 = ptvCtrlPts[i + 2];
			P3 = ptvCtrlPts[i + 3];
			convertPoints(pts, P0, P1, P2, P3);
			pushPoints(ptvEvaluatedCurvePts, pts);
		}
	}
	else {
		// first
		Point P0 = ptvCtrlPts[0];
		Point P1 = ptvCtrlPts[0];
		Point P2 = ptvCtrlPts[1];
		Point P3 = ptvCtrlPts[2];
		convertPoints(pts, P0, P1, P2, P3);
		pushPoints(ptvEvaluatedCurvePts, pts);

		// last
		pts.clear();
		P0 = ptvCtrlPts[iCtrlPtCount - 3];
		P1 = ptvCtrlPts[iCtrlPtCount - 2];
		P2 = ptvCtrlPts[iCtrlPtCount - 1];
		P3 = ptvCtrlPts[iCtrlPtCount - 1];
		convertPoints(pts, P0, P1, P2, P3);
		pushPoints(ptvEvaluatedCurvePts, pts);

		// middle curve
		int i;
		for (i = 0; i + 3 < iCtrlPtCount; i++) {
			pts.clear();
			P0 = ptvCtrlPts[i];
			P1 = ptvCtrlPts[i + 1];
			P2 = ptvCtrlPts[i + 2];
			P3 = ptvCtrlPts[i + 3];
			convertPoints(pts, P0, P1, P2, P3);
			pushPoints(ptvEvaluatedCurvePts, pts);
		}

		ptvEvaluatedCurvePts.push_back(Point(0, ptvCtrlPts[0].y));
		ptvEvaluatedCurvePts.push_back(Point(fAniLength, ptvCtrlPts[iCtrlPtCount - 1].y));
	}
}
Exemplo n.º 5
0
 // add N indices
 inline void pushLines(const Vec2 *points, size_t N)
 {
     pushPoints(points, N);
 }