Esempio n. 1
0
        public static warp_Matrix rotateMatrix(float dx, float dy, float dz)
        {
            warp_Matrix res = new warp_Matrix();

            float SIN;
            float COS;

            if (dx != 0)
            {
                warp_Matrix m = new warp_Matrix();
                SIN   = warp_Math.sin(dx);
                COS   = warp_Math.cos(dx);
                m.m11 = COS;
                m.m12 = SIN;
                m.m21 = -SIN;
                m.m22 = COS;

                res.transform(m);
            }
            if (dy != 0)
            {
                warp_Matrix m = new warp_Matrix();
                SIN   = warp_Math.sin(dy);
                COS   = warp_Math.cos(dy);
                m.m00 = COS;
                m.m02 = SIN;
                m.m20 = -SIN;
                m.m22 = COS;

                res.transform(m);
            }
            if (dz != 0)
            {
                warp_Matrix m = new warp_Matrix();
                SIN   = warp_Math.sin(dz);
                COS   = warp_Math.cos(dz);
                m.m00 = COS;
                m.m01 = SIN;
                m.m10 = -SIN;
                m.m11 = COS;

                res.transform(m);
            }

            return(res);
        }
Esempio n. 2
0
        public float EstimateBoxProjectedArea(warp_Vector pos, warp_Vector size, warp_Matrix rotation)
        {
            warp_Matrix om = new warp_Matrix();

            om.scale(size.x, size.y, size.z);
            om.transform(rotation);

            float xmax;
            float ymax;

            /*
             * if (defaultCamera.isOrthographic)
             * {
             *  xmax = Math.Abs(om.m00);
             *  ymax = Math.Abs(om.m22);
             *  if (xmax < 1f || ymax < 1f)
             *      return -1;
             *  return xmax * ymax / (width * height);
             * }
             */
            om.m03 = pos.x;
            om.m13 = pos.y;
            om.m23 = pos.z;
            warp_Vector side;
            warp_Vector v;
            float       xmin;
            float       ymin;

            warp_Matrix m = warp_Matrix.multiply(defaultCamera.getMatrix(), matrix);

            om.transform(m);

            float zmin;

            side = new warp_Vector(-1f, -1f, -1f);
            v    = side.transform(om);
            xmin = v.x;
            xmax = xmin;
            ymin = v.y;
            ymax = ymin;
            zmin = v.z;

            side.x = 1f;
            v      = side.transform(om);
            if (xmin > v.x)
            {
                xmin = v.x;
            }
            else if (xmax < v.x)
            {
                xmax = v.x;
            }
            if (ymin > v.y)
            {
                ymin = v.y;
            }
            else if (ymax < v.y)
            {
                ymax = v.y;
            }
            if (zmin > v.z)
            {
                zmin = v.z;
            }

            side.x = -1f;
            side.y = 1f;
            v      = side.transform(om);
            if (xmin > v.x)
            {
                xmin = v.x;
            }
            else if (xmax < v.x)
            {
                xmax = v.x;
            }
            if (ymin > v.y)
            {
                ymin = v.y;
            }
            else if (ymax < v.y)
            {
                ymax = v.y;
            }
            if (zmin > v.z)
            {
                zmin = v.z;
            }

            side.x = 1f;
            v      = side.transform(om);
            if (xmin > v.x)
            {
                xmin = v.x;
            }
            else if (xmax < v.x)
            {
                xmax = v.x;
            }
            if (ymin > v.y)
            {
                ymin = v.y;
            }
            else if (ymax < v.y)
            {
                ymax = v.y;
            }
            if (zmin > v.z)
            {
                zmin = v.z;
            }

            side.x = -1f;
            side.y = -1f;
            side.z = 1f;
            v      = side.transform(om);
            if (xmin > v.x)
            {
                xmin = v.x;
            }
            else if (xmax < v.x)
            {
                xmax = v.x;
            }
            if (ymin > v.y)
            {
                ymin = v.y;
            }
            else if (ymax < v.y)
            {
                ymax = v.y;
            }
            if (zmin > v.z)
            {
                zmin = v.z;
            }

            side.x = 1f;
            v      = side.transform(om);
            if (xmin > v.x)
            {
                xmin = v.x;
            }
            else if (xmax < v.x)
            {
                xmax = v.x;
            }
            if (ymin > v.y)
            {
                ymin = v.y;
            }
            else if (ymax < v.y)
            {
                ymax = v.y;
            }
            if (zmin > v.z)
            {
                zmin = v.z;
            }

            side.x = -1f;
            side.y = 1f;
            v      = side.transform(om);
            if (xmin > v.x)
            {
                xmin = v.x;
            }
            else if (xmax < v.x)
            {
                xmax = v.x;
            }
            if (ymin > v.y)
            {
                ymin = v.y;
            }
            else if (ymax < v.y)
            {
                ymax = v.y;
            }
            if (zmin > v.z)
            {
                zmin = v.z;
            }

            side.x = 1f;
            v      = side.transform(om);
            if (xmin > v.x)
            {
                xmin = v.x;
            }
            else if (xmax < v.x)
            {
                xmax = v.x;
            }
            if (ymin > v.y)
            {
                ymin = v.y;
            }
            else if (ymax < v.y)
            {
                ymax = v.y;
            }
            if (zmin > v.z)
            {
                zmin = v.z;
            }


            xmax -= xmin;
            ymax -= ymin;

            if (xmax < 1f || ymax < 1f)
            {
                return(-1);
            }
            return(xmax * ymax / (width * height));
        }
Esempio n. 3
0
 public void transform(warp_Matrix m)
 {
     matrix.transform(m);
     normalmatrix.transform(m);
 }
Esempio n. 4
0
 public void project(warp_Matrix m)
 {
     matrix2 = m.getClone();
     matrix2.transform(m);
     v2 = v.transform(matrix2);
 }