当前位置: 首页>>代码示例>>C++>>正文


C++ BezierCurve类代码示例

本文整理汇总了C++中BezierCurve的典型用法代码示例。如果您正苦于以下问题:C++ BezierCurve类的具体用法?C++ BezierCurve怎么用?C++ BezierCurve使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了BezierCurve类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: BezierCurve

SceneObjectPtr
BezierCurve::copy(DeepCopier& copier) const
{
  BezierCurve * ptr = new BezierCurve(*this);
  copier.copy_attribute(ptr->getCtrlPointList());
  return SceneObjectPtr(ptr);
}
开发者ID:kkremitzki,项目名称:plantgl,代码行数:7,代码来源:beziercurve.cpp

示例2: handleEvent

void CurveEditor::handleEvent(Event *event) {

    if(mode == MODE_ADD) {
        if(event->getDispatcher() == bg) {
            if(event->getEventCode() == InputEvent::EVENT_MOUSEDOWN) {
                InputEvent *inputEvent = (InputEvent*)event;
                if(selectedCurve) {
                    Vector2 pos = inputEvent->mousePosition;
                    pos.x = pos.x/610.0;
                    pos.y = 1.0-(pos.y/254.0);

                    BezierCurve *targetCurve = selectedCurve->targetCurve;

                    bool done = false;
                    for(int i=0; i < targetCurve->getNumControlPoints(); i++) {
                        if(pos.x < targetCurve->getControlPoint(i)->p2.x && !done) {
                            targetCurve->insertPoint = targetCurve->getControlPoint(i);
                            done = true;
                        }
                    }

                    targetCurve->addControlPoint2dWithHandles(pos.x-0.1, pos.y, pos.x, pos.y, pos.x + 0.1, pos.y);
                    selectedCurve->updatePoints();
                    selectedCurve->updateCurve();
                }
            }
        }
    }

    if(event->getDispatcher() == selectButton) {
        selectorImage->setPosition(selectButton->getPosition().x - 4, selectButton->getPosition().y - 4);
        setMode(0);
    }

    if(event->getDispatcher() == addButton) {
        selectorImage->setPosition(addButton->getPosition().x - 4, addButton->getPosition().y - 4);
        setMode(1);
    }

    if(event->getDispatcher() == removeButton) {
        selectorImage->setPosition(removeButton->getPosition().x - 4, removeButton->getPosition().y - 4);
        setMode(2);
    }

    if(event->getDispatcher() == treeContainer->getRootNode()) {
        if(event->getEventCode() == UITreeEvent::SELECTED_EVENT) {
            EditCurve *curve = (EditCurve *)treeContainer->getRootNode()->getSelectedNode()->getUserData();
            if(selectedCurve) {
                selectedCurve->Deactivate();
            }
            selectedCurve = curve;
            if(curve) {
                curve->Activate();
                curve->setMode(mode);
            }
        }
    }

    UIWindow::handleEvent(event);
}
开发者ID:reffle,项目名称:Polycode,代码行数:60,代码来源:PolycodeFrame.cpp

示例3: transformed

BezierCurve BezierCurve::transformed(QTransform transformation)
{
    BezierCurve transformedCurve = *this; // copy the curve
    if (isSelected(-1)) { transformedCurve.setOrigin(transformation.map(origin)); }
    for(int i=0; i< vertex.size(); i++)
    {
        if (isSelected(i-1)) { transformedCurve.setC1(i, transformation.map(c1.at(i))); }
        if (isSelected(i))
        {
            transformedCurve.setC2(i, transformation.map(c2.at(i)));
            transformedCurve.setVertex(i, transformation.map(vertex.at(i)));
        }
    }
    //transformedCurve.smoothCurve();
    /*QPointF newOrigin = origin;
    if (isSelected(-1)) { newOrigin =  transformation.map(newOrigin); }
    transformedCurve.setOrigin( newOrigin );
    for(int i=0; i< vertex.size(); i++) {
    	QPointF newC1 = c1.at(i);
    	QPointF newC2 = c2.at(i);
    	QPointF newVertex = vertex.at(i);
    	if (isSelected(i-1)) { newC1 = transformation.map(newC1); }
    	if (isSelected(i)) { newC2 = transformation.map(newC2);  newVertex = transformation.map(newVertex); }
    	transformedCurve.appendCubic( newC1, newC2, newVertex, pressure.at(i) );
    	if (isSelected(i)) { transformedCurve.setSelected(i, true); }
    }
    transformedCurve.setWidth( width);
    transformedCurve.setVariableWidth( variableWidth );
    //transformedCurve.setSelected(true); // or select only the selected elements of the orginal curve?
    */
    return transformedCurve;
}
开发者ID:qbdp,项目名称:pencil,代码行数:32,代码来源:beziercurve.cpp

示例4: w_BezierCurve_evaluate

int w_BezierCurve_evaluate(lua_State *L)
{
	BezierCurve *curve = luax_checkbeziercurve(L, 1);
	double t = luaL_checknumber(L, 2);

	luax_catchexcept(L, [&]() {
		Vector v = curve->evaluate(t);
		lua_pushnumber(L, v.x);
		lua_pushnumber(L, v.y);
	});

	return 2;

}
开发者ID:AntonioModer,项目名称:LoveMore,代码行数:14,代码来源:wrap_BezierCurve.cpp

示例5: findDistance

qreal BezierCurve::findDistance(BezierCurve curve, int i, QPointF P, QPointF& nearestPoint, qreal& t)   //finds the distance between a cubic section and a point
{
    //qDebug() << "---- INTER CUBIC SEGMENT";
    int nSteps = 24;
    int k0 = 0;
    QPointF Q;
    Q = curve.getVertex(i-1);
    qreal distMin = eLength(Q-P);
    nearestPoint = Q;
    t = 0;
    for(int k=1; k<=nSteps; k++)
    {
        qreal s = (k+0.0)/nSteps;
        Q = curve.getPointOnCubic(i, s);
        qreal dist = eLength(Q-P);
        if (dist <= distMin)
        {
            distMin = dist;
            nearestPoint = Q;
            t = s;
            k0 = k;
        }
    }
    //QPointF Q1 = curve.getPointOnCubic(i, t);
    return distMin;
}
开发者ID:qbdp,项目名称:pencil,代码行数:26,代码来源:beziercurve.cpp

示例6: mouse

void mouse(int button, int state, int x, int y)
{
	double vertex[3];

	//获取矩阵信息
	glGetIntegerv(GL_VIEWPORT, g_Viewport);
	glGetDoublev(GL_MODELVIEW_MATRIX, g_ModelMatrix);
	glGetDoublev(GL_PROJECTION_MATRIX, g_ProjMatrix);

	y = g_Viewport[3] - y;
	gluUnProject( x, y, 0,
		g_ModelMatrix, g_ProjMatrix, g_Viewport,
		&vertex[0], &vertex[1], &vertex[2] );

	if (button==GLUT_LEFT && state==GLUT_DOWN)
	{
		myBezier.mouseSynchro( BezierCurve::LButtonDown, vertex );
		glutSetCursor( GLUT_CURSOR_RIGHT_ARROW );
	}
	else if (button == GLUT_LEFT && state == GLUT_UP)
	{
		myBezier.mouseSynchro( BezierCurve::LButtonUp, vertex );
	}

	glutPostRedisplay();
}
开发者ID:andreaswatch,项目名称:dizuo,代码行数:26,代码来源:BezierCurve_App.cpp

示例7: w_BezierCurve_getDerivative

int w_BezierCurve_getDerivative(lua_State *L)
{
	BezierCurve *curve = luax_checkbeziercurve(L, 1);
	BezierCurve *deriv = new BezierCurve(curve->getDerivative());
	luax_pushtype(L, MATH_BEZIER_CURVE_ID, deriv);
	deriv->release();
	return 1;
}
开发者ID:AntonioModer,项目名称:LoveMore,代码行数:8,代码来源:wrap_BezierCurve.cpp

示例8: w_BezierCurve_translate

int w_BezierCurve_translate(lua_State *L)
{
	BezierCurve *curve = luax_checkbeziercurve(L, 1);
	float dx = (float) luaL_checknumber(L, 2);
	float dy = (float) luaL_checknumber(L, 3);
	curve->translate(Vector(dx,dy));
	return 0;
}
开发者ID:AntonioModer,项目名称:LoveMore,代码行数:8,代码来源:wrap_BezierCurve.cpp

示例9: w_BezierCurve_scale

int w_BezierCurve_scale(lua_State *L)
{
	BezierCurve *curve = luax_checkbeziercurve(L, 1);
	double s = luaL_checknumber(L, 2);
	float ox = (float) luaL_optnumber(L, 3, 0);
	float oy = (float) luaL_optnumber(L, 4, 0);
	curve->scale(s, Vector(ox,oy));
	return 0;
}
开发者ID:AntonioModer,项目名称:LoveMore,代码行数:9,代码来源:wrap_BezierCurve.cpp

示例10: w_BezierCurve_removeControlPoint

int w_BezierCurve_removeControlPoint(lua_State *L)
{
	BezierCurve *curve = luax_checkbeziercurve(L, 1);
	int idx = (int) luaL_checknumber(L, 2);

	if (idx > 0) // 1-indexing
		idx--;

	luax_catchexcept(L, [&](){ curve->removeControlPoint(idx); });
	return 0;
}
开发者ID:AntonioModer,项目名称:LoveMore,代码行数:11,代码来源:wrap_BezierCurve.cpp

示例11: groupCurveLength

float BccWorld::groupCurveLength(GeometryArray * geos)
{
	float sum = 0.f;
	const unsigned n = geos->numGeometries();
     unsigned i = 0;
    for(;i<n;i++) {
        BezierCurve * c = static_cast<BezierCurve *>(geos->geometry(i));
        sum += c->length();
    }
	return sum;
}
开发者ID:kkaushalp,项目名称:aphid,代码行数:11,代码来源:BccWorld.cpp

示例12: BezierCurve

BezierCurve* GameEngine::generateCurve(int numPoints, int sizeCurve) {
    BezierCurve *curve = new BezierCurve();
    float randX, randY, randZ;

    for (int j=0; j < numPoints; j++) {
        randX = rand() % sizeCurve - (sizeCurve/2.0);
        randY = rand() % sizeCurve - (sizeCurve/2.0);
        randZ = rand() % sizeCurve - (sizeCurve/2.0);
        curve->addSmoothHandlePoint(randX,randY,randZ);
    }
    return curve;
}
开发者ID:CharlesYeh,项目名称:rollercoaster,代码行数:12,代码来源:gameengine.cpp

示例13: w_BezierCurve_insertControlPoint

int w_BezierCurve_insertControlPoint(lua_State *L)
{
	BezierCurve *curve = luax_checkbeziercurve(L, 1);
	float vx = (float) luaL_checknumber(L, 2);
	float vy = (float) luaL_checknumber(L, 3);
	int idx = (int) luaL_optnumber(L, 4, -1);

	if (idx > 0) // 1-indexing
		idx--;

	luax_catchexcept(L, [&](){ curve->insertControlPoint(Vector(vx,vy), idx); });
	return 0;
}
开发者ID:AntonioModer,项目名称:LoveMore,代码行数:13,代码来源:wrap_BezierCurve.cpp

示例14: w_BezierCurve_getSegment

int w_BezierCurve_getSegment(lua_State *L)
{
	BezierCurve *curve = luax_checkbeziercurve(L, 1);
	double t1 = luaL_checknumber(L, 2);
	double t2 = luaL_checknumber(L, 3);

	BezierCurve *segment;
	luax_catchexcept(L, [&](){ segment = curve->getSegment(t1, t2); });
	luax_pushtype(L, MATH_BEZIER_CURVE_ID, segment);
	segment->release();

	return 1;
}
开发者ID:AntonioModer,项目名称:LoveMore,代码行数:13,代码来源:wrap_BezierCurve.cpp

示例15:

void Shape2D_Impl::add_rotated_curve(Path2D &path, const Pointf &center, const Angle &angle, Pointf point_1,  Pointf point_2,  Pointf point_3)
{
	if (angle.to_radians() != 0.0f)
	{
		point_1.rotate(center, angle);
		point_2.rotate(center, angle);
		point_3.rotate(center, angle);
	}
	BezierCurve curve;
	curve.add_control_point(point_1);
	curve.add_control_point(point_2);
	curve.add_control_point(point_3);
	path.add_curve(curve);

}
开发者ID:Cassie90,项目名称:ClanLib,代码行数:15,代码来源:shape2d_impl.cpp


注:本文中的BezierCurve类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。