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 - Nemetz

Pages: 1 [2] 3 4
16
Support / Re: Version updates!
« on: August 03, 2011, 07:50:16 am »
Yes, i tested some simple applications based on JPCT. On smaller  Galaxy Tab  in visual  and perfomance case i did't see any differences between Galaxy Tab and HTC Desire S.

17
Support / Re: Strange behavior
« on: August 02, 2011, 05:18:32 pm »
I use last version, 1.23.
The code from this simple example i posted in this message
http://www.jpct.net/forum2/index.php/topic,2148.msg16077.html#msg16077

18
Support / Re: Strange behavior
« on: August 02, 2011, 11:16:28 am »
here you can see this
http://www.jpct.net/forum2/index.php/topic,2148.msg16077.html#msg16077
if we made, size of box less than 12, for example 10, we've got error:
Code: [Select]
E/AndroidRuntime( 9493): FATAL EXCEPTION: GLThread 10
E/AndroidRuntime( 9493): java.lang.ArrayIndexOutOfBoundsException
E/AndroidRuntime( 9493): at com.threed.jpct.Object3D.addTriangle(Object3D.java:5394)
E/AndroidRuntime( 9493): at com.threed.jpct.Object3D.addTriangle(Object3D.java:5170)
E/AndroidRuntime( 9493): at com.threed.jpct.Object3D.addTriangle(Object3D.java:5165)
E/AndroidRuntime( 9493): at com.threed.jpct.Object3D.addTriangle(Object3D.java:5134)
E/AndroidRuntime( 9493): at com.threed.jpct.example.TextureBox.addTextureDown(TextureBox.java:99)
E/AndroidRuntime( 9493): at com.threed.jpct.example.TextureBox.<init>(TextureBox.java:67)
E/AndroidRuntime( 9493): at com.threed.jpct.example.HelloWorld$MyRenderer.onSurfaceChanged(HelloWorld.java:217)
E/AndroidRuntime( 9493): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1356)
E/AndroidRuntime( 9493): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1118)

But if size will be 15, everything works fine.

19
Support / Re: Picking question
« on: August 02, 2011, 11:07:30 am »
Oops, sorry(
I'm just tried to find setCollisionListener(
UPD. That helps, thank you!

20
Support / Re: Picking question
« on: August 02, 2011, 11:02:42 am »
How to add this one?

21
Support / Re: Picking question
« on: August 02, 2011, 10:30:27 am »
Here is a project exmaple, so, in logcat you can see, what project is picking, but the method public void collision(CollisionEvent ce)
doesnt call, as i understand, that method just like callback...Maybe mistake in this point.


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

import java.lang.reflect.Field;

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

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

import com.threed.jpct.Camera;
import com.threed.jpct.Config;
import com.threed.jpct.FrameBuffer;
import com.threed.jpct.Interact2D;
import com.threed.jpct.Light;
import com.threed.jpct.Logger;
import com.threed.jpct.Object3D;
import com.threed.jpct.RGBColor;
import com.threed.jpct.SimpleVector;
import com.threed.jpct.Texture;
import com.threed.jpct.TextureManager;
import com.threed.jpct.World;
import com.threed.jpct.util.BitmapHelper;
import com.threed.jpct.util.MemoryHelper;

/**
 * A simple demo. This shows more how to use jPCT-AE than it shows how to write
 * a proper application for Android.
 * It includes basic activity management to handle pause and resume...
 *
 * @author EgonOlsen
 *
 */
public class HelloWorld extends Activity {

// Used to handle pause and resume...
private static HelloWorld master = null;

private GLSurfaceView mGLView;
private MyRenderer renderer = null;
private FrameBuffer fb = null;
private World world = null;
private RGBColor back = new RGBColor(50, 50, 100);

private float touchTurn = 0;
private float touchTurnUp = 0;

private float xpos = -1;
private float ypos = -1;

private TextureBox cube = null;
private int fps = 0;

private Light sun = null;
Camera cam = new Camera();
TextureBox pickedObject;

protected void onCreate(Bundle savedInstanceState) {

Logger.log("onCreate");

if (master != null) {
copy(master);
}

super.onCreate(savedInstanceState);
mGLView = new GLSurfaceView(getApplication());

mGLView.setEGLConfigChooser(new GLSurfaceView.EGLConfigChooser() {
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) {
// Ensure that we get a 16bit framebuffer. Otherwise, we'll fall
// back to Pixelflinger on some device (read: Samsung I7500)
int[] attributes = new int[] { EGL10.EGL_DEPTH_SIZE, 16, EGL10.EGL_NONE };
EGLConfig[] configs = new EGLConfig[1];
int[] result = new int[1];
egl.eglChooseConfig(display, attributes, configs, 1, result);
return configs[0];
}
});

renderer = new MyRenderer();
Config.collideOffset = 500;
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();
}

private void copy(Object src) {
try {
Logger.log("Copying data from master Activity!");
Field[] fs = src.getClass().getDeclaredFields();
for (Field f : fs) {
f.setAccessible(true);
f.set(this, f.get(src));
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}

private TextureBox getTouchedBox(int x, int y) {


SimpleVector dir = Interact2D.reproject2D3DWS(cam, fb, x, y)
.normalize();
Object[] res = world.calcMinDistanceAndObject3D(cam.getPosition(), dir,
300);
TextureBox b = null;
if (res[1] != null && res[1] instanceof TextureBox) {
b = ((TextureBox) res[1]);
}
return b;

}

public boolean onTouchEvent(MotionEvent me) {

pickedObject = getTouchedBox((int)me.getX(), (int)me.getY());
if (pickedObject != null){
Logger.log("Object name is:" + pickedObject.getName());
}
if (me.getAction() == MotionEvent.ACTION_DOWN) {
xpos = me.getX();
ypos = me.getY();
return true;
}

if (me.getAction() == MotionEvent.ACTION_UP) {
xpos = -1;
ypos = -1;
touchTurn = 0;
touchTurnUp = 0;
return true;
}

if (me.getAction() == MotionEvent.ACTION_MOVE) {
float xd = me.getX() - xpos;
float yd = me.getY() - ypos;

xpos = me.getX();
ypos = me.getY();

touchTurn = xd / -100f;
touchTurnUp = yd / -100f;
return true;
}

try {
Thread.sleep(15);
} catch (Exception e) {
// No need for this...
}

return super.onTouchEvent(me);
}

protected boolean isFullscreenOpaque() {
return true;
}

class MyRenderer implements GLSurfaceView.Renderer {

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

public MyRenderer() {
}

public void stop() {
stop = true;
}

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

if (master == null) {

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

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

// Create a texture out of the icon...:-)
Texture texture = new Texture(BitmapHelper.rescale(BitmapHelper.convert(getResources().getDrawable(R.drawable.icon)), 64, 64));
TextureManager.getInstance().addTexture("texture", texture);
TextureManager.getInstance().addTexture("beetle",
new Texture(getResources().openRawResource(R.drawable.beetle), true));
cube = new TextureBox("beetle", // left
"beetle",// front,
"beetle",// right,
"beetle",// back,
"beetle",// up,
"beetle",// down,
15, TextureManager.getInstance());
cube.setTransparency(50);
cube.setName("simple cube");
cube.build();
cube.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);
world.addObject(cube);

cam = world.getCamera();
cam.moveCamera(Camera.CAMERA_MOVEOUT, 50);
cam.lookAt(cube.getTransformedCenter());

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

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) {
if (touchTurn != 0) {
cube.rotateY(touchTurn);
touchTurn = 0;
}

if (touchTurnUp != 0) {
cube.rotateX(touchTurnUp);
touchTurnUp = 0;
}

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++;
} else {
if (fb != null) {
fb.dispose();
fb = null;
}
}
} catch (Exception e) {
Logger.log(e, Logger.MESSAGE);
}
}
}
}


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

import android.content.Intent;
import android.graphics.drawable.shapes.ArcShape;
import android.util.FloatMath;
import android.util.Log;

import com.threed.jpct.CollisionEvent;
import com.threed.jpct.CollisionListener;
import com.threed.jpct.Logger;
import com.threed.jpct.Object3D;
import com.threed.jpct.SimpleVector;
import com.threed.jpct.TextureManager;

public class TextureBox extends Object3D implements
CollisionListener {

/**
* serial version of UID
*/
private static final long serialVersionUID = -74005917658996332L;
/**
*
*/
int size = 10;
public float angle = 0;



private static SimpleVector upperLeftFront = null;
private static SimpleVector upperRightFront = null;
private static SimpleVector lowerLeftFront = null;
private static SimpleVector lowerRightFront = null;

private static SimpleVector upperLeftBack = null;
private static SimpleVector upperRightBack = null;
private static SimpleVector lowerLeftBack = null;
private static SimpleVector lowerRightBack = null;




public TextureBox(String textureName, int size) {
super(size);
this.setTexture(textureName);
}

public TextureBox(java.lang.String left, java.lang.String front,
java.lang.String right, java.lang.String back, java.lang.String up,
java.lang.String down, int size, TextureManager textureManager) {
super(size);
upperLeftFront = new SimpleVector(-size, -size, -size);
upperRightFront = new SimpleVector(size, -size, -size);
lowerLeftFront = new SimpleVector(-size, size, -size);
lowerRightFront = new SimpleVector(size, size, -size);

upperLeftBack = new SimpleVector(-size, -size, size);
upperRightBack = new SimpleVector(size, -size, size);
lowerLeftBack = new SimpleVector(-size, size, size);
lowerRightBack = new SimpleVector(size, size, size);

addTextureFront(front, textureManager, 0);
addTextureLeft(left, textureManager, 0);
addTextureBack(back, textureManager, 0);
addTextureRight(right, textureManager, 0);
addTextureUp(up, textureManager, 0);
addTextureDown(down, textureManager, 0);
this.build();
}

public TextureBox(int size, TextureManager texturemanager) {
this(null, null, null, null, null, null, size, texturemanager);
}


public void addTextureUp(String name, TextureManager textureManager, int seq) {
int textureId = isTexturePresent(name, textureManager);
try {
this.addTriangle(upperLeftBack, 0, 0, upperLeftFront, 0, 1,
upperRightBack, 1, 0, textureId, seq);
this.addTriangle(upperRightBack, 1, 0, upperLeftFront, 0, 1,
upperRightFront, 1, 1, textureId, seq);

} catch (NullPointerException npe) {
npe.printStackTrace();
Logger.log("NPE in add Texture up");

}
}



public void addTextureDown(String name, TextureManager textureManager,
int seq) {
int textureId = isTexturePresent(name, textureManager);
try {
this.addTriangle(lowerLeftBack, 0, 0, lowerRightBack, 1, 0,
lowerLeftFront, 0, 1, textureId, seq);
this.addTriangle(lowerRightBack, 1, 0, lowerRightFront, 1, 1,
lowerLeftFront, 0, 1, textureId, seq);
} catch (NullPointerException npe) {
npe.printStackTrace();
Logger.log("NPE in add Texture down");

}

}


public void addTextureFront(String name, TextureManager textureManager,
int seq) {

int textureId = isTexturePresent(name, textureManager);
try {
this.addTriangle(upperLeftFront, 0, 0, lowerLeftFront, 0, 1,
upperRightFront, 1, 0, textureId, seq);
this.addTriangle(upperRightFront, 1, 0, lowerLeftFront, 0, 1,
lowerRightFront, 1, 1, textureId, seq);
} catch (NullPointerException npe) {
npe.printStackTrace();
Logger.log("NPE in add Texture front");

}

}

public void addTextureLeft(String name, TextureManager textureManager,
int seq) {
int textureId = isTexturePresent(name, textureManager);
try {
this.addTriangle(upperLeftFront, 1, 0, upperLeftBack, 0, 0,
lowerLeftFront, 1, 1, textureId, seq);
this.addTriangle(upperLeftBack, 0, 0, lowerLeftBack, 0, 1,
lowerLeftFront, 1, 1, textureId, seq);

} catch (NullPointerException npe) {
npe.printStackTrace();
Logger.log("NPE in add Texture left");

}
}



public void addTextureBack(String name, TextureManager textureManager,
int seq) {
int textureId = isTexturePresent(name, textureManager);
try {

this.addTriangle(upperRightBack, 0, 0, lowerRightBack, 0, 1,
lowerLeftBack, 1, 1, textureId, seq);
this.addTriangle(upperLeftBack, 1, 0, upperRightBack, 0, 0,
lowerLeftBack, 1, 1, textureId, seq);

} catch (NullPointerException npe) {
npe.printStackTrace();
Logger.log("NPE in add Texture back");

}

}

public void addTextureRight(String name, TextureManager textureManager,
int seq) {
int textureId = isTexturePresent(name, textureManager);
try {

this.addTriangle(upperRightFront, 0, 0, lowerRightFront, 0, 1,
upperRightBack, 1, 0, textureId, seq);
this.addTriangle(upperRightBack, 1, 0, lowerRightFront, 0, 1,
lowerRightBack, 1, 1, textureId, seq);
} catch (NullPointerException npe) {
npe.printStackTrace();
Logger.log("NPE in add Texture right");

}

}


private int isTexturePresent(String name, TextureManager textureManager) {
if (name == null || name.equals("")) {
return textureManager.getTextureID("empty");
} else {
return textureManager.getTextureID(name);
}

}


/**
*
*/
@Override
public void collision(CollisionEvent ce) {
Logger.log("COLLISION EVEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEENT");
ce.getTargets();

}

@Override
public boolean requiresPolygonIDs() {
Logger.log("requres polygon IDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD");
return true;
}
}

22
Support / Re: Picking question
« on: August 01, 2011, 11:02:30 am »
Already increase this value in Config...
Maybe i'm doing something wrong?

23
Support / Re: Picking question
« on: August 01, 2011, 10:08:16 am »
Of course, after object initiation set
   object.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);

24
Support / Re: Picking question
« on: July 29, 2011, 10:55:34 am »
Thank you!
I implemented CollisionListener into my objects, and overrided 2 methods.
Picking object like  this:
Code: [Select]
SimpleVector dir = Interact2D.reproject2D3DWS(cam, fb, x, y)
.normalize();
Object[] res = world.calcMinDistanceAndObject3D(cam.getPosition(), dir,
distProjection);
but method
Code: [Select]
public void collision(CollisionEvent ce) {
doesnt' calling...

25
Support / Re: setTransparency rotate my object??
« on: July 26, 2011, 09:09:25 am »
Just try to use setSortOffset, and setCulling(Object3D.CULLING_DISABLED) for your object

26
Support / Re: Strange behavior
« on: July 19, 2011, 03:46:46 pm »
Thats true...
For example, if you have a box with 12 polygons, you can't make it size less than 12.
If I can't make one object smaller, then i can make all world object bigger))))

28
Support / Re: 2cameras at once/stereoscopic 3d?
« on: July 19, 2011, 01:37:34 am »
Jpct doesn't support any camera itself, but you can implement it)
If you saw camera class in documentation, it's another camera, which translate objects form the World to screen.
If you want make some application with camera, just use search....
for example this one  - http://www.jpct.net/forum2/index.php?topic=1586.0

29
Support / Re: Strange behavior
« on: July 18, 2011, 09:59:53 pm »
There are just code from your message here......
http://www.jpct.net/forum2/index.php/topic,393.msg2093.html#msg2093
UPD. So i'm adding 2 polygons for each side, that means what i have 12 polygons in object.
Mybe this is an issue? If quantity of polygons less than object size, engine throws exception?

30
Support / Strange behavior
« on: July 18, 2011, 03:22:59 pm »
Hi!
Found some strange thing. Whean i'm creating new object with, for example size = 32 by exmaple , which Mr. Egon gave me, like this
Code: [Select]
upperLeftFront = new SimpleVector(-size, -size, -size);
upperRightFront = new SimpleVector(size, -size, -size);
and adding texture:
Code: [Select]
this.addTriangle(upperLeftBack, 0, 0, upperLeftFront, 0, 1,
upperRightBack, 1, 0, textureId, seq);
this.addTriangle(upperRightBack, 1, 0, upperLeftFront, 0, 1,
upperRightFront, 1, 1, textureId, seq);
Texture size  is 128x128
Everything is ok, looks pretty.
But whan i'm trying to make a small box (size smaler than 12), i have an exception:
Code: [Select]
[ 1310995133186 ] - ERROR: Polygon index out of range - object is too large!
I/jPCT-AE ( 4560): java.lang.RuntimeException: [ 1310995133186 ] - ERROR: Polygon index out of range - object is too large!
I/jPCT-AE ( 4560): at com.threed.jpct.Logger.log(Logger.java:189)
I/jPCT-AE ( 4560): at com.threed.jpct.Object3D.addTriangle(Object3D.java:5858)
I/jPCT-AE ( 4560): at com.threed.jpct.Object3D.addTriangle(Object3D.java:5616)
I/jPCT-AE ( 4560): at com.threed.jpct.Object3D.addTriangle(Object3D.java:5611)
I/jPCT-AE ( 4560): at com.threed.jpct.Object3D.addTriangle(Object3D.java:5580)
I/jPCT-AE ( 4560): at com.Box.addTextureDown(Box.java:127)
Do you have any suggestions?
UPD:
Trying texture size 64*54, and 32*32, and still have the same result.

Pages: 1 [2] 3 4