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


C++ Obj::getInnerData方法代码示例

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


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

示例1: setObject

void Explosion::setObject( Obj& object )
{
    std::vector<glm::vec3> originalVertices;
    std::vector<glm::vec2> originalUVs;
    std::vector<glm::vec3> originalNormals;

    m_zeroPositionVertices.clear();
    m_zeroPositionUVs.clear();
    m_zeroPositionNormals.clear();
    m_triangleRotation.clear();

    object.getInnerData( originalVertices, originalUVs, originalNormals );
    // get mesh data and triangle indices
    std::vector<Mesh*>& meshList = object.getMeshList();
    // Generate a mesh for each triangle
    for( std::vector<Mesh*>::iterator mesh = meshList.begin() ; mesh != meshList.end() ; ++mesh )
    {
        for( int i = 0 ; i < static_cast<int>((*mesh)->m_vertexIndex.size()) ; i=i+3 )
        {
            int a = (*mesh)->m_vertexIndex[i];
            int b = (*mesh)->m_vertexIndex[i+1];
            int c = (*mesh)->m_vertexIndex[i+2];
            // Generate vertex list
            m_zeroPositionVertices.push_back( originalVertices[a] );
            m_zeroPositionVertices.push_back( originalVertices[b] );
            m_zeroPositionVertices.push_back( originalVertices[c] );
            m_zeroPositionUVs.push_back( originalUVs[a] );
            m_zeroPositionUVs.push_back( originalUVs[b] );
            m_zeroPositionUVs.push_back( originalUVs[c] );
            m_zeroPositionNormals.push_back( originalNormals[a] );
            m_zeroPositionNormals.push_back( originalNormals[b] );
            m_zeroPositionNormals.push_back( originalNormals[c] );
            // Generate mesh
            Mesh* m = new Mesh();
            m->m_vertexIndex.push_back(i);
            m->m_vertexIndex.push_back(i+1);
            m->m_vertexIndex.push_back(i+2);
            m_meshList.push_back(m);
            // generate random rotation scheme
            glm::vec3 rot(rand(), rand(), rand());
            m_triangleRotation.push_back(glm::normalize(rot));
        }
    }
    // Store the meshes
    setInnerData( m_zeroPositionVertices, m_zeroPositionUVs, m_zeroPositionNormals );

    m_objectCenterPoint = glm::vec3(0,0,0);
    // find the center point of the object using the middle point of the elements
    for( std::vector<glm::vec3>::iterator it = m_vertices.begin() ; it != m_vertices.end() ; ++it )
    {
        m_objectCenterPoint += (*it);
    }
    int nVertices = static_cast<int>(m_vertices.size());
    m_objectCenterPoint.x /= nVertices;
    m_objectCenterPoint.y /= nVertices;
    m_objectCenterPoint.z /= nVertices;
}
开发者ID:jgoenetxea,项目名称:gre,代码行数:57,代码来源:explosion.cpp


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