Use world camera matrix in GL11 to render points

Started by kakashi, June 05, 2009, 01:14:10 AM

Previous topic - Next topic

kakashi

Hi,

I want to know how to use the world camera and projection matrix with the glBegin, glVertex3f, glEnd functions to render a list of points with GL_POINTS, but I want to use the same camera and projection of the world object.
Any idea of how to do this?

Thanks a lot for any help  :)

EgonOlsen

#1
There should be no need to setup a projection matrix. jPCT will do this for you. For the rest, something like this may work (not tested):


FloatBuffer floatBuffer64 = ByteBuffer.allocateDirect(64).order(ByteOrder.nativeOrder()).asFloatBuffer();
Matrix mat = new Matrix();
Matrix m3 = new Matrix();

GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glPushMatrix();

SimpleVector poss = cam.getPosition();
m3.mat[3][0] = -poss.x;
m3.mat[3][1] = -poss.y;
m3.mat[3][2] = -poss.z;

Matrix mo=obj.getWorldTransformation(); // or new Matrix() if no Object3D involved...or whatever...

mat.setTo(cam.getBack());
mat.rotateX((float) Math.PI); // Transform into GL

mo.matMul(m3);
mo.matMul(mat);
dump=mo.getDump();

floatBuffer64.put(dump);
floatBuffer64.rewind();

GL11.glLoadMatrix(floatBuffer64);

// Render your stuff here...

GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glPopMatrix();


Edit: Keep in mind that, when using a threaded renderer (like the AWTGLRenderer), this has to happen in IPaintListener's finishedPainting()-method or otherwise, the application will crash.

kakashi