Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!

1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!

Joey P

Member Since 29 Jun 2012
Offline Last Active Jul 08 2012 04:28 AM

Topics I've Started

Rajawali Engine - anyone used it?

04 July 2012 - 03:36 PM

I've been looking around lately for an OpenGL ES 2.0 engine, basically all I need it to do is render static meshes in open space and load .obj files, texturing, and directional and point lighting, nothing fancy.

I came across one called Rajawali, it seems to do everything I need it to, and is open source so I can integrate it into my project changing what I need to. Just wondering if anyone here has used it in a serious application? If so would you recommend it? Only thing I'm worried about is, it seems to load the .obj files from disk during runtime, which can be a bit slow, instead of providing a tool to convert them to vertex arrays or VBO's before compiling...

Help! My directional light gets rotated along with my meshes :(

01 July 2012 - 04:43 AM

So I have some meshes that do full rotations every say 10 seconds by rotating the model matrix an amount based on the modulus of the system clock... beginner stuff.

Great, except I have directional light coming from the sun. So I pass in sunVector to my shader, along with the vertex position and normal vector, and calculate the diffuse. Then the vertex gets MVP matrixified After the color was calculated. So it looks like the directional sunlight is rotating along with the mesh - the same side is always lit.

Vertex shader:
[source lang="java"]private final String vertexShaderCode = "uniform mat4 u_MVPMatrix; \n" + "uniform mat4 u_MVMatrix; \n" + "uniform vec3 u_SunVector; \n" + "attribute vec4 a_Position; \n" + "attribute vec4 a_Color; \n" + "attribute vec3 a_Normal; \n" + "varying vec4 v_Color; \n" + "void main() \n" + "{ \n" + " vec3 modelViewNormal = vec3(u_MVMatrix * vec4(a_Normal, 0.0)); \n" // Normalize sun vector + " vec3 nSunVector = normalize(u_SunVector); \n" // Lambert factor + " float diffuse = max(dot(a_Normal, nSunVector), 0.0); \n" + " v_Color[0] = a_Color[0] * diffuse; \n" + " v_Color[1] = a_Color[1] * diffuse; \n" + " v_Color[2] = a_Color[2] * diffuse; \n" + " v_Color[3] = a_Color[3]; \n". + " gl_Position = u_MVPMatrix \n" + " * a_Position; \n" + "} \n"; [/source]

I must be missing a matrix somewhere?

[Open GL ES 2.0] Set camera position with SetLookAtM() giving goofy results

30 June 2012 - 03:14 PM

Hi all,

First post here.In my Renderer class I have these vars:

[source lang="java"] // Direction of camera private float lookX = 0.0f; private float lookY = 1.0f; private float lookZ = 0.0f; // Camera tilt private float upX = 0.0f; private float upY = 0.0f; private float upZ = 1.0f; // Position of camera private float eyeX = 0.0f; private float eyeY = 0.0f; private float eyeZ = 0.0f;[/source]
Then to set the view matrix I use:

[source lang="java"]Matrix.setLookAtM(mViewMatrix, 0, eyeX, eyeY, eyeZ, lookX, lookY, lookZ, upX, upY, upZ);[/source]

This all works perfectly well if eyeX, eyeY, and eyeZ are all set to 0. I can change the look vector and up vector when I want to rotate the camera position around and view the world. Works beautiful.

The problem is once I change the eyeX, eyeY, and eyeZ to some other arbitrary values so I can view my meshes from some place other than the origin, the rotations no longer work as expected. When I rotate the camera, all the meshes stay in view in front of me and just follow me.

What is it I need to do differently?

Thanks for any insights.