+
+#ifdef OPENGL_MORE_EFFECT
+/*****************************************************************************
+ * Transform: Calculate the distorted grid coordinates
+ *****************************************************************************/
+static void Transform( int distortion, float width, float height,int i, int j, int i_visible_width, int i_visible_height, double *ix, double *iy )
+{
+ double x,y,xnew,ynew;
+ double r,theta,rnew,thetanew;
+
+ x = (double)i * (width / ((double)i_visible_width));
+ y = (double)j * (height / ((double)i_visible_height));
+
+ x = (2.0 * (double)x / width) - 1;
+ y = (2.0 * (double)y / height) - 1;
+ xnew = x;
+ ynew = y;
+ r = sqrt(x*x+y*y);
+ theta = atan2(y,x);
+
+ switch (distortion)
+ {
+/* GRID2D TRANSFORMATION */
+ case SINEXY:
+ xnew = sin(PID2*x);
+ ynew = sin(PID2*y);
+ break;
+ case SINER:
+ rnew = sin(PID2*r);
+ thetanew = theta;
+ xnew = rnew * cos(thetanew);
+ ynew = rnew * sin(thetanew);
+ break;
+ case SQUAREXY:
+ xnew = x*x*SIGN(x);
+ ynew = y*y*SIGN(y);
+ break;
+ case SQUARER:
+ rnew = r*r;
+ thetanew = theta;
+ xnew = rnew * cos(thetanew);
+ ynew = rnew * sin(thetanew);
+ break;
+ case ASINXY:
+ xnew = asin(x) / PID2;
+ ynew = asin(y) / PID2;
+ break;
+ case ASINR:
+ rnew = asin(r) / PID2;
+ thetanew = theta;
+ xnew = rnew * cos(thetanew);
+ ynew = rnew * sin(thetanew);
+ break;
+/* OTHER WAY: 3D MODEL */
+ default:
+ xnew = x;
+ ynew = y;
+ }
+
+ *ix = width * (xnew + 1) / (2.0);
+ *iy = height * (ynew + 1) / (2.0);
+}
+
+/*****************************************************************************
+ * Z_Compute: Calculate the Z-coordinate
+ *****************************************************************************/
+static float Z_Compute(float p, int distortion, float x, float y)
+{
+ float f_z = 0.0;
+ double d_p = p / 100.0;
+
+ switch (distortion)
+ {
+/* 3D MODEL */
+ case CYLINDER:
+ if (d_p > 0)
+ f_z = (1 - d_p * d_p) / (2 * d_p) - sqrt(fabs((d_p * d_p + 1) / (2 * d_p) * (d_p * d_p + 1) / (2 * d_p) - x * x));
+ else
+ f_z = (1 - d_p * d_p) / (2 * d_p) + d_p + sqrt(fabs((d_p * d_p + 1) / (2 * d_p) * (d_p * d_p + 1) / (2 * d_p) - x * x));
+ break;
+ case TORUS:
+ if (d_p > 0)
+ f_z = (1 - d_p * d_p) / (d_p) - sqrt(fabs((d_p * d_p + 1) / (2 * d_p) * (d_p * d_p + 1) / (2 * d_p) - x * x)) - sqrt(fabs((d_p * d_p + 1) / (2 * d_p) * (d_p * d_p + 1) / (2 * d_p) - y * y));
+ else
+ f_z = (1 - d_p * d_p) / (d_p) + 2 * d_p + sqrt(fabs((d_p * d_p + 1) / (2 * d_p) * (d_p * d_p + 1) / (2 * d_p) - x * x)) + sqrt(fabs((d_p * d_p + 1) / (2 * d_p) * (d_p * d_p + 1) / (2 * d_p) - y * y));
+ break;
+ case SPHERE:
+ if (d_p > 0)
+ f_z = (1 - d_p * d_p) / (2 * d_p) - sqrt(fabs((d_p * d_p + 1) / (2 * d_p) * (d_p * d_p + 1) / (2 * d_p) - x * x - y * y));
+ else
+ f_z = (1 - d_p * d_p) / (2 * d_p) + d_p + sqrt(fabs((d_p * d_p + 1) / (2 * d_p) * (d_p * d_p + 1) / (2 * d_p) - x * x - y * y));
+ break;
+/* OTHER WAY: GRID2D TRANSFORMATION */
+ case SINEXY:;
+ case SINER:
+ case SQUAREXY:
+ case SQUARER:;
+ case ASINXY:
+ case ASINR:
+ f_z = 0.0;
+ break;
+ default:
+ f_z = 0.0;
+ }
+ return f_z;
+}
+#endif
+
+