VBO - 10000 Particiles
| dist- dist-windows-i586.rar dist-windows-amd64.rar dist-macosx-ppc.rar dist-macosx-universal.rar |
dist - 10000 VBO * 5 = 50 000 p dist-windows-i586.rar dist-windows-amd64.rar dist-macosx-ppc.rar dist-macosx-universal.rar |
| dist- dist-windows-i586.rar dist-windows-amd64.rar dist-macosx-ppc.rar dist-macosx-universal.rar |
dist - 10000 VBO * 5 = 50 000 p dist-windows-i586.rar dist-windows-amd64.rar dist-macosx-ppc.rar dist-macosx-universal.rar |
Vous devez être connecté pour publier un commentaire.
2 octobre 2008 à 13:40
Could you add some techinical details?
Can you publish the Processing code?
VERY NICE INDEED :)
2 octobre 2008 à 18:19
That is in Java… using the jogl librarie… (same as processing…)
I will work later to simplifiy that into some processing object. later… not so far…
Else you can just search tutorial about jogl…
Regards.
4 octobre 2008 à 3:50
Thanks for the info :)
I gave a try to Jogl already but prefer Processing :-D
What really interests to me are the techniques you used to create this effect…
Did you use particle system with texture? Have you implemented a sort of metaball post effect ?!
I really wish you could tell more of post some code…
THANKS AND COMPLIMENTS !!!
4 octobre 2008 à 9:01
package org.yourorghere;
import com.sun.opengl.util.BufferUtil;
import javax.media.opengl.*;
import com.sun.opengl.util.texture.*;
import java.io.*;
import java.net.URL;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
public class LocalizeFog {
private String path;
private float angle;
private IntBuffer indiceBuffer;
private Texture texture;
private FloatBuffer colorBuffer;
private FloatBuffer vertexBuffer;
private FloatBuffer test;
private boolean completed;
public Life particule[];
public static int tailleGlobal = 4000;
public static boolean negFog = false;
public static boolean show = true;
public Wind wind;
public static int nbtoDraw;
public LocalizeFog(GL gl, int numParticles) {
vertexCount = numParticles;
this.path = “images/ellipse.png”;
wind = new Wind();
loadTexture();
newList();
vertexPipe(gl);
texturePipe(gl);
indexPipe(gl);
colorPipe(gl);
completed = true;
}
public void updateXYZ() {
wind.updateWind();
for (int i = 0; i < nbtoDraw; i++) {
particule[i].update();
}
}
public void constrainNBDraw() {
if (nbtoDraw > vertexCount) {
nbtoDraw = vertexCount;
}
}
// GL_ONE_MINUS_SRC_ALPHA
// GL_CONSTANT_ALPHA
// GL_DST_ALPHA
public void drawPipe(GL gl) {
if (completed && show && nbtoDraw > 0) {
constrainNBDraw();
updateXYZ();
vertexPipe(gl);
colorPipe(gl);
gl.glEnable(GL.GL_TEXTURE_2D);
gl.glDisable(GL.GL_DEPTH_TEST);
gl.glEnable(GL.GL_BLEND);
gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_CONSTANT_ALPHA);
if (!negFog) {
gl.glBlendEquation(gl.GL_FUNC_REVERSE_SUBTRACT);
} else {
gl.glBlendEquation(gl.GL_FUNC_ADD);
}
gl.glEnableClientState(GL.GL_COLOR_ARRAY);
gl.glColorPointer(4, GL.GL_FLOAT, 0, 0);
/////////////////////////////////////////
gl.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY);
gl.glBindBufferARB(GL.GL_ARRAY_BUFFER, VBOTexture[0]);
/////////////////////////////////////////
//gl.glTexEnvf(gl.GL_TEXTURE_2D, gl.GL_ALPHA_SCALE, 0.1f);
gl.glTexCoordPointer(2, GL.GL_FLOAT, 0, 0);
gl.glBindBufferARB(GL.GL_ARRAY_BUFFER, VBOVertices[0]);
/////////////////////////////////////////
//gl.glEnableClientState(GL.GL_COLOR_ARRAY);
//gl.glColorPointer(4, GL.GL_FLOAT, 0, 0);
/////////////////////////////////////////
gl.glEnableClientState(GL.GL_VERTEX_ARRAY);
gl.glVertexPointer(3, GL.GL_FLOAT, 0, 0);
/////////////////////////////////////////
//gl.glAccum(gl.GL_ACCUM, 0.01f/i);
// Draw All Of The Triangles At Once
//gl.glDrawElements(GL.GL_POLYGON, 5, GL.GL_UNSIGNED_INT, indiceBuffer);
gl.glDrawArrays(GL.GL_QUADS, 0, nbtoDraw);
// Disable Texture Coord Arrays
/////////////////////////////////////////
gl.glDisableClientState(GL.GL_TEXTURE_COORD_ARRAY);
gl.glDisableClientState(GL.GL_VERTEX_ARRAY);
gl.glDisableClientState(GL.GL_COLOR_ARRAY);
/////////////////////////////////////////
gl.glDisable(GL.GL_BLEND);
gl.glEnable(gl.GL_DEPTH_TEST);
//gl.glDisable(GL.GL_TEXTURE_2D);
}
}
//////////////////////////////////////////////////////////////////////////////
private int[] VBOVertices;
private int[] VBOTexture;
private int[] VBOIndice;
private int[] VBOColor;
public int vertexCount;
public void newList() {
//nbtoDraw = vertexCount;
particule = new Life[vertexCount];
for (int i = 0; i < vertexCount; i++) {
particule[i] = new Life();
}
//////////////////////
}
public void vertexPipe(GL gl) {
vertexBuffer = BufferUtil.newFloatBuffer(3 * 4 * vertexCount);
for (int i = 0; i < vertexCount; i++) {
////////////////////////////
//Math.cos(xyz[i].x);
vertexBuffer.put(particule[i].x - particule[i].taille);
vertexBuffer.put(particule[i].y - particule[i].taille);
vertexBuffer.put(particule[i].z);
////////////////////////////
vertexBuffer.put(particule[i].x + particule[i].taille);
vertexBuffer.put(particule[i].y - particule[i].taille);
vertexBuffer.put(particule[i].z);
////////////////////////////
vertexBuffer.put(particule[i].x + particule[i].taille);
vertexBuffer.put(particule[i].y + particule[i].taille);
vertexBuffer.put(particule[i].z);
////////////////////////////
vertexBuffer.put(particule[i].x - particule[i].taille);
vertexBuffer.put(particule[i].y + particule[i].taille);
vertexBuffer.put(particule[i].z);
}
vertexBuffer.flip();
////////////////////////////////////////////
if (VBOVertices == null) {
VBOVertices = new int[1];
gl.glGenBuffersARB(1, VBOVertices, 0);
}
gl.glBindBufferARB(GL.GL_ARRAY_BUFFER, VBOVertices[0]);
gl.glBufferDataARB(GL.GL_ARRAY_BUFFER, vertexCount * 3 * 4 * BufferUtil.SIZEOF_FLOAT, vertexBuffer, GL.GL_STREAM_DRAW);
/////
}
public void texturePipe(GL gl) {
FloatBuffer textureBuffer = BufferUtil.newFloatBuffer(4 * 2 * vertexCount);
for (int i = 0; i < vertexCount; i++) {
textureBuffer.put(0.2f);
textureBuffer.put(0.2f);
textureBuffer.put(0.8f);
textureBuffer.put(0.2f);
textureBuffer.put(0.8f);
textureBuffer.put(0.8f);
textureBuffer.put(0.2f);
textureBuffer.put(0.8f);
}
//////////////////////////////
textureBuffer.flip();
//////////////////////////////
if (VBOTexture == null) {
VBOTexture = new int[1];
gl.glGenBuffersARB(1, VBOTexture, 0);
}
gl.glBindBufferARB(GL.GL_ARRAY_BUFFER, VBOTexture[0]);
gl.glBufferDataARB(GL.GL_ARRAY_BUFFER, vertexCount * 2 * 4 * BufferUtil.SIZEOF_FLOAT, textureBuffer, GL.GL_STATIC_DRAW);
//////
}
public void indexPipe(GL gl) {
indiceBuffer = BufferUtil.newIntBuffer(4 * vertexCount);
int count = 0;
for (int i = 0; i < vertexCount; i++) {
indiceBuffer.put(count++);
indiceBuffer.put(count++);
indiceBuffer.put(count++);
indiceBuffer.put(count++);
}
indiceBuffer.flip();
///////////////////////////////////
if (VBOIndice == null) {
VBOIndice = new int[1];
gl.glGenBuffersARB(1, VBOIndice, 0);
}
gl.glBindBufferARB(GL.GL_ARRAY_BUFFER, VBOIndice[0]);
gl.glBufferDataARB(GL.GL_ARRAY_BUFFER, vertexCount * 4 * BufferUtil.SIZEOF_INT, indiceBuffer, GL.GL_STATIC_DRAW);
}
public void colorPipe(GL gl) {
colorBuffer = BufferUtil.newFloatBuffer(4 * 4 * vertexCount);
for (int i = 0; i < vertexCount; i++) {
for (int n = 0; n < 4; n++) {
colorBuffer.put(particule[i].getA());
colorBuffer.put(particule[i].getA());
colorBuffer.put(particule[i].getA());
colorBuffer.put(particule[i].getA());
}
}
colorBuffer.flip();
///////////////////////////////////
if (VBOColor == null) {
VBOColor = new int[1];
gl.glGenBuffersARB(1, VBOColor, 0);
}
gl.glBindBufferARB(GL.GL_ARRAY_BUFFER, VBOColor[0]);
gl.glBufferDataARB(GL.GL_ARRAY_BUFFER, vertexCount * 4 * 4 * BufferUtil.SIZEOF_FLOAT, colorBuffer, GL.GL_STREAM_DRAW);
}
public void loadTexture() {
try {
ClassLoader c1 = this.getClass().getClassLoader();
URL url = c1.getResource(path);
texture = TextureIO.newTexture(url, true, null);
System.out.println(”Texture as been loaded : ” + url.getPath());
} catch (IOException e) {
e.printStackTrace();
} catch (GLException e) {
e.printStackTrace();
}
}
// gl.glGenTextures(1, textureId, 0);
// gl.glBindTexture(GL.GL_TEXTURE_2D, textureId[0]);
// gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR);
///gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR);
//gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, 4, texture.getImageWidth(), texture.getImageHeight(), 0, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, texture.);
}
4 octobre 2008 à 9:04
Voilou la class principal du fog…
4 octobre 2008 à 15:07
wow.
that’s very kind of you… but why not publish the entire file?
:-P
Do you have any references otherwise (books, sites, …) ?
REALLY MANY THANKS!!!
5 octobre 2008 à 8:35
I had publish a post about Opengl Superbible…
And the Nehe tuttorial are great…
Have fun….!