我正试图在我的场景中第一次使用我的3D模型:
org.rajawali3d.loader.LoaderOBJ
我无法让它发挥作用。该应用程序不断崩溃与下面的错误。 挖掘代码我发现导致崩溃的部分是这一行:
String extensions = GLES20.glGetString(GLES20.GL_EXTENSIONS);
扩展名为空,图书馆不检查其有效性。
我片段的onCreateView:
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
mLayout = (FrameLayout) inflater.inflate(R.layout.opengl_scene, container, false);
mRenderSurface = (ISurface) mLayout.findViewById(R.id.opengl);
mRenderer = new RocketArrowRenderer(getContext());
applyRenderer();
return mLayout;
}
渲染器:
public class RocketArrowRenderer extends Renderer {
private PointLight mLight;
private Object3D mObjectGroup;
private Animation3D mCameraAnim, mLightAnim;
public RocketArrowRenderer(Context context) {
super(context);
setFrameRate(60);
initScene();
}
protected void initScene() {
mLight = new PointLight();
mLight.setPosition(0, 0, 4);
mLight.setPower(3);
getCurrentScene().addLight(mLight);
getCurrentCamera().setZ(16);
LoaderOBJ objParser = new LoaderOBJ(mContext.getResources(), mTextureManager, R.raw.falcon_heavy_obj);
try {
objParser.parse();
mObjectGroup = objParser.getParsedObject();
getCurrentScene().addChild(mObjectGroup);
mCameraAnim = new RotateOnAxisAnimation(Vector3.Axis.Y, 360);
mCameraAnim.setDurationMilliseconds(8000);
mCameraAnim.setRepeatMode(Animation.RepeatMode.INFINITE);
mCameraAnim.setTransformable3D(mObjectGroup);
} catch(ParsingException e) {
e.printStackTrace();
}
mLightAnim = new EllipticalOrbitAnimation3D(new Vector3(),
new Vector3(0, 10, 0), Vector3.getAxisVector(Vector3.Axis.Z), 0,
360, EllipticalOrbitAnimation3D.OrbitDirection.CLOCKWISE);
mLightAnim.setDurationMilliseconds(3000);
mLightAnim.setRepeatMode(Animation.RepeatMode.INFINITE);
mLightAnim.setTransformable3D(mLight);
getCurrentScene().registerAnimation(mCameraAnim);
getCurrentScene().registerAnimation(mLightAnim);
mCameraAnim.play();
mLightAnim.play();
}
@Override
public void onOffsetsChanged(float xOffset, float yOffset, float xOffsetStep, float yOffsetStep, int xPixelOffset, int yPixelOffset) {
}
@Override
public void onTouchEvent(MotionEvent event) {
}
}