c++ - OpenGL Sphere deforms when setting center coordinate to high values -
so drawing sphere not using "subdividing icosahedron" approach using triangle strips , parameteric equation of sphere.
here code
glbegin(gl_triangle_srip); for(float = -pi/2; < pi/2; i+= 0.01f) { temp = i+0.01f; for(float j = 0; j < 2*pi; j+=0.01f) { temp -= 0.01f; glvertex3f( cx + rad * cos(j) * cos(temp), cy + rad * cos(temp) * sin(j), cz + rad * sin(temp)); temp += 0.01f; glvertex3f( cx + rad * cos(j) * cos(temp), cy + rad * cos(temp) * sin(j), cz + rad * sin(temp)); } } glend();
the approach followes. imagine circle in xy plane. drawn using inner loop. imagine xy plane moved above or below in z-axis , radius changed cause it's sphere. done using outer loop. first triangle coordinate given circle when xy plane @ initial position. after temp+=0.01f
plane moved 0.01 , second triangle vertex coordinate given. how strip calculated.
the problem if cx = cy = cz = 0
or low value 2 or 3 sphere seems fine. if put e.g cx = 15, cy = 15, cz = -6
sphere gets deformed. here pic.
if use gl_points
im getting
sorry stupid mistake, wasn't converting values put in glfrustum
correctly hence weird fov being generated. solved issue now. thanks
Comments
Post a Comment