int32_t function_entry(){
#ifdef EXCLUDE_TIMER
    funcInfos[*functionIndexAddr].count++;
#else
    pushIndex(*functionIndexAddr, read_timestamp_counter());
#endif
    //    PRINT_INSTR(stdout, "%s entry %d", functionNames[*functionIndexAddr], *functionIndexAddr);
}
Beispiel #2
0
void CMC_MeshData::loadFromTZW(const rapidjson::Value &value)
{
    //load material index.
    m_materialIndex = value["material_index"].GetInt ();

    //load vertices
    auto& verticesObj = value["vertices"];
    for(auto iter = verticesObj.Begin ();iter!= verticesObj.End ();iter++)
    {
        auto& vertexObj = *iter;
        CMC_Vertex vertex;
        vertex.loadFromTZW (vertexObj);
        pushVertex (vertex);
    }

    //load indices
    auto& indicesObj = value["indices"];
    for(auto iter = indicesObj.Begin ();iter != indicesObj.End ();iter++)
    {
        auto& indexObj = * iter;
        pushIndex (indexObj.GetInt ());
    }
}
Beispiel #3
0
bool Loader::loadFromModel(const char *fileName)
{
    printf("load %s begin\n",fileName);
    printf("parsing..\n");
    const aiScene* pScene = m_Importer.ReadFile(fileName,aiProcess_Triangulate | aiProcess_FlipUVs | aiProcess_GenSmoothNormals |aiProcess_CalcTangentSpace);
    this->m_pScene = (aiScene*)pScene;
    if(!m_pScene)
    {
        printf("parsing failure!\n");
        return false;
    }
    else
    {
        printf("parsing succes!\n");
        printf("extracting data to memory...\n");
        m_model = new CMC_ModelData();

        auto inverseTransform = pScene->mRootNode->mTransformation;
        inverseTransform = inverseTransform.Inverse();
        m_model->setGlobalInverseTransform (toQMatrix(inverseTransform));
        LoadMaterial(pScene,fileName);

        const aiVector3D Zero3D(0.0f, 0.0f, 0.0f);
        for(int i =0 ;i< pScene->mNumMeshes ;i++)
        {
            const aiMesh* the_mesh = pScene->mMeshes[i];
            auto mesh = new CMC_MeshData;
            m_model->addMesh(mesh);
            //set material
            mesh->setMaterialIndex (the_mesh->mMaterialIndex);
            for(int j =0; j<the_mesh->mNumVertices;j++)
            {
                const aiVector3D* pPos = &(the_mesh->mVertices[j]);
                const aiVector3D* pNormal = &(the_mesh->mNormals[j]);
                const aiVector3D* pTexCoord = the_mesh->HasTextureCoords(0) ? &(the_mesh->mTextureCoords[0][j]) : &Zero3D;
                const aiVector3D* pTangent = &(the_mesh->mTangents[i]);
                CMC_Vertex  vec;
                vec.setPos (QVector3D(pPos->x,pPos->y,pPos->z));
                vec.setNormal (QVector3D(pNormal->x,pNormal->y,pNormal->z));
                vec.setUV (QVector2D(pTexCoord->x,pTexCoord->y));
            if(pTangent)
            {
                 vec.setTangent (QVector3D(pTangent->x,pTangent->y,pTangent->z));
            }
            mesh->pushVertex (vec);
            }

            for (unsigned int k = 0 ; k < the_mesh->mNumFaces ; k++) {
                const aiFace& Face = the_mesh->mFaces[k];
                assert(Face.mNumIndices == 3);
                mesh->pushIndex (Face.mIndices[0]);
                mesh->pushIndex(Face.mIndices[1]);
                mesh->pushIndex(Face.mIndices[2]);
            }
            //load bones
            loadBoneList(the_mesh,mesh);
            //mesh->finish();
        }
        loadNodeHeirarchy(nullptr,m_pScene->mRootNode);
        loadAnimations ();
        printf("extracting finish..\n");
        return true;
    }
}
Beispiel #4
0
 void startElement(unsigned index)
 {
     pushIndex(index);
     getDerived().startElementImpl();
 }