Opengl stripped surface when viewed under angle -


i have problem stripped surface in program.

i render surfaces using opengl(tao). use triangle_strip. have 3d impression use lighting. normals set correctly thing.

at first used crossproduct, use derivation of implicit function. both methods seem give right results, derivation may better because of precision. see on surface vertical stripes. 2 neighbor triangles in strip have different hue/shade. 1,3,5,7 ... , 2,4,6... have same hue/shade. smaller viewing angle bigger difference is. @ 90° it's ok.

how can rid of stripes?

here can see images: enter image description here enter image description here enter image description here enter image description here enter image description here enter image description here

initialization:

private float[] materialambient = { 1.0f, 1.0f, 1.0f, 1.0f }; private float[] materialdifuse = { 0.6f, 0.6f, 0.6f, 1.0f }; private float[] materialodlesky = { 0.2f, 0.2f, 0.2f, 1.0f }; private float[] materialshininess = { 50.0f }; private float[] light_position = { 0.0f, 0.0f, 1.0f, 1.0f}; private float[] light_color = { 0.7f, 0.7f, 0.7f }  gl.glshademodel(gl.gl_smooth); gl.glenable(gl.gl_depth_test); gl.glhint(gl.gl_line_smooth_hint, gl.gl_nicest); gl.gldepthfunc(gl.gl_less); gl.glenable(gl.gl_color_material);  gl.glmaterialfv(gl.gl_front_and_back, gl.gl_ambient, materialambient); gl.glmaterialfv(gl.gl_front_and_back, gl.gl_diffuse, materialdifuse);   gl.glmaterialfv(gl.gl_front_and_back, gl.gl_specular, materialodlesky);  gl.glmaterialfv(gl.gl_front_and_back, gl.gl_shininess, materialshininess); gl.gllightfv(gl.gl_light0, gl.gl_position, light_position); gl.gllightfv(gl.gl_light0, gl.gl_diffuse, light_color);  gl.gllightmodeli(gl.gl_light_model_two_side, gl.gl_true);   gl.glenable(gl.gl_lighting); gl.glenable(gl.gl_light0); 

drawing code:

double foo = 15;         (double v = -foo; v < foo; v += vstep)         {             if (v > foo - vstep)                 v = foo - vstep;             gl.glbegin(gl.gl_triangle_strip);             gl.glcolor3dv(_color);             (double u = -foo; u < foo + ustep; u += ustep)             {                 if (u > foo)                     u = foo;                 setvextexandhisnormal(u, v);                 setvextexandhisnormal(u, v + vstep);                 if (u == foo)                     break;             }             gl.glend();             if (v == foo - vstep)                 break;         }    public void setvextexandhisnormal(double u, double v)     {         vector v1 = computecoordinatesat(u, v);         double x = (-2 / (_a + _a)) * v1.getx();         double y = (2 / (_b + _b)) * v1.gety();         double z = -2*_k;         vector normal = new vector(x, y, z);         normal.nornvector();          gl.glnormal3d(_normalsign * normal.getx(), _normalsign * normal.gety(), _normalsign * normal.getz());         gl.glvertex3d(v1.getx(), v1.gety(), v1.getz());     } 


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -