matrix operations in java

Started by deepthought, July 27, 2011, 19:45:10

Previous topic - Next topic

deepthought

since we're now supposed to come up with our own modelview and projection matrices, does anybody have a java implementation of ortho(), perspective(), glulookat(), and possibly a camera class that generates the matrices?

CodeBunny

Um... why don't you use the glOrth(), gluLookAt(), etc. methods already in LWJGL? They work...

Also, if my understanding of what you're attempting to do instead is correct (create a matrix and send it over to the GPU once it has been constructed), I don't really see how that would be faster - especially because you have to send an entire matrix down the graphics pipeline every time you want to make a change.

jediTofu

Is this like for a homework assignment?  Mesa3d is an open source implementation of the OpenGL specification (I believe ???), so you could download the source code and look at the math there (for the specific methods) and do a good old copy&paste.  Then manipulate it to your liking.  It's probably in C, which shouldn't be hard to translate to Java.

Otherwise...do a google search?
cool story, bro

deepthought

in the current version of opengl, these functions are deprecated, and in opengl ES, totally absent. we are now supposed to come up with it ourselves and load it as a uniform into a shader.

Grabix

ortho(), perspective(), glulookat()

Every of such transforamtion are basen on multiplication of vector [x y z 1] by same matrix, this matrix are also a multiplication of same basic matrixes; each of such methode produce one of them and this is described in documentation of OpenGL:

for reference:
http://www.opengl.org/sdk/docs/man/xhtml/glTranslate.xml
http://www.opengl.org/sdk/docs/man/xhtml/glRotate.xml
http://www.opengl.org/sdk/docs/man/xhtml/glScale.xml

about your question:
http://www.opengl.org/sdk/docs/man/xhtml/glOrtho.xml
http://www.opengl.org/sdk/docs/man/xhtml/gluPerspective.xml

I think this is more complicated (not sure, I don't want to read :P)
http://www.opengl.org/sdk/docs/man/xhtml/gluLookAt.xml