Inspire08 demo log, day 25

May 7th 2008

Status:
1(2) days left until Inspire08
Effects


Here we go with some effects... dots and HypnoRays. The demo is not supposed to look like this btw, I'm just adding effects on top of each other by now.

/projects/inspire08/07/

I may try to avoid loading images for this prod... I don't know... It's late tho, time to sleep.

Oh, here is the code for the hypnoray, it's just an idea I had on the bus on the way home today (vertex colors power ;D).

package effects;

import javax.media.opengl.GL;

import com.xplsv.utils.Timer;

import core.Vertex;

public class EffectHypnoRays extends Effect
{
	private Vertex[] meshData;
	
	public EffectHypnoRays(GL gl, int start, int duration)
	{
		super(gl, start, duration);
	}
	
	public void init()
	{
		int sides = 200;
		int radious = 4;
		float angle = ( 360.0f / (float)(sides-1) ) * ( (float)Math.PI / 180.0f );
		
		meshData = new Vertex[sides+1];
		
		Vertex v = new Vertex();

		v.position.x = 0.0f;
		v.position.y = 0.0f;
		v.position.z = 0.0f;

		v.colour.r = 0.0f;
		v.colour.g = 0.0f;
		v.colour.b = 0.2f;
		
		meshData[0] = v;
		
		for (int i = 1; i <= sides; i++)
		{
			v = new Vertex();

			v.position.x = (float) (radious * Math.cos(i * angle));
			v.position.y = (float) (radious * Math.sin(i * angle));
			v.position.z = 0;			

			v.colour.r = (float)Math.random() + (float)Math.sin(i*.5) - 1.0f; 
			v.colour.g = v.colour.r;
			v.colour.b = v.colour.r + 0.2f; 

			meshData[i] = v;
		}
	}
	
	public void render()
	{
		if(!active())
			return;
		
		gl.glLoadIdentity();
		gl.glTranslatef(0.0f, 0.0f, - 5.0f);
		gl.glRotatef((float)(Timer.get()*.01f), 0.1f, 0.0f, 1.0f);
		
		gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE);
		gl.glBegin(GL.GL_TRIANGLE_FAN);

		for (int i = 0; i < meshData.length; i++)
		{
			gl.glColor4f(meshData[i].colour.r, meshData[i].colour.g, meshData[i].colour.b, 1.0f);
			gl.glVertex3f(meshData[i].position.x, meshData[i].position.y, meshData[i].position.z);
		}

		gl.glEnd();
	}
}
0 comments written so far...


Have your say!

Name:

Website:

Comment:

Some of the projects that I worked on.



Some of the HTML5 and Actionscript experiments I've done.