iphone - How to use coordinates in glClipPlanef? -


I want to clip some closed path area from the texture image in OpenGL ES and iPhone SDK.

I have found that this can be done with planes and glClipPlanef:

  glClipPlanef (GL_CLIP_PLANE0, v); GlEnable (GL_CLIP_PLANE0); GlDrawArrays (GL_TRIANGLE_STRIP, 0, 4); GlDisable (GL_CLIP_PLANE0);  

Where there is a const GL float array of v coordinate

I do not understand how to set these cores to clip off the area of ​​closing? How do I use glClipPlanef:

  const GLfloat v [/ p>  

] = {A, B, C, -D}; // Force the plane to click glClipPlanef (GL_CLIP_PLANE0, v); // Enable this glEnable (GL_CLIP_PLANE0); // Some Draw arguments glDrawArrays (GL_TRIANGLE_STRIP, 0, 4); // clip area glDisable (GL_CLIP_PLANE0);

Where the parameters of A, B, C, D -

If we have three points with chorodes (x1, y1, z1), (x 2, y2, j2), (x3, y3, z3), then

  a = y1 * (z2 - z3) + y2 (z3 - z1) + y3 (Z1 - z2) b = z1 * (x2 - x3) + z2 (x3 - x1) + z3 (x1 - x2) c = x1 * (y2 - y3) + x2 (y3 - y1) + x3 (y1 - y2 ) - D = x1 * (y2 * z3 - y3 * z2) + x2 * (y3 * z1 - y1 * z3) + x3 * (y1 * z2) If you have 2D texture then you need to define digits Will be: (x1, y1, 0), (x2, y2, 0 and (x3, y3)  

, 1). it will work.

Hope this will help anyone in the future.


Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -