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

Pages: [1] 2
1
Hi,

Simple question:
Is there any "simple way" (far away more simpler than the "picking coding") to implement an object click or touch listener, like Androids view setOnClickListener or setOnTouchListener?
Chears..

EDITED:
Disclaimer: for an 3DS loaded object

2
Support / [SOLVED] 3DS frame animation HELP!
« on: October 12, 2014, 10:37:26 pm »
Dear Egon

1.
Again, thank you for jPCT and this excellent response and effort. That was all; simple changes in the instructions sequence LOL !!! / IT WORKS!.
T  h a n k   y o u !

2. One last question about built() method. I read that the built() it’s a heavy method and cost a little performance. Inside jPCT, applying built() for each object 3D being created at the time, cost the same that applying one “buildAllObjects()”? or is there any benefic using “buildAllObjects()”?

Regards,
Nicolás Nyerges Miklossy

3
Support / Re: 3DS frame animation HELP!
« on: October 11, 2014, 08:28:49 pm »
Here is the flagtest2.zip file attached..

4
Support / Re: 3DS frame animation HELP!
« on: October 11, 2014, 08:28:11 pm »
Dear Egon,

I did what you suggest without any changes.  I really don’t know what is going on. Maybe I’m doing something wrong with the .3ds files.  Attached you will find the original .md2 flag animation file. I use Blender 2.49b to import the md2 file and export the first three keyframes into the three .3ds files (attached) that I use in my jPCT example. If you can take your time and see where the problem is is, will be a lot of help. Note: I also attach the .blender file where all the import export job was done.

Here is the onSurfaceChanged code:
Code: [Select]
@Override
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(50, 50, 50);

cam = world.getCamera();
float yfov = (float) (2 * Math.atan(cam.getFOV() / 2 * h / w)); // <<---OK
cam.setYFovAngle(yfov);
float z = (float) (0.5 * h / (10 * Math.tan(yfov / 2)));
cam.setPosition(0, -10 / scaleY, -z);
cam.lookAt(SimpleVector.ORIGIN);


// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

flag = new Object3D(load3DSModel("xflag/flag1.3ds", 4 * h / 552));
flag.build();
flaganim = new Animation(3);
flaganim.createSubSequence("example");
flaganim.setInterpolationMethod(Animation.LINEAR);

Object3D flagframes = new Object3D(load3DSModel("xflag/flag2.3ds", 4 * h / 552));
flagframes.calcBoundingBox();
flagframes.calcNormals();
flaganim.addKeyFrame(flagframes.getMesh());

flagframes = new Object3D(load3DSModel("xflag/flag3.3ds", 4 * h / 552));
flagframes.calcBoundingBox();
flagframes.calcNormals();
flaganim.addKeyFrame(flagframes.getMesh());

flag.setAnimationSequence(flaganim);
world.addObject(flag);

// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

world.buildAllObjects();

MemoryHelper.compact();
if (master == null) {
master = CopyOfActivityT.this;
}
}
}

The onDrawFrame code:
Code: [Select]
@Override
public void onDrawFrame(GL10 arg0) {


// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

flagkey += 0.018f;
if (flagkey > 1f) {
flagkey -= 1f;
}
flag.animate(flagkey, 1);

// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

fb.clear(transp);
world.renderScene(fb);
world.draw(fb);
fb.display();

}

(Note: for test simplicity, I'm not using the texture file of the object, but is attached anyway).

flagtest1.zip = flag.md2 + flag.png + flag248.blender
flagtest2.zip = the three .3ds files ( becouse upload size limitations, I will attach this zip in the next post)
Thanks in advance.

5
Support / Re: 3DS frame animation HELP!
« on: October 11, 2014, 03:52:56 am »
Dear Egon

First of all, thank you very much for your quick response and sorry for not having answered before, since I was on a work trip. This weekend I will try what you are telling me. I'll keep you informed.

Chears

6
Support / 3DS frame animation HELP!
« on: October 07, 2014, 04:36:33 pm »
Hello,
In my example, I have a <flag object> in MD2 format, placed in my animation code and works perfectly. However, since MD2 is an old single byte and obsolete format, it’s preferable to use 3DS for animation.  I am learning to use 3DS for animation and follow all jPCT documentation, examples and forum topics about.  Using Blender 2.72, I managed to create all the 3DS keyframes files of the <flag object> and add them to my modified animation code.  Everything loads ok, but the FLAG doesn’t MOVE.

I have been hours treating to see why. Don’t see where it is the problem. PLEASE HELP!

The following code,  is to check the mesh’s, preloading and post animation:

Code: [Select]
Object3D flag = new Object3D(load3DSModel("xflag/flag_000001.3ds", 40 * h / 552));
flag.build();
Mesh M1 = flag.getMesh();

Object3D flag2 = new Object3D(load3DSModel("xflag/flag_000002.3ds", 40 * h / 552));
flag2.strip();
flag2.build();
Mesh M2 = flag2.getMesh();

System.out.println("------------   CHECK INITIAL MESH's -------------");
if (M1 == M2) {
System.out.println("M1 = M2");
} else {
System.out.println("M1 << >> M2");  // <<<< PERFECT >>>>
}
- Load frame “flag” and store the corresponding  mesh in “M1”, for future verification
- Load the second frame “flag2” and store the mesh in “M2”.
- Verify that M1 is different than M2. Please note that I check both 3DS files, and have the same number of vertex, but in different positions.

Code: [Select]
flaganim = new Animation(2);
flaganim.setInterpolationMethod(Animation.LINEAR);
flaganim.createSubSequence("example");
flaganim.addKeyFrame(M1);
flaganim.addKeyFrame(M2);

flag.setAnimationSequence(flaganim);

world.addObject(flag);

world.buildAllObjects();
- Add M1 and M2 to the animation sequence “flaganim”
- Assign the animation to “flag”
- Add “flag” to WORLD

Code: [Select]
flag.animate(0, 0);
Mesh posM1 = flag.getMesh();

flag.animate(1, 0);
Mesh posM2 = flag.getMesh();

System.out.println("------------   CHECK MESH BASED ON ANIMATION -------------");
if (posM1 == posM2) {
System.out.println("posM1 = posM2");  //  <<<<< THIS IS MY PROBLEM  >>>>
} else {
System.out.println("posM1 << >> posM2");
}
- Calculate a new mesh for object “flag”, based on the first keyframe of its animation sequence “flag.animate (0, 0)” and save the new mesh to “posM1” for future verification.
- Re/Calculate a new mesh for object “flag”, based on the LAST (second) keyframe of its animation sequence “flag.animate (1, 0)” and save the new mesh to “posM2”.
- Compare posM1 with posM2 and they ARE EQUAL ????. For that reason the flag doesn’t move.

jPCT is calculating two same mesh, but WHY? WHAT I AM MAKING WRONG?

7
Support / Re: Problem with FOV value
« on: October 03, 2014, 05:58:26 pm »
[ SOLVED ]
What a fool I am, It took a whole night breaking my head, and I did not realize I have to put the scaled values ​​of the rectangle. I just see it as soon i write you.!

            SimpleVector v1 = SimpleVector.create(-320/scaleX, -200/scaleY, 0);
            SimpleVector v2 = SimpleVector.create(320/scaleX, -200/scaleY, 0);
            SimpleVector v3 = SimpleVector.create(320/scaleX, 200/scaleY, 0);
            SimpleVector v4 = SimpleVector.create(-320/scaleX, 200/scaleY, 0);
            SimpleVector v5 = SimpleVector.create(-320/scaleX, -200/scaleY, 0);

..thanks for your patience. Excellent work you do. Congratulations

8
Support / Re: Problem with FOV value
« on: October 03, 2014, 05:53:35 pm »
Im getting a perfect aspect radio of the "green scuare" (see attached image), but still can't see the scuare to be 640x400 pixels in the screen.
Please help!

This is my code:

Code: [Select]
@Override
public void onSurfaceChanged(GL10 gl, int w, int h) {

// -------------------------------------------------------
// Setup 2D View's
// -------------------------------------------------------

// draw's the background grid as reference (you can discard this from the code)
framel.newImageView((graphics.newImage("xtemppatron.png", ImageFormat.ARGB4444)).getBitmap(), 0, 000);

// -------------------------------------------------------
// Setup OpenGL objects
// -------------------------------------------------------
if (fb != null) {
fb.dispose();
}
fb = new FrameBuffer(gl, w, h);

if (master == null) {

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

// Place camera according with device screen
cam = world.getCamera();
float YFOV = (float) (2 * Math.atan(cam.getFOV()/2 * h / w)); // <<---OK
cam.setYFovAngle(YFOV);
float z = (float) (0.5 * h / Math.tan(YFOV/2));
cam.setPosition(0, 0, -z);
cam.lookAt(SimpleVector.ORIGIN);

// custom class to print logs to lower left corner on my screen (you can discard this and use Logger)
//debug("w= " + w + " h= " + h + " FOV= " + (float) ((2 * Math.atan(cam.getFOV()/2) *180f) / Math.PI) +  " YFOV= " + (float) ((YFOV *180f) / Math.PI) + " CameraZ= " + z);
Logger.log("w= " + w + " h= " + h + " FOV= " + (float) ((2 * Math.atan(cam.getFOV()/2) *180f) / Math.PI) +  " YFOV= " + (float) ((YFOV *180f) / Math.PI) + " CameraZ= " + z);

sun = new Light(world);
sun.setIntensity(2250, 2250, 2250);
sv.set(0, 0,0);
sun.setPosition(sv);

SimpleVector v1 = SimpleVector.create(-320, -200, 0);
SimpleVector v2 = SimpleVector.create(320, -200, 0);
SimpleVector v3 = SimpleVector.create(320, 200, 0);
SimpleVector v4 = SimpleVector.create(-320, 200, 0);
SimpleVector v5 = SimpleVector.create(-320, -200, 0);
SimpleVector[] vec = new SimpleVector[] { v1,v2,v3,v4,v5 };
Polyline line1 = new Polyline(vec, RGBColor.GREEN);
world.addPolyline(line1);

MemoryHelper.compact();

if (master == null) {
master = ActivityCarpa.this;
}
}
}

9
Support / Re: Problem with FOV value
« on: October 03, 2014, 04:26:59 pm »
SORRY I MISTAKE ....

Forget the 1st and 3rd question (point 1 and 3 of my last post) and the other last post. I have the wrong yFOV formulas and  the Knickedi formula ITS CORRECT. Sorry y should need some sleep..!

Resume:

function getFOV returns = tan(fov / 2) * 2 = tanFOV, so

FOV = 2 * atan (getFOV/2)
YFOV = 2 * atan(getFOV() / 2 * screenHeight / screenWidth)



I still have a question about yFOV:
Why setting any value to YFOV using setYFovAngle, gets a different output? setting cam.setYFovAngle = 0.6 returns aprox. 0.7 with getYFOV ?



chears


10
Support / Re: Problem with FOV value
« on: October 03, 2014, 07:25:11 am »
Separating the fact from the yFOV error, I want to solve my problem:
- Suppose I have a 1280 (w) x 800 (h) screen
 -Draw a cross using two Polylines, one horizontal of 400 pixels vector (- 200.0.0) - (200,0,0) and the vertical of 400 pixels vector  (0, - 200.0) - (0,200,0).
 - I want to place the camera in the coordinates (0, 0, Z), looking at the center (0, 0, 0), in such a way, that the cross is seen in perspective exactly of 400px (w) x 400px (h).
How I calculate the values of Z, FOB and YFOV?
 With the present functions of Set/ Get of FOB and YFOV and using your formulas or my trigonometric formulas, I have not managed to do it. Emphasize the fact, that for values of Z greater than approximately 1100, the camera disappears.

11
Support / Re: Problem with FOV value
« on: October 01, 2014, 09:22:24 pm »
Knickedi,

Dear Knickedi,

Maybe my trigonometry is wrong (and excuse me if I'm wrong). No matter the value that jPCT gets out for FOV, using basic trigonometry the value of YFOV angle is given by:

  YFOV = 2 * asin (sin (FOV / 2) * height / width)

There is a simple test: the distance of the camera focal point (Z axis) must be the same on the YZ plane or the XZ plane:

Z (YZ plane) = Math.sqrt (Math.pow (x / Math.tan (0.5 * FOV), 2) - Math.pow (y, 2))
Z (XZ plane) = Math.sqrt (Math.pow (y / Math.tan (0.5 * YFOV), 2) - Math.pow (x, 2))

where x = width/2 and y = height /2,  the Z value must be equal  Z (yz) = Z (xz)

You write:
..fovy = 2 * atan(getFOV() / 2 * screenHeight / screenWidth).
The result is the full vertical FOV in radian.

if you apply your YFOV formula, you will see that Z (yz) != Z (xz)

Please correct the formula. Maybe this help others not to fight hours trying to get the correct values like me LOL.

  EDITED: SORRY IS MY MISTAKE (see above post #12)

Chears

12
Support / Re: EGLConfigChooser & Transparent Backgrounds help
« on: October 01, 2014, 05:29:27 pm »
After making several attempts and changing the order of commands and views, I got the transparent background of mGLView. Using parent FrameLayout (fl) and two childs: a second FrameLayout (mbView) and (mGLView) in that order. Important to force mGLView.setZOrderOnTop (true) and not to forget to clear the frambuffer to an alpha RGBColor color (0, 0, 0, 0). This is an example:

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
   if (master != null) {
      copy(master);
   }

   myWidth =1280;
   myHeight =800;
 
   requestWindowFeature(Window.FEATURE_NO_TITLE);
   getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
   boolean isPortrait = getResources().getConfiguration().orientation ==  Configuration.ORIENTATION_PORTRIT;
   int frameBufferWidth = isPortrait ? myHeight : myWidth;
   int frameBufferHeight = isPortrait ? myWidth : myHeight;
   Bitmap frameBuffer = Bitmap.createBitmap(frameBufferWidth, frameBufferHeight, Config.RGB_565); // for mbView
   scaleX = (float) frameBufferWidth / getWindowManager().getDefaultDisplay().getWidth();
   scaleY = (float) frameBufferHeight / getWindowManager().getDefaultDisplay().getHeight();

   FrameLayout fl = new FrameLayout(this);
   FrameLayout.LayoutParams flp = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);

               mbView = new FrameLayout(this);
   fl.addView(mbView);

   mGLView = new GLSurfaceView(this);
   mGLView.setZOrderOnTop(true);
   mGLView.setEGLConfigChooser(8, 8, 8, 8, 16, 0);
   mGLView.getHolder().setFormat(PixelFormat.TRANSLUCENT);   renderer = new RendererCarpa();
   mGLView.setRenderer(renderer);
   
   fl.addView(mGLView);

   this.setContentView(fl, flp);
}


.............

      @Override
      public void onDrawFrame(GL10 arg0) {
         // TODO Auto-generated method stub

         if (touchTurn != 0) {
            carpa.rotateY(touchTurn);
            touchTurn = 0;
         }
         if (touchTurnUp != 0) {
            carpa.rotateX(touchTurnUp);
            touchTurnUp = 0;
         }

         // 2D Redraw

         // 3D Redraw
         fb.clear(transp);  // where transp = RGBColor transp = new RGBColor(0, 0, 0, 0)
         world.renderScene(fb);
         world.draw(fb);
         fb.display();

      }

13
Support / Re: jPCT-AE HELLO WORLD 3D Engine doesn't close
« on: October 01, 2014, 05:03:02 pm »
Egon, I have only one month learning to program android and your forum is helping me a lot. Thank you for the information.

About de error, please read post http://www.jpct.net/forum2/index.php/topic,3987.msg29027.html#msg29027

Chears,
Nicolás

14
Support / EGLConfigChooser & Transparent Backgrounds help
« on: September 30, 2014, 04:58:08 pm »
Hi

1. I'm trying to understand the following line code on "HelloWorld-AE" example:


Quote
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];
   }
});

1.1 How it works?. Its a complicate method to setup EGL configuration.
1.2 Why not use setEGLConfigChooser(8, 8, 8, 8, 16, 0) instead ?


2. I have read all jPCT's and all internet post's, about making the 3D surface background transparent .I Try all methods and combinations, without results.

2.1 Does somebody have successfully place a normal 2D SurfaceView behind a 3D GLSurfaceView?

Thanks in advance

15
I just found that calling System.exit(0) on the onStop() method, solves the Fatal signal 11 error on the emulator. Works for me.

Pages: [1] 2