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

Pages: [1]
I scrapped my approach and now pass the rotation values (from the touchscreen) directly to the pose calculation method. The AR engine provides a method for rotating the pose matrix, so I just pass the values I usually would use for object.rotateX/Y/Z() to the JNI function and rotate the matrix itself.
Thanks anyway!

If you use a combined matrix as rotation matrix, you'll change the rotation pivot by this translation. The new rotation pivot should be the negative translation.

If I set the negative pivot as pivot, the model will instantly snap back to its previous position when trying to rotate it.

I've tried the other solution, but since it uses a different (geographic) coordinate system again, it doesn't work either. The model gets attached to the camera and doesn't stay where it should.

No Luck, that doesn't work either :/

I tried a different approach, and set the GL-Matrix as the rotation matrix of my model. This works fine for placement and picking, but now the rotations (With object.rotateX()) rotate around an axis which seems to be far above the object (so it's pretty unusable). Which is normal I guess, since I modified the rotation matrix. Is there a way to get a proper axis that I can use with rotateAxis() or the like?

Support / Re: Start jpct-ae fresh when activity starts.
« on: December 20, 2011, 10:39:28 am »
I was asking the thread author ;)

Usually, onCreate is only called if the activity is, well, created. If you switch to another activity, the current one is paused. If you switch back to the paused activity onResume() is called. But since on switching activites the OpenGL context may get destoyed and you need to re-initialize your 3D-stuff. Depending on where you do that, onResume() or onSurfaceChanged() is a good place to do so.

Support / Re: Start jpct-ae fresh when activity starts.
« on: December 20, 2011, 10:14:08 am »
Where do you initialize the jpct-stuff? You likely want to put it into a method and call it in onCreate() and onResume().

Just that I get it right:
What should I use for VIEWPLANE_Z_VALUE, the far clipping plane?
Code: [Select]

public SimpleVector reproject2D3DWS(Camera camera, FrameBuffer buffer, int x, int y, SimpleVector toFill) {
SimpleVector ray = Interact2D.reproject2D3D(camera, buffer, x, y, 2000, toFill);
return ray;

public void findNearestObject(int touchX, int touchY) {

SimpleVector dir = reproject2D3DWS(camera, frameBuffer, touchX, touchY, new SimpleVector()).normalize();
Object[] res = world.calcMinDistanceAndObject3D(camera.getPosition(), dir, 10000);

Is that correct?

Yes, besides some unwanted minor movement of the model when I move my device, everything but picking works. But the separating doesn't really work. As soon as I set the position of the camera, the model doesn't stay on the marker.

The GL-like matrix that does the placement correctly (but not the picking) looks like this:
Code: [Select]
-0.996   0.069  -0.063   0.000
0.092   0.808  -0.582   0.000
0.011  -0.586  -0.811   0.000
-75.993 -110.593 1902.010   1.000

I set this directly as the backbuffer and leave the position alone.

The unmodified pose itself is just transposed:

Code: [Select]
-0.996   0.092   0.011 -75.993
0.069   0.808  -0.586 -110.593
-0.063  -0.582  -0.811 1902.010

Looks like a 3x3 rotation matrix and a 3x1 translation vector to me.

If I set this matrix as the cameras backbuffer and this vector as the position, the picking works but the model is somewhere far off and doesn't stay on the marker if I move the device.

Thanks, that brought me on the right track. The AR-engine converted the pose to a OpenGL-compatible matrix beforehand, which additionally screwed my calculations. But now I have some trouble doing the correct conversions between the coordinate systems now.
The AR-engine uses a right handed system (Picture). According to your wiki, I need to rotate the matrix by 180 around x to convert it to the jPCT system. But do I need to do it before or after setting the camera matrix? I currently extract the rotation/translation from the float array, dump it into a Matrix/SimpleVector, rotate the Matrix/SimpleVector by 180 around x and set them as the backbuffer/position. The car is fixed to the marker, but behaves totally unpredictable (it seems as the model sticks to the camera, and not to the marker) as I move around my device, so I guess my conversion is wrong.

Support / Problem with object picking and modified camera backbuffer matrix
« on: December 15, 2011, 03:40:51 pm »

I'm currently developing an AR-App and use jPCT-ae for rendering. To affix the model on a marker I receive a pose matrix and apply her to the camera with camera.setBack(). This works for putting my model on the marker, but I can't get picking to work with it. If I just render my model without changing the camera matrix it works fine, but as soon as I change her, it doesn't work anymore (calcMinDistanceAndObject3D() returns everywhere on my object COLLISION_NONE). Since the picking needs the camera position, I assume that something with the position vector is wrong.

My picking code:
Code: [Select]

private void doPicking(int touchX, int touchY){
SimpleVector dir = Interact2D.reproject2D3DWS(camera, frameBuffer, touchX, touchY).normalize();
Object[] res = world.calcMinDistanceAndObject3D(camera.getPosition(), dir, 10000);
  if (res[1] != null) {
    //do something...

Object properties:

Code: [Select]
Object3D[] serializedObject = Loader.loadSerializedObjectArray(serializedInputStream);

for (int i = 0; i < serializedObject.length; i++) {
if (i > 0) serializedObject[i].addParent(serializedObject[0]);


Camera pose setting:

Code: [Select]

public void onDrawFrame(GL10 arg0) {


float[] matrix = getMatrixForJPCT(new float[16]);

Matrix mat = new Matrix();

//If I comment this out, picking works flawless:


Any idea why that is?

Support / Re: jPCT-AE wiki
« on: November 16, 2011, 12:53:41 pm »
I thought I share my simple implementation of the serializer (for *.obj and *.mtl files) for the Android version, might be useful for others. If you don't mind, you can add it to the wiki.
I expected worse when I read that "It's a bit painful to use right now"  ;) It has no special error checking etc., but its usable and should be quickly adaptable for other filetypes.

Code: [Select]
import com.threed.jpct.DeSerializer;
import com.threed.jpct.Loader;
import com.threed.jpct.Object3D;

public class Serializer {

              //Adjust the paths as necessary
private static final String INPUT_MODEL = "c:/myobj.obj";
private static final String INPUT_MATERIAL = "c:/mymtl.mtl";
private static final String OUTPUT_FILE = "c:/serialized.obj";

public static void main(String[] args) {

Object3D[] objs = null;
objs = Loader.loadOBJ(INPUT_MODEL, INPUT_MATERIAL, 1);

for (Object3D o : objs);

DeSerializer ds = new DeSerializer();

try {

FileOutputStream baos = new FileOutputStream(OUTPUT_FILE);
ds.serializeArray(objs, baos, true);

} catch (Exception e) {




Load in jpct-ae with:

Code: [Select]
Object3D[] serializedObject = null;
serializedObject = Loader.loadSerializedObjectArray(res.openRawResource(R.raw.INSERT_FILE_NAME));

Support / Getting the pose of the camera?
« on: November 15, 2011, 10:16:07 am »

is it possible to get the pose of the camera? I tried getting the backbuffer matrix with getBack(), but that doesn't seem to be the same. If I apply e.g. a translation on the camera, the backbuffer matrix will remain the same as before the transformation.

Support / Re: Getting Sub-Objects from *.obj file?
« on: October 12, 2011, 02:30:59 pm »
I thought that I could somehow get access the sub-objects that the compiler mentioned (i.e. check if a collision occured with such a sub-object).

Edit: I think they are called groups inside the *.obj file.

Edit2: I obviously completely failed to realize, that all of those sub-objects are loaded independendtly. I just mashed them together with mergeAll() and overlooked that you can shove all sub-objects from the Obj-Loader into an Object3D[]-Array.  :o

Support / Re: Getting Sub-Objects from *.obj file?
« on: October 12, 2011, 01:53:21 pm »
I'm not sure I understand you correctly. I already get the object I'm picking with the instructions from the wiki. I gave the objects different names with .setName() and can differentiate between them by checking the name of the currently picked object. The CollisionListener would only return me the whole object that caused the collision, would it?

Support / Getting Sub-Objects from *.obj file?
« on: October 12, 2011, 12:03:47 pm »

I'm loading a Wavefront obj file, that consists of serveral sub-objects (I noticed that jpct processes each of these objects when compiling). Using the picking tutorial from the wiki, I can now successfully choose between the objects I have in my scene with the touchscreen. It would now be interesting to somehow access (like adding transparency, or removing them temporarily) these sub-objects. I found that I can create a PolygonManager from the object, but it doesn't seem to help me, because I can only manipulate the polygons (duh). Is there any way to get access to the sub-objects in jpct?

Pages: [1]