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

Topics - K24A3

#1
Support / Lava shader
May 02, 2013, 03:20:32 PM
Anyone know where I can download a shader that mimics lava with the texture of an object?

Basically something that warps the texture dependent on a supplied variable between 0 and 255
#2
Support / Calc 3rd SimpleVector in a line
April 30, 2013, 12:14:21 PM
Having a bit of a SimpleVector brain fade lol, trying to calculate the position of the yellow SimpleVector from the first two red SimpleVectors, but the yellow one has to be exactly 500 units away from the middle red SimpleVector.

I could dissect xyx of the vectors and do it the long way but what is the quickest and easiest way of doing this using calcSub etc..?
#3
Support / OpenGL changes in Android 4.2
December 04, 2012, 12:57:50 AM
This is a general OpenGL question not directly related to jPCT but I would like to ask if anyone here is aware of any OpenGL ES1.x changes in Android 4.2 (JellyBean MR1)?

@Egon, did you need to make any modifications for Jellybean compatibility?

I have an app that uses pure OpenGL ES1.1 and the textures are all messed up on multiple 4.2 devices plus the emulator. If I load 5 textures, the last texture loaded is used for all 5 textures, but if I load only 2 textures, those 2 textures render fine. The texture clipping is also not working properly. The whole texture is rendered instead of the clipping region.

I create the textures by:

int[] textures = new int[5];
gl.glGenTextures(5, textures, 0);

Then load an image resource into a byteBuffer and upload it to the GPU:

gl.glBindTexture(GL11.GL_TEXTURE_2D, textures[n])
gl.glTexParameterf(GL10.GL_TEXTURE_2D,GL10.GL_TEXTURE_MAG_FILTER,GL10.GL_LINEAR)     
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER,GL10.GL_LINEAR)
gl.glTexImage2D(GL10.GL_TEXTURE_2D, 0, GL10.GL_RGBA, 512, 512,0, GL10.GL_RGBA, GL10.GL_UNSIGNED_BYTE, byteBuffer) 

Drawing:

textureCrop0[0] = 0// Left
textureCrop0[1] = 0 // Bottom
textureCrop0[2] = 512// Width
textureCrop0[3] = 512 // Height
gl.glTexParameteriv(GL11.GL_TEXTURE_2D, GL11Ext.GL_TEXTURE_CROP_RECT_OES, textureCrop0, 0)


Were any of these functions changed in 4.2?
            
#4
Support / Confirming 32bit color output via jPCT
October 05, 2012, 05:15:44 PM
Is there a way to confirm that the app is rendering in 32bit mode via jPCT during runtime?

I've set everything up to use 8:8:8:8 but the output still looks 16bit with excessive color banding and I'm not sure if it's a texture/transparency issue or a configuration issue with the new Wallpaper service I'm using.

#5
Support / setTransparency precision
September 30, 2012, 04:19:54 PM
Object3D.setTransparency(int trans) only seems to work from 0 to 15, anything over 15 defaults to the transparency of 15.

The difference between each level is quite a big jump. I need a smooth transition of a textured plane.

Is there a way to vary the transparency to 256 levels or a floating point value?
Can we add a new function that takes a float from 0.0 to 1.0? i.e. Object3D.setTransparency(float fTrans);

ps. The image already has alpha so I'm using the alpha flag when creating the texture (boolean useAlpha).
#6
Support / getSphere high RAM usage
September 27, 2012, 10:10:15 AM
I have about 32-50 textured spheres in my scene, they are fairly simple, no shaders (using default jPCT shaders), 256x256 texture sizes (total 5 textures shared).

For some reason when I increase the face count from 16 to 32, RAM usage almost doubles:

no spheres = 26MB/48MB
16 faces = 27MB/48MB
24 faces = 33MB/48MB
32 faces = 41MB/48MB

Surely adding an additional 16 faces per globe (800 extra in total) wouldn't cause such a huge spike?



obj3DMain = Primitives.getSphere(32, fScale); // 16 // 24
obj3DMain.setTexture(sTextureName);
obj3DMain.calcTextureWrapSpherical();
obj3DMain.strip();
obj3DMain.setSpecularLighting(true);
world.addObject(obj3DMain);   


jPCT 1.26 beta
OGL ES2.0
Galaxy Note / Intel Emulator+HAX (same outcome on both)
#7
Support / Shaders and SetTransparency
September 24, 2012, 04:12:57 PM
I've just started learning ES2.0 using the included HelloShader example as a base, I'm trying to make the shaded face texture transparent using the usual Object3D.SetTransparency but it doesn't work at all. SetAdditionalColor also doesn't work.

Do these functions only work with standard non-shaded textures?

I'm guessing you would need to add these functions as code in the shader program.
#8
Support / Billboard rotation
January 30, 2012, 01:11:12 PM
Is there a way to rotate a billboarded Object3D on it's Z Axis?

I have a textured plane that has billboarding enabled and would like to rotate it clockwise as if you were looking at a fan spinning from the front.
#9
I'm using low transparency on my three multilayered skyboxes (3DS files not the jPCT skybox) and have found that there is a huge difference on two different GPU's, namely the Tegra2 and PowerVR (Omap 4430).

To equalize the transparency on both devices, I need to set the transparency much higher on the PowerVR.

Using Transparency of 4 looks vibrant on the Tegra2, but almost black on the PowerVR.
Using Transparency of 16 looks great on the PowerVR but too bright and very washed out on the Tegra2.

Setting the transparency to Additive doesn't resolve the problem.
I tried setting the transparency of the layers incrementally (for example 2, then 4, then 8 ) but that doesn't help.

I'm assuming it's a design trait of the GPU's in question, so the solution would be to detect the GPU and set the transparency accordingly or let the user modify the values manually.

Is this a generally known issue? Does jPCT calculate transparency based on OpenGL flags? Or am I missing something?

(OpenGL ES 1.1, jPCT 1.24)
#10
Support / ClearRotation resets the scale
December 22, 2011, 04:34:05 PM
Is Object3D.clearRotation() supposed to reset the scaling of the object?

If yes, perhaps we can add a note to the docs mentioning that it will clear the scaling as well.
If not, it may be a bug because scaling gets reset when calling clearRotation() even after I build the object3D before cloning it. I believe the original object3D is also affected so build->clone is irrelevant.

This was driving me nuts for an hour until I traced it to clearRotation()  :P
#11

When changing the sequence from say object3D.animate(fAnim, 1) to object3D.animate(fAnim, 2) causes the animation to snap instantly.

Is there an option to interpolate smoothly between sequences? Or must this be done manually by controlling the float index so the index is reset to zero before switching sequences? (assuming that each sequence uses the same mesh when at index 0f)
#12
Support / Huge RAM usage when rendering
November 27, 2011, 04:07:06 AM
I'm seeing a huge difference between the RAM usage on a phone and a tablet. My project only uses 16MB/32MB on the phone, but 45MB/48MB on the Tablet. The Tablet intermittently throws an out of memory exception when rendering. (I'm using jPCT 1.24)


To rule out a bug in my project, I created a test app with 50 spheres using no texture. I clone 49 spheres from the first sphere.

In the test app, the Tablet is using 20MB compared to 9MB on the phone.


PowerVR Omap4430 Gingerbread 2.3.5 phone:
- 6MB/32MB after loading textures
- 8MB/32MB after calling world.buildallobjects()
- 9MB/32MB when rendering

Tegra2 Honeycomb 3.1 Tablet:
- 8MB/48MB after loading textures
- 9MB/48MB after calling world.buildallobjects()
- 20MB/48MB when rendering

I tried MemoryHelper.compact(), mesh.compress(), but it made little difference.
I tried using Primitives.getSphere() on all 50 objects instead of using clone(), but that only increased the usage by one or two MB.

I doubt it's a screen resolution problem because they are not much different.
Phone: 960×540
Tablet: 1280x800

I doubt there is a memory leak, the RAM usage is generally consistent after 20 minutes.

I can't figure out why so much RAM is used. Perhaps the Tegra2 OpenGL driver is inefficient? Or is jPCT loading extra poly/vertex information on the Tablet?


Attached are the logs and main class.


[attachment deleted by admin]
#13
I have two Matrices;

1) object3D1: The source Object3D rotational matrix (getRotationMatrix())
2) object3D2: The destination Object3D rotational matrix (getRotationMatrix())

I would like to slowly rotate the source object to match the rotation matrix of the destination object frame by frame, so both rotations are exactly the same (both objects are facing the same way).

I'm guessing I can use object3D1.getZAxis() and object3D2.rotateAxis() but how do you do the calculations?

Or can I use Matrix.interpolate()?

#14
Is there an 'official' way of aligning/rotating projectiles shot from a 3D Object?

I've managed to whip up the following code:


SimpleVector sv = new SimpleVector();
sv = player.getZAxis();
bullet[n].clearTranslation();
bullet[n].clearRotation();
bullet[n].setRotationPivot(sv);
bullet[n].align(player);
sv = player.getTranslation();
sv.y += 6f; // Adjust offset
sv.x -= 2f; // Adjust offset
bullet[n].translate(sv);


Which works ok but the bullet is shot with a slight translation offset depending on the axis of the player.
I realize that sv.y+=6f and sv.x-=2f; is probably the cause, but I was wandering if there is a concrete solution for projecting projectiles from a 3D object.
#15
I'm trying to rotate an object so it's facing the way it's moving.

Is there a function in jPCT or Java that can calculate the rotation angle based on an object's translation movement?


If the object is travelling up Z using translation(0,0,2), the angle would be 270 degrees.
If the object is travelling down Z  using translation(0,0,-2), the angle would be 90 degrees (or PI/2).
If the object is travelling up X  using translation(2,0,0), the angle would be 0 degrees.
If the object is travelling down X  using translation(-2,0,0), the angle would be 180 degrees (or PI).
If the object is travelling down X and up Z using translation(-2,0,2), the angle would be 225 (270-180).
#16
Support / checkForCollisionEllipsoid() framerate drop
October 08, 2011, 05:34:35 PM
Basically I'm trying to increase the frame rate as much as possible.

I'm using checkForCollisionEllipsoid to collision check the main character but it's dropping the frame rate down from 60FPS+ to about 30-35 FPS, even when using the lowest recursionDepth of 1.

The checkForCollisionEllipsoid frame rate drops even when there are no COLLISION_CHECK_OTHERS objects nearby (they are visible though), does checkForCollisionEllipsoid do any object/mesh distance filtering before calculating using ellipsoid collision?
Perhaps the function could be modified to do a translation/boundingbox distance check before focusing on the ellipsoid precision.
The function seems to be based on the visibility of objects since the framerate dropped as soon as the objects were visible.

I tried using three checkForCollisionSpherical() checks which helped considerably, the frame rate was around 45-50FPS. However I would like to improve the FPS a bit more if possible


Perhaps a new checkForCollisionDualBox() function can be introduced that does dual-box calculations?
i.e. the function would parse two boxes, one large/main box to cover the main body, and another smaller box to cover the head and feet.
checkForCollisionDualBox(SimpleVector translation, SimpleVector box1size, SimpleVector box2size)
#17
Support / Object3D.setBillboarding()
October 07, 2011, 04:09:22 AM
Question 1: How can I scale billboarded objects? setScale() appears to do nothing.

Question 2: How can I disable billboarding lighting? setLighting(LIGHTING_NO_LIGHTS) doesn't ignore nearby lighting.



obj = Primitives.getPlane(2, 2);
obj.setTexture("bb");
obj.setTransparency(50);
obj.setLighting(Object3D.LIGHTING_NO_LIGHTS); //?
obj.setBillboarding(true);
obj.setScale(0.02f); //?
world.addObject(obj);

#18
Support / Switching between multiple Worlds
September 19, 2011, 04:09:06 PM
I'm trying to utilize two separate worlds, one world is for the menu, the other is for the game.

My design is this:

-start the app
-load the menu world
-when 'start' is pressed, load another world
-go back to the original world when done

I created a class for the menu world, within that menu world I load another world on the fly, and redirect the main GLSurfaceView.Renderer OnFrame call to the game world.

I've ran into all kinds of problems. It's crashing when loading the game world, it always crashed on world.draw() for some reason. If I remove world.draw, the skymap renders ok but nothing else. If I remove all the object3D creations, draw.world works fine.
I tried using the same World both both the menu and game, but still have problems.
The confusing thing is, if I load the game world first, it works ok.


But anyway, ignore all that... Time to start fresh!

1. My main questions is, how do you handle two separate worlds correctly? Logically?

2. Do you need to dispose the first world then reload the second?  Or can both worlds coexists side by side, redirecting the onFrame method to the current world?

3. Rather calling/loading a world from within a world (in terms of class files), would it be better to create a World Handler that disposes the current world before creating the new world, having each world in it's own class?


Any help is appreciated, thanks.