Egon, thanks for prompt response.
Now everything is clear.
Now everything is clear.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts Menu
InputStream objStream = mContext.getResources().openRawResource(R.raw.test_obj);
Object3D[] loadRes = Loader.loadOBJ(objStream, null, 1);
cube = loadRes[0];
float[] bb = cube.getMesh().getBoundingBox();
cube.translate(-(bb[0] + ((bb[1] - bb[0]) / 2)),
-(bb[2] + ((bb[3] - bb[2]) / 2)), -(bb[4] + ((bb[5] - bb[4]) / 2)));
cube.translateMesh();
cube.setTranslationMatrix(new Matrix());
cube.build();
cube.setCenter(SimpleVector.ORIGIN);
cube.setRotationPivot(SimpleVector.ORIGIN);
cube.scale(0.05f);
world.addObject(cube);
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();
}
}
Page created in 0.019 seconds with 12 queries.