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


C++ Triangle3D::UpdateNormalFromGeom方法代码示例

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


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

示例1: LoadIn

//data loading
bool ModelData::LoadIn(QString filepath)
{	
    bool loaderReady;
    bool abort;

    STLTri* pLoadedTri = NULL;
    Triangle3D newtri;

	this->filepath = filepath;
	
	if(filepath.isEmpty())
		return false;
	
	//extract filename from path!
    filename = QFileInfo(filepath).fileName();

    B9ModelLoader mLoader(filepath,loaderReady,NULL);

    if(loaderReady == false)//error opening model data
	{
        //display Loader Error
		QMessageBox msgBox;
        msgBox.setText(mLoader.GetError());
        msgBox.exec();
		return false;
	}

    //make a progress bar and connect it to
    LoadingBar loadbar(0,100);
    loadbar.useCancelButton(false);
    loadbar.setDescription("Importing: " + filename);
    QObject::connect(&mLoader,SIGNAL(PercentCompletedUpdate(qint64,qint64)),
                     &loadbar,SLOT(setProgress(qint64,qint64)));



    //now we are ready to walk the loader through reading each triangle
    //and copying it into the this model data.
    while(mLoader.LoadNextTri(pLoadedTri,abort))
    {
        if(abort)
        {
            //display Loader abort error
            QMessageBox msgBox;
            msgBox.setText(mLoader.GetError());
            msgBox.exec();
            return false;
        }
        else
        {
            //newtri.normal.setX(pLoadedTri->nx);
            //newtri.normal.setY(pLoadedTri->ny);
            //newtri.normal.setZ(pLoadedTri->nz);

            newtri.vertex[0].setX(pLoadedTri->x0);
            newtri.vertex[0].setY(pLoadedTri->y0);
            newtri.vertex[0].setZ(pLoadedTri->z0);
            newtri.vertex[1].setX(pLoadedTri->x1);
            newtri.vertex[1].setY(pLoadedTri->y1);
            newtri.vertex[1].setZ(pLoadedTri->z1);
            newtri.vertex[2].setX(pLoadedTri->x2);
            newtri.vertex[2].setY(pLoadedTri->y2);
            newtri.vertex[2].setZ(pLoadedTri->z2);

            //use right hand rule for importing normals - ignore file normals..
            newtri.UpdateNormalFromGeom();

            delete pLoadedTri;
            newtri.UpdateBounds();

            triList.push_back(newtri);
        }
    }



    qDebug() << "Loaded triangles: " << triList.size();
	//now center it!
	CenterModel();

    //generate a normal display lists.

    int displaySuccess = FormNormalDisplayLists();

    if(displaySuccess)
        return true;
    else
        return false;
}
开发者ID:B9Creations,项目名称:B9Creator,代码行数:90,代码来源:modeldata.cpp

示例2: RotateVector

//Baking
//using all rotations scales positions etc, generates the list of triangles that
//is represented by the rendered shapes.
//similar to instance baking.
//remember that this function needed to always reflect what render() does but inverted.
void B9SupportStructure::BakeToInstanceGeometry()
{
    unsigned int t;
    unsigned short int v;
    Triangle3D* pNewTri;
    QVector3D topScale;
    QVector3D topPos;
    QVector3D midScale;
    QVector3D midPos;
    QVector3D bottomScale;
    QVector3D bottomPos;


    //first bake the top
    topScale = QVector3D(topRadius*2.0,topRadius*2.0,topLength + topPenetration);
    topPos = QVector3D((topPenetrationPoint.x() + topPivot.x())*0.5
                          ,(topPenetrationPoint.y() + topPivot.y())*0.5
                          ,(topPenetrationPoint.z() + topPivot.z())*0.5);
    if(topAttachShape != NULL)
    for(t = 0; t < topAttachShape->GetTriangles()->size(); t++)
    {
        pNewTri = new Triangle3D(topAttachShape->GetTriangles()->at(t));


        for(v=0;v<3;v++)
        {
            //scale triangle vertices 1st
            pNewTri->vertex[v] *= topScale;

            //Rotate 2nd
            //dont deal with y - not needed in rendering or baking
            RotateVector(pNewTri->vertex[v], topThetaX, QVector3D(1,0,0));//x
            RotateVector(pNewTri->vertex[v], topThetaZ, QVector3D(0,0,1));//z

            //Translate 3rd into global space
            pNewTri->vertex[v] += topPos;
            pNewTri->vertex[v] += instanceParent->GetPos();
        }

        //Update the triangle bounds and normal
        pNewTri->UpdateBounds();
        pNewTri->UpdateNormalFromGeom();

        //Add To List
        instanceParent->triList.push_back(pNewTri);
    }

    //second bake the middle
    midScale = QVector3D(midRadius*2.0,midRadius*2.0,midLength);
    midPos = QVector3D((topMidExtensionPoint.x() + bottomMidExtensionPoint.x())*0.5
                      ,(topMidExtensionPoint.y() + bottomMidExtensionPoint.y())*0.5
                      ,(topMidExtensionPoint.z() + bottomMidExtensionPoint.z())*0.5);

    if(midAttachShape != NULL)
    for(t = 0; t < midAttachShape->GetTriangles()->size(); t++)
    {
        pNewTri = new Triangle3D(midAttachShape->GetTriangles()->at(t));



        for(v=0;v<3;v++)
        {
            //scale triangle vertices 1st
            pNewTri->vertex[v] *= midScale;

            //Rotate 2nd
            //dont deal with y - not needed in rendering or baking
            RotateVector(pNewTri->vertex[v], midThetaX, QVector3D(1,0,0));//x
            RotateVector(pNewTri->vertex[v], midThetaZ, QVector3D(0,0,1));//z

            //Translate 3rd into global space
            pNewTri->vertex[v] += midPos;
            pNewTri->vertex[v] += instanceParent->GetPos();
        }

        //Update the triangle bounds and normal
        pNewTri->UpdateBounds();
        pNewTri->UpdateNormalFromGeom();

        //Add To List
        instanceParent->triList.push_back(pNewTri);
    }

    //third bake the bottom
    bottomScale = QVector3D(bottomRadius*2.0,bottomRadius*2.0,bottomLength + bottomPenetration);
    bottomPos = QVector3D((bottomPenetrationPoint.x() + bottomPivot.x())*0.5
                          ,(bottomPenetrationPoint.y() + bottomPivot.y())*0.5
                          ,(bottomPenetrationPoint.z() + bottomPivot.z())*0.5);

    if(bottomAttachShape != NULL)
    for(t = 0; t < bottomAttachShape->GetTriangles()->size(); t++)
    {
        pNewTri = new Triangle3D(bottomAttachShape->GetTriangles()->at(t));


//.........这里部分代码省略.........
开发者ID:denisoft,项目名称:B9Creator,代码行数:101,代码来源:b9supportstructure.cpp


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