Java openGL - drawing a 3D object -



Java openGL - drawing a 3D object -

im looking draw 3d object in opengl whats best way approach this? thinking of drawing side profile of in 2d , maybe fleshing out become 3d possible? think easier way go straight 3d if cant id wasting time.

i cant figure out how add together sky , maybe sea reflection, done?

gl.glclear(gl.gl_color_buffer_bit); gl.glcolor3f(1.0f, 1.0f, 1.0f); gl.glpushmatrix(); gl.gltranslatef(-1.0f, 0.0f, 0.0f); gl.glrotatef((float) shoulder, 0.0f, 0.0f, 1.0f); gl.gltranslatef(1.0f, 0.0f, 0.0f); // gl.glpushmatrix(); gl.glscalef(2.0f, 0.4f, 1.0f); glut.glutwirecube(1.0f); // gl.glpopmatrix(); gl.gltranslatef(1.0f, 0.0f, 0.0f); gl.glrotatef((float) elbow, 0.0f, 0.0f, 1.0f); gl.gltranslatef(1.0f, 0.0f, 0.0f); // gl.glpushmatrix(); gl.glscalef(2.0f, 0.4f, 1.0f); glut.glutwirecube(1.0f); // gl.glpopmatrix(); gl.gltranslatef(1.0f, 1.0f, 1.0f); gl.glrotatef((float) hand, 0.0f, 0.0f, 1.0f); gl.gltranslatef(1.0f, 0.0f, 0.0f); // gl.glpushmatrix(); gl.glscalef(2.0f, 0.4f, 1.0f); glut.glutwirecube(1.0f); // gl.glpopmatrix();

ive been trying random numbers seek , work not such luck far!

ok first, reflections can hard depending on how want them. need larn more opengl before attempting that. second, 3d objects require more matrix stuff, illustration init method in 3d game:

private void initgl() { glviewport(0, 0, display.getwidth(), display.getheight()); glmatrixmode(gl_projection); glloadidentity(); glu.gluperspective(45.0f, display.getwidth() / display.getheight(), 1.0f, 100.0f); glmatrixmode(gl_modelview); glloadidentity(); glclearcolor(0.0f, 0.0f, 0.0f, 0.0f); glcleardepth(1.0f); gldepthfunc(gl_lequal); glenable(gl_depth_test); glshademodel(gl_smooth); glhint(gl_perspective_correction_hint, gl_nicest); glenable(gl_fog); glfogi(gl_fog_mode, gl_exp2); glfogf(gl_fog_density, density); glhint(gl_fog_density, gl_fastest); glenable(gl_cull_face); glcullface(gl_back); }

you need clear buffer before drawing:

glclear(gl_color_buffer_bit | gl_depth_buffer_bit);

you right when flesh out 2d object. if still using immediate mode (glbegin()/glend()), approach correct. however, immediate mode deprecated , utilize vbos. suggest going on youtube , searching thecodinguniverse if using lwjgl, has video on vbos , advanced rendering, how learned them!

good luck in world of 3d, not easy @ all, (in opinion), much more satisfying 2d when working.

also, consider investing in redbook, lwjgl.

java opengl

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -