Show Posts

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.


Messages - y_muse

Pages: [1]
1
Support / Re: CollisionEvent never called
« on: December 16, 2015, 06:07:49 pm »
Great! thank you, I had already checked that example but I didn't understand that it was the CheckForCollisionEllipsoid function throwing the CollisionEvent.
For reference this is the correct solution of my example:
Code: [Select]
package com.threed.jpct.example;

import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;

import com.threed.jpct.*;

import android.app.Activity;
import android.opengl.GLSurfaceView;
import android.os.Bundle;

public class HelloWorld extends Activity {
private static HelloWorld master = null;

private GLSurfaceView mGLView;
private MyRenderer renderer = null;
private FrameBuffer buffer = null;

private World world = null;
private RGBColor back = new RGBColor(50, 50, 100);

private SimpleVector moveCube = new SimpleVector(0, 0, 0), ellipsoid = new SimpleVector(1, 1, 1);

private Object3D cube1 = null;
private Object3D cube2 = null;

private Light sun = null;
private Camera cam = null;


protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mGLView = new GLSurfaceView(getApplication());
renderer = new MyRenderer();
mGLView.setRenderer(renderer);
setContentView(mGLView);
}

@Override
protected void onPause() {
super.onPause();
mGLView.onPause();
}

@Override
protected void onResume() {
super.onResume();
mGLView.onResume();
}

protected void onStop() {
super.onStop();
}


class MyRenderer implements GLSurfaceView.Renderer {

private long time = System.currentTimeMillis();
private boolean stop = false;

public MyRenderer() {
}

public void onSurfaceChanged(GL10 gl, int w, int h) {
if (buffer != null) {
buffer.dispose();
}
buffer = new FrameBuffer(gl, w, h);

if (master == null) {

world = new World();
world.setAmbientLight(150, 150, 150);

sun = new Light(world);
sun.setIntensity(250, 250, 250);

cube1 = Primitives.getCube(1);
cube2 = Primitives.getCube(1);

cube1.setCollisionMode(Object3D.COLLISION_CHECK_SELF | Object3D.COLLISION_CHECK_OTHERS);
cube1.setCollisionOptimization(true);
cube1.addCollisionListener(new CollisionListener() {
@Override
public void collision(CollisionEvent collisionEvent) {
Logger.log("Collision1");
}

@Override
public boolean requiresPolygonIDs() {
return false;
}
});


cube2.translate(15f, 0f, 0f);
cube2.setCollisionMode(Object3D.COLLISION_CHECK_SELF | Object3D.COLLISION_CHECK_OTHERS);
cube2.setCollisionOptimization(true);
cube2.addCollisionListener(new CollisionListener() {
@Override
public void collision(CollisionEvent collisionEvent) {
Logger.log("Collision2");
}

@Override
public boolean requiresPolygonIDs() {
return false;
}
});


cube1.build();
cube2.build();
world.addObject(cube1);
world.addObject(cube2);


cam = world.getCamera();
cam.moveCamera(Camera.CAMERA_MOVEOUT, 50);
cam.moveCamera(Camera.CAMERA_MOVEUP, 15);
SimpleVector cameraView = cube1.getTransformedCenter();
cameraView.x += 10;
cam.lookAt(cameraView);
cam.setFOV(cam.getMinFOV());


SimpleVector sv = new SimpleVector();
sv.set(cube1.getTransformedCenter());
sv.y -= 100;
sv.z -= 100;
sun.setPosition(sv);

if (master == null) {
Logger.log("Saving master Activity!");
master = HelloWorld.this;
}
}
}

public void onSurfaceCreated(GL10 gl, EGLConfig config) {
}

public void onDrawFrame(GL10 gl) {

try {
if (!stop) {

buffer.clear(back);
world.renderScene(buffer);
world.draw(buffer);
buffer.display();

if (System.currentTimeMillis() - time >= 10) {
moveCube.set(0.1f, 0f, 0f);

moveCube = cube1.checkForCollisionEllipsoid(moveCube, ellipsoid, 8);
cube1.translate(moveCube);

time = System.currentTimeMillis();
}

} else {
if (buffer != null) {
buffer.dispose();
buffer = null;
}
}
} catch (Exception e) {
Logger.log(e, Logger.MESSAGE);
}
}

}
}

2
Support / CollisionEvent never called
« on: December 16, 2015, 12:06:22 am »
Hi! I'm trying to detect a CollisionEvent but I just can't get it right.

I made a very simple project with two cubes colliding...the problem is that neither of the two CollisionEvents is called, am I missing something in the initialization of the Objects? Following is the test project:

Code: [Select]
package com.threed.jpct.example;

import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;

import com.threed.jpct.*;

import android.app.Activity;
import android.opengl.GLSurfaceView;
import android.os.Bundle;

public class HelloWorld extends Activity {
private static HelloWorld master = null;

private GLSurfaceView mGLView;
private MyRenderer renderer = null;
private FrameBuffer buffer = null;

private World world = null;
private RGBColor back = new RGBColor(50, 50, 100);

private Object3D cube1 = null;
private Object3D cube2 = null;

private Light sun = null;
private Camera cam = null;


protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mGLView = new GLSurfaceView(getApplication());
renderer = new MyRenderer();
mGLView.setRenderer(renderer);
setContentView(mGLView);
}

@Override
protected void onPause() {
super.onPause();
mGLView.onPause();
}

@Override
protected void onResume() {
super.onResume();
mGLView.onResume();
}

protected void onStop() {
super.onStop();
}


class MyRenderer implements GLSurfaceView.Renderer {

private long time = System.currentTimeMillis();
private boolean stop = false;

public MyRenderer() {
}

public void onSurfaceChanged(GL10 gl, int w, int h) {
if (buffer != null) {
buffer.dispose();
}
buffer = new FrameBuffer(gl, w, h);

if (master == null) {

world = new World();
world.setAmbientLight(150, 150, 150);

sun = new Light(world);
sun.setIntensity(250, 250, 250);

cube1 = Primitives.getCube(1);
cube2 = Primitives.getCube(1);

cube1.setCollisionMode(Object3D.COLLISION_CHECK_SELF | Object3D.COLLISION_CHECK_OTHERS);
cube1.setCollisionOptimization(true);
cube1.addCollisionListener(new CollisionListener() {
@Override
public void collision(CollisionEvent collisionEvent) {
Logger.log("Collision1");
}

@Override
public boolean requiresPolygonIDs() {
return false;
}
});


cube2.translate(15f, 0f, 0f);
cube2.setCollisionMode(Object3D.COLLISION_CHECK_SELF | Object3D.COLLISION_CHECK_OTHERS);
cube2.setCollisionOptimization(true);
cube2.addCollisionListener(new CollisionListener() {
@Override
public void collision(CollisionEvent collisionEvent) {
Logger.log("Collision2");
}

@Override
public boolean requiresPolygonIDs() {
return false;
}
});


cube1.build();
cube2.build();
world.addObject(cube1);
world.addObject(cube2);


cam = world.getCamera();
cam.moveCamera(Camera.CAMERA_MOVEOUT, 50);
cam.moveCamera(Camera.CAMERA_MOVEUP, 15);
SimpleVector cameraView = cube1.getTransformedCenter();
cameraView.x += 10;
cam.lookAt(cameraView);
cam.setFOV(cam.getMinFOV());


SimpleVector sv = new SimpleVector();
sv.set(cube1.getTransformedCenter());
sv.y -= 100;
sv.z -= 100;
sun.setPosition(sv);

if (master == null) {
Logger.log("Saving master Activity!");
master = HelloWorld.this;
}
}
}

public void onSurfaceCreated(GL10 gl, EGLConfig config) {
}

public void onDrawFrame(GL10 gl) {

try {
if (!stop) {

buffer.clear(back);
world.renderScene(buffer);
world.draw(buffer);
buffer.display();

if (System.currentTimeMillis() - time >= 10) {
cube1.translate(0.1f, 0f, 0f);

time = System.currentTimeMillis();
}

} else {
if (buffer != null) {
buffer.dispose();
buffer = null;
}
}
} catch (Exception e) {
Logger.log(e, Logger.MESSAGE);
}
}

}
}

3
Support / Re: 3D propeller animation
« on: December 02, 2015, 10:29:19 pm »
Thanks ;D

4
Support / 3D propeller animation
« on: December 02, 2015, 06:26:12 pm »
I created an airplane in Blender. I was wondering which one of these two options is the best:

1) create an animation and add it to the Object3D.
2) create two separate Object3D, the plane and the propellers, and rotate the propeller Object.

Pages: [1]