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

Pages: [1]
Support / ArrayIndexOutOfBoundsException on Object3D.copy()
« on: September 09, 2013, 04:31:17 am »
I am trying to port my Android project to PC and getting an exception during Object3D.copy() when invoking the Object3d(Object3D) constructor and Object3D.cloneObject().  Everything is working fine on the Android version.  Seems to happen on all of my objects (which are serialized MD2s), although with a different array index of course.  Using the latest version from the Download page.
Code: [Select]
java.lang.ArrayIndexOutOfBoundsException: 1790
at com.threed.jpct.Object3D.copy(
at com.threed.jpct.Object3D.<init>(
at com.threed.jpct.Object3D.<init>(
I uploaded the mesh that resulted in the above error here.

Projects / Slink & Shank
« on: August 31, 2013, 06:52:06 am »
I've been working on this project, on-and-off for about 2 years.  It's a stealth action game where you try to sneak by enemies, cameras, and gun turrets undetected.  I have a mostly complete beta, and planning to release sometime in the next month or so. 

Most of the game is played in third-person, but you can look and shoot from first-person view, as well as stick to walls and peek around corners.  The focus is on sneaking, but you can fire assault rifles, shotguns, pistols, throw grenades, and slash throats too. 

Some screenshots from the latest beta:

Slashing throat

Enemies on alert

First-person view

Thanks for checking it out.  I welcome any feedback.

Support / Shader performance on Tegra 2
« on: June 11, 2013, 06:14:29 am »
I'm wondering if anyone has managed to get decent shader performance on Tegra devices.  My shader uses all 8 lights provided by jPCT and calculates per-pixel lighting on textured geometry in the fragment shader.  It does nothing else and has no conditional statements.  On a Galaxy S4, my game (including all game logic etc) gets 50-60fps. No surprises there. Even on my old HTC Evo I get an acceptable framerate (20-30fps).  On a Motorola Xoom, it's down to an unplayable 1-3fps.

I tried the default shaders and it runs at a solid 60fps.  I tried using a stripped-down version of my shader with just one light and the framerate dropped immediately to 20fps.  Am I doing something inefficient? Is per-pixel lighting just a no-go for Tegra 2?  My stripped-down 1 light shaders are below:

Vertex shader:
Code: [Select]
uniform mat4 modelViewMatrix;
uniform mat4 modelViewProjectionMatrix;
uniform mat4 textureMatrix;

attribute vec4 position;
attribute vec3 normal;
attribute vec2 texture0;

varying vec2 texCoord;
varying vec3 vNormal, vPosition;

void main()
    texCoord = (textureMatrix * vec4(texture0, 0, 1)).xy;
    // Transform the vertex into eye space.
    vPosition = vec3(modelViewMatrix * position);
    // Transform the normal's orientation into eye space.
    vNormal = vec3(modelViewMatrix * vec4(, 0.0));
    gl_Position = modelViewProjectionMatrix * position;

Fragment shader:
Code: [Select]
precision mediump float;

varying vec2 texCoord;
varying vec3 vNormal, vPosition;

uniform vec4 ambientColor;
uniform sampler2D textureUnit0;
uniform float shininess;
uniform vec3 lightPositions[8];
uniform vec3 diffuseColors[8];
uniform vec3 specularColors[8];
uniform float attenuation[8];

void main()
    float diffuse0 = 0.0;
    vec3 diffColor0 = vec3(0.0,0.0,0.0);
    // For attenuation
    float quadratic = 0.01;
    float distance = length(lightPositions[0] - vPosition);
    // Get a lighting direction vector from the light
    vec3 lightVector = normalize(lightPositions[0] - vPosition);
    // Calculate the dot product of the light vector and vertex normal.
    diffuse0 = max(dot(vNormal, lightVector), 0.1);
    // Add attenuation
    float att = 1.0 / (1.0 + (attenuation[0] * distance) + (quadratic * distance * distance));
    diffuse0 = att * diffuse0;
    diffColor0 = (diffuseColors[0] * diffuse0) + (att * specularColors[0] * shininess);
    vec4 base = texture2D(textureUnit0, texCoord);
    gl_FragColor = (base) * (ambientColor + (vec4(diffColor0, 1.0)));

Support / Multitexture and multiple lights (shader)
« on: May 03, 2013, 02:47:48 am »
Is it the case that only one light is passed to the shader when you use multitexturing?  Seems like my multitextured faces are only affected by one of the lights in my world.

Edit: OK, by manually assigning the shader to my Object3D instead of just overriding the default shaders, all lights seem to be affecting it,but my shader is also behaving differently in general.  The light attenuation seems to be much greater after assigning manually such that the lights affect a much smaller area than they did before and the scene looks way darker overall.  I am a shader novice, so I don't really know what to make of this.  Would appreciate any help.

Edit2: I think I was just confused about which default shaders I had actually overridden. Everything seems to be in order, so this thread may be disregarded.

Support / checkForCollisionSpherical for small sphere
« on: April 08, 2013, 11:26:33 pm »
I have a large mesh that I use for a level and multiple smaller meshes representing players that reside within it.  The players collide with each other and the map without issue, using a mix of ellipsoid and spherical checks.  I also have even smaller meshes that I was using for grenades, but the spherical collision detection is not working consistently for these unless I use a radius that is way too large.  Basically, using checkForCollisionSpherical with radius 0.5, sometimes the grenades collide with the walls/floor correctly, but other times they pass straight through without registering a collision.  The same things happens with ellipsoid collision at the same size. If I up the radius to 1, every collision is detected, but the result looks bad because the grenade reacts before it visually hits the wall and floats above the floor due to the too-large sphere. If I decrease the radius (say 0.3), no collisions are detected.

I tried checking the docs for some config settings that might help, but I don't see anything that obviously relates to this.  Playing with Config.collideOffset didn't seem to make a difference. I would appreciate any help/ideas.

Support / Collision allocations
« on: April 19, 2011, 11:39:09 pm »
I am working on a little project and I noticed that the GC seems to be running every couple of seconds and causing noticeable stuttering despite my efforts to avoid object allocations.  Using the Dalvik allocation tracker, I see that many objects are being allocated during runtime by the ellipsoid collision detection methods (Object3D.checkForCollisionEllipsoid).  Has anyone else encountered similar problems and can offer a solution or workaround to cut down on GCs?  I would hope to avoid it, but might switching to spherical or ray-polygon collisions result in fewer allocations?  Thanks in advance.

Also, since this is my first post here, I would like to say thank you to Egon for this wonderful engine.

Pages: [1]