-OPENGL5-

Posted gearslogy

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了-OPENGL5-相关的知识,希望对你有一定的参考价值。

ASSIMP构建大纲:

因为递归的原因有必要把大纲还原,类似katana和maya大纲一样

以maya为例:(输出的时候别导出obj,fbx可以保护层级,abc也可以,但是现在assimp不支持,回头可以用abc api 搞一个)

技术图片

 

所以我在函数原型加入一个pwd

void processNode(aiNode * node, const aiScene* scene,string pwd);
技术图片
#include <iostream>
#include <assimp/Importer.hpp>
#include <assimp/scene.h>
#include <assimp/postprocess.h>
#include <string>
using namespace std;

void processNode(aiNode * node, const aiScene* scene, string pwd);
int main(){
    Assimp::Importer import;
    string path = "maya.fbx";
    const aiScene * scene = import.ReadFile(path, aiProcess_Triangulate | aiProcess_FlipUVs);
    if(!scene || scene->mFlags & AI_SCENE_FLAGS_INCOMPLETE || !scene->mRootNode)
    {
        cout << "ERROR::ASSIMP::" << import.GetErrorString() << endl;

    }

    string directory = path.substr(0, path.find_last_of(/));
    cout << directory << endl;

    // Get Root Node
    aiNode * node = scene->mRootNode;
    processNode(node,scene,"/");





    return 0;
}

void processNode(aiNode * node, const aiScene* scene,string pwd){

    cout << ">>LOOP At Node:" << pwd <<" WORLD MATRIX:" << endl;
    aiMatrix4x4 mat =  node->mTransformation;
    cout << "{
";
    cout << "	" <<mat.a1 << " " << mat.a2 << " " << mat.a3 << " " << mat.a4 << endl;
    cout << "	" <<mat.b1 << " " << mat.b2 << " " << mat.b3 << " " << mat.b4 << endl;
    cout << "	" <<mat.c1 << " " << mat.c2 << " " << mat.c3 << " " << mat.c4 << endl;
    cout << "	" <<mat.d1 << " " << mat.d2 << " " << mat.d3 << " " << mat.d4 << endl;
    cout << "}
";

    for(unsigned int i = 0; i < node->mNumMeshes; i++)
    {
        aiMesh *mesh = scene->mMeshes[node->mMeshes[i]];

        // mesh points
        cout <<">>Num points:" <<mesh->mNumVertices<< endl;

        // Dump materials infos
        aiMaterial *mat = scene->mMaterials[mesh->mMaterialIndex];
        cout << ">>Get Mesh Name: "<<mesh->mName.C_Str()<< " <->  MaterialName: " << mat->GetName().C_Str()  << endl;
        cout << ">>start dumping the texture:
";
        cout << "{
";
        for(unsigned int i = 0; i < mat->GetTextureCount(aiTextureType_DIFFUSE); i++)
        {
            aiString str;
            mat->GetTexture(aiTextureType_DIFFUSE, i, &str);
            cout << "	diffuseTexture: "<<str.C_Str() << endl;
        }
        for(unsigned int i = 0; i < mat->GetTextureCount(aiTextureType_NORMALS); i++)
        {
            aiString str;
            mat->GetTexture(aiTextureType_NORMALS, i, &str);
            cout << "	NormalTexture: "<<str.C_Str() << endl;
        }
        for(unsigned int i = 0; i < mat->GetTextureCount(aiTextureType_AMBIENT); i++)
        {
            aiString str;
            mat->GetTexture(aiTextureType_AMBIENT, i, &str);
            cout << "	AmbientTexture: "<<str.C_Str() << endl;
        }
        for(unsigned int i = 0; i < mat->GetTextureCount(aiTextureType_OPACITY); i++)
        {
            aiString str;
            mat->GetTexture(aiTextureType_OPACITY, i, &str);
            cout << "	OpacityTexture: "<<str.C_Str() << endl;
        }
        for(unsigned int i = 0; i < mat->GetTextureCount(aiTextureType_SPECULAR); i++)
        {
            aiString str;
            mat->GetTexture(aiTextureType_SPECULAR, i, &str);
            cout << "	SpecularTexture: "<<str.C_Str() << endl;
        }
        for(unsigned int i = 0; i < mat->GetTextureCount(aiTextureType_HEIGHT); i++)
        {
            aiString str;
            mat->GetTexture(aiTextureType_HEIGHT, i, &str);
            cout << "	HeightTexture: "<<str.C_Str() << endl;
        }
        for(unsigned int i = 0; i < mat->GetTextureCount(aiTextureType_UNKNOWN); i++)
        {
            aiString str;
            mat->GetTexture(aiTextureType_HEIGHT, i, &str);
            cout << "	UnkownTexture: "<<str.C_Str() << endl;
        }
        cout << "}
";

    }

    for(unsigned int i = 0; i < node->mNumChildren; i++)
    {

        string pathName =  pwd + node->mChildren[i]->mName.C_Str();
        pathName += "/";
        processNode(node->mChildren[i], scene,pathName);
    }


    cout << "
";

}
main.cpp

 

DUMP:

maya.fbx
>>LOOP At Node:/ WORLD MATRIX:
{
    1 0 0 0
    0 1 0 0
    0 0 1 0
    0 0 0 1
}
>>LOOP At Node:/Geometry/ WORLD MATRIX:
{
    1 0 0 0
    0 1 0 0
    0 0 1 0
    0 0 0 1
}
>>LOOP At Node:/Geometry/part1/ WORLD MATRIX:
{
    1 0 0 0
    0 1 0 0
    0 0 1 0
    0 0 0 1
}
>>LOOP At Node:/Geometry/part1/pSphere1/ WORLD MATRIX:
{
    1 0 0 0
    0 1 0 0
    0 0 1 0
    0 0 0 1
}
>>Num points:1560
>>Get Mesh Name: pSphere1 <->  MaterialName: lambert1
>>start dumping the texture:
{
}

>>LOOP At Node:/Geometry/part1/pSphere2/ WORLD MATRIX:
{
    1 0 0 0
    0 1 0 2.17013
    0 0 1 0
    0 0 0 1
}
>>Num points:1560
>>Get Mesh Name: pSphere2 <->  MaterialName: lambert1
>>start dumping the texture:
{
}

>>LOOP At Node:/Geometry/part1/pSphere3/ WORLD MATRIX:
{
    1 0 0 0
    0 1 0 4.34026
    0 0 1 0
    0 0 0 1
}
>>Num points:1560
>>Get Mesh Name: pSphere3 <->  MaterialName: lambert1
>>start dumping the texture:
{
}

>>LOOP At Node:/Geometry/part1/pSphere4/ WORLD MATRIX:
{
    1 0 0 0
    0 1 0 6.51039
    0 0 1 0
    0 0 0 1
}
>>Num points:1560
>>Get Mesh Name: pSphere4 <->  MaterialName: lambert1
>>start dumping the texture:
{
}


>>LOOP At Node:/Geometry/part2/ WORLD MATRIX:
{
    1 0 0 0
    0 1 0 0
    0 0 1 0
    0 0 0 1
}
>>LOOP At Node:/Geometry/part2/pSphere5/ WORLD MATRIX:
{
    1 0 0 0
    0 1 0 8.68052
    0 0 1 0
    0 0 0 1
}
>>Num points:1560
>>Get Mesh Name: pSphere5 <->  MaterialName: lambert1
>>start dumping the texture:
{
}

>>LOOP At Node:/Geometry/part2/pSphere6/ WORLD MATRIX:
{
    1 0 0 0
    0 1 0 10.8507
    0 0 1 0
    0 0 0 1
}
>>Num points:1560
>>Get Mesh Name: pSphere6 <->  MaterialName: lambert1
>>start dumping the texture:
{
}

>>LOOP At Node:/Geometry/part2/pSphere7/ WORLD MATRIX:
{
    1 0 0 0
    0 1 0 13.0208
    0 0 1 0
    0 0 0 1
}
>>Num points:1560
>>Get Mesh Name: pSphere7 <->  MaterialName: lambert1
>>start dumping the texture:
{
}

 

以上是关于-OPENGL5-的主要内容,如果未能解决你的问题,请参考以下文章

VSCode自定义代码片段——CSS选择器

谷歌浏览器调试jsp 引入代码片段,如何调试代码片段中的js

片段和活动之间的核心区别是啥?哪些代码可以写成片段?

VSCode自定义代码片段——.vue文件的模板

VSCode自定义代码片段6——CSS选择器

VSCode自定义代码片段——声明函数