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

Pages: 1 [2] 3
16
Support / Ray picking (im doing something wrong but im not sure what)
« on: June 23, 2015, 03:00:53 pm »
I'm trying to do ray picking, partially on my own as i don't intend to use "minCalDistance" or Object3d's directly

However it only seems to partially work. I can hit objects i tap but the collision does not occur exactly at the point i picked. but seems to be offset vertically.

Code: [Select]
public static SimpleVector[] touch(MotionEvent e,FrameBuffer fb) {

     int x = (int)e.getX();
     int y = (int)e.getY();

             SimpleVector raydirection = Interact2D.reproject2D3DWS(camera, fb, x, y).normalize();
              SimpleVector cameraposition= new SimpleVector(camera.getPosition());

             return sphereIntersect(cameraPosition, ray,object_positions,objectradius);

}






My sphere intersection function



Code: [Select]
public static SimpleVector[] sphereIntersect(SimpleVector rayOrigin,SimpleVector rayDirection, SimpleVector sphereOrigin, float sphereRadius )
 {

        sphereOrigin.sub(rayOrigin);

        double c = (double) sphereOrigin.length();
        double v = (double) sphereOrigin.calcDot(rayDirection);
        double d = sphereRadius * sphereRadius - (c * c - v * v);

        if (d < 0.0) {
            return new SimpleVector[0];
        }
     
        float distance = (float) (v - Math.sqrt(d));
        rayDirection.scalarMul(distance);
        SimpleVector r1 = new SimpleVector(rayDirection.calcAdd(rayOrigin));

        return new SimpleVector[]{r1};
   }


Perhaps it's an issue with how android handles screen coordinates?

17
Support / Are object3d s centered?
« on: June 10, 2015, 03:17:54 pm »
Just wanted to know if i create a sphere using this method

ExtendedPrimitives.createEllipsoid(new SimpleVector(plsize,plsize,plsize), 128, 1f, 1f);

Will the  the sphere be at the origin/center or offset from it in some way?

18
Support / What do you use for audio/music
« on: June 09, 2015, 12:55:48 am »
I realize this might be slightly unrelated but i wanted to know in particular what libraries/frameworks do devs using jpct-ae rely on for playing back sounds , music, perhaps even managing playlists.

19
Support / ArcBall in JPCT?
« on: May 26, 2015, 03:59:25 pm »
anyone used ArcBall before with jpct? it looks like it could be very handy for rotating about things on touchscreen.

I'm attempting to implement it now with jpct and wanted to know if anyone else has already had success with this?

http://www.java-tips.org/other-api-tips-100035/112-jogl/1714-arcball-rotation-nehe-tutorial-jogl-port.html


http://en.wikibooks.org/wiki/OpenGL_Programming/Modern_OpenGL_Tutorial_Arcball

20
Support / Annoying logcat spam, anyone else encountered this.
« on: December 16, 2014, 01:51:36 am »
Has anyone encountered logcat spam like this? I'm happens many times a second so im guessing it's something i'm doing wrong repeatedly with object3d 's but im not quite sure what.

It's not crashing the game and everything is still fast. But it's a nuisance, and might indicate im doing something wrong. I could probably filter it but i would prefer to see if i can simply stop it from happening.




21
Support / Object3d switching/swapping in renderhook.
« on: November 21, 2014, 06:32:03 pm »
Is there a standard way for quickly swapping out objects?

I'm thinking of making an addition to my game so that objects get swapped for very simple billboards at large distances.

If i can i get two benefits:

incredible distant objects can be made easily selectable.

Rendering very large quantities of objects will have less of an impact of rendering speed(I'm not really worried by this though as it hasn't been an issue so far).

22
Support / signed distance field fonts
« on: October 09, 2014, 01:38:25 am »
Thought this might be of interest to you guys , ive been working on a simple package for doing signed distance field fonts on Android.

https://github.com/lawlessc/distance-field-glyphs

It's shader based on what Paul Houx did here with Lib Cinder https://forum.libcinder.org/topic/signed-distance-field-font-rendering to implement valves paper.

And i have also written it so it uses SDFFonts in the his generator outputs them.
https://forum.libcinder.org/topic/signed-distance-field-font-rendering

It's incomplete at the moment but i hope to add more to it as i go along, and if other people want to make additions to it or fork it into something better thats even better. I think it may be useful for display some small amounts of text on screen(ideally without distortion at many resolutions) , at the moment the text can look a bit rough.

23
Support / Shaders, possible optimization?
« on: September 08, 2014, 03:28:42 pm »
This is just thought i haven't had a chance to try yet.

But i have multiple floats being sent to a shader, at the moment i do them one at a time.
Would it make more sense to simply add all these floats to an array and send them in one setUniform command?

So instead of using

setUniform(String name, float val) ;
setUniform(String name, float val) ;
setUniform(String name, float val) ;
setUniform(String name, float val) ;


I would use setUniform(String name, float[] val) ;

24
Support / Shifting an objects position in shaders
« on: August 22, 2014, 01:08:14 pm »
Is it possible to shift the position of pixels being drawn in JPCT? im trying to render something and im using IRenderHooks repeatRendering method with an overlay and i want to shift it to the right on each rendering.

I've tried changing the overlay position itself in the repeatRendering method , that doesn't work however because of the way rendering all those objects remain in the same place.

The only way i can think is perhaps with pixel shaders, which i dont believe JPCT supports.


edit:  I may be misunderstanding how the shaders work but so far attempts to sue gl_position to shift the position of where i want a pixel to appear have failed.

25
Support / Can shaders be applied to textures?
« on: June 16, 2014, 11:24:28 pm »
I wanted to know this as id like to know if i't possible to apply shaders to textures such as for a UI, or something that will get placed on the framebuffer. The only way i can currently think of doing this might be to apply it to a flat mesh and have against the camera.

26
Support / Multiple shared shaders
« on: May 15, 2014, 10:56:02 pm »
Is there a way to quickly copy or share GLSLShader objects. I incorrectly assumed that using one shader among many objects would be ok but ive only just copped it that you need a shader for every instance, otherwise the uniforms will be set to those of the very last item updated before rendering.

27
Support / Allowed shader types?
« on: March 11, 2014, 01:27:04 am »
Is it feasible to use shaders such as this for creating glassy effects? Or can JPCT only contain certain uniforms names?

// from the Orange Book 2nd edition

const float Eta = 0.66;
const float FresnelPower = 0.5;
const float F = ((1.0-Eta)*(1.0-Eta))/((1.0+Eta)*(1.0+Eta));

varying vec3 Reflect;
varying vec3 Refract;
uniform float Ratio;

void main()
{
    vec4 ecPosition = gl_ModelViewMatrix * gl_Vertex;
    vec3 ecPosition3 = ecPosition.xyz / ecPosition.w;

    vec3 i = normalize(ecPosition3);
    vec3 n = normalize(gl_NormalMatrix * gl_Normal);

    Ratio = F + (1.0 - F) * pow((1.0 - dot(-i, n)), FresnelPower);

    Refract = refract(i, n, Eta);
    Refract = vec3(gl_TextureMatrix[0] * vec4 (Refract, 1.0));

    Reflect = reflect(i, n);
    Reflect = vec3(gl_TextureMatrix[0] * vec4 (Reflect, 1.0));

    gl_Position = ftransform();
}








Fragment shader


// from the Orange Book 2nd edition

varying vec3 Reflect;
varying vec3 Refract;
uniform float Ratio;

uniform sampler2D MyTex;

void main (void)
{
vec3 refractColor = vec3(texture2D( MyTex, Refract));
vec3 reflectColor = vec3(texture2D( MyTex, Reflect));

vec3 color = mix(refractColor, reflectColor, Ratio);

gl_FragColor = vec4(color, 1.0);
}




28
Support / odd texture error causing wrap around?
« on: February 28, 2014, 01:13:08 am »
I've run into this odd quirk with a texture i loaded, to demonstrate it i have replaced the texture with one a bit more simple. when i view the textures in an editor they look fine, however loading them into jpct causes the a chunk of the left side to be cut of and moved to the right side.

Here is the texture

Here it is being rendered.



If you are wondering about the fuzziness it's because i haven't got shaders set up entirely correctly yet.

29
Support / A touchscreen UI with blitter
« on: February 26, 2014, 02:54:09 pm »
Is there what would be considered a good or standard way of doing a UI with the blitter?

For example if i want to place a button and make it touchable with it interfering with what is happening behind it how would i do that?

At the moment im thinking of simply doing a ray trace and checking if a line coming from the touch would intersect it but that might be wrong.

30
Support / Multiple entities using the same models/textures.
« on: February 11, 2014, 11:23:40 pm »
Is there a correct way to have multiple copies of objects in jPCT game?

I want to spawn multiple identical entities that would have the same 3d models and textures. If i was handling the graphics myself i would just spawn the one object and repeat the draw command for the object in each location where there is an instance of the entity.

But since jPCT handles that aspect of it im not sure how to proceed.

Pages: 1 [2] 3