Sunday, January 15, 2017

Points in 3D with gaussian Distribution

Snapshot:


In JOGL this is so easy that I was amazed. Im Trying to generate blobby objects. In the hearn and baker text book its mentioned that points in a gaussian distribution with a surface where the density of the points falls below a threshold is rendered. Will keep updated everyone if this does result in a blobby object.
This piece of code does the magic:

                GL2 gl = arg0.getGL().getGL2();
for(int i=0;i<MAX_RAND;i++)
{
x[i]=1-randomno.nextGaussian()*2;
y[i]=1-randomno.nextGaussian()*2;
z[i]=1-randomno.nextGaussian()*2;
}
gl.glBegin(GL2.GL_POINTS);
for(int i=0;i<MAX_RAND;i++)
{

gl.glVertex3d(x[i],y[i],z[i]);

}
gl.glEnd();

Thanks!

No comments:

Post a Comment