调用aiGetMaterialFloat时出现奇怪的错误(ASSIMP,C)

时间:2016-07-18 11:26:43

标签: c assimp

我正在关注Assimp's documentation以从 struct aiMaterial 类型中检索属性。从他们的文档中,这是 aiGetMaterialString()的用法:

aiGetMaterialFloat(mat,<material-key>,<where-to-store>)

我能够使用 aiGetMaterialString()获取材质名称,并使用 aiGetMaterialColor()获取属性的颜色,但是将其添加到我的代码中:

float f = 1.0f;
aiGetMaterialFloat(mat, AI_MATKEY_SHININESS, (float*)&f);

结果:

gcc src/*.c examples/game.c -o bin/game.o -lGL -lGLEW -lSDL2 -lSDL2_image -lassimp -lm

    In file included from /usr/include/assimp/scene.h:53:0,
                 from src/../include/mesh.h:13,
                 from src/mesh.c:1:
src/mesh.c: In function ‘mesh_setMaterialData’:
src/mesh.c:71:2: error: ‘pMat’ undeclared (first use in this function)
  aiGetMaterialFloat(mat, AI_MATKEY_SHININESS, (float*)&f);
  ^
src/mesh.c:71:2: note: each undeclared identifier is reported only once for each function it appears in
src/mesh.c:71:2: error: ‘type’ undeclared (first use in this function)
  aiGetMaterialFloat(mat, AI_MATKEY_SHININESS, (float*)&f);
  ^
src/mesh.c:71:2: error: ‘pKey’ undeclared (first use in this function)
  aiGetMaterialFloat(mat, AI_MATKEY_SHININESS, (float*)&f);
  ^
src/mesh.c:71:2: error: ‘pOut’ undeclared (first use in this function)
  aiGetMaterialFloat(mat, AI_MATKEY_SHININESS, (float*)&f);
  ^
src/mesh.c:71:2: error: expected ‘;’ before ‘aiGetMaterialFloatArray’
  aiGetMaterialFloat(mat, AI_MATKEY_SHININESS, (float*)&f);
  ^
make: *** [makefile:2: ALL] Error 1

(在我的代码中,mat的类型为struct aiMaterial *)。

我使用的代码与assimp / material.h,第1363行中描述的代码基本相同:

  

float specStrength = 1.f; //默认值,如果我们失败则保持不变。

     

aiGetMaterialFloat(mat,AI_MATKEY_SHININESS_STRENGTH,      (浮点*)及specStrength);

有人可以向我解释我做错了吗?

谢谢。

修改 这是 aiGetMaterialFloat

的定义
#define aiGetMaterialFloat (pMat, type, index, pKey, pOut) \
    aiGetMaterialFloatArray(pMat, type, index, pKey, pOut, NULL)

aiGetMaterialFloatArray

ASSIMP_API C_ENUM aiReturn aiGetMaterialFloatArray(const C_STRUCT aiMaterial* pMat, const char* pKey, unsigned int type, unsigned int index, float* pOut, unsigned int* pMax);

我取代了之前的内容:

aiGetMaterialFloatArray(mat, AI_MATKEY_SHININESS, &f, NULL);

并编译......如果我在这个函数调用上交换参数,我可以让gcc告诉我,我发送的第四个参数实际上被认为是 aiGetMaterialFloatArray 的第6个参数(无符号) int * pMax)。我真的不太了解宏来了解正在发生的事情。

0 个答案:

没有答案
相关问题