yue_pan_pan 2022-08-17 15:50 采纳率: 45.5%
浏览 24
已结题

为什么提示aiImportFileFromMemory 这个函数找不找呢。我看明明存在得

问题遇到的现象和发生背景

img

img

问题相关代码,请勿粘贴截图

#include <jni.h>
#include <android/log.h>
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#include
#include
#include
#include <inc/Matrix.h>
#include <inc/Texture.h>
#include <assimp/cimport.h>
#include <assimp/scene.h>
#include
GLuint vertexLocation;
GLuint samplerLocation;
GLuint projectionLocation;
GLuint modelViewLocation;
GLuint textureCordLocation;
GLuint colorLocation;
GLuint textureId;
GLuint vertexNormalLocation;
GLuint tangentLocation;
GLuint biNormalLocation;
float projectionMatrix[16];
float modelViewMatrix[16];
GLuint glProgram;
float angle = 0;
bool setupGraphics(int width, int height)
{
glProgram = createProgram(glVertexShader, glFragmentShader);
if (!glProgram)
{
LOGE("Could not create program");
return false;
}
vertexLocation = glGetAttribLocation(glProgram, "vertexPosition");
textureCordLocation = glGetAttribLocation(glProgram, "vertexTextureCord");
projectionLocation = glGetUniformLocation(glProgram, "projection");
modelViewLocation = glGetUniformLocation(glProgram, "modelView");
samplerLocation = glGetUniformLocation(glProgram, "texture");
vertexNormalLocation = glGetAttribLocation(glProgram, "vertexNormal");
colorLocation = glGetAttribLocation(glProgram, "vertexColor");
tangentLocation = glGetAttribLocation(glProgram, "vertexTangent");
biNormalLocation = glGetAttribLocation(glProgram, "vertexBiNormal");
/* Setup the perspective. */
matrixPerspective(projectionMatrix, 45, (float)width / (float)height, 0.1f, 100);
glEnable(GL_DEPTH_TEST);
glViewport(0, 0, width, height);

std::string sphere = "s 0 0 0 10";

scene = aiImportFileFromMemory(sphere.c_str(), sphere.length(), 0, ".nff");
if (!scene)
         {
             LOGE("Open Asset Importer could not load scene. \n");
             return false;
         }
     /* [Load a model into the Open Asset Importer.] */
    
         /* [Accumulate the model vertices and indices.] */
         int vertices_accumulation = 0;
     /* Go through each mesh in the scene. */
         for (int i = 0; i < scene->mNumMeshes; i++)
         {
             /* Add all the vertices in the mesh to our array. */
                 for (int j = 0; j < scene->mMeshes[i]->mNumVertices; j++)
                 {
                     const aiVector3D & vector = scene->mMeshes[i]->mVertices[j];
                     vertices.push_back(vector.x);
                     vertices.push_back(vector.y);
                     vertices.push_back(vector.z);
                 }
    
                 /*
                  * Add all the indices in the mesh to our array.
                  * Indices are listed in the Open Asset importer relative to the mesh they are in.
                  * Because we are adding all vertices from all meshes to one array we must add an offset
                  * to the indices to correct for this.
                  */
                 for (unsigned int j = 0; j < scene->mMeshes[i]->mNumFaces; j++)
                 {
                     const aiFace & face = scene->mMeshes[i]->mFaces[j];
                     indices.push_back(face.mIndices[0] + vertices_accumulation);
                     indices.push_back(face.mIndices[1] + vertices_accumulation);
                     indices.push_back(face.mIndices[2] + vertices_accumulation);
                 }
    
                 /* Keep track of number of vertices loaded so far to use as an offset for the indices. */
                 vertices_accumulation += scene->mMeshes[i]->mNumVertices;
         }
     /* [Accumulate the model vertices and indices.] */
    
         return true;

}

运行结果及报错内容

img

我想要达到的结果

为什么提示aiImportFileFromMemory 这个函数找不找呢。我看明明存在得

  • 写回答

1条回答 默认 最新

  • 赵4老师 2022-08-17 16:33
    关注

    ld连接器报错,少-lxxx参数,指定连接libxxx.a或libxxx.so
    其中libxxx.a或libxxx.so中提供了aiImportFileFromMemory的实现

    评论

报告相同问题?

问题事件

  • 已结题 (查看结题原因) 8月19日
  • 创建了问题 8月17日