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.


Topics - kiffa

Pages: 1 ... 3 4 [5] 6
61
Support / How does the Virtualizer work?
« on: September 04, 2012, 07:16:06 am »
I want to use the Virtualizer class of jPCT-AE to resolve OOM, and i have read the doc, but i want to know a little more, thanks.

The process of my app is like this:

Load all models(.ser and .bones) ->
entry Scene1 -> Load all textures which are used in scene1 only -> some logic\event\draw ->
switch to Scene2 -> removeAndUnload all textures(Config.unloadImmediately = true) ->
entry Scene2 -> Load all textures which are used in scene2 only -> repeat like scene1 ... ...
-> switch to SceneN ... ...

And the OOM usually happened in the stage of "entry new scene -> load textures", my question:

1, Does the process of loading texture need more memory(peak) than the texture itself? For example:  new Texture("1024X1024.jpg"), the texture will consume 1024x1024x4 bytes of memory finally, but does the process of "new Texture(like io、decode-jpg and so on)" need more memory than 4MB?     

2, Does TextureManager.removeAndUnload () guarantee freeing memory immediately ?

3, Does the follow memory-route right?

new Texture(1024X1024) -> 4MB

set Virtualizer -> set context -> virtualize the texture -> swap the texture from vm to disk(flash) -> 0MB

Frambuffer.draw() -> upload the texture to GPU -> I don't know what happen with the virtualized-texture in this stage, help please.

removeAndUnload the virtualized-texture -> what happened?

Does the virtualized-texture need be swapped back(from disk to vm) in any situation? When? Does the process of virtualizing need more memory(peak) than the texture itself? How much time does the process of virtualizing consume typically?

4, Seems there are enough memory in every scene of my app(all of them can run fine alone),  but OOM happened in the scene switching, any suggestions? Many thanks! I have reduced my texture to two jpg(512X512) per scene, and it's hard to reduce more. And i also enabled Texture.4bpp, disabled Texture.Mipmapping.

62
Support / How does the (Object3D)parent affect the children?
« on: August 27, 2012, 04:17:46 pm »
My codes:

Code: [Select]
   
    Object3D mDog = xxxxxx; //Loader init
    Object3D obj =  Object3D.createDummyObj();
    obj.addChild(mDog);
    obj.addChild(otherObjs);
    obj.rotateY(1);

   if(mDog.getRotationMatrix().isIdentity()){
      log.d("xx", "true");
  };

   if(mDog.getTranslationMatrix().isIdentity()){
      log.d("xx", "true2");
  };


The result is "true"、"true2".

I want to reset "mDog" to its original position after "obj.rotateY(1)",  and the code "mDog.clearRotation()" is useless. Doesn't the rotation of the parent-Object3D affect the RotationMatrix of children-Object3D?

63
Support / How to set the transparency of texture?
« on: August 27, 2012, 09:35:16 am »
I used a PNG file with alpha channel as the texture of an Objcet3D, and some fragment of the Object3D were mapped to full-transparency pixel of the texture.

But when i run the app, the fragment which should be full-transparency were filled with black color.

How do i set the transparency of texture? My codes:

Code: [Select]
      in = res.openRawResource(R.raw.tex_world_trees);
      Texture t = new Texture(in, true);  // with alpha
      tm.addTexture("world_trees", t);
      in.close();
     
     obj.setTexture("world_trees");

    world.addObject(obj);
    //render、draw、display...
   

64
Bones / Could i load the skin-animations separately?
« on: August 10, 2012, 08:38:59 am »
I have an animated-dog, it has many skin-animation-frames(about 2000+, sampled by 24frame/s).

If i load all of them in one time, the left memory will be not enough. So, i want to load 1 - 1000 frames in scene1, and when the world switch to scene2, i will release 1-1000 frames, and load 1000-2000 frames.

How could i do this?

65
I have the models of a dog and an island, and the dog is animated, the island is not.

I combined the island to the dog in maya, so the island will be the sub-meshes of the dog.  And i exported the combined model into only one .mesh.xml, then converted to .bones which named dog.bones(included the dog and the island in fact).

Then, i use BonesIO.loadGroup to load  the dog.bones, and there will create some Animated3D objects, one(the dog) have animation-data, the others have not.

My question is: With the same model, does the Animated3D obj retain more memory than the Object3D?

For examble, with the same island model:
A: The island model(.bones) is loaded into an Animated3D object as a sub-mesh of the animated-dog-model.
B: The island model(.obj or .ser)  is loaded into an Object3D object.
Will "A" retain more memory than "B"?  And if so, about how many than?

66
Support / Memory leak when i tried to switch views.
« on: August 06, 2012, 05:19:26 am »
My app has 2 views, the one is SurfaceView, the other is GLSurfaceView. I need switch between them frequently, so i want to just load the models once and keep them in the memory in order to speed up the switching process.

The process:
entry SurfaceView -> switch to GLSurfaceView -> load models -> init world and others -> render and display world -> switch to SurfaceView -> switch to GLSurfaceView -> just use pre-loading models without reloading -> init world and others -> render and display world -> .....

But there seems a memory-leak in my test-app, my codes(some pseudo code):
Code: [Select]
//onSurfaceCreated

if(modelsPreloded)
  use preloadedModels and textures;
else
  loadModels() and initTextures();

initWorldAndOthers();
addAllModelsToWorld();
buildAllObjctes();

// onSurfaceChanged
  mFrameBuffer = new FrameBuffer(width, height);

// onDrawFrame
animate();
mWorld.renderScene(mFrameBuffer);
mWorld.draw(mFrameBuffer);
mFrameBuffer.display();

// onTouchEvent
if(touch down)
  mActivity.setContentView(new MyGLSurfaceView(mActivity));

With per touching down, the memory usage will increase about 500K. But what i expect is that there should be non memory usage increasing when switching from an old GLSurfaceView to the new one.

And if i change code to de-active "mWorld.renderScene(mFrameBuffer)" and "mWorld.draw(mFrameBuffer)", there will no memory usage increase when i touch down:

Code: [Select]
// onDrawFrame
animate();
//mWorld.renderScene(mFrameBuffer);
//mWorld.draw(mFrameBuffer);
mFrameBuffer.display();

Should i do some clear work before switching views? I tried mFrameBuffer.freeMemory() and mFrameBuffer.dispose(), seems useless.

67
First i have a animated-obj(.bones) with 1566 frames(24frames/s) animations, with this obj, my code ran fine. And the heap-free-mem was about 11M which was reported by DDMS.

And then i added some more animations to this obj(1566 -> 1755),  with this one, OutOfMemoryError happened.

I don't think  1755 - 1566 = 189 frames-bones-animation will eat 11M of memory.

When i run my app, the heap changed like this:
  first, there was about 3 - 4 M free memory  ---- maybe loading obj...
  then,  the free memory suddenly jumped to 11M.
  then,  OutOfMemoryError happened:

05-13 20:08:31.500: E/AndroidRuntime(4704): java.lang.OutOfMemoryError
05-13 20:08:31.500: E/AndroidRuntime(4704):    at org.apache.harmony.luni.platform.OSMemory.malloc(Native Method)
05-13 20:08:31.500: E/AndroidRuntime(4704):    at org.apache.harmony.luni.platform.PlatformAddressFactory.alloc(PlatformAddressFactory.java:129)
05-13 20:08:31.500: E/AndroidRuntime(4704):    at java.nio.DirectByteBuffer.<init>(DirectByteBuffer.java:65)
05-13 20:08:31.500: E/AndroidRuntime(4704):    at java.nio.ReadWriteDirectByteBuffer.<init>(ReadWriteDirectByteBuffer.java:48)
05-13 20:08:31.500: E/AndroidRuntime(4704):    at java.nio.BufferFactory.newDirectByteBuffer(BufferFactory.java:93)
05-13 20:08:31.500: E/AndroidRuntime(4704):    at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:65)
05-13 20:08:31.500: E/AndroidRuntime(4704):    at com.threed.jpct.GLRenderer.convertTexture(GLRenderer.java:800)
05-13 20:08:31.500: E/AndroidRuntime(4704):    at com.threed.jpct.GLRenderer.setTextures(GLRenderer.java:2270)
05-13 20:08:31.500: E/AndroidRuntime(4704):    at com.threed.jpct.GLRenderer.drawVertexArray(GLRenderer.java:2195)
05-13 20:08:31.500: E/AndroidRuntime(4704):    at com.threed.jpct.World.draw(World.java:1307)
05-13 20:08:31.500: E/AndroidRuntime(4704):    at com.threed.jpct.World.draw(World.java:1074)
05-13 20:08:31.500: E/AndroidRuntime(4704):    at com.zwenyu.scene.Main3DScene.renderWorld(Main3DScene.java:76)
05-13 20:08:31.500: E/AndroidRuntime(4704):    at com.zwenyu.scene.SceneBegin.onDrawFrame(SceneBegin.java:120)
05-13 20:08:31.500: E/AndroidRuntime(4704):    at com.zwenyu.view.Main3DSurfaceView$MyRenderer.onDrawFrame(Main3DSurfaceView.java:376)
05-13 20:08:31.500: E/AndroidRuntime(4704):    at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1363)
05-13 20:08:31.500: E/AndroidRuntime(4704):    at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1118)




68
Support / How to estimate the memory-usage in jPCT-AE?
« on: August 02, 2012, 06:20:15 am »
I have read this: http://www.jpct.net/wiki/index.php/Reducing_memory_usage

But i want to know more. Thanks!

 How to estimate the memory-usage of an Object3D obj with some known attributes(such as  triangles、vertexs and so on )? For examble: How many memories will the jPCT-AE allocate when loading a 6000-triangles model? And what's the situation when invoke methods of this Object3D obj?

 How to estimate  the memory-usage of a texture? Is that right: 
 
  1,   By default,  a 256*256 texture will need 256*256*4 bytes memory when "new texture(...)".
  2.a,  If enable "defaultToKeepPixels", there will need another 256*256*4 bytes when "World.draw(...)"(if enable4bpp then will be 256*256*2 bytes).
  2.b,  If disable "defaultToKeepPixels", there will need no extra memory when uploaded to gpu.

  How to estimate the memory-usage of both keyframe-animation and bones-animation?

  What's the situation when i use FrameBuffer.blit(...)?

69
Support / Does jPCT-AE support shadow?
« on: August 01, 2012, 08:36:40 am »
There is a ShadowHelper  class in jPCT but not in jPCT-AE.

I want to use shadow in my world with jPCT-AE, is there any simple way to do this?

Thanks!

70
Bones / How to set material for objects in .bones?
« on: July 31, 2012, 10:58:18 am »
OgreMax exported the .material.xml,  but how to use it?

Is .bones including the material info?

71
Support / ERROR: before: glError 1285
« on: July 30, 2012, 03:07:55 pm »

Everything was ok when  my code like this:

 
Code: [Select]
Texture dogTexture = new Texture(mResources.openRawResource(R.raw.dog));  //the same texture-res
      Texture worldTexture = new Texture(mResources.openRawResource(R.raw.dog));    //the same texture-res
      Texture skyTexture = new Texture(mResources.openRawResource(R.raw.dog));       //the same texture-res

      TextureManager.getInstance().addTexture("dog", dogTexture);
      TextureManager.getInstance().addTexture("sky", dogTexture);
      TextureManager.getInstance().addTexture("world", worldTexture);

 
But crashed when i changed the codes to:

 
Code: [Select]
Texture dogTexture = new Texture(mResources.openRawResource(R.raw.dog));
      Texture worldTexture = new Texture(mResources.openRawResource(R.raw.dog));
      Texture skyTexture = new Texture(mResources.openRawResource(R.raw.dog));

      TextureManager.getInstance().addTexture("dog", dogTexture);
      TextureManager.getInstance().addTexture("sky", skyTexture);       //modified here
      TextureManager.getInstance().addTexture("world", worldTexture);


res/raw/dog is a 512*512 jpg. Crash info:

07-30 20:18:08.656: E/AndroidRuntime(10787): FATAL EXCEPTION: GLThread 10
07-30 20:18:08.656: E/AndroidRuntime(10787): java.lang.RuntimeException: [ 1343650688631 ] - ERROR: before: glError 1285
07-30 20:18:08.656: E/AndroidRuntime(10787):    at com.threed.jpct.Logger.log(Logger.java:189)
07-30 20:18:08.656: E/AndroidRuntime(10787):    at com.threed.jpct.GL20.checkError(GL20.java:142)
07-30 20:18:08.656: E/AndroidRuntime(10787):    at com.threed.jpct.GL20.glGenBuffers(GL20.java:1312)
07-30 20:18:08.656: E/AndroidRuntime(10787):    at com.threed.jpct.CompiledInstance.compileToVBO(CompiledInstance.java:1291)
07-30 20:18:08.656: E/AndroidRuntime(10787):    at com.threed.jpct.CompiledInstance.render(CompiledInstance.java:529)
07-30 20:18:08.656: E/AndroidRuntime(10787):    at com.threed.jpct.GLRenderer.drawVertexArray(GLRenderer.java:2211)
07-30 20:18:08.656: E/AndroidRuntime(10787):    at com.threed.jpct.World.draw(World.java:1307)
07-30 20:18:08.656: E/AndroidRuntime(10787):    at com.threed.jpct.World.draw(World.java:1074)
07-30 20:18:08.656: E/AndroidRuntime(10787):    at net.wenyu.Main3DSurfaceView$MyRenderer.renderWorld(Main3DSurfaceView.java:245)
07-30 20:18:08.656: E/AndroidRuntime(10787):    at net.wenyu.Main3DSurfaceView$MyRenderer.onDrawFrame(Main3DSurfaceView.java:145)
07-30 20:18:08.656: E/AndroidRuntime(10787):    at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1363)
07-30 20:18:08.656: E/AndroidRuntime(10787):    at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1118)

72
Bones / How to improve the performance of animation?
« on: July 29, 2012, 02:13:47 pm »
My dog has 10364 triangles.

On my phone, the static-dog-fps is about 60, that's not bad, but when played the skin-animation, the fps dropped to only 6 fps, it seemed to be rather slow.

I have refered to jpct-ae-wiki-"Performance tips for Android", but seemed to be little help with my situation.

So, are there any advices to improve the performance of animation without reducing the faces of dog-model?

I am a beginner of 3D-graphics, so i want to know why an animating-object is much slower than the static one? What's the hotspot? And how to resolve it? I have tried to do the profiling with android-ADT,  and seemed like that the applySkeletonPose() cost the most cpu-time. I don't know if the bones-animation used the gpu(or other graphic-hardware) power, and how to profile this.  And how the hardware of a phone affect the performance, which is the most important factor: cpu、ram、gpu or others?

Thanks!

And my code is rather simple:
    Load an .bones animated-object, set AmbientLight, then play skin-animation.

There is almost little difference of the performance  between opengles-1.X and opengles-2.0 with my simple project.

73
Bones / Animation seems strange
« on: July 27, 2012, 07:02:48 am »
Maya2012 + OgreMax

First i made an dog-animation "run without position-moving"(which means the dog just run in situ). The animation played fine on my phone.

Then i changed the animation to "run with position-moving"(which means the dog run here and there). The .mesh and .skeleton runs fine in OgreMax-WinViewer. But when i played it on my phone(with .bones), something seemed to be strange:
 
  The dog's body moved, but the tail didn't move with the body. The tail seemed to stretched from origin position to where the dog's body moved to.

I tried jme3 with the same .mesh.xml and .skeleton.xml , evething was ok.

Shall i send the xml-file to you?

I will try .xml instead of .bones.

74
Bones / Proplem with blending pose-animation and skin-animation.
« on: July 25, 2012, 09:53:48 am »
My scene:
 1, Objcets: a rock + a dog
 2, Animations: rock-skin + dog-skin + dog-pose

I want to play all animations at the same time, my codes:

Code: [Select]
           //AnimatedGroup group
            group.animatePose(index, mAnimationIndex);             //dog-pose
            group.animateSkin(index, mAnimationIndex);              //dog-skin
            group.animateSkin(index, mAnimationIndex + 1);        //rock-skin
            group.applyAnimation();

When it run, just play rock-skin and dog-skin, dog-pose didn't be played. But if i changed my code like this(change order):


Code: [Select]
   group.animateSkin(index, mAnimationIndex);          //dog-skin
            group.animatePose(index, mAnimationIndex);         //dong-pose
            group.animateSkin(index, mAnimationIndex + 1);    //rock-skin
            group.applyAnimation();

Rock-skin 、dog-skin、dog-pose are all played.


And if:

 
Code: [Select]
   group.animateSkin(index, mAnimationIndex);          //dog-skin
            group.animateSkin(index, mAnimationIndex + 1);       //rock-skin
            group.animatePose(index, mAnimationIndex);           //dog-pose
            group.applyAnimation();

Dog-pose was played, and rock-skin seems to be played too, but rock-skin was rather different from what seen in maya.

Any advices?


75
OgreMax + Maya2012

I want to merge all objects in one mesh.xml, OgreMax-doc say :
  Export the scene as a mesh file - When selecting the .mesh extension during an export all meshes in the scene will be merged into a single mesh centered around the world origin.

But when i converted the mesh.xml to .bones, error happened:

  Warning: Invalid triangle mode specified, assuming indexed triangles

  // many same waring...

Exception in thread "main" java.lang.NullPointerException
        at com.jmex.model.ogrexml.anim.OgreMesh.saveCurrentToBindPose(OgreMesh.
ava:174)
        at com.jmex.model.ogrexml.anim.MeshAnimationController.<init>(MeshAnima
ionController.java:124)
        at com.jmex.model.ogrexml.OgreLoader.loadMesh(OgreLoader.java:752)
        at com.jmex.model.ogrexml.OgreLoader.loadModel(OgreLoader.java:241)
        at com.jmex.model.ogrexml.OgreLoader.loadModel(OgreLoader.java:193)
        at raft.jpct.bones.util.JMEOgreImporter.loadGroup(JMEOgreImporter.java:
10)
        at raft.jpct.bones.util.JMEOgreImporter.loadGroup(JMEOgreImporter.java:
8)
        at raft.jpct.bones.util.JMEOgreImporter.run(JMEOgreImporter.java:69)
        at raft.jpct.bones.util.JMEOgreImporter.main(JMEOgreImporter.java:170)

Pages: 1 ... 3 4 [5] 6