Cool ~
If some APIs of Particles could be added, it will be more better~
If some APIs of Particles could be added, it will be more better~
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@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
}
@Override
public void onSurfaceChanged(GL10 gl, int width, int height) {
glViewport(0, 0, width, height);
fb = new FrameBuffer( width, height); // OpenGL ES 1.x constructor
world = new World();
sun = new Light(world);
sun.setIntensity(200, 20, 200);
loadOBJ("cube.obj" , "cube.mtl" , "cube_triangle.png");
cubeColor.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);
world.addObject(cubeColor);
cam = world.getCamera();
cam.moveCamera(Camera.CAMERA_MOVEOUT, 50);
cam.lookAt(cubeColor.getTransformedCenter());
sv.set(cubeColor.getTransformedCenter());
sv.y -= 100;
sv.z -= 100;
sun.setPosition(sv);
MemoryHelper.compact();
}
@Override
public void onDrawFrame(GL10 gl) {
glClear(GL_COLOR_BUFFER_BIT);
if (touchTurn != 0) {
cubeColor.rotateY(touchTurn);
touchTurn = 0;
}
if (touchTurnUp != 0) {
cubeColor.rotateX(touchTurnUp);
touchTurnUp = 0;
}
if (actionEventDown_x != -1) {
SimpleVector dir= Interact2D.reproject2D3DWS(cam, fb, (int)actionEventDown_x, (int)actionEventDown_y).normalize();
Object[] res = world.calcMinDistanceAndObject3D(cam.getPosition(), dir, 10000 /*or whatever*/);
actionEventDown_x = -1;
actionEventDown_y = -1;
if(res[1] != null){
Log.i("jPCT_Picking", "res[0]="+res[0]+" , res[1]="+res[1]);
}
}
fb.clear(back);
world.renderScene(fb);
world.draw(fb);
fb.display();
if (System.currentTimeMillis() - time >= 1000) {
Logger.log(fps + "fps");
fps = 0;
time = System.currentTimeMillis();
}
fps++;
}
private InputStream mod = null;
private InputStream mtl = null;
private Object3D cubeColor = null;
private Object3D[] other = null;
public void loadOBJ(String strObjFileName, String strMtlFileName , String strTexFileName) {
try {
mod = this.context.getAssets().open(strObjFileName);
mtl = this.context.getAssets().open(strMtlFileName);
TextureManager.getInstance().addTexture(strTexFileName, new Texture(context.getAssets().open(strTexFileName)));
} catch (Exception e) {
e.printStackTrace();
}
other = Loader.loadOBJ(mod, mtl,10.0f);
cubeColor = other[0];
}
// Front
front = new Object3D(2);
front.addTriangle(upperLeftFront,0,0, lowerLeftFront,0,1, upperRightFront,1,0, TextureManager.getInstance().getTextureID("frontt"));
front.addTriangle(upperRightFront,1,0, lowerLeftFront,0,1, lowerRightFront,1,1,TextureManager.getInstance().getTextureID("frontt"));
cube.addChild(front);
world.addObject(front);
front.setCollisionMode( Object3D.COLLISION_CHECK_SELF);
// Back...
// Upper...
// Lower...
// Left...
// Right ...
cube.strip();
cube.build();
world.addObject(cube);
cube.setCulling(false);
cube.scale( 0.05f);
cube.setCollisionMode( Object3D.COLLISION_CHECK_SELF);
public int Pickint( int fX, int fY){
//fY = fb.getHeight() - fY;
SimpleVector dir = Interact2D.reproject2D3DWS( cam, fb, fX, fY).normalize();
Object[] res=world.calcMinDistanceAndObject3D(cam.getPosition(), dir, 10000 );
Object3D picked = (Object3D)res[1];
Object3D picked = (Object3D)res[1];
if( picked == null){
return -1;
}
if( picked.getID() == front.getID())
Log.i("jpctae", "touch front");
else if( picked.getID() == back.getID())
Log.i("jpctae", "touch back");
else if( picked.getID() == upper.getID())
Log.i("jpctae", "touch upper");
else if( picked.getID() == lower.getID())
Log.i("jpctae", "touch lower");
else if( picked.getID() == left.getID())
Log.i("jpctae", "touch left");
else if( picked.getID() == right.getID())
Log.i("jpctae", "touch right");
return 1;
}
Page created in 0.039 seconds with 12 queries.