我一直在尝试加载Rajawali的.Obj文件,并且正在应用,但遇到了我无法理解的错误,我们将不胜感激。目标是加载.obj文件并具有基本的外观。
initScene代码:
public void initScene(){
mLight = new DirectionalLight(1f, 0.2f, -1.0f); // set the direction
mLight.setColor(1.0f, 1.0f, 5.0f);
mLight.setPower(2);
Material material = new Material();
material.enableLighting(true);
material.setDiffuseMethod(new DiffuseMethod.Lambert());
material.setSpecularMethod(new SpecularMethod.Phong());
material.setColorInfluence(0);
Object3D Object;
LoaderOBJ objParser = new LoaderOBJ(this, "afile.obj");
try {
objParser.parse();
Object = objParser.getParsedObject();
Object.setMaterial(material);
getCurrentScene().addChild(Object);
getCurrentScene().addLight(mLight);
getCurrentCamera().setZ(4.2f);
} catch (ParsingException e) {
e.printStackTrace();
}
}
我得到的日志是:
I/Rajawali: Parsing object: Object4202
I/Rajawali: Object4202 has no material definition.
E/Rajawali: Getting location of uniform: uTime returned -1!
Getting location of uniform: uLightPosition0 returned -1!
我还放置了我要给出形状的示例.obj文件,并将其垂直旋转。 (在我设法提供了适当的材料之后)可以从here下载。