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

Pages: [1]
Support / Particle system problem
« on: February 12, 2013, 02:53:17 pm »
I've been working on making a 3D particle system for a class project. It's been going well so far....except for the speed.

At first, I was trying to do 3D objects (cubes), but half of the sides wouldn't be visible (plus, the particles would be small majority of the time unless they were near the camera). So I decided on doing them all in 2D with billboarding, and each object has only 2 triangles to worry about.
With this current setup, I'm getting around 30 fps with 100 objects and 5 fps with 400 objects. Which isn't the most appealing thing, since the game is supposed to have more particles (about 2k).

After checking out the Rajawali's implementation ( of a large particle system, I tried to do the same with jPCT (see, I'm not abandoning this engine).

First I was having problems changing the vertices (using the vertexController, still haven't completely got it working :-/) Then I found out that the code to change each particle's transparency/ color would no longer work in this method (because of how vertices share color with each other)

So, what would be the best way to do this system?
- particles which move in 3D space
- each particle has its own position/velocity/color/transparency/life
- many particles (around 2k) with a smooth frame rate
- dynamic creation of particles

Note: The particles don't need any high-quality stuff or collision. Although eventual gravity would be nice, it's on the far back burner.

Bugs / Fogging problems
« on: June 12, 2012, 08:10:54 am »
I think this is a bug because it happens without any apparent logic.
In the game play part of my game, I have the game objects rendered in one world and the hud objects rendered in another world (so they would stay static while the rest of the game move). The game objects have transparency, while the hud objects don't.

On the first render frame, it renders the scene for both worlds and then draws the worlds (game then hud), but it's not displaying the fog on the game play's world objects. When I disable the rendering/ drawing of the hud world, the first render has the fog enabled.
With the hud world enabled and the scene incorrectly displaying, after touching the screen, the fog re-enables.

I tried using the framebuffer's clearZBufferOnly() before the hud's render/ draw line, but that didn't do anything. Then I played with some code which would render/ draw the worlds twice on only the first render frame, but that also did nothing. I also tried to disable the fog in the HUD's world (not sure how that would be helped)....but it also didn't do anything. Lastly, I disabled all the lighting in the HUD's world, both ambient light and any other lights added to the world, but the only thing that did was make the hud objects black.

= Gameplay code
Code: [Select]
boolean firstR = true;
public void Render(FrameBuffer fb)
{// attempted fix, which does nothing


if((Touching || resetting) || firstR)
firstR = false;


= HUD render code
Code: [Select]
private boolean render = true;
void Render(FrameBuffer fb)
render = false;


Note: the renderScenes are linked to bool requirements so the worlds won't be needlessly rendering every frame (it made my phone hot and the fps slow).

The HUD currently only has 1 thing, which is the bottom left

= Pre-touch

= Post-touch (ignore the half-lighted/half-darked block, the picture was taken between render frames)

Support / Generating images from a template
« on: June 08, 2012, 11:27:25 am »
I tried looking through the forum and Javadoc for something which would do this, but I haven't came back with much luck. What I'm trying to do is generate new pictures from a template image, which would reduce the need to package the game with multiple images.

Each template image is a 256x256 nodpi png in an 8-bit format. Currently what I'm doing is converting the template image into int[] "done once per game start", create a new int[] of the same size, test each pixel if it matches a list of values, then change that pixel to another pixel color (in the new int[]). Then when the new int[] is finished, its made into a ARGB_8888 bitmap which it loaded into the TextureManager.

Example: change all the pixels which have a red channel of 20 into a ARGB of 200:128:0:128 (purple with a transparency of 200, change all the pixels with an red channel of 40 into an ARGB of 200:255:0:0. Every other pixel is copied as is.

The method I have now works, but it takes about 3-4 second per image (good thing they are all done in threads). The problem is that the whole bulk of them are created each time the game starts (and oddly when the phone resumes from standby). I was thinking about using the ITextureEffect, but I'm still not sure how to use it.

Is there another method of doing this or a tutorial of how ITextureEffect works? Majority of the new images won't change, but I would want to have some of the images animated eventually (using the same color scheme).

= Current code to generate the images =
Code: [Select]
private void MakeImage(Panel data, int[] pcolors)

return;// if the template image was not able to be added, then skip making this image

Bitmap nBit = Bitmap.createBitmap(adjust(data.ImageAttribute.Location, pcolors), 256, 256, Config.ARGB_8888);
tm.addTexture(data.Name, new Texture(nBit, true));
data.TexHandle = tm.getTextureID(data.Name);
data.Colors = pcolors;
panels.put(data.Name, data);

private int[] adjust(String d, int[] pcolors)
if(pcolors == null)
return rawBmp.get(d);

    int cID = -1;
    int toColor = 0;
    int nPixel = 0;
    int[] nPanel = new int[256*256];
    for(int p = 0; p < rawBmp.get(d).length; p++)
        nPixel = rawBmp.get(d)[p];
        nPanel[p] = nPixel;
        cID = match(nPixel);
        if(cID > -1 && cID < pcolors.length)
        toColor = Color.argb(,[pcolors[cID]]),[pcolors[cID]]),[pcolors[cID]]));
        nPanel[p] = toColor;
        if(cID == -2)
        toColor = Color.argb(, 100, 100, 100);
        nPanel[p] = toColor;
    return nPanel;

private int match(int pixel)
case 0:
return -2;
case 20:
return 0;
case 40:
return 1;
case 60:
return 2;
case 80:
return 3;
case 100:
return 4;

return -1;

Support / Faster Render by using the same object?
« on: May 31, 2012, 03:57:43 am »
Currently my scene has 222 visible objects (1,296 faces). 37 of the objects (216 faces out of the 1,296) are unique, the rest are copies from the original, but translated 10 points to the left. In each group of 37 objects, 24 of the faces are using transparent textures.

The world has 2 lights (ambient + 1 light with low intensity) right now, and I don't yet see a need to add any more lights

= Object breakdown
- 12 objects (2 faces each), transparency enabled
- 12 objects (12 faces each), no transparency
- 12 objects (2 faces each), no transparency
- 1 object (24 faces), no transparency

When running the game, I get an average of 10 fps. The sections of the program which use the most cpu are:
World.renderScene (@ 57.1%)
- Object3D.transformVerticies (@ 46.8%)
- Object3D.render (@ 41.3%)
- VisList.sort (@ 10.1%)

World.draw (@40.5%)
- GLRender.drawVertexArray (@ 100%)

note: All of those classes are from the engine

My question is, instead of creating all 222 objects, I just create the 37 objects. Then each time the scene needs to be rendered, it's moved to the leftmost visible object spot, textures are applied, render to framebuffer, move 10 to the right, re-texture, render again, and repeat till the object is out of the camera view. Or would this just lower the memory requirement and keep the cpu still at a high (or higher) amount?

I can not merge the objects into 1 whole object, because I would lose the object names (assumed). The names are needed so the 3 groups of 12 objects can have their textures changed dynamically during game play.

Attached is an image of what the objects look like. All of the per-object details have been stripped for the example image, the framerate is still the same though.

Support / Obj name change
« on: May 27, 2012, 11:02:35 am »
Previously I was loading each model as it's own obj file, attaching that model to a parent Object3D, then access each needed object3D through though a series of class calls. The sub-object was in it's own class, and the parent had an array of the child was taking up too much space and the subclass was easily able to be knocked out since the parent always contains the same number of children.

So, I made a new object with the children already attached. Each object has it's own name and is numbered incrementally. To access the 4th block element, I would use hub[10].getName() and it would be "Block_4". is where my problem comes in, rather than returning the name "Block_4", it would return "_jPCT17". Only the first loaded object in the Obj has a correctish name, it return the object's name plus "_jPCT-2", so it reads "HubSides_jPCT-2".

Is there a way to load the obj file and keep each object's name? The objects are labeled: "HubSides", "Front_" + (1 - 12), "Sides_" + (1 - 12), and "Back_" + (1 - 12).

Pages: [1]