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


C++ QVector2D函数代码示例

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


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

示例1: while

/*
 *
 * **************************************************/
void CubeObj::takeTexture() {
    // Calculate Matrix using the parent matrixes too
    std::stack<QMatrix4x4> mats;
    QMatrix4x4 cmat;

    // Store previous matrixes in stack
    CubeObj *po = this;
    bool notroot = true;
    while ( notroot ) {
        if ( po != pro.objectRoot ) {
            mats.push( po->getMatrix() );
           // qDebug() << po->m_itemData;
            po = (CubeObj * ) po->parentItem();
        } else {
            mats.push( po->getMatrix() );
            //qDebug() << po->m_itemData;
            notroot = false;
        }
    }

    // camera mat * parent mat * parent mat ..... * parent mat * this mat * this scale
//    cmat = pro.getManger().fixCamera->getMatrix();          // TODO
    for ( int i=0 , e = mats.size(); i < e ; i ++ ) {
        cmat *= mats.top();
        mats.pop();
       // qDebug() << "mat";
    }
    cmat.scale(scale);

    // Project points to screen
    QVector3D vect;
    qDebug() << "verticies " << vertices.size();
    qDebug() << "TexCoords " << texCoords.size();

    QVector<QVector2D> projectedPoints;
    for ( int i = 0; i < vertices.size(); i++) {    // verticies.size
        vect =  cmat * vertices[i];
        projectedPoints.append(  QVector2D ( ( vect.x()   + 1 ) / 2   , ( 1 - vect.y() )  / 2 ) );
    }

    // The output texture image coordinate and size
    int w,h;
    w = textureMat->cols;
    h = textureMat->rows;

    cv::Point2f ocoords[ 4 ];
    ocoords[0] = cv::Point2f (0, 0);
    ocoords[1] = cv::Point2f (0, h);
    ocoords[2] = cv::Point2f (w, h);
    ocoords[3] = cv::Point2f (w, 0);

    cv::Point2f textpoints[24];      // TODO
 //   UvtoCvCoordinate( *pro.actualBackground, projectedPoints, textpoints ); TODO
/*
    // for test
    for ( int i = 0; i < 24 ; i++) {
        //qDebug() << textpoints[i].x << " : " << textpoints[i].y;
        cv::circle( pro.actualBackground, textpoints[i],3, cv::Scalar(1,255,1), 2 );
        pro.reLoadback();
    }
    // -------------------*/

    GLWidget & gl = pro.getManger().getMainGLW();
    for ( int i =0; i < 6; i++) {
        cv::Mat ptransform = getPerspectiveTransform ( &textpoints[i*4], ocoords);
//        cv::warpPerspective( *pro.actualBackground, *textureMat, ptransform,  textureMat->size() );
        if ( textureIDs[i] == 0 ) {
            gl.glGenBuffers( 1, &textureIDs[i]);
            qDebug() << "TextureId:" << textureIDs[i];
        }
        gl.glBindTexture ( GL_TEXTURE_2D , textureIDs[i]);
        gl.glTexImage2D(  GL_TEXTURE_2D, 0, GL_RGB, textureMat->cols, textureMat->rows, 0, GL_RGB,
                          GL_UNSIGNED_BYTE, ( GLvoid * ) textureMat->data );
        gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
        gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
        gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
        gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    }



  /*  texCoords[0] =  QVector2D ( 0,0);                      // Set Texture coordinate
    texCoords[1] =  QVector2D ( 0,1);
    texCoords[2] =  QVector2D ( 1,1);
    texCoords[3] =  QVector2D ( 1,0);*/
 /*  textPixmap   =  QPixmap::fromImage( this->cvMatToQImage( *textureMat) );*/


}
开发者ID:Nand-e,项目名称:2to3d,代码行数:92,代码来源:cubeObj.cpp

示例2: QVector2D

void Quad::rightPress(BrushArea& brush, QMouseEvent* e) {
	brush.texelRange = QVector2D(1,1);
	brush.position = endPoint_- QVector2D(1,1);
	endPoint_ = startPoint_;
	abort_ = true;
}
开发者ID:EmeraldGit,项目名称:elias_broschin_tup,代码行数:6,代码来源:Quad.cpp

示例3: Candidate

    Candidate(const QVector2D &f, const QPointF &s, GeometryUtilities::Side t) : first(f), second(s), third(t) { }

    QVector2D first;
    QPointF second;
    GeometryUtilities::Side third = GeometryUtilities::SideUnspecified;
};

}

bool GeometryUtilities::placeRectAtLine(const QRectF &rect, const QLineF &line, double lineOffset, double distance,
                                        const QLineF &intersectionLine, QPointF *placement, Side *horizontalAlignedSide)
{
    QMT_ASSERT(placement, return false);

    QList<Candidate> candidates;
    candidates << Candidate(QVector2D(rect.topRight() - rect.topLeft()), QPointF(0.0, 0.0), SideTop)
               << Candidate(QVector2D(rect.topLeft() - rect.topRight()), rect.topRight() - rect.topLeft(), SideTop)
               << Candidate(QVector2D(rect.bottomLeft() - rect.topLeft()), QPointF(0.0, 0.0), SideLeft)
               << Candidate(QVector2D(rect.topLeft() - rect.bottomLeft()), rect.bottomLeft() - rect.topLeft(), SideLeft)
               << Candidate(QVector2D(rect.bottomRight() - rect.bottomLeft()), rect.bottomLeft() - rect.topLeft(), SideBottom)
               << Candidate(QVector2D(rect.bottomLeft() - rect.bottomRight()), rect.bottomRight() - rect.topLeft(), SideBottom)
               << Candidate(QVector2D(rect.bottomRight() - rect.topRight()), rect.topRight() - rect.topLeft(), SideRight)
               << Candidate(QVector2D(rect.topRight() - rect.bottomRight()), rect.bottomRight() - rect.topLeft(), SideRight);

    QVector<QVector2D> rectEdgeVectors;
    rectEdgeVectors << QVector2D(rect.topLeft() - rect.topLeft())
                    << QVector2D(rect.topRight() - rect.topLeft())
                    << QVector2D(rect.bottomLeft() - rect.topLeft())
                    << QVector2D(rect.bottomRight() -rect.topLeft());

    QVector2D directionVector(line.p2() - line.p1());
开发者ID:kai66673,项目名称:qt-creator,代码行数:31,代码来源:geometryutilities.cpp

示例4: QVector2D

double Cone::F(const QVector3D &p)
{
	QVector3D s = p - position;
	    float q = QVector2D(s.x(), s.z()).length();
	    return QVector2D::dotProduct(c, QVector2D(q, s.y()));
}
开发者ID:artyrian,项目名称:graphicon,代码行数:6,代码来源:Object.cpp

示例5: wglGetProcAddress

void GlWidget::initializeGL()
{
    #ifdef WIN32
        glActiveTexture = (PFNGLACTIVETEXTUREPROC) wglGetProcAddress((LPCSTR) "glActiveTexture");
    #endif

    glEnable(GL_DEPTH_TEST);
    glEnable(GL_CULL_FACE);

    qglClearColor(QColor(Qt::black));

    shaderProgram.addShaderFromSourceFile(QGLShader::Vertex, ":/vertexShader.vsh");
    shaderProgram.addShaderFromSourceFile(QGLShader::Fragment, ":/fragmentShader.fsh");
    shaderProgram.link();

    vertices << QVector3D(-0.5, -0.5,  0.5) << QVector3D( 0.5, -0.5,  0.5) << QVector3D( 0.5,  0.5,  0.5) // Front
             << QVector3D( 0.5,  0.5,  0.5) << QVector3D(-0.5,  0.5,  0.5) << QVector3D(-0.5, -0.5,  0.5)
             << QVector3D( 0.5, -0.5, -0.5) << QVector3D(-0.5, -0.5, -0.5) << QVector3D(-0.5,  0.5, -0.5) // Back
             << QVector3D(-0.5,  0.5, -0.5) << QVector3D( 0.5,  0.5, -0.5) << QVector3D( 0.5, -0.5, -0.5)
             << QVector3D(-0.5, -0.5, -0.5) << QVector3D(-0.5, -0.5,  0.5) << QVector3D(-0.5,  0.5,  0.5) // Left
             << QVector3D(-0.5,  0.5,  0.5) << QVector3D(-0.5,  0.5, -0.5) << QVector3D(-0.5, -0.5, -0.5)
             << QVector3D( 0.5, -0.5,  0.5) << QVector3D( 0.5, -0.5, -0.5) << QVector3D( 0.5,  0.5, -0.5) // Right
             << QVector3D( 0.5,  0.5, -0.5) << QVector3D( 0.5,  0.5,  0.5) << QVector3D( 0.5, -0.5,  0.5)
             << QVector3D(-0.5,  0.5,  0.5) << QVector3D( 0.5,  0.5,  0.5) << QVector3D( 0.5,  0.5, -0.5) // Top
             << QVector3D( 0.5,  0.5, -0.5) << QVector3D(-0.5,  0.5, -0.5) << QVector3D(-0.5,  0.5,  0.5)
             << QVector3D(-0.5, -0.5, -0.5) << QVector3D( 0.5, -0.5, -0.5) << QVector3D( 0.5, -0.5,  0.5) // Bottom
             << QVector3D( 0.5, -0.5,  0.5) << QVector3D(-0.5, -0.5,  0.5) << QVector3D(-0.5, -0.5, -0.5);

    textureCoordinates << QVector2D(0, 0) << QVector2D(1, 0) << QVector2D(1, 1) // Front
                       << QVector2D(1, 1) << QVector2D(0, 1) << QVector2D(0, 0)
                       << QVector2D(0, 0) << QVector2D(1, 0) << QVector2D(1, 1) // Back
                       << QVector2D(1, 1) << QVector2D(0, 1) << QVector2D(0, 0)
                       << QVector2D(0, 0) << QVector2D(1, 0) << QVector2D(1, 1) // Left
                       << QVector2D(1, 1) << QVector2D(0, 1) << QVector2D(0, 0)
                       << QVector2D(0, 0) << QVector2D(1, 0) << QVector2D(1, 1) // Right
                       << QVector2D(1, 1) << QVector2D(0, 1) << QVector2D(0, 0)
                       << QVector2D(0, 0) << QVector2D(1, 0) << QVector2D(1, 1) // Top
                       << QVector2D(1, 1) << QVector2D(0, 1) << QVector2D(0, 0)
                       << QVector2D(0, 0) << QVector2D(1, 0) << QVector2D(1, 1) // Bottom
                       << QVector2D(1, 1) << QVector2D(0, 1) << QVector2D(0, 0);

    texture = bindTexture(QPixmap(":/texture.png"));
}
开发者ID:s0dz,项目名称:playingWithOpenGL,代码行数:43,代码来源:glwidget.cpp

示例6: QVector2D

void Fill::neighbourCheck(QVector2D pos) {
	int lw = lvl_->levelDimensions().x();
	int lh = lvl_->levelDimensions().y();
	int sx = startPos_.x()-30;
	if(sx <= 0)
		sx = 0;
	int sy = startPos_.y()-30;
	if(sy <= 0)
		sy = 0;
	int ex = startPos_.x()+30;
	if(ex >= lw)
		ex = lw;
	int ey = startPos_.y()+30;
	if(ey >= lh)
		ey = lh;

	if(!(int(pos.x()) >= sx && int(pos.x()) < ex && int(pos.y()) >= sy && int(pos.y()) < ey)) return;
	if(Util::List::findElement(visited_, pos)) return;

	std::vector<QVector2D> neighbours;

	auto leftPos = QVector2D(int(pos.x())-1, int(pos.y()));
	auto left = lvl_->getTile(leftPos.x(), leftPos.y(), lvl_->currentLayer());

	if(left && int(left->setLocation.x()) == int(fillTile_->setLocation.x()) && int(left->setLocation.y()) == int(fillTile_->setLocation.y()))
		if(!Util::List::findElement(visited_, leftPos))
			neighbours.push_back(leftPos);

	auto topPos = QVector2D(int(pos.x()), int(pos.y())-1);
	auto top = lvl_->getTile(topPos.x(), topPos.y(), lvl_->currentLayer());

	if(top && int(top->setLocation.x()) == int(fillTile_->setLocation.x()) && int(top->setLocation.y()) == int(fillTile_->setLocation.y()))
		if(!Util::List::findElement(visited_, topPos))
			neighbours.push_back(topPos);

	auto rightPos = QVector2D(int(pos.x())+1, int(pos.y()));
	auto right = lvl_->getTile(rightPos.x(), rightPos.y(), lvl_->currentLayer());

	if(right && int(right->setLocation.x()) == int(fillTile_->setLocation.x()) && int(right->setLocation.y()) == int(fillTile_->setLocation.y()))
		if(!Util::List::findElement(visited_, rightPos))
			neighbours.push_back(rightPos);

	auto downPos = QVector2D(int(pos.x()), int(pos.y())+1);
	auto down = lvl_->getTile(downPos.x(), downPos.y(), lvl_->currentLayer());

	if(down && int(down->setLocation.x()) == int(fillTile_->setLocation.x()) && int(down->setLocation.y()) == int(fillTile_->setLocation.y()))
		if(!Util::List::findElement(visited_, downPos))
			neighbours.push_back(downPos);

	std::pair<int,int> pair = std::make_pair(int(pos.x()), int(pos.y()));
	if(!Util::Map::findKey(urTiles_,pair)) {
		auto prevTile = lvl_->getTile(pair.first, pair.second, lvl_->currentLayer());
		URTile prev;
		if(prevTile) {
			prev = {*prevTile, pos, lvl_->currentLayer()};
		} else
			prev = {Tile(), QVector2D(-1,-1), lvl_->currentLayer()};
		std::pair<URTile,URTile> urPair = std::pair<URTile,URTile>(prev,{*selectedTile_,pos, lvl_->currentLayer()});
		urTiles_[pair] = urPair;
	}
	visited_.push_back(pos);

	for(auto &n : neighbours)
		neighbourCheck(n);
}
开发者ID:EmeraldGit,项目名称:elias_broschin_tup,代码行数:65,代码来源:Fill.cpp

示例7: QVector2D

 QVector2D WarpGrid::getTexCoord(int _x, int _y) const
 {
     return QVector2D(float(_x) / (horizontal() - 1),
                      float(_y) / (vertical() - 1));
 }
开发者ID:emervark,项目名称:omnidome,代码行数:5,代码来源:WarpGrid.cpp

示例8: QVector2D

void SurfaceGraph::mousePressEvent(QMouseEvent *e)
{
    // Save mouse press position
    mousePressPosition = QVector2D(e->localPos());
    isDragging = true;
}
开发者ID:gareins,项目名称:surface-reconstruction,代码行数:6,代码来源:surfacegraph.cpp

示例9: file

RawModel *OBJLoader::Load(QString path)
{
    QVector<QVector3D> tempVertices, outVertices;
    QVector<QVector2D> tempTextures, outTextures;
    QVector<QVector3D> tempNormals, outNormals;

    QVector<int> vertexIndices;
    QVector<int> texIndices;
    QVector<int> normalIndices;

    QFile file(":/res/"+path+".obj");
    if(!file.open(QIODevice::ReadOnly)) {
        QMessageBox::information(0, "error", file.errorString());
        return NULL;
    }

    QTextStream in(&file);
    while(!in.atEnd())
    {
        QString line = in.readLine();
        QStringList fields = line.split(" ", QString::SkipEmptyParts);
        if (line.startsWith("v "))
        {
            tempVertices.append(QVector3D(fields[1].toFloat(), fields[2].toFloat(), fields[3].toFloat()));
        }
        else if (line.startsWith("vt"))
        {
            tempTextures.append(QVector2D(fields[1].toFloat(), fields[2].toFloat()));
        }
        else if (line.startsWith("vn"))
        {
            tempNormals.append(QVector3D(fields[1].toFloat(), fields[2].toFloat(), fields[3].toFloat()));
        }
        else if (line.startsWith("f "))
        {
            for (int i=0; i<3; i++)
            {
                QStringList indeces = fields[i+1].split("/");
                vertexIndices.append(indeces[0].toInt());
                texIndices   .append(indeces[1].toInt());
                normalIndices.append(indeces[2].toInt());
            }
        }
    }
    for(int i=0; i<vertexIndices.size(); i++)
    {
        unsigned int vertexIndex = vertexIndices[i];
        outVertices.append(tempVertices[vertexIndex-1]);
    }
    for(int i=0; i<texIndices.size(); i++)
    {
        unsigned int texIndex = texIndices[i];
        outTextures.append(tempTextures[texIndex-1]);
    }
    for(int i=0; i<normalIndices.size(); i++)
    {
        unsigned int normalIndex = normalIndices[i];
        outNormals.append(tempNormals[normalIndex-1]);
    }
    return new RawModel(outVertices, outTextures, outNormals);
}
开发者ID:Victer3965,项目名称:OGL2,代码行数:61,代码来源:objloader.cpp

示例10: RoadEdgePtr

/**
* 指定されたtensor filedに基づいて、ptからsegment_length分の道路セグメントを生成する。
* ただし、ターゲットエリア外に出るか、既存セグメントとの交差点が既存交差点の近くなら、途中で終了する。
*
* @param tensor				tensor field
* @param segment_length		segment length
* @param near_threshold		near threshold
* @param srcDesc			src vertex desc
* @param tgtDesc [OUT]		tgt vertex desc
* @param type				1 -- major eigen vector / 2 -- minor eigen vector
* @return					0 -- 正常終了 / 1 -- ターゲットエリア外に出て終了 / 2 -- 既存交差点の近くで交差して終了
*/
int PMRoadGenerator::generateRoadSegmentByTensor(const cv::Mat& tensor, float segment_length, float near_threshold, RoadVertexDesc srcDesc, RoadVertexDesc& tgtDesc, int type) {
	int num_step = 5;
	float step_length = (segment_length + Util::genRand(-1.0, 1.0)) / num_step;

	BBox bbox = targetArea.envelope();

	QVector2D pt = roads.graph[srcDesc]->pt;
	RoadEdgePtr new_edge = RoadEdgePtr(new RoadEdge(RoadEdge::TYPE_AVENUE, 1));
	new_edge->addPoint(pt);

	for (int i = 0; i < num_step; ++i) {
		// ターゲットエリア外ならストップ
		if (!targetArea.contains(pt)) {
			return 1;
		}

		/////////////////////////////////////////////////////////////////////
		// use Runge-Kutta 4 to obtain the next angle
		int c = pt.x() - bbox.minPt.x();
		int r = pt.y() - bbox.minPt.y();
		float angle1 = tensor.at<float>(r, c);
		if (type == 2) angle1 += M_PI / 2;	// minor eigen vectorならPI/2を足す

		// angle2
		QVector2D pt2 = pt + QVector2D(cosf(angle1), sinf(angle1)) * (step_length * 0.5);
		int c2 = pt2.x() - bbox.minPt.x();
		int r2 = pt2.y() - bbox.minPt.y();
		float angle2 = angle1;
		if (c2 >= 0 && c2 < tensor.cols && r2 >= 0 && r2 < tensor.rows) {
			angle2 = tensor.at<float>(r2, c2);
			if (type == 2) angle2 += M_PI / 2;	// minor eigen vectorならPI/2を足す
		}

		// angle3
		QVector2D pt3 = pt + QVector2D(cosf(angle2), sinf(angle2)) * (step_length * 0.5);
		int c3 = pt3.x() - bbox.minPt.x();
		int r3 = pt3.y() - bbox.minPt.y();
		float angle3 = angle2;
		if (c3 >= 0 && c3 < tensor.cols && r3 >= 0 && r3 < tensor.rows) {
			angle3 = tensor.at<float>(r3, c3);
			if (type == 2) angle3 += M_PI / 2;	// minor eigen vectorならPI/2を足す
		}

		// angle4
		QVector2D pt4 = pt + QVector2D(cosf(angle3), sinf(angle3)) * step_length;
		int c4 = pt4.x() - bbox.minPt.x();
		int r4 = pt4.y() - bbox.minPt.y();
		float angle4 = angle3;
		if (c4 >= 0 && c4 < tensor.cols && r4 >= 0 && r4 < tensor.rows) {
			angle4 = tensor.at<float>(r4, c4);
			if (type == 2) angle4 += M_PI / 2;	// minor eigen vectorならPI/2を足す
		}

		// RK4によりangleを計算
		float angle = angle1 / 6.0 + angle2 / 3.0 + angle3 / 3.0 + angle4 / 6.0;

		// 次のステップの座標を求める
		QVector2D next_pt = pt + QVector2D(cosf(angle), sinf(angle)) * step_length;

		// 交差点を求める
		RoadEdgeDesc nearestEdgeDesc;
		QVector2D intPt;
		if (GraphUtil::isIntersect(roads, pt, next_pt, nearestEdgeDesc, intPt)) {
			int edgeEigenType = roads.graph[nearestEdgeDesc]->eigenType;

			// 他のエッジにスナップ
			tgtDesc = GraphUtil::splitEdge(roads, nearestEdgeDesc, intPt);
			intPt = roads.graph[tgtDesc]->pt;
			roads.graph[tgtDesc]->eigenType |= type;
			roads.graph[tgtDesc]->eigenType |= edgeEigenType;
			roads.graph[tgtDesc]->new_vertx = true;

			new_edge->addPoint(intPt);

			// エッジを生成
			new_edge->eigenType = type;
			GraphUtil::addEdge(roads, srcDesc, tgtDesc, new_edge);

			// エッジを交差点から再開させる
			srcDesc = tgtDesc;
			pt = intPt;
			new_edge = RoadEdgePtr(new RoadEdge(RoadEdge::TYPE_AVENUE, 1));
			new_edge->addPoint(pt);

			// 既に近くに頂点がないかチェック
			bool foundNearVertex = false;
			RoadVertexIter vi, vend;
			for (boost::tie(vi, vend) = boost::vertices(roads.graph); vi != vend; ++vi) {
//.........这里部分代码省略.........
开发者ID:gnishida,项目名称:SimpleCities,代码行数:101,代码来源:PMRoadGenerator.cpp

示例11: while

/**
 * 座標pt、角度angleから開始して1本の道路を生成する。
 *
 * @param size						ターゲットエリアの一辺の長さ
 * @param angle						角度 [rad]
 * @param pt						開始位置
 * @param curvature					曲率
 * @param segment_length			segment length
 * @param regular_elements [OUT]	tensor fieldを指定するためのコントロール情報
 * @param seeds [OUT]				生成された頂点をseedリストに追加する
*/
void PMRoadGenerator::growRoads(float angle, RoadVertexDesc srcDesc, float curvature, float segment_length, int type, std::vector<std::pair<QVector2D, float>>& regular_elements, std::list<RoadVertexDesc>& seeds) {
	int num_steps = 5;

	QVector2D pt = roads.graph[srcDesc]->pt;

	bool loop = true;
	while (loop) {
		// 今後5ステップ分の曲率を、平均がcurvatureになるようランダムに決定する。
		std::vector<float> rotates;
		float total = 0.0f;
		for (int i = 0; i < num_steps; ++i) {
			float r = rand() % 100;
			rotates.push_back(r);
			total += r;
		}
		for (int i = 0; i < num_steps; ++i) {
			rotates[i] = rotates[i] / total * curvature * num_steps;
		}

		// 曲がる方向を決定する
		int rotate_dir = rand() % 2 == 0 ? 1 : -1;

		// 5ステップ分の道路セグメントを生成する
		for (int i = 0; i < num_steps; ++i) {
			// ターゲットエリア外なら終了
			if (!targetArea.contains(pt)) return;

			angle += rotates[i] * rotate_dir;
			QVector2D pt2 = pt + QVector2D(cosf(angle), sinf(angle)) * (segment_length + Util::genRand(-1.0, 1.0));

			RoadEdgeDesc closestEdge;
			QVector2D intPt;
			if (GraphUtil::isIntersect(roads, pt, pt2, closestEdge, intPt)) {
				// 他のエッジにスナップ
				RoadVertexDesc tgtDesc = GraphUtil::splitEdge(roads, closestEdge, intPt);
				roads.graph[tgtDesc]->eigenType |= type;

				// エッジを生成
				RoadEdgePtr new_edge = RoadEdgePtr(new RoadEdge(RoadEdge::TYPE_AVENUE, 1));
				new_edge->addPoint(pt);
				new_edge->addPoint(intPt);
				new_edge->eigenType = type;
				GraphUtil::addEdge(roads, srcDesc, tgtDesc, new_edge);

				return;
			}		

			// add a vertex
			RoadVertexPtr v = RoadVertexPtr(new RoadVertex(pt2));
			RoadVertexDesc tgtDesc = GraphUtil::addVertex(roads, v);
			roads.graph[tgtDesc]->eigenType = type;

			// add this vertex to the seeds
			seeds.push_back(tgtDesc);

			// add an edge
			RoadEdgePtr new_edge = RoadEdgePtr(new RoadEdge(RoadEdge::TYPE_AVENUE, 1));
			new_edge->addPoint(pt);
			new_edge->addPoint(pt2);
			GraphUtil::addEdge(roads, srcDesc, tgtDesc, new_edge);

			regular_elements.push_back(std::make_pair(pt2, angle));

			pt = pt2;
			srcDesc = tgtDesc;
		}
	}
}
开发者ID:gnishida,项目名称:SimpleCities,代码行数:79,代码来源:PMRoadGenerator.cpp

示例12: atan2f

/**
 * 指定されたpolylineに従って、srcDesc頂点からエッジを伸ばす。
 * エッジの端点が、srcDescとは違うセルに入る場合は、falseを返却する。
 */
bool PatchRoadGenerator::growRoadSegment(int roadType, RoadVertexDesc srcDesc, ExFeature& f, const Polyline2D &polyline, int lanes, float angleTolerance, std::list<RoadVertexDesc> &seeds) {
	float angle = atan2f(polyline[1].y() - polyline[0].y(), polyline[1].x() - polyline[0].x());

	RoadEdgePtr new_edge = RoadEdgePtr(new RoadEdge(roadType, lanes));
	new_edge->polyline.push_back(roads.graph[srcDesc]->pt);

	RoadVertexDesc tgtDesc;
	bool found = false;
	{
		// 指定された方向で、直近の頂点があるかチェックする。
		// まずは、指定された方向に非常に近い頂点があるかチェックする。この際、距離は少し遠くまで許容する。
		// 次に、方向のレンジを少し広げて、その代わり、距離を短くして、改めてチェックする。
		/*if (GraphUtil::getVertex(roads, srcDesc, polyline.length() * 2.0f, angle, 0.1f, tgtDesc)) {
			found = true;
		} else if (GraphUtil::getVertex(roads, srcDesc, polyline.length() * 1.5f, angle, 0.2f, tgtDesc)) {
			found = true;
		} else if (GraphUtil::getVertex(roads, srcDesc, polyline.length(), angle, 0.3f, tgtDesc)) {
			found = true;
		}
		*/
		if (GraphUtil::getVertexExceptDeadend(roads, srcDesc, polyline.length() * 2.0f, angle, 0.3f, tgtDesc)) {
			found = true;
		}

		if (found) {
			// もしスナップ先が、シードじゃないなら、エッジ生成をキャンセル
			if (std::find(seeds.begin(), seeds.end(), tgtDesc) == seeds.end()) {
				//(要検討。80%の確率ぐらいにすべきか?)
				if (Util::genRand(0, 1) < 0.8f) return false;
			}

			// もしスナップ先の頂点が、redundantなエッジを持っているなら、エッジ生成をキャンセル
			Polyline2D snapped_polyline;
			snapped_polyline.push_back(QVector2D(0, 0));
			snapped_polyline.push_back(QVector2D(roads.graph[srcDesc]->pt - roads.graph[tgtDesc]->pt));
			if (RoadGeneratorHelper::isRedundantEdge(roads, tgtDesc, snapped_polyline, 0.3f)) {
				//(とりあえず、ものすごい鋭角の場合は、必ずキャンセル)
				return false;
			}

			// もし他のエッジに交差するなら、エッジ生成をキャンセル
			// (キャンセルせずに、交差させるべき?)
			QVector2D intPoint;
			RoadEdgeDesc closestEdge;
			new_edge->polyline.push_back(roads.graph[tgtDesc]->pt);
			if (GraphUtil::isIntersect(roads, new_edge->polyline, srcDesc, closestEdge, intPoint)) {
				if (Util::genRand(0, 1) < 0.5f) return false;

				new_edge->polyline[1] = intPoint;

				// 他のエッジにスナップ
				tgtDesc = GraphUtil::splitEdge(roads, closestEdge, intPoint);
				roads.graph[tgtDesc]->properties["generation_type"] = "snapped";
				roads.graph[tgtDesc]->properties["group_id"] = roads.graph[closestEdge]->properties["group_id"];
				roads.graph[tgtDesc]->properties["ex_id"] = roads.graph[closestEdge]->properties["ex_id"];
				roads.graph[tgtDesc]->properties.remove("example_desc");
			} else {
				new_edge->polyline.push_back(roads.graph[tgtDesc]->pt);
			}
		}
	}

	if (!found) {
		// snap先がなければ、指定されたpolylineに従ってエッジを生成する。
		new_edge->polyline.push_back(roads.graph[srcDesc]->pt + polyline[1]);

		// もし、新規エッジが、既存グラフと交差するなら、エッジ生成をキャンセル
		QVector2D intPoint;
		RoadEdgeDesc closestEdge;
		if (GraphUtil::isIntersect(roads, new_edge->polyline, srcDesc, closestEdge, intPoint)) {
			// 60%の確率でキャンセル?
			if (Util::genRand(0, 1) < 0.6f) return false;

			// 交差する箇所で中断させる
			new_edge->polyline[1] = intPoint;

			// 他のエッジにスナップ
			tgtDesc = GraphUtil::splitEdge(roads, closestEdge, intPoint);
			roads.graph[tgtDesc]->properties["generation_type"] = "snapped";
			roads.graph[tgtDesc]->properties["group_id"] = roads.graph[closestEdge]->properties["group_id"];
			roads.graph[tgtDesc]->properties["ex_id"] = roads.graph[closestEdge]->properties["ex_id"];
			roads.graph[tgtDesc]->properties.remove("example_desc");

			found = true;
		}
	}

	if (!found) {
		// 頂点を追加
		RoadVertexPtr v = RoadVertexPtr(new RoadVertex(new_edge->polyline.last()));
		tgtDesc = GraphUtil::addVertex(roads, v);

		// エリアの外なら、onBoundaryフラグをセット
		if (!targetArea.contains(roads.graph[tgtDesc]->pt)) {
			roads.graph[tgtDesc]->onBoundary = true;
		}
//.........这里部分代码省略.........
开发者ID:gnishida,项目名称:QtUrban2,代码行数:101,代码来源:PatchRoadGenerator.cpp

示例13: mTextureType

/****************************************************************************
**
** Copyright (C) 2016 - 2017
**
** This file is generated by the Magus toolkit
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
****************************************************************************/

// Include
#include <float.h>
#include <QMessageBox>
#include <QSettings>
#include "constants.h"
#include "hlms_node_samplerblock.h"
#include "hlms_node_porttypes.h"

//****************************************************************************/
HlmsNodeSamplerblock::HlmsNodeSamplerblock(QString title, QGraphicsItem* parent) :
    Magus::QtNode(title, parent),
    mTextureType(0),
    mTextureIndex(0),
    mSamplerblockEnabled(true),
    mTextureAddressingModeU(0),
    mTextureAddressingModeV(0),
    mTextureAddressingModeW(0),
    mMipLodBias(0.0f),
    mMaxAnisotropy(1.0f),
    mCompareFunction(8),
    mMinLod(-FLT_MAX),
    mMaxLod(FLT_MAX),
    mBorderColourRed(255.0f),
    mBorderColourGreen(255.0f),
    mBorderColourBlue(255.0f),
    mUvSet(0),
    mBlendMode(0),
    mMapWeight(1.0f),
    mEmissiveColourRed(0.0f),
    mEmissiveColourGreen(0.0f),
    mEmissiveColourBlue(0.0f),
    mAnimationEnabled(false),
    mSequenceNumber(-1)
{
    mFileNameTexture = QString("");
    mBaseNameTexture = QString("");
    mPathTexture = QString("");
    mOffset = QVector2D(0.0f, 0.0f);
    mScale = QVector2D(1.0f, 1.0f);
    mAnimationScale = QVector2D(1.0f, 1.0f);
    mAnimationTranslate = QVector2D(0.0f, 0.0f);

    // Define the connection policy
    HlmsPbsDatablockSamplerblockPortType hlmsPbsDatablockSamplerblockPortType;
    HlmsSamplerblockDatablockPortType hlmsSamplerblockDatablockPortType;
    hlmsPbsDatablockSamplerblockPortType.addPortTypeToConnectionPolicy(hlmsSamplerblockDatablockPortType);

    // Apply values from settings.cfg
    QSettings settings(FILE_SETTINGS, QSettings::IniFormat);
    mTextureMinFilter = settings.value(SETTINGS_SAMPLERBLOCK_FILTER_INDEX).toInt();
    mTextureMagFilter = settings.value(SETTINGS_SAMPLERBLOCK_FILTER_INDEX).toInt();
    mTextureMipFilter = settings.value(SETTINGS_SAMPLERBLOCK_FILTER_INDEX).toInt();

    // Custome node settings
    setTitleColor(Qt::white);
    setHeaderTitleIcon(ICON_SAMPLERBLOCK);
    setAction1Icon(ICON_MINMAX);
    setAction2Icon(ICON_CLOSE);
    alignTitle(Magus::ALIGNED_LEFT);
    setHeaderColor(QColor("#874E96"));
    mPort = createPort(PORT_ID_SAMPLERBLOCK,
                       PORT_DATABLOCK,
                       hlmsPbsDatablockSamplerblockPortType,
                       QColor("#874E96"),
                       Magus::PORT_SHAPE_CIRCLE,
                       Magus::ALIGNED_LEFT,
                       QColor("#874E96"));

    setPortNameColor(Qt::white);
    setZoom(0.9);
}
开发者ID:spookyboo,项目名称:HLMSEditor,代码行数:91,代码来源:hlms_node_samplerblock.cpp

示例14: QVector3D

void CubeObj::makeobject () {
    vertices.append ( QVector3D ( -0.5f , 0.5f , 0.5f ));        // Make face Front
    vertices.append ( QVector3D ( -0.5f ,-0.5f , 0.5f ));
    vertices.append ( QVector3D (  0.5f ,-0.5f , 0.5f ));
    vertices.append ( QVector3D (  0.5f , 0.5f , 0.5f ));

    vertices.append ( QVector3D (  0.5f , 0.5f ,  0.5f ));        // Make face Right side
    vertices.append ( QVector3D (  0.5f ,-0.5f ,  0.5f ));
    vertices.append ( QVector3D (  0.5f ,-0.5f , -0.5f ));
    vertices.append ( QVector3D (  0.5f , 0.5f , -0.5f ));

    vertices.append ( QVector3D ( -0.5f , 0.5f , 0.5f ));        // Make face Left side
    vertices.append ( QVector3D ( -0.5f , 0.5f , -0.5f ));
    vertices.append ( QVector3D ( -0.5f , -0.5f , -0.5f ));
    vertices.append ( QVector3D ( -0.5f , -0.5f , 0.5f ));

    vertices.append ( QVector3D ( -0.5f , 0.5f , -0.5f ));        // Make face up
    vertices.append ( QVector3D ( -0.5f , 0.5f ,  0.5f ));
    vertices.append ( QVector3D (  0.5f , 0.5f , 0.5f ));
    vertices.append ( QVector3D (  0.5f , 0.5f , -0.5f ));

    vertices.append ( QVector3D ( -0.5f , -0.5f , -0.5f ));        // Make face down
    vertices.append ( QVector3D ( -0.5f , -0.5f ,  0.5f ));
    vertices.append ( QVector3D (  0.5f , -0.5f , 0.5f ));
    vertices.append ( QVector3D (  0.5f , -0.5f , -0.5f ));

    vertices.append ( QVector3D ( -0.5f , 0.5f , -0.5f ));        // Make face Back
    vertices.append ( QVector3D (  0.5f , 0.5f , -0.5f ));
    vertices.append ( QVector3D (  0.5f , -0.5f , -0.5f ));
    vertices.append ( QVector3D (  -0.5f , -0.5f , -0.5f ));

    texCoords.clear();
    texCoords.append( QVector2D ( 0,0));                          // Set Texture coordinate
    texCoords.append( QVector2D ( 0,1));
    texCoords.append( QVector2D ( 1,1));
    texCoords.append( QVector2D ( 1,0));
    // Set Texture coordinate
    texCoords.append( QVector2D ( 0,0));
    texCoords.append( QVector2D ( 0,1));
    texCoords.append( QVector2D ( 1,1));
    texCoords.append( QVector2D ( 1,0));
    // Set Texture coordinate
    texCoords.append( QVector2D ( 0,0));
    texCoords.append( QVector2D ( 0,1));
    texCoords.append( QVector2D ( 1,1));
    texCoords.append( QVector2D ( 1,0));

    // Set Texture coordinate
    texCoords.append( QVector2D ( 0,0));
    texCoords.append( QVector2D ( 0,1));
    texCoords.append( QVector2D ( 1,1));
    texCoords.append( QVector2D ( 1,0));
    // Set Texture coordinate
    texCoords.append( QVector2D ( 0,0));
    texCoords.append( QVector2D ( 0,1));
    texCoords.append( QVector2D ( 1,1));
    texCoords.append( QVector2D ( 1,0));

    // Set Texture coordinate
    texCoords.append( QVector2D ( 0,0));
    texCoords.append( QVector2D ( 0,1));
    texCoords.append( QVector2D ( 1,1));
    texCoords.append( QVector2D ( 1,0));
}
开发者ID:Nand-e,项目名称:2to3d,代码行数:64,代码来源:cubeObj.cpp

示例15: toVector2D

/*!
    Returns the 2D vector form of this 4D vector, dividing the x and y
    coordinates by the w coordinate and dropping the z coordinate.
    Returns a null vector if w is zero.

    \sa toVector2D(), toVector3DAffine(), toPoint()
*/
QVector2D QVector4D::toVector2DAffine() const
{
    if (qIsNull(wp))
        return QVector2D();
    return QVector2D(xp / wp, yp / wp, 1);
}
开发者ID:husninazer,项目名称:qt,代码行数:13,代码来源:qvector4d.cpp


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