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


C++ Vector2dVector类代码示例

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


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

示例1: RigTriangulate

bool RigTriangulate(const Rig& rig, std::vector<Rig>& finalTriangles)
{
    Vector2dVector a;
    for(int i = 0; i < rig.size(); i++)
    {
        a.push_back(Vector2d(rig[i].x,rig[i].y));
    }
    Vector2dVector result;
    bool success = Triangulate::Process(a,result);
    
    // print out the results.
    int tcount = result.size()/3;
    for (int i=0; i<tcount; i++)
    {
        const Vector2d &p1 = result[i*3+0];
        const Vector2d &p2 = result[i*3+1];
        const Vector2d &p3 = result[i*3+2];
        
        Rig triangle;
        triangle.push_back(ccp(p1.GetX(),p1.GetY()));
        triangle.push_back(ccp(p2.GetX(),p2.GetY()));
        triangle.push_back(ccp(p3.GetX(),p3.GetY()));
        
        finalTriangles.push_back(triangle);
    }
    
    return success;
}
开发者ID:agiantwhale,项目名称:segments,代码行数:28,代码来源:Rig.cpp

示例2: drawSquare

void CPhysics::drawSquare(b2Vec2* points,b2Vec2 center,float angle,int VertexCount, float Camera_Z)
{

	Vector2dVector a;

	for (int i = 0; i < VertexCount; i++)
	{
		a.push_back(Vector2d(points[i].x,points[i].y));
	}
	Vector2dVector result;
	Triangulate::Process(a,result);
	int tcount = result.size()/3;

	glColor3f(0.7,0.3,0.7);
	//glMatrixMode(GL_MODELVIEW);
	glPushMatrix();

	glTranslatef(center.x *M2P,center.y*M2P,Camera_Z);


	glRotatef(angle*180.0/M_PI,0,0,1);
	glBegin(GL_TRIANGLES);

	for(int i=0;i<tcount;i++){
		if (i == 0)
			glColor3f(1,0,1);
		else if (i == 1)
			glColor3f(1,0,0);
		else if (i == 2)
			glColor3f(0,1,0);
		else if (i == 3)
			glColor3f(0,0,1);
		else if (i == 4)
			glColor3f(0,1,1);
		else if (i == 5)
			glColor3f(1,0,1);


		glVertex2f(result[i*3+0].GetX()*M2P,result[i*3+0].GetY()*M2P);
		glVertex2f(result[i*3+1].GetX()*M2P,result[i*3+1].GetY()*M2P);
		glVertex2f(result[i*3+2].GetX()*M2P,result[i*3+2].GetY()*M2P);
	}
	glEnd();
	glPopMatrix();

	glColor3f(1,1,1);
}
开发者ID:KonradJablonski,项目名称:InLine2D,代码行数:47,代码来源:Physics.cpp

示例3: Vector2d

void ModuleBuildings::addBuildingRoof(Building* building, float height, float elevation){
    //create && fill vector a with polygon corners
    Vector2dVector a;
    bool first = true;
    for(auto corner : building->getCorners()) {
        if (first) { first=false; continue; }
        a.push_back( Vector2d(corner[0], corner[1]));
    }

    Vector2dVector result; // allocate an STL vector to hold the answer.
    Triangulate::Process(a,result); //  Invoke the triangulator to triangulate this polygon.

    //create roof
    height = (float)height * Config::get()->BUILDING_FLOOR_HEIGHT + elevation;
    int tcount = result.size()/3;
    for (int i=0; i<tcount; i++) {
        const Vector2d &p1 = result[i*3+0];
        const Vector2d &p2 = result[i*3+1];
        const Vector2d &p3 = result[i*3+2];

        //create triangle
        for (int j=0; j<3; j++) {
            r_geo_d->inds->addValue(r_geo_d->inds->size());
            r_geo_d->norms->addValue(Vec3f(0, 1, 0));
        }

        r_geo_d->pos->addValue(Vec3f(p1.GetX(), height, p1.GetY()));
        r_geo_d->pos->addValue(Vec3f(p2.GetX(), height, p2.GetY()));
        r_geo_d->pos->addValue(Vec3f(p3.GetX(), height, p3.GetY()));

        //r_geo_d->texs->addValue(Vec2f(p1.GetX()/factor, p1.GetY()/factor)); //use only border color of texture
        //r_geo_d->texs->addValue(Vec2f(p2.GetX()/factor, p2.GetY()/factor)); //use only border color of texture
        //r_geo_d->texs->addValue(Vec2f(p3.GetX()/factor, p3.GetY()/factor)); //use only border color of texture

        float mx = (p1.GetX() + p2.GetX() + p3.GetX() )/3.0;
        float my = (p1.GetY() + p2.GetY() + p3.GetY() )/3.0;

        r_geo_d->texs->addValue(convRTC(p1.GetX(), p1.GetY(), Vec2f(mx,my))); //use only border color of texture
        r_geo_d->texs->addValue(convRTC(p2.GetX(), p2.GetY(), Vec2f(mx,my))); //use only border color of texture
        r_geo_d->texs->addValue(convRTC(p3.GetX(), p3.GetY(), Vec2f(mx,my))); //use only border color of texture

        //r_geo_d->texs->addValue(Vec2f(0.0, 0.9)); //use only border color of texture
        //r_geo_d->texs->addValue(Vec2f(0.1, 0.9)); //use only border color of texture
        //r_geo_d->texs->addValue(Vec2f(0.0, 1.0)); //use only border color of texture
    }
}
开发者ID:AntonChalakov,项目名称:polyvr,代码行数:46,代码来源:ModuleBuildings.cpp

示例4: CC_SAFE_FREE

void PRFilledPolygon::setPoints(Vector2dVector &points) {
    
    CC_SAFE_FREE(areaTrianglePoints);
    CC_SAFE_FREE(textureCoordinates);
    
    Vector2dVector triangulatedPoints = PRRatcliffTriangulator::triangulateVertices(points);
    
    areaTrianglePointCount = triangulatedPoints.size();
    areaTrianglePoints = (CCPoint*) malloc(sizeof(CCPoint) * areaTrianglePointCount);
    textureCoordinates = (CCPoint*) malloc(sizeof(CCPoint) * areaTrianglePointCount);
    
    for (int i = 0; i < areaTrianglePointCount; i++) {
        Vector2d v = (Vector2d)triangulatedPoints.at(i);
        areaTrianglePoints[i] = CCPointMake(v.GetX(), v.GetY());
    }
    
    calculateTextureCoordinates();
}
开发者ID:asurada,项目名称:SGLegend,代码行数:18,代码来源:PRFilledPolygon.cpp

示例5: Point

void CCutScene::createBackground()
{
    
    Point points[4] =
    {
        Point(0, 0), Point(0, 2048), Point(2048, 2048), Point(2048, 0)
    };
    Vector2dVector vcPoints;
    vcPoints.clear();
    for (int i = 0; i < 4; i++)
    {
        vcPoints.push_back(Vector2d(points[i].x, points[i].y));
    }
    
    PRFilledPolygon *filledPolygon = PRFilledPolygon::filledPolygonWithPointsAndTexture(vcPoints, "daanban.png");
    //filledPolygon->setPhysicsBody(PhysicsBody::createPolygon(points, 4));
    filledPolygon->setPosition(Vec2::ZERO + Vec2(0, (1536 - 2048) / 2));
    addChild(filledPolygon, 80);
}
开发者ID:GitofThunder,项目名称:gitskills,代码行数:19,代码来源:CutScene.cpp

示例6: Area

LDEfloat Triangulate::Area(const Vector2dVector &contour)
{
    int n = contour.size();
    
    LDEfloat A=0.0f;
    
    for(int p=n-1,q=0; q<n; p=q++)
    {
        A+= contour[p].x*contour[q].y - contour[q].x*contour[p].y;
    }
    return A*0.5f;
}
开发者ID:HappyLDE,项目名称:Faya-Editor,代码行数:12,代码来源:Triangulate.cpp

示例7: addChild

bool PRKitDemoScene::init()
{
    if(!Layer::init())
    {
        return false;
    }
    
    auto color_bg = LayerColor::create(Color4B(125, 125, 125, 125));
    addChild(color_bg);
    
    auto demo_info_label = Label::create(demo_info(), "Helvetica", 25, Size(500, 200), TextHAlignment::LEFT);
    this->addChild(demo_info_label);
    demo_info_label->setAnchorPoint(Point(0.0f, 1.0f));
    demo_info_label->setColor(Color3B(255, 255, 255));
    demo_info_label->setPosition(VisibleRect::leftTop() + Point(60, -60));
    
    auto backMenuItem = MenuItemImage::create("backNormal.png", "backSelected.png", CC_CALLBACK_1(PRKitDemoScene::backCallback, this));
    auto restartMenuItem = MenuItemImage::create("refreshNormal.png", "refreshSelected.png", CC_CALLBACK_1(PRKitDemoScene::restartCallback, this));
    
    restartMenuItem->setPosition(VisibleRect::rightTop() + Point(-200, -80));
    backMenuItem->setPosition(restartMenuItem->getPosition() + Point(90, 0));
    auto menu = Menu::create(backMenuItem, restartMenuItem, NULL);
    menu->setPosition(Point::ZERO);
    this->addChild(menu, 300);
    
    //--------------------- START
    Vector2dVector polygonPoints;
    polygonPoints.push_back(Vector2d(100, 100));
    polygonPoints.push_back(Vector2d(200, 100));
    polygonPoints.push_back(Vector2d(300, 200));
    polygonPoints.push_back(Vector2d(400, 300));
    polygonPoints.push_back(Vector2d(500, 500));

    Texture2D *texture = Director::getInstance()->getTextureCache()->addImage("pattern1.png");
    PRFilledPolygon *filledPolygon = PRFilledPolygon::filledPolygonWithPointsAndTexture(polygonPoints, texture);
    addChild(filledPolygon);
    //---------------------- END
    
    return true;
}
开发者ID:1007650105,项目名称:RockChipmunk2D,代码行数:40,代码来源:PRKitDemoScene.cpp

示例8: Area

double Triangulate::Area(const Vector2dVector &contour)
{

  int n = contour.size();

  double A=0.0;

  for(int p=n-1,q=0; q<n; p=q++)
  {
    A+= contour[p].GetX()*contour[q].GetY() - contour[q].GetX()*contour[p].GetY();
  }
return A*0.5;
}
开发者ID:Rambo2015,项目名称:TaxiVis,代码行数:13,代码来源:Triangulator.cpp

示例9: initWithTexture

PolygonSprite* PolygonSprite::initWithTexture(Texture2D* texture, b2Body* body, bool original)
{
	//gather all the vertices from our Box2D shape
	b2Fixture *originalFixture = body->GetFixtureList();
	b2PolygonShape *shape = (b2PolygonShape*)originalFixture->GetShape();
	int vertexCount = shape->GetVertexCount();

	Vector2dVector points;

	for(int i = 0; i < vertexCount; i++) {
		points.push_back( Vector2d(shape->GetVertex(i).x * PTM_RATIO, shape->GetVertex(i).y * PTM_RATIO) );
	}

	if(initWithPointsAndTexture(points, texture))
	{
		_body = body;
		_body->SetUserData(this);
		_original = original;
		// gets the center of the polygon
		_centroid = this->_body->GetLocalCenter();
		// assign an anchor point based on the center
		_anchorPoint = ccp(_centroid.x * PTM_RATIO / texture->getContentSize().width, 
								 _centroid.y * PTM_RATIO / texture->getContentSize().height);

		// more init stuff here later when you expand PolygonSprite

		// slice
		_sliceExited = false;
		_sliceEntered = false;
		_entryPoint.SetZero();
		_exitPoint.SetZero();
		_sliceEntryTime = 0;

		// fruits
		_state = kStateIdle;
	}

	return this;
}
开发者ID:rtothecore,项目名称:SaladMaker,代码行数:39,代码来源:PolygonSprite.cpp

示例10: Area

float Triangulate::Area(const Vector2dVector &contour)
{
    
    int n = (int)contour.size();
    
    float A=0.0f;
    
    for(int p=n-1,q=0; q<n; p=q++)
    {
        A+= contour[p].GetX()*contour[q].GetY() - contour[q].GetX()*contour[p].GetY();
    }
    return A*0.5f;
}
开发者ID:danskcarvalho,项目名称:rolltheball,代码行数:13,代码来源:Triangulate.cpp

示例11: triangulateVertices

NS_CC_BEGIN


Vector2dVector PRRatcliffTriangulator::triangulateVertices ( Vector2dVector aVertices ) 
{
	Vector2dVector*		pInputPointsForTriangulation = new Vector2dVector;

	for ( KDuint uIndex = 0; uIndex < aVertices.size ( ); uIndex++ )
	{
		Vector2d		tValue = (Vector2d) aVertices.at ( uIndex );
		pInputPointsForTriangulation->push_back ( tValue );
	}

	// Triangulate results
	Vector2dVector		aTriangulatedPoints;

	Triangulate::Process ( *pInputPointsForTriangulation, aTriangulatedPoints );

	delete pInputPointsForTriangulation;

	return aTriangulatedPoints;
}
开发者ID:mcodegeeks,项目名称:OpenKODE-Framework,代码行数:22,代码来源:PRRatcliffTriangulator.cpp

示例12: CC_SAFE_FREE

void EasyPolygon::setPoints(Vector2dVector &points) {
    
    if (points.size() <= 0) {
        areaTrianglePointCount = 0;
        return;
    }
    
    CC_SAFE_FREE(areaTrianglePoints);
    CC_SAFE_FREE(textureCoordinates);
    
    /*Vector2dVector triangulatedPoints = PRRatcliffTriangulator::triangulateVertices(points);
    
    areaTrianglePointCount = (int)triangulatedPoints.size();
    areaTrianglePoints = (Point*) malloc(sizeof(Point) * areaTrianglePointCount);
    textureCoordinates = (Point*) malloc(sizeof(Point) * areaTrianglePointCount);
    
    for (int i = 0; i < areaTrianglePointCount; i++) {
        Vector2d v = (Vector2d)triangulatedPoints.at(i);
        areaTrianglePoints[i] = Point(v.GetX(), v.GetY());
       // printf("x = %f, y = %f\n", v.GetX, v.GetY);
    }*/
    areaTrianglePointCount = 6;
    areaTrianglePoints = (Point*) malloc(sizeof(Point) * areaTrianglePointCount);
    textureCoordinates = (Point*) malloc(sizeof(Point) * areaTrianglePointCount);
    
    Vector2d v = points.at(0);
    areaTrianglePoints[0] = Point(v.GetX(), v.GetY());
    v = points.at(3);
    areaTrianglePoints[1] = Point(v.GetX(), v.GetY());
    v = points.at(2);
    areaTrianglePoints[2] = Point(v.GetX(), v.GetY());
    v = points.at(2);
    areaTrianglePoints[3] = Point(v.GetX(), v.GetY());
    v = points.at(1);
    areaTrianglePoints[4] = Point(v.GetX(), v.GetY());
    v = points.at(0);
    areaTrianglePoints[5] = Point(v.GetX(), v.GetY());

    
    calculateTextureCoordinates();
}
开发者ID:gouri34,项目名称:heist,代码行数:41,代码来源:EasyPolygon.cpp

示例13: CC_CALLBACK_2

bool FruitCutNinjaScene::init()
{
    if (!Layer::init())
    {
        return false;
    }
    
    _visibleSize = Director::getInstance()->getVisibleSize();
    _deltaRemainder = 0.0f;
    _sliceTag = 1;
    
    //createBackground();
    //加入封闭的盒子,用作墙壁
    auto body = PhysicsBody::createEdgeBox(_visibleSize, PHYSICSBODY_MATERIAL_DEFAULT, 3);
    auto wallNode = Node::create();
    wallNode->setPosition(_visibleSize.width/2, _visibleSize.height/2);
    wallNode->setPhysicsBody(body);
    this->addChild(wallNode);
    
    auto touchListener = EventListenerTouchAllAtOnce::create();
    touchListener->onTouchesBegan = CC_CALLBACK_2(FruitCutNinjaScene::onTouchesBegan, this);
    touchListener->onTouchesMoved = CC_CALLBACK_2(FruitCutNinjaScene::onTouchesMoved, this);
    touchListener->onTouchesEnded = CC_CALLBACK_2(FruitCutNinjaScene::onTouchesEnded, this);
    _eventDispatcher->addEventListenerWithSceneGraphPriority(touchListener, this);
    
    auto texture = Director::getInstance()->getTextureCache()->addImage("streak.png");
    
    for (int i = 0; i < 3; i++)
    {
        Blade* blade = Blade::createWithMaximumPoint(50);
        blade->setAutoDim(false);
        blade->setTexture(texture);
        
        addChild(blade, 100);
        _blades.pushBack(blade);
    }
    
    //PEShapeCache::getInstance()->addBodysWithFile("pineapple.plist");
    //auto body = PEShapeCache::getInstance()->getPhysicsBodyByName("pineapple");
    
    
    //Point points[4] = {Point(-128 + 128, -128 + 128), Point(-128 + 128, 128 + 128), Point(128 + 128, 128 + 128), Point(128 + 128, -128 + 128)};
    /*
    Point points[9] =
    {
        Point(157,50), Point(119, 13), Point(54, 0), Point(7,36), Point(5, 78), Point(23,118), Point(170,252), Point(235, 244), Point(237,158)
    };
    */
    Point points[4] =
    {
        Point(0, 0), Point(0, 512), Point(512, 512), Point(512, 0)
    };
    Vector2dVector vcPoints;
    vcPoints.clear();
    for (int i = 0; i < 4; i++)
    {
        vcPoints.push_back(Vector2d(points[i].x, points[i].y));
    }
    
    //texture = Director::getInstance()->getTextureCache()->addImage("boluo.png");
    PRFilledPolygon *filledPolygon = PRFilledPolygon::filledPolygonWithPointsAndTexture(vcPoints, "boluo.png");
    filledPolygon->setPhysicsBody(PhysicsBody::createPolygon(points, 4));
    filledPolygon->setPosition(Vec2(400, 700));
    filledPolygon->getPhysicsBody()->setTag(_sliceTag);
    filledPolygon->getPhysicsBody()->setGravityEnable(false);
    addChild(filledPolygon, 80);
    
    filledPolygon = PRFilledPolygon::filledPolygonWithPointsAndTexture(vcPoints, "xigua.png");
    filledPolygon->setPhysicsBody(PhysicsBody::createPolygon(points, 4));
    filledPolygon->setPosition(Vec2(1200, 700));
    filledPolygon->getPhysicsBody()->setTag(_sliceTag);
    filledPolygon->getPhysicsBody()->setGravityEnable(false);
    addChild(filledPolygon, 80);
    
    for (int i = 0; i < PARTICLE_COUNT; i++)
    {
        m_pEmitter[i] = ParticleSystemQuad::create("pineapple_splurt.plist");
        this->addChild(m_pEmitter[i], 100);
        m_pEmitter[i]->setAutoRemoveOnFinish(false);
        m_pEmitter[i]->setDuration(0.1f);
        m_pEmitter[i]->setScale(1.5f);
    }
    
    //本DEMO要做成一个切水果原型,尚未完成:)
    scheduleUpdate();
    return true;
}
开发者ID:GitofThunder,项目名称:gitskills,代码行数:87,代码来源:FruitCutNinjaScene.cpp

示例14: clipPoly

void FruitCutNinjaScene::clipPoly(PhysicsShapePolygon* shape, Point normal, float distance)
{
    PhysicsBody* body = shape->getBody();
    int count = shape->getPointsCount();
    int pointsCount = 0;
    Point* points = new Point[count + 1];
    
    Vector2dVector vcPoints;
    vcPoints.clear();
    Vector2d v2Point(0, 0);
    
    for (int i=0, j=count-1; i<count; j=i, ++i)
    {
        Point a = body->local2World(shape->getPoint(j));
        float aDist = a.dot(normal) - distance;
        
        if (aDist < 0.0f)
        {
            points[pointsCount] = a;
            ++pointsCount;
        }
        
        Point b = body->local2World(shape->getPoint(i));
        float bDist = b.dot(normal) - distance;
        
        if (aDist*bDist < 0.0f)
        {
            float t = std::fabs(aDist)/(std::fabs(aDist) + std::fabs(bDist));
            Vec2 v2Tmp = a.lerp(b, t);
            points[pointsCount] = v2Tmp;
            ++pointsCount;
        }
    }
    
    Point center = PhysicsShape::getPolyonCenter(points, pointsCount);
    
    for (int i = 0; i < pointsCount; i++)
    {
        points[i] = body->world2Local(points[i]);
        vcPoints.push_back(Vector2d(points[i].x, points[i].y));
    }
    
    PhysicsBody* polyon = PhysicsBody::createPolygon(points, pointsCount);
    
    PRFilledPolygon* pNode = (PRFilledPolygon*)(body->getNode());
    std::string sName = pNode->getTextureName();
    //auto texture = Director::getInstance()->getTextureCache()->addImage("pineapple.png");
    PRFilledPolygon *filledPolygon = PRFilledPolygon::filledPolygonWithPointsAndTexture(vcPoints, sName.c_str());
    filledPolygon->setPhysicsBody(polyon);
    filledPolygon->setPosition(body->getPosition() + normal * -40);
    filledPolygon->getPhysicsBody()->setTag(_sliceTag);
    filledPolygon->getPhysicsBody()->setGravityEnable(false);
    
    polyon->setVelocity(body->getVelocityAtWorldPoint(center));
    polyon->setAngularVelocity(body->getAngularVelocity());
    polyon->setTag(_sliceTag);
    //polyon->applyImpulse(normal * -100);
    addChild(filledPolygon, 80);
    
    /*
    CPolygonSprite* pSprite = CPolygonSprite::create();
    pSprite->initWithFile("pineapple.png", polyon, false);
    pSprite->setPosition(body->getPosition());
    polyon->setTag(_sliceTag);
    addChild(pSprite);
    */
    
    /*
    Node* node = Node::create();
    PhysicsBody* polyon = PhysicsBody::createPolygon(points, pointsCount, PHYSICSBODY_MATERIAL_DEFAULT, -center);
    node->setPosition(center);
    node->setPhysicsBody(polyon);
    polyon->setVelocity(body->getVelocityAtWorldPoint(center));
    polyon->setAngularVelocity(body->getAngularVelocity());
    polyon->setTag(_sliceTag);
    addChild(node);
    */
    delete[] points;
}
开发者ID:GitofThunder,项目名称:gitskills,代码行数:79,代码来源:FruitCutNinjaScene.cpp

示例15: clipPoly

void CCutScene::clipPoly(PhysicsShapePolygon* shape, Point normal, float distance)
{
    PhysicsBody* body = shape->getBody();
    int count = shape->getPointsCount();
    int pointsCount = 0;
    Point* points = new Point[count + 1];
    
    Vector2dVector vcPoints;
    vcPoints.clear();
    Vector2d v2Point(0, 0);
    
    for (int i=0, j=count-1; i<count; j=i, ++i)
    {
        Point a = body->local2World(shape->getPoint(j));
        float aDist = a.dot(normal) - distance;
        
        if (aDist < 0.0f)
        {
            points[pointsCount] = a;
            ++pointsCount;
        }
        
        Point b = body->local2World(shape->getPoint(i));
        float bDist = b.dot(normal) - distance;
        
        if (aDist*bDist < 0.0f)
        {
            float t = std::fabs(aDist)/(std::fabs(aDist) + std::fabs(bDist));
            Vec2 v2Tmp = a.lerp(b, t);
            points[pointsCount] = v2Tmp;
            ++pointsCount;
        }
    }
    
    Point center = PhysicsShape::getPolyonCenter(points, pointsCount);
    
    for (int i = 0; i < pointsCount; i++)
    {
        points[i] = body->world2Local(points[i]);
        vcPoints.push_back(Vector2d(points[i].x, points[i].y));
    }
    
    PhysicsBody* polyon = PhysicsBody::createPolygon(points, pointsCount);
    
    CFoodCut* pNode = (CFoodCut*)(body->getNode());
    std::vector<int> vMaterials;
    vMaterials.clear();
    vMaterials = pNode->getMaterials();
    MATERIAL_ID eId = MI_MAX;
    if (vMaterials.size() != 0)
    {
        eId = (MATERIAL_ID)vMaterials[0];
    }
    
    CFoodCut *filledPolygon = CFoodCut::create(eId, vcPoints, pNode->getPanziIndex(), pNode->getTouchedIndex());
    filledPolygon->setPhysicsBody(polyon);
    int nTmp = rand() % 50 + 50;
    int nTmpRotate = rand() % 30 - 60;
    filledPolygon->setPosition(body->getPosition());
    //filledPolygon->setRotation(filledPolygon->getRotation() + nTmpRotate);
    filledPolygon->getPhysicsBody()->setTag(_sliceTag);
    filledPolygon->getPhysicsBody()->setGravityEnable(false);
    
    
    polyon->setVelocity(body->getVelocityAtWorldPoint(center));
    //polyon->setAngularVelocity(body->getAngularVelocity());
    polyon->setTag(_sliceTag);
    
    float fMass = polyon->getMass();
    float fV = 80;
    float fImpulse = fMass * fV;
    float fTmpX = (float)(Random() % 30) / 100.0f - 0.15f;
    float fTmpY = (float)(rand() % 30) / 100.0f - 0.15f;
    polyon->applyImpulse((normal + Vec2(fTmpX, fTmpY)) * -fImpulse);
    polyon->setLinearDamping(0.8f);
    addChild(filledPolygon, 80);
    filledPolygon->setBirthTime(getCurTime());
    m_vCutFoods.push_back(filledPolygon);
    m_nSliceCount ++;
    delete[] points;
}
开发者ID:GitofThunder,项目名称:gitskills,代码行数:81,代码来源:CutScene.cpp


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