Hi all. I have some problem with displaying obj model.
Here code of my renderer class:
package com.amulet_it.openglexample;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
import android.content.Context;
import android.graphics.Color;
import android.graphics.PointF;
import android.opengl.GLES20;
import android.opengl.GLSurfaceView;
import android.widget.Toast;
import com.threed.jpct.Camera;
import com.threed.jpct.FrameBuffer;
import com.threed.jpct.Interact2D;
import com.threed.jpct.Light;
import com.threed.jpct.Loader;
import com.threed.jpct.Matrix;
import com.threed.jpct.Object3D;
import com.threed.jpct.Primitives;
import com.threed.jpct.SimpleVector;
import com.threed.jpct.Texture;
import com.threed.jpct.TextureManager;
import com.threed.jpct.World;
import java.io.InputStream;
import java.util.HashMap;
public class MyRenderer implements GLSurfaceView.Renderer {
private Context mContext = null;
private FrameBuffer fb = null;
private World world = null;
private Camera cam = null;
public MyRenderer(Context context) {
mContext = context;
}
@Override
public void onSurfaceCreated(GL10 unused, EGLConfig config) {
}
@Override
public void onSurfaceChanged(GL10 unused, int width, int height) {
if ( fb != null ) {
fb.dispose();
}
fb = new FrameBuffer(width, height);
world = new World();
cam = world.getCamera();
InputStream objStream = mContext.getResources().openRawResource(R.raw.test_obj);
Object3D[] loadRes = Loader.loadOBJ(objStream, null, 3);
Object3D cube = loadRes[0];
cube.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS | Object3D.COLLISION_CHECK_SELF);
cube.build();
world.addObject(cube);
Light light = new Light(world);
light.setPosition(new SimpleVector(0, -80, 0));
light.setIntensity(140, 120, 120);
light.setAttenuation(-1);
world.setAmbientLight(20, 20, 20);
cam.moveCamera(Camera.CAMERA_MOVEOUT, 200);
cam.moveCamera(Camera.CAMERA_MOVEUP, 200);
cam.lookAt(cube.getTransformedCenter());
}
@Override
public void onDrawFrame(GL10 unused) {
fb.clear(Color.RED);
world.renderScene(fb);
world.draw(fb);
fb.display();
}
}
Obj file in attachment as test.txt.
The main problem i'm don't see loaded object on the scene.
Can some help me please?