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 [2] 3 4 ... 6
Support / Can not clone a striped Object3D
« on: October 17, 2013, 03:34:03 am »
Code: [Select]
Object3D src;;
Object3D obj = src.cloneObject(); // will throw a NullPointerException

Should this behavior be legal?

Support / How to do the runtime texture compression in jPCT-AE?
« on: October 16, 2013, 11:37:55 am »
Just like the engine doing for ETC1, I want to support S3TC\DXT... . The textures are stored as .jpg\.png, and will be dynamic compressed to specific format rely to GL-extension in runtime.

Is there any hook\method to do this ?

Support / How could I decrease the peak of vm memory?
« on: October 11, 2013, 02:29:19 pm »
As I know, android used a non-compacting GC before 3.0(!topic/android-developers/7VeEnvcF1CE),  which will not return the vm memory to system for external memory(non-vm-memory) using, but the external memory can be returned to system for vm memory using. For example:

Code: [Select]
// Assuming the memory limit of process is 24M, and the usage of memory of a app now is 1M/2M(vm),  1M/2M(external)
byte [] tmp = new byte[1024*1024*20];  // 21M/22M, 1M/2M
tmp = null;
system.gc();//1M/22M, 1M/2M, there are 22M vm-memory allocated, 1M used, 21M free;
//trying to allocate 3M-external memory will cause an OOM, because the heap don't shrink for external memory.
new Bitmap(xx); //before android 3.0, bitmap alloacate in external memory.

So if I want to avoid OOM, I must control the  peak of vm memory.

I found when loading/uploading asserts(models and textures), the engine will cause a high peak of memory usage, when all things done(after uploading/virtualizing), the peak will drop down much(but the vm memory won't return as saying before). So when I finished 3D-scene, return to 2D view activity(with many bitmaps\external memory), the OOM happens frequently. There is enough memory, but the peak is unreasonable.

Could I decrease the peak of vm memory when loading/uploading assets? For example:

Decreasing the tmp buffer for uploading(for 16-depth bitmap, using short[] instead of int[]);

Converting-uploading-freeing memory of asserts one at a time, instead of converting all -> uploading all -> freeing all

In my test, when using Object3D.shareCompiledData , the usage of memory will decrease for some Object3Ds but increase for another Object3Ds. I don't know if the format of models will affect this(I use 2 formats: .obj and .ser). I got the result by android's log:
Code: [Select]
10-13 18:24:54.970: D/dalvikvm(7816): GC_CONCURRENT freed 700K, 47% free 3582K/6727K, external 5000K/5097K, paused 2ms+2ms
And the decreased\increased memory is external memory.

My code:
Code: [Select]
public static Object3D clone(Object3D src, boolean shareVBO, boolean shareTexture){
    Object3D ret = src.cloneObject();
    return ret;

for(int i = 0; i < num; ++i){
  clone[i] = clone(srcObj, true, true);

Support / Could I release the mesh after uploading it as VBO?
« on: October 10, 2013, 10:58:41 am »
There are some static BackGround Object3Ds in my game which are only used for rendering,  so I think their meshes could be released after uploading.

And my purpose is to free some main memory. I tried Object3D.decoupleMesh(), but got an incorrect result.

Support / How to render a batch of similar object3D effectively?
« on: September 29, 2013, 10:38:32 am »
For example, many trees which share the same mesh and the same texture, but have different translations and rotations and need be checked collision dividually(which means I can collide with only one of these trees and don't affect others).

Now I'm doing this like:
Code: [Select]

Object3D tree;
for(int i = 0; i < treeNum; ++i){
  trees[i] = tree.cloneObject();

But when the treeNum going large, the performance will drop down heavily. Each tree has about 20 tris, there are about 10 - 80 trees on screen.

1, Generally, is this(rendering 10 - 80 objects of 20-tiris ) a problem(with other objects of the scene)?

2, Could I render these trees once(like merging them to one large object3D)but check collision dividually?

In my car-racing game, I need calc the distance between "rear\front" and road. But the result seems incorrect.

The car and road:

 |       |
|                        |
rear               front
----------------------------------------  road

Code: [Select]
    mCar.Translate(0, 50, 0); // move up
    SimpleVector d = new SimpleVector(0, -1, 0);
    float frontHeight = mRoad.calcMinDistance(front, d, 4 * 30);
    float rearHeight = mRoad.calcMinDistance(rear, d, 4 * 30);
    WLog.d("front: " + front);
    WLog.d("rear: " + rear);
    WLog.d("frontHeight: " + frontHeight);
    WLog.d("rearHeight: " + rearHeight);


Code: [Select]
09-15 16:30:56.680: D/Woo3d(4707): frontHeight: 50.03162
09-15 16:30:56.680: D/Woo3d(4707): rearHeight: 1.0E12
09-15 16:30:56.690: D/Woo3d(4707): front: (-2172.8433,50.031296,-1480.5132)
09-15 16:30:56.690: D/Woo3d(4707): rear: (-2172.3599,50.031296,-1543.8423)
09-15 16:30:56.690: D/Woo3d(4707): frontHeight: 50.03162
09-15 16:30:56.690: D/Woo3d(4707): rearHeight: 1.0E12
09-15 16:30:56.710: D/Woo3d(4707): front: (-2172.8623,50.031296,-1477.4586)
09-15 16:30:56.710: D/Woo3d(4707): rear: (-2172.379,50.031296,-1540.7877)
09-15 16:30:56.710: D/Woo3d(4707): frontHeight: 50.03162
09-15 16:30:56.710: D/Woo3d(4707): rearHeight: 50.03162

But there shouldn't be the result of COLLISION_NONE(1.0E12).  What's the possible reason?

Support / Some question about the order of drawing.
« on: September 10, 2013, 09:43:12 am »
How does jPCT-AE implement the order of drawing(rendering)?   

Dose jPCT-AE use any Occlusion culling?

I need these info to help my  art  partner to design the game scene. For example, one-large-combined-mesh VS small meshes, small textures VS one-large-texture, and so on.

by depth (necessity for accurate draw order / painter's algorithm)
-by program (context changes may be costly!)
--by texture in program (that texture context changes may be costly...)
---by mesh that uses that texture
----by discrete entity transform (every entity using this mesh)

The same code to blit a full screen transparency texture:
Code: [Select]
frameBuffer.blit(mSpeedUpTexture, 0, 0, 0, 0, 128, 64, Constant.screenWidthPx, Constant.screenHeightPx, 0xff, false);
but cause the different performance on different devices:

1,  On Tegra2, when bliting, the FPS droped from 59 to 49. Screen: 800*480

2, On Adreno305, when bliting, the FPS(62-63) nearly doesn't drop. Screen: 960*540

What's the possible reason? Is this a fill rate issue? If I FrameBuffer.resize(400*240), the fps(59-60) won't drop when bliting on Tegra2.

And how to resolve this?

In my game, I called Object3D.checkForCollisionEllipsoid() per frame, and I found there are some creating of new objects per call(Seems they are CollisionInfo and SimpleVector).

Is there any way to avoid this? I use the Allocation Tracker tool of Android to do the profiling, and there is the report:

Support / Black texture when enable mipmapping.
« on: August 14, 2013, 10:22:38 am »
Some textures(Seems 2^n * 2^m, not 2^n * 2^n) will be black if i enable mipmapping, and be fine if i disable mipmapping. Codes:

Code: [Select]
Config.glTransparencyMul = 1 / 255f;
    Config.glTransparencyOffset = 0;
    Config.farPlane = 7000;
    Config.unloadImmediately = true;


Code: [Select]
Config.glTransparencyMul = 1 / 255f;
    Config.glTransparencyOffset = 0;
    Config.farPlane = 7000;
    Config.unloadImmediately = true;


Code: [Select]
OS: Android 2.3.3\Android 4.2\Android 2.3\Android 4.0
Devices: Tegra2\Mali 400 MP\SGX 531\Adreno 203

And if i enable ETC1 and mipmapping, app will crash on Tegra2. If i enable ETC 1, disable mipmapping, app runs fine. The crash will not happen on Mali 400\SGX 531\Adreno 203.

The crash log:

08-14 16:07:30.850: I/jPCT-AE(8233): Subobject of object 32/object34 compiled to indexed fixed point data using 30/20 vertices in 17ms!
08-14 16:07:30.850: I/jPCT-AE(8233): Object 32/object34 compiled to 1 subobjects in 18ms!
08-14 16:07:30.850: I/jPCT-AE(8233): [ 1376467650865 ] - WARNING: Texture's size is 256/128, but textures should be square for OpenGL ES2.0! This may result in a black texture!
08-14 16:07:30.860: I/jPCT-AE(8233): Creating buffers...
08-14 16:07:30.860: I/jPCT-AE(8233): [ 1376467650874 ] - ERROR: before: glError 1282
08-14 16:07:30.870: W/dalvikvm(8233): threadid=13: thread exiting with uncaught exception (group=0x401c0560)
08-14 16:07:30.870: W/System.err(8233): java.lang.RuntimeException: [ 1376467650874 ] - ERROR: before: glError 1282
08-14 16:07:30.870: W/System.err(8233):    at com.threed.jpct.Logger.log(
08-14 16:07:30.870: W/System.err(8233):    at com.threed.jpct.GL20.checkError(
08-14 16:07:30.870: W/System.err(8233):    at com.threed.jpct.GL20.glGenBuffers(
08-14 16:07:30.870: W/System.err(8233):    at com.threed.jpct.CompiledInstance.compileToVBO(
08-14 16:07:30.870: W/System.err(8233):    at com.threed.jpct.CompiledInstance.render(
08-14 16:07:30.870: W/System.err(8233):    at com.threed.jpct.GLRenderer.drawVertexArray(
08-14 16:07:30.870: W/System.err(8233):    at com.threed.jpct.World.draw(
08-14 16:07:30.870: W/System.err(8233):    at com.threed.jpct.World.draw(
08-14 16:07:30.870: W/System.err(8233):    at com.zwenyu.woo3d.util.SkyBox.render(
08-14 16:07:30.870: W/System.err(8233):    at
08-14 16:07:30.870: W/System.err(8233):    at
08-14 16:07:30.870: W/System.err(8233):    at com.zwenyu.woo3d.defaultimpl.DefaultSceneManager.beforeRender(
08-14 16:07:30.870: W/System.err(8233):    at com.zwenyu.woo3d.components.GameRenderer.handleGameRender(
08-14 16:07:30.870: W/System.err(8233):    at com.zwenyu.woo3d.components.GameRenderer.onDrawFrame(
08-14 16:07:30.870: W/System.err(8233):    at android.opengl.GLSurfaceView$GLThread.guardedRun(
08-14 16:07:30.870: W/System.err(8233):    at android.opengl.GLSurfaceView$

Support / How to do the profiling in jPCT-AE?
« on: August 12, 2013, 10:13:27 am »
My purpose is to do some performance profiling, and there are another questions:

1, Is there a method to print the exact numbers of draw calls per frame?

2, How to print the total numbers of triangles(vertices) in world?

3, How to print the total  numbers of triangles(vertices) which was exactly  rendering in world?(means which was not culled/in display list/in visible list ...).

4, How to print the consuming time of gpu and cpu per frame?

Support / How to change the screen-resolution of a 3D game?
« on: July 31, 2013, 08:36:45 am »
Many 3D games of PC have the settings of changing screen-resolution.

Could I do this in android with jPCT-AE?

E.g: My device is 480*800, i want to simulate a 320*533 screen(full screen).

If I coding like "new FrameBuffer(320, 533)", I will get a game screen of 320*533, but it's not full screen.

Support / How to effectively implement GUI with jPCT-AE?
« on: July 31, 2013, 07:32:29 am »
GUI means menu\button\dash board\HP-bar and so on,  they are 2D images in most case.

I have tried 2 methods:
  1, Use Android GUI mechanism: This is simple, but will be slow when the view(s) need to update frequently(send msg to UI-Thread, then measure\layout\draw the View-hierarchy.)

 2, Use FrameBuffer.blit(): Need to code yourself for some special effects, and seems to be not very fast(Maybe I used it in a wrong way).

My question:
  1, Could you explain the implementation of FrameBuffer.blit()? And how fast should it be?

  2, Is there a third way? The performance is the most important factor  to me.

Support / Does jni make sense?
« on: July 31, 2013, 04:41:44 am »
For jPCT-AE, does jni make sense?

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