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

Pages: 1 [2] 3 4
Support / Re: out of memory...again
« on: May 13, 2012, 06:55:48 pm »
I'm disposing everything because I have 3 levels and they are populated by different buildings, towns, boats, airfields etc. and the object counts vary in each level.
I suppose i could try and re-use my models. I'll see how long that would take.

I'm also thinking of just adding a few delays to the menu and loading system to pad out the reset.

Support / Re: out of memory...again
« on: May 12, 2012, 06:16:16 pm »
Ok. so it's not adding a texture or anything at that point?

Just been testing, and if I go back to the main menu and leave it for about a minute, there is an automated garbage collection (gc_concurrent), the memory is cleared and I can run the game again with all objects.

Do you know of anyway to speed up the memory clearing? I am calling system.gc() but that doest really help.


Support / Re: out of memory...again
« on: May 11, 2012, 10:15:28 pm »
Thanks for the replies.

None of those seem to work though. :(
I've also added world.dispose() then null it and re initialize it. but the problems stays the same.

this is my log output: Is it running out when loading a texture?

Code: [Select]
05-11 19:59:21.359: E/AndroidRuntime(7571): FATAL EXCEPTION: GLThread 243
05-11 19:59:21.359: E/AndroidRuntime(7571): java.lang.OutOfMemoryError
05-11 19:59:21.359: E/AndroidRuntime(7571): at
05-11 19:59:21.359: E/AndroidRuntime(7571): at
05-11 19:59:21.359: E/AndroidRuntime(7571): at com.threed.jpct.ZipHelper.unzip(
05-11 19:59:21.359: E/AndroidRuntime(7571): at com.threed.jpct.GLRenderer.convertTexture(
05-11 19:59:21.359: E/AndroidRuntime(7571): at com.threed.jpct.GLRenderer.setTextures(
05-11 19:59:21.359: E/AndroidRuntime(7571): at com.threed.jpct.GLRenderer.drawVertexArray(
05-11 19:59:21.359: E/AndroidRuntime(7571): at com.threed.jpct.World.draw(
05-11 19:59:21.359: E/AndroidRuntime(7571): at com.threed.jpct.World.draw(
05-11 19:59:21.359: E/AndroidRuntime(7571): at my.program.MyProgram$MyRenderer.onDrawFrame(
05-11 19:59:21.359: E/AndroidRuntime(7571): at android.opengl.GLSurfaceView$GLThread.guardedRun(
05-11 19:59:21.359: E/AndroidRuntime(7571): at android.opengl.GLSurfaceView$

The only thing that's zipped is my player model and that's 94kb uncompressed and 38k compressed.
Textures are always the same and are only loaded once at the start of the game.

I do create a layered texture for my level which is a 512 texture and a 128 tiled textured (tiled quite large) could that be it?
but the temporary object i create are nulled after I'm finished with them.

Support / out of memory...again
« on: May 10, 2012, 02:46:09 pm »
I have a problem when resetting my game.

I have a couple of levels which are populated from a pool of objects using an xml file. everything works fine untill i restart a level or pick a new level. I think my models remain in memory but i do clear them.

this is how it works:

I'm declaring an array and a world so i can easily access my objects:
Code: [Select]
private List<Object3D> worldObjectsArray = new ArrayList<Object3D>();
private List<Integer> worldObjectsArrayType = new ArrayList<Integer>();//identifies the object type
private Object3D worldEnvironment = null

Then i load my world when a level is selected from the frontend:
Code: [Select]
worldEnvironment = Loader.loadSerializedObject(res.openRawResource(R.raw.levelA));

then I process an xml file and get the object type from it: (exluded the loop from example)
Code: [Select]
node = getxmlelement;//this is an xml element loaded from a loop

if (node == "buildingA") {
tempobject = new Object3D((Loader.loadSerializedObject(res.openRawResource(R.raw.buildinga))), true);
objectType = 1;

if (node == "carA") {
tempobject = new Object3D((Loader.loadSerializedObject(res.openRawResource(R.raw.cara))), true);
objectType = 2;

tempobject = null;

which all works fine, my world is populated and I can access all objects no problem.
All transforms and data comes through from the xml fine.

but when I reset my game or game over I call reset:

Code: [Select]
if (worldObjectsArray.size() > 0) {

for (int i=worldObjectsArray.size()-1;i>=0;i--) {
if (worldObjectsArray.get(i) != null) {
worldObjectsArray.set(i,null);//probably overkill

and reset the world:
Code: [Select]

after this, my world.size() is zero, the array is cleared and i should have some more free ram but no.
the memory that was filled when loading the level is not cleared and it looks like the model references are kept in ram. Because when i reload the level, more ram is being used untill i eventually run out of memory and the game crashes. (I'm looking at ddms here)
If my xml file has 50 objects, i can probably restart the game about 5 times, if i have 300 objects, i can only play only once.

I've looked on the forum but cant find anything that fixes it. I've tried world.disposeAll(), removing and reloading the textures. removing mesh data, etc.

Object polygon sizes are about 100 polygons each. Serialized
Level is about 2000 polygons.
Textures are all powers of 2, no bigger than 512x512 (compressed and 4bp) probably no more that about 2 for level and 5 for the frontend

I've run out of ideas so any help would be erm.. helpful.

Support / getting and re-applying object rotation
« on: April 04, 2012, 11:26:44 pm »
Hi all,

I'm struggling with saving my game state. basically when the player quits my game, I want to save the health, position and rotation of the player.
Everything works fine apart from the rotation part.

To rotate my player in the world, I use either a joystick or screen tilt input and apply it like this:
Code: [Select]
I thought that I could just take the value like this:
Code: [Select]
save_rotation_data_Y = player.getRotationMatrix().getYAxis().x
then when the game restarts, all objects are re-initialized (player rotation is back to default)
and then I reload the rotation data and apply it like this:
Code: [Select]
But the rotation is not what it should be. The data saves and loads correctly (fuel, missiles, translation all are fine) but I dont think I'm looking in the right place for the rotation.
I've tried every axis and even tried saving out the rotation matrix but I know even less about that so I must be doing it wrong.

Any help would be very much appreciated.

Support / Re: object on screen using interact2d
« on: March 08, 2012, 09:22:11 pm »
Never even considered doing it like that. works perfectly. thanks

Support / object on screen using interact2d
« on: March 07, 2012, 09:31:51 pm »
Hey all,

can anyone help me or explain to me the interact2d function? I'm trying to put an object on screen but I cant get it in the right place.

this is sort of what i want to do: A 2 polygon plane that fits nicely into a radar frame. (radar frame is blitted on screen)
for example using a screen size of 800x480, the radar frame is always an 8th of the size of the frame buffer width (100 x 100) so the middle point where the radar object should be positioned is half of that (50 x50)
It's not a pivot problem but the radar object is a child of the player object and the camera is offset from the player

Code: [Select]
ui_frame_pos_x = (fb.height/16);// gives us the middle of the radar frame
ui_frame_pos_y = (fb.heigth/16);

SimpleVector dir=Interact2D.reproject2D3D(camera, fb, ui_frame_pos_x,ui_frame_pos_y).normalize();
but that doesnt work, the radar object appears to be positioned at (150x0)

this does work (sort of) it's roughly in the right place but I cant accept that this is right:
Code: [Select]
SimpleVector dir=Interact2D.reproject2D3D(cam, fb, (-ui_frame_size_x+(ui_frame_size_x/2))+8, (ui_frame_size_y+ui_frame_size_x/2));
also, when my screen is 1024 wide, the above formula doesnt work and I need to do this, which is absolutely crazy:
Code: [Select]
SimpleVector dir=Interact2D.reproject2D3D(cam, fb, (-ui_frame_size_x)-(ui_frame_size_x/2)-(ui_frame_size_x/16), ui_frame_size_y+(ui_frame_size_y/2)-(ui_frame_size_y/16)).normalize();

So I dont think i'm doing it right. I have considered doing a lookup table for screen sizes but that's my last resort.
Any help much appreciated

Support / Re: Objective arrow indicator
« on: January 29, 2012, 12:23:40 pm »
Nearly there, nearly there.

You'll be the first to see it.

Support / Re: multiple worlds and clipping planes
« on: January 29, 2012, 12:21:57 pm »
Cool! that works. (ofcourse)


Support / Re: multiple worlds and clipping planes
« on: January 28, 2012, 01:30:17 pm »
Well, its nothing to do with transparancies i think.
here is my testcase. had to adjust it a bit to set it up like my game.
Move up and down to move away from the object. further it gets, the more it 'sinks'

thanks for looking into this.

Support / Re: multiple worlds and clipping planes
« on: January 27, 2012, 10:43:06 am »
Offset doesnt make a difference.

The brown stuff is the landscape and the dark grey box is a building. On this first screenshot it's sitting on top of the landscape. On the right screen, i've moved backwards so the building is further away and only the top half of the building is above ground. Nothing is transparant on the screenshots.

I'll get a test case done this weekend.

Support / Re: multiple worlds and clipping planes
« on: January 27, 2012, 01:18:27 am »
Sorry to open an old thread but I found out some more info.
My helicopter has a model with a transparant texture for the rotor blades. When I don't draw the blades the drawing order is fine. But when I do draw them. The problem occurs. Its like the building sinks into the landscape the further it gets from the camera. But it happens quite nearby so its quite obvious.
Its the same on my nexus s and archoid tablet.

Support / Re: Objective arrow indicator
« on: January 23, 2012, 09:55:48 pm »
ah sorry. I've been trying everything to make this work so the code was in a bit of a mess.

I've done as you said which does make it work as it should. Only problem was that it didnt rotate when the camera rotated. So I've fixed that by attaching the arrow to another dummy which i rotate in the oposite of the camera.
It all works now. thanks for taking the time to look at my (bad) code.

Support / Re: Objective arrow indicator
« on: January 23, 2012, 02:29:13 pm »
Yeah that's what I've got.

the playerRadarDummy is always offset from the camera so that it displays my minimap, radar and objective arrow
the arrow is always at the top of the screen and gets its rotation from the lookat function.

but I guess the lookat function is not taking into account either my rotation
dummy or translation dummy.

thanks though

Support / Objective arrow indicator
« on: January 22, 2012, 10:43:42 pm »
Hi all,

I've been looking to implement a target indicator. An arrow at the top of the screen that always points at my next selected objective.

I've been using the code in this topic:,1385.msg9704.html#msg9704

But that doesnt work as i want it to. the arrow seems to point at a point in the world when i move forwards and backwards
but when I rotate the helicopter, the arrow doesnt move and so the rotation goes all wrong.

It's probably to do with my setup:

playerLift (movement dummy)
playerTilt (rotation dummy - child of playerLift)
Player (helicopter model - child of playerTilt)
PlayerRadarDummy (dummy that positions the radarmap and compass - child of player)
PlayerObjectiveArrow (arrow mesh - child of playerRadarDummy)

WorldObjects is an Object3D array that holds my collection of objectives.

Code: [Select]
SimpleVector lookAtPoint = playerLift.getTransformedCenter().calcSub(WorldObjects.get(0).getTransformedCenter());
lookAtPoint.add( WorldObjects.get(0).getZAxis() );
SimpleVector direction = new SimpleVector(lookAtPoint.calcSub( object.getTranslation() ) );
Matrix rotationMatrix = new Matrix( direction.getRotationMatrix() );
PlayerObjectiveArrow.setRotationMatrix( rotationMatrix );

Any help would be much appreciated as this is the last piece of code to make my game work.

Pages: 1 [2] 3 4