Main Menu
Menu

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.

Show posts Menu

Messages - sisu

#1
Hi, I need to load 3D models which are of relative large size (1MB-10MB). The loading of an object takes a long time (20 sec for a model of 1.5MB), when I look at the logs I see that the garbage collector is constantly freeing memory and pausing. See below for a few logs:

...
07-20 17:37:25.340: D/dalvikvm(2826): GC_FOR_ALLOC freed <1K, 8% free 79443K/85575K, paused 86ms
07-20 17:37:25.350: I/dalvikvm-heap(2826): Grow heap (frag case) to 78.511MB for 852408-byte allocation
07-20 17:37:25.450: D/dalvikvm(2826): GC_FOR_ALLOC freed <1K, 8% free 80275K/86471K, paused 95ms
07-20 17:37:25.550: D/dalvikvm(2826): GC_FOR_ALLOC freed <1K, 8% free 80275K/86471K, paused 85ms
07-20 17:37:25.550: I/dalvikvm-heap(2826): Grow heap (frag case) to 79.325MB for 852408-byte allocation
07-20 17:37:25.660: D/dalvikvm(2826): GC_FOR_ALLOC freed <1K, 8% free 81108K/87367K, paused 96ms
07-20 17:37:25.760: D/dalvikvm(2826): GC_FOR_ALLOC freed 0K, 8% free 81108K/87367K, paused 87ms
07-20 17:37:25.760: I/dalvikvm-heap(2826): Grow heap (frag case) to 80.137MB for 852408-byte allocation
07-20 17:37:25.870: D/dalvikvm(2826): GC_FOR_ALLOC freed <1K, 8% free 81940K/88263K, paused 98ms
07-20 17:37:26.060: D/dalvikvm(2826): GC_CONCURRENT freed <1K, 5% free 83988K/88263K, paused 3ms+12ms
07-20 17:37:26.200: D/dalvikvm(2826): GC_FOR_ALLOC freed <1K, 5% free 84715K/88263K, paused 120ms
07-20 17:37:26.200: I/dalvikvm-heap(2826): Grow heap (frag case) to 83.660MB for 852312-byte allocation
07-20 17:37:26.310: D/dalvikvm(2826): GC_FOR_ALLOC freed 0K, 5% free 85547K/89159K, paused 102ms
07-20 17:37:26.420: D/dalvikvm(2826): GC_FOR_ALLOC freed <1K, 5% free 85547K/89159K, paused 95ms
07-20 17:37:26.420: I/dalvikvm-heap(2826): Grow heap (frag case) to 84.473MB for 852312-byte allocation
07-20 17:37:26.520: D/dalvikvm(2826): GC_FOR_ALLOC freed <1K, 5% free 86379K/90055K, paused 105ms
07-20 17:37:26.640: D/dalvikvm(2826): GC_FOR_ALLOC freed <1K, 4% free 87212K/90055K, paused 117ms
07-20 17:37:26.650: I/dalvikvm-heap(2826): Grow heap (frag case) to 86.098MB for 852312-byte allocation
....


Is it possible to let the garbage collector free memory after the model is loaded?

Thanks
#2
Ow I see. I appreciate the effort you put in jPCT, you should put a donate button on the website :)
#3
Okay, I managed to take a snapshot with a hackish way: I set a boolean to true in the onTouchEvent and in the onDraw method I check the boolean and if true take a snapshot. I think I can't access the framebuffer in the onTouchEvent because it is running in another thread or something. If you have a beter solution, I'd like to hear it :)
#4
I don't think my device doesn't support it because I can use the getPixels() method in the onDrawFrame(GL10 gl) and take a snapshot with no problem, It only doesn't work if I use it in the onTouchEvent (which is outside the 'MyRenderer implements GLSurfaceView.Renderer' class).

The device I use is a Samsung Galaxy Tab 8.9 (WiFi) P7310 and I am working with Android 3.0 platform.
#5
Hi, thank you very much!! It works now and I am starting to understand the interaction between the different coordinate systems.

I've got another problem though: I'd like to save a snapshot of the framebuffer onto the phone when the user touches the screen but I get a 'called unimplemented OpenGL ES API' error and a black image is saved. I use following code:

if (me.getAction() == MotionEvent.ACTION_DOWN) {
Bitmap image = null;
if (fb != null){
image = Bitmap.createBitmap(fb.getPixels(), fb.getWidth(), fb.getHeight(), Bitmap.Config.ARGB_8888);
       
                //Stuff to store the image
String extr = Environment.getExternalStorageDirectory().toString() + File.separator + "Deco";
String fileName = new SimpleDateFormat("'Snapshot_'yyyy'-'MM'-'dd'_'hh':'mm':'ss'.jpg'").format(new Date());
String filePath = extr + "/" + fileName;
File myPath = new File(extr, fileName);

try {
FileOutputStream fos = new FileOutputStream(myPath);
image.compress(Bitmap.CompressFormat.JPEG, 100, fos);
fos.flush();
fos.close();
//MediaStore.Images.Media.insertImage(getContentResolver(), b, "Screen", "screen");
}catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
               // end stuff to store image
}
return true;
}


When I use this code in the onDrawFrame(GL10 gl) of the MyRenderer class after following lines, it works.
fb.clear(back);
world.renderScene(fb);
world.draw(fb);


Do you know how to solve this? In the documentation is also written that it is recommended to use getPixels() after update(), but it seems that there is no update method for the jPCT-AE version.
#6
Hi, thanks for you quick response. I changed the value to 50f, but when I drag the cube, it jumps to another z-level I guess. The value of cam.getPosition().z is indeed (-)50 which is logical because when loading the cube it moves out the camera 50f.

[attachment deleted by admin]
#7
Hey, thanks for your answer, but I couldn't fix it. I tried several solutions in the forum the last few days but none worked out for me. In the attachment I put the HelloWorld file from the wiki with your proposed solution added. Is there something missing? (I only changed the code in the "me.getAction() == MotionEvent.ACTION_MOVE")

[attachment deleted by admin]
#8
Hi

I have a problem with touch gestures using jPCT-AE. When I want to drag an Object3D, the object moves faster than my finger. I use following code:

public boolean onTouchEvent(MotionEvent me) {
if (me.getAction() == MotionEvent.ACTION_DOWN) {
xpos = me.getX();
ypos = me.getY();
return true;
}

if (me.getAction() == MotionEvent.ACTION_UP) {
xpos = -1;
ypos = -1;
                        dragging = false;
moveX = 0; //used for dragging
moveY = 0; //used for dragging
return true;
}

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

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

dragging = true;
moveX = xd; //used for dragging
moveY = yd; //usedf or dragging
return true;
}

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

return super.onTouchEvent(me);
}

public void onDrawFrame(GL10 gl) {
        if(dragging){
cube.translate(0, moveY, 0);
cube.translate(moveX, 0, 0);
dragging = false;
        }

}



Any suggestions on how I can keep the object under my finger?

PS: I'm fairly new to this library, but I really like it so far!! Great job!