This post was updated on .
I didn't have a chance to look all over through the JOGL docs, i'm mostly coding at the help of samples.
the initi() setup is like below, my 3D obj have a very strong deformation while rotating. it looks like the deformation is because "bigger nearer and smaller faraway", i tried a few combinaions of "DEPTH" (i have no idea what's depth func, just trying -_-!!) but does have no luck. what do i miss? UPDATE: my code is modified from this:https://github.com/ILDAR1976/JoglObjLoader-master, i replaced the original obj with mine, the obj still deformed, but i didn't look that much with the "plane obj". i have an exe ObjViewer, and that does not deform at all. And another question, how do i make the light just shine like sun, no shader, do not change reflections while rotating? GL2 gl = drawable.getGL().getGL2(); gl.glEnable(GL2.GL_DEPTH_TEST); gl.glShadeModel(GL2.GL_SMOOTH); gl.glBlendFunc(GL2.GL_SRC_ALPHA, GL2.GL_ONE_MINUS_SRC_ALPHA); gl.glEnable(GL2.GL_BLEND); gl.glHint(GL2.GL_LINE_SMOOTH_HINT, GL2.GL_NICEST); gl.glEnable(GL2.GL_LINE_SMOOTH); gl.glEnable(GL2.GL_SMOOTH); gl.glEnable(GL2.GL_POINT_SMOOTH); gl.glEnable(GL2.GL_LINE_SMOOTH); gl.glEnable(GL2.GL_POLYGON_SMOOTH); gl.glHint(GL2.GL_PERSPECTIVE_CORRECTION_HINT, GL2.GL_NICEST); gl.glEnable(GL2.GL_CULL_FACE); gl.glEnable(GL2.GL_NORMALIZE); gl.glMatrixMode(GL2.GL_PROJECTION); gl.glLoadIdentity(); gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glLoadIdentity(); gl.glEnable(GL2.GL_LIGHTING); gl.glEnable(GL2.GL_LIGHT0); gl.glEnable(GL2.GL_LIGHT1); gl.glShadeModel(GL2.GL_SMOOTH); |
Administrator
|
Hi
You don't understand what you do, you should learn the basics of OpenGL before coding. gluPerspective and glFrustum must be called when the matrix mode is GL_PROJECTION, gluLookAt can be called when the matrix mode is GL_MODELVIEW. Your source code is correct in your reshape method but not in your init method. Moreover, don't call new GLU(), rather call GLU.createGLU(GL). By the way, there are 2 WaveFront OBJ importers in JogAmp (one in JOGL and another one in JOGL-Utils) and there are a WaveFront OBJ importer and a WaveFront OBJ exporter in JogAmp's Ardor3D Continuation, the last importer I mention is probably the most robust you can find in Java. You should look at TextureIO and use a try with resource when opening streams.
Julien Gouesse | Personal blog | Website
|
still have a long way to go~~, i have nearly zero basic skills about 3D and so as in JOGL. i don't think i'd turn to other APIs right now, it would only just take me much more time, any of these should be adequate except me myself.
what's better by using GLU.createGLU(GL)? |
Administrator
|
This post was updated on .
When you create a GLU instance directly, you benefit only of a subset of features supported by all other GLU implementations. When you call GLU.createGLU(GL), it chooses the most appropriate GLU implementation for you which supports much more features, there are less cases in which you may receive an UnsupportedOperationException.
I don't advise you to use another API but their source code can be a good source of inspiration and the WaveFront OBJ importer you use is very incomplete in comparison with the ones I mentioned in my previous post. You can't learn the concepts of 3D computer graphics only by reading some source code. I advise you to look at the OpenGL red book and its examples were ported to JOGL several years ago: https://github.com/gouessej/jogl-demos/tree/master/src/redbook/src
Julien Gouesse | Personal blog | Website
|
below comments come from chapter 3 of the RED book, it surely answered my question. So i guess my problem is quite normal or reasonable... The other type of projection is orthographic, which maps objects directly onto the screen without affecting their relative size. Orthographic projection is used in architectural and computer-aided design applications where the final image needs to reflect the measurements of objects rather than how they might look. Architects create perspective drawings to show how particular buildings or interior spaces look when viewed from various vantage points; the need for orthographic projection arises when blueprint plans or elevations are generated, which are used in the construction of buildings. (See "Projection Transformations" for a discussion of ways to specify both kinds of projection transformations.) |
Free forum by Nabble | Edit this page |