Exemplo n.º 1
0
        public void rot(int amount)
        {
            addnewrow();
            translatebackrow();
            rotatecounter = 0;


            rowmovement           += amount;
            rowmovementcheckspike += amount;
            bow.Play();
            Movingcube.cam = cam;
            Movingcube.LoadFromFile("Cube2.txt");
            Transformation_API.Scale(ref Movingcube.L_3D_Pts, 0.2f, 0.2f, 0.2f);
            _3D_Model tempground2 = (_3D_Model)Ground[rowmovement];

            for (int i = 0; i < Movingcube.L_3D_Pts.Count; i++)
            {
                CPoint3D_Node temp        = (CPoint3D_Node)Movingcube.L_3D_Pts[i];
                CPoint3D_Node tempground3 = (CPoint3D_Node)tempground2.L_3D_Pts[i];
                temp.X = tempground3.X;
                temp.Z = tempground3.Z;
            }
            Transformation_API.TranslateY(ref Movingcube.L_3D_Pts, -70);

            Movingcube.clr = Color.Blue;
            whichground    = false;
        }
Exemplo n.º 2
0
        public static void Scale(ref ArrayList L_Model, float sx, float sy, float sz)
        {
            ArrayList L_new = new ArrayList();

            for (int i = 0; i < L_Model.Count; i++)
            {
                CPoint3D_Node v = (CPoint3D_Node)L_Model[i];

                float x = v.X;
                float y = v.Y;
                float z = v.Z;

                float x_ = x * sx;
                float y_ = y * sy;
                float z_ = z * sz;

                v.X = x_;
                v.Y = y_;
                v.Z = z_;
                L_new.Add(v);
            }

            L_Model.Clear();
            L_Model = L_new;
        }
Exemplo n.º 3
0
        public static void RotatZ(ref ArrayList L_Model, float theta)
        {
            ArrayList L_new = new ArrayList();

            float th = (float)(Math.PI * theta / 180);

            for (int i = 0; i < L_Model.Count; i++)
            {
                CPoint3D_Node v = (CPoint3D_Node)L_Model[i];

                float x = v.X;
                float y = v.Y;
                float z = v.Z;

                float x_ = (float)(x * Math.Cos(th) - y * Math.Sin(th));
                float y_ = (float)(x * Math.Sin(th) + y * Math.Cos(th));
                float z_ = z;

                v.X = x_;
                v.Y = y_;
                v.Z = z_;
                L_new.Add(v);
            }

            L_Model.Clear();
            L_Model = L_new;
        }
Exemplo n.º 4
0
        public void Rotat_Aroun_Edge(int iEdge, int checkside, int amount)
        {
            if (iEdge < 0 || iEdge >= L_Edges.Count)
            {
                return;
            }

            Edge          e        = (Edge)L_Edges[iEdge];
            CPoint3D_Node pointer  = (CPoint3D_Node )L_3D_Pts[e.E0];
            CPoint3D_Node pointer2 = (CPoint3D_Node)L_3D_Pts[e.E1];

            CPoint3D_Node v1 = new CPoint3D_Node(pointer.X, pointer.Y, pointer.Z);
            CPoint3D_Node v2 = new CPoint3D_Node(pointer2.X, pointer2.Y, pointer2.Z);

            if (checkside == 0)
            {
                Transformation_API.RotateArbitrary(
                    ref L_3D_Pts,
                    v1,                         //(CPoint3D_Node)L_3D_Pts[0],
                    v2,                         //(CPoint3D_Node)L_3D_Pts[1],
                    amount);
            }
            else if (checkside == 1)
            {
                Transformation_API.RotateArbitrary(
                    ref L_3D_Pts,
                    v1,                         //(CPoint3D_Node)L_3D_Pts[0],
                    v2,                         //(CPoint3D_Node)L_3D_Pts[1],
                    -amount);
            }
        }
Exemplo n.º 5
0
        public static void RotateArbitrary(ref ArrayList L_Model,
                                           CPoint3D_Node v1,
                                           CPoint3D_Node v2,
                                           int ang)
        {
            Transformation_API.TranslateX(ref L_Model, v1.X * -1);
            Transformation_API.TranslateY(ref L_Model, v1.Y * -1);
            Transformation_API.TranslateZ(ref L_Model, v1.Z * -1);

            float dx = v2.X - v1.X;
            float dy = v2.Y - v1.Y;
            float dz = v2.Z - v1.Z;

            float theta = (float)Math.Atan2(dy, dx);
            float phi   = (float)Math.Atan2(Math.Sqrt(dx * dx + dy * dy), dz);

            theta = (float)(theta * 180 / Math.PI);
            phi   = (float)(phi * 180 / Math.PI);
            Transformation_API.RotatZ(ref L_Model, theta * -1);
            Transformation_API.RotatY(ref L_Model, phi * -1);

            Transformation_API.RotatZ(ref L_Model, ang);

            Transformation_API.RotatY(ref L_Model, phi * 1);
            Transformation_API.RotatZ(ref L_Model, theta * 1);
            Transformation_API.TranslateZ(ref L_Model, v1.Z * 1);
            Transformation_API.TranslateY(ref L_Model, v1.Y * 1);
            Transformation_API.TranslateX(ref L_Model, v1.X * 1);
        }
Exemplo n.º 6
0
 public Camera()
 {
     cop    = new CPoint3D_Node(0, 0, -350); // new Point3D(0, -50, 0);
     lookAt = new CPoint3D_Node(0, 0, 50);   //new Point3D(0, 50, 0);
     up     = new CPoint3D_Node(0, 1, 0);
     front  = 10;                            // 70.0;
     back   = 300.0;
 }
Exemplo n.º 7
0
        static public void Normalise(CPoint3D_Node v)
        {
            float length;

            length = (float)Math.Sqrt(v.X * v.X + v.Y * v.Y + v.Z * v.Z);
            v.X   /= length;
            v.Y   /= length;
            v.Z   /= length;
        }
Exemplo n.º 8
0
        static public CPoint3D_Node CrossProduct(CPoint3D_Node p1, CPoint3D_Node p2)
        {
            CPoint3D_Node p3;

            p3   = new CPoint3D_Node(0, 0, 0);
            p3.X = p1.Y * p2.Z - p1.Z * p2.Y;
            p3.Y = p1.Z * p2.X - p1.X * p2.Z;
            p3.Z = p1.X * p2.Y - p1.Y * p2.X;
            return(p3);
        }
Exemplo n.º 9
0
        public void TransformToOrigin_And_Rotate(CPoint3D_Node a, CPoint3D_Node e)
        {
            CPoint3D_Node w = new CPoint3D_Node(a.X, a.Y, a.Z);

            w.X -= cop.X;
            w.Y -= cop.Y;
            w.Z -= cop.Z;

            e.X = w.X * basisa.X + w.Y * basisa.Y + w.Z * basisa.Z;
            e.Y = w.X * basisc.X + w.Y * basisc.Y + w.Z * basisc.Z;
            e.Z = w.X * lookDir.X + w.Y * lookDir.Y + w.Z * lookDir.Z;
        }
Exemplo n.º 10
0
        public static void TranslateZ(ref ArrayList L_Model, float tz)
        {
            ArrayList L_new = new ArrayList();

            for (int i = 0; i < L_Model.Count; i++)
            {
                CPoint3D_Node v = (CPoint3D_Node)L_Model[i];
                v.Z = v.Z + tz;
                L_new.Add(v);
            }
            L_Model.Clear();
            L_Model = L_new;
        }
Exemplo n.º 11
0
        public static ArrayList DoParallelProjection(ArrayList L_3D)
        {
            ArrayList L_2D = new ArrayList();

            for (int i = 0; i < L_3D.Count; i++)
            {
                CPoint3D_Node ptrv = (CPoint3D_Node)L_3D[i];
                PointF        pnn  = new PointF(ptrv.X, ptrv.Y);
                L_2D.Add(pnn);
            }

            return(L_2D);
        }
Exemplo n.º 12
0
        public PointF TransformToOrigin_And_Rotate_And_Project(CPoint3D_Node w1)
        {
            CPoint3D_Node e1, n1;

            e1 = new CPoint3D_Node(0, 0, 0);
            n1 = new CPoint3D_Node(0, 0, 0);

            TransformToOrigin_And_Rotate(w1, e1);
            Projection.DoPrespectiveProjection(e1, n1, focal);

            // view mapping
            n1.X = (int)(ceneterX + cxScreen * n1.X / 2);
            n1.Y = (int)(ceneterY - cyScreen * n1.Y / 2);

            return(new PointF(n1.X, n1.Y));
        }
Exemplo n.º 13
0
        public void BuildNewSystem()
        {
            lookDir = new CPoint3D_Node(0, 0, 0);
            basisa  = new CPoint3D_Node(0, 0, 0);
            basisc  = new CPoint3D_Node(0, 0, 0);

            lookDir.X = lookAt.X - cop.X;
            lookDir.Y = lookAt.Y - cop.Y;
            lookDir.Z = lookAt.Z - cop.Z;
            Matrix.Normalise(lookDir);

            basisa = Matrix.CrossProduct(up, lookDir);
            Matrix.Normalise(basisa);

            basisc = Matrix.CrossProduct(lookDir, basisa);
            Matrix.Normalise(basisc);
        }
Exemplo n.º 14
0
        void addspikes(CPoint3D_Node copy)
        {
            //////////////////////
            int           theta     = 0;
            CPoint3D_Node forspikes = copy;
            _3D_Model     circle    = new _3D_Model();

            circle.cam      = cam;
            circle.clr      = Color.Gold;
            circle.L_3D_Pts = new ArrayList();
            circle.L_Edges  = new ArrayList();
            circle.upordown = false;

            CPoint3D_Node pnnn = new CPoint3D_Node((forspikes.X), (forspikes.Y - 10), (float)(forspikes.Z + 2 + 20));

            circle.L_3D_Pts.Add(pnnn);

            for (int c = 0; c < 36; c++)
            {
                float xcircle = (float)((forspikes.X) + (4 * Math.Cos(theta * Math.PI / 180)));
                float ycircle = (float)((forspikes.Y - 30) + (4 * Math.Sin(theta * Math.PI / 180)));
                float zcircle = forspikes.Z + 20;


                CPoint3D_Node pnn = new CPoint3D_Node(xcircle, ycircle, zcircle);


                circle.L_3D_Pts.Add(pnn);


                if (c > 0)
                {
                    Edge pn = new Edge(c, c - 1);
                    circle.L_Edges.Add(pn);
                }

                Edge pn2 = new Edge(0, c);
                circle.L_Edges.Add(pn2);

                theta += 10;
            }
            Spikes.Add(circle);
        }
Exemplo n.º 15
0
        public void LoadFromFile(string strF)
        {
            L_3D_Pts = new ArrayList();
            L_Edges  = new ArrayList();
            StreamReader sr = new StreamReader(strF);

            string strLine;
            int    Flag = 0;

            while ((strLine = sr.ReadLine()) != null)
            {
                if (strLine[0] == 'L')
                {
                    Flag = 1;
                    continue;
                }

                if (Flag == 0)
                {
                    string []     ss  = strLine.Split(',');
                    CPoint3D_Node pnn = new CPoint3D_Node(
                        float.Parse(ss[0].Trim()),
                        float.Parse(ss[1].Trim()),
                        float.Parse(ss[2].Trim())
                        );

                    L_3D_Pts.Add(pnn);
                }

                if (Flag == 1)
                {
                    string[] ss  = strLine.Split(',');
                    Edge     pnn = new Edge(
                        int.Parse(ss[0].Trim()),
                        int.Parse(ss[1].Trim())
                        );

                    L_Edges.Add(pnn);
                }
            }

            sr.Close();
        }
Exemplo n.º 16
0
        public void removeoldrow()
        {
            if (dropground < 8)
            {
                if (dropground < 7)
                {
                    _3D_Model temp1 = (_3D_Model)Ground[5];
                    _3D_Model temp2 = (_3D_Model)Ground[4];
                    _3D_Model temp3 = (_3D_Model)Ground[3];
                    _3D_Model temp4 = (_3D_Model)Ground[2];
                    _3D_Model temp5 = (_3D_Model)Ground[1];
                    _3D_Model temp6 = (_3D_Model)Ground[0];

                    for (int i = 0; i < temp1.L_3D_Pts.Count; i++)
                    {
                        CPoint3D_Node temppoint = (CPoint3D_Node)temp1.L_3D_Pts[i];
                        temppoint.Y--;
                    }

                    for (int i = 0; i < temp2.L_3D_Pts.Count; i++)
                    {
                        CPoint3D_Node temppoint = (CPoint3D_Node)temp2.L_3D_Pts[i];
                        temppoint.Y -= 2;
                    }
                    for (int i = 0; i < temp3.L_3D_Pts.Count; i++)
                    {
                        CPoint3D_Node temppoint = (CPoint3D_Node)temp3.L_3D_Pts[i];
                        temppoint.Y--;
                    }
                    for (int i = 0; i < temp4.L_3D_Pts.Count; i++)
                    {
                        CPoint3D_Node temppoint = (CPoint3D_Node)temp4.L_3D_Pts[i];
                        temppoint.Y -= 3;
                    }
                    for (int i = 0; i < temp5.L_3D_Pts.Count; i++)
                    {
                        CPoint3D_Node temppoint = (CPoint3D_Node)temp5.L_3D_Pts[i];
                        temppoint.Y -= 4;
                    }
                    for (int i = 0; i < temp6.L_3D_Pts.Count; i++)
                    {
                        CPoint3D_Node temppoint = (CPoint3D_Node)temp6.L_3D_Pts[i];
                        temppoint.Y -= 2;
                    }
                }
                else
                {
                    Ground.RemoveAt(5);
                    Ground.RemoveAt(4);
                    Ground.RemoveAt(3);
                    Ground.RemoveAt(2);
                    Ground.RemoveAt(1);
                    Ground.RemoveAt(0);
                    rowmovement -= 6;
                }
                dropground++;
            }
            else if (dropground >= 8 && dropground < 13)
            {
                if (dropground < 12)
                {
                    _3D_Model temp1 = (_3D_Model)Ground[4];
                    _3D_Model temp2 = (_3D_Model)Ground[3];
                    _3D_Model temp3 = (_3D_Model)Ground[2];
                    _3D_Model temp4 = (_3D_Model)Ground[1];
                    _3D_Model temp5 = (_3D_Model)Ground[0];

                    for (int i = 0; i < temp1.L_3D_Pts.Count; i++)
                    {
                        CPoint3D_Node temppoint = (CPoint3D_Node)temp1.L_3D_Pts[i];
                        temppoint.Y--;
                    }
                    for (int i = 0; i < temp2.L_3D_Pts.Count; i++)
                    {
                        CPoint3D_Node temppoint = (CPoint3D_Node)temp2.L_3D_Pts[i];
                        temppoint.Y -= 2;
                    }
                    for (int i = 0; i < temp3.L_3D_Pts.Count; i++)
                    {
                        CPoint3D_Node temppoint = (CPoint3D_Node)temp3.L_3D_Pts[i];
                        temppoint.Y--;
                    }
                    for (int i = 0; i < temp4.L_3D_Pts.Count; i++)
                    {
                        CPoint3D_Node temppoint = (CPoint3D_Node)temp4.L_3D_Pts[i];
                        temppoint.Y -= 3;
                    }
                    for (int i = 0; i < temp5.L_3D_Pts.Count; i++)
                    {
                        CPoint3D_Node temppoint = (CPoint3D_Node)temp5.L_3D_Pts[i];
                        temppoint.Y -= 4;
                    }
                }
                else
                {
                    Ground.RemoveAt(4);
                    Ground.RemoveAt(3);
                    Ground.RemoveAt(2);
                    Ground.RemoveAt(1);
                    Ground.RemoveAt(0);

                    rowmovement -= 5;
                }
                dropground++;
            }
            else if (dropground >= 13)
            {
                dropground = 0;
            }
        }
Exemplo n.º 17
0
        public void addnewrow()
        {
            if (whichtoadd == false)
            {
                int           startfgroundx = -75;
                float         startgroundz;
                _3D_Model     tempgr1 = (_3D_Model)Ground[Ground.Count - 3];
                CPoint3D_Node tempgr2 = (CPoint3D_Node)tempgr1.L_3D_Pts[1];
                startgroundz  = tempgr2.Z;
                startgroundz += 45;

                _3D_Model cube3 = new _3D_Model();
                cube3.cam = cam;
                cube3.LoadFromFile("Cubewall.txt");
                cube3.typeofcube = 3;
                cube3.upordown   = false;
                Transformation_API.Scale(ref cube3.L_3D_Pts, 0.2f, 0.2f, 0.2f);
                Transformation_API.TranslateZ(ref cube3.L_3D_Pts, (startgroundz - 10) - 50);
                Transformation_API.TranslateY(ref cube3.L_3D_Pts, -108);
                Transformation_API.TranslateX(ref cube3.L_3D_Pts, -163);
                cube3.Rotat_Aroun_Edge(3, 0, 90);
                cube3.Rotat_Aroun_Edge(8, 1, 146);
                cube3.Rotat_Aroun_Edge(7, 0, 12);

                cube3.clr = Color.DarkRed;
                Ground.Add(cube3);


                Random rnd1 = new Random();
                chanceornot = rnd1.Next(3);
                Random rnd2 = new Random();
                hole = rnd2.Next(4);


                for (int i = 0; i < 4; i++)
                {
                    _3D_Model cube2 = new _3D_Model();
                    cube2.cam = cam;
                    cube2.LoadFromFile("Cube2.txt");
                    cube2.upordown = false;
                    Transformation_API.Scale(ref cube2.L_3D_Pts, 0.2f, 0.005f, 0.2f);
                    Transformation_API.TranslateZ(ref cube2.L_3D_Pts, startgroundz);
                    Transformation_API.TranslateY(ref cube2.L_3D_Pts, -100);
                    Transformation_API.TranslateX(ref cube2.L_3D_Pts, startfgroundx);
                    cube2.Rotat_Aroun_Edge(1, 0, 45);
                    bool whichcolor = false;

                    if (chanceornot == 0)
                    {
                        cube2.typeofcube = 0;
                    }
                    else if (chanceornot == 1)
                    {
                        if (hole == i)
                        {
                            cube2.typeofcube = 1;
                        }
                    }
                    else if (chanceornot == 2)
                    {
                        if (hole == i)
                        {
                            cube2.typeofcube = 2;
                            whichcolor       = true;
                            CPoint3D_Node forspikess = (CPoint3D_Node)cube2.L_3D_Pts[0];
                            addspikes(forspikess);
                        }
                    }

                    if (whichcolor == false)
                    {
                        cube2.clr = Color.DarkGray;
                    }
                    else if (whichcolor == true)
                    {
                        cube2.clr = Color.Purple;
                    }
                    startfgroundx += 50;
                    Ground.Add(cube2);
                }

                cube3     = new _3D_Model();
                cube3.cam = cam;
                cube3.LoadFromFile("Cubewall.txt");
                cube3.typeofcube = 3;
                cube3.upordown   = false;
                Transformation_API.Scale(ref cube3.L_3D_Pts, 0.2f, 0.2f, 0.2f);
                Transformation_API.TranslateZ(ref cube3.L_3D_Pts, startgroundz - 10);
                Transformation_API.TranslateY(ref cube3.L_3D_Pts, -108);
                Transformation_API.TranslateX(ref cube3.L_3D_Pts, 102);
                cube3.Rotat_Aroun_Edge(3, 0, 90);
                cube3.Rotat_Aroun_Edge(8, 0, 45);

                cube3.clr = Color.DarkRed;
                Ground.Add(cube3);
                whichtoadd = true;
            }
            else if (whichtoadd == true)
            {
                int           startfgroundx = -100;
                float         startgroundz;
                _3D_Model     tempgr1 = (_3D_Model)Ground[Ground.Count - 2];
                CPoint3D_Node tempgr2 = (CPoint3D_Node)tempgr1.L_3D_Pts[1];
                startgroundz  = tempgr2.Z;
                startgroundz += 50;

                Random rnd1 = new Random();
                chanceornot = rnd1.Next(3);
                Random rnd2 = new Random();
                hole = rnd2.Next(5);

                for (int i = 0; i < 5; i++)
                {
                    _3D_Model cube2 = new _3D_Model();
                    cube2.cam      = cam;
                    cube2.upordown = false;
                    cube2.LoadFromFile("Cube2.txt");
                    Transformation_API.Scale(ref cube2.L_3D_Pts, 0.2f, 0.005f, 0.2f);
                    Transformation_API.TranslateZ(ref cube2.L_3D_Pts, startgroundz);
                    Transformation_API.TranslateY(ref cube2.L_3D_Pts, -100);
                    Transformation_API.TranslateX(ref cube2.L_3D_Pts, startfgroundx);
                    cube2.Rotat_Aroun_Edge(1, 0, 45);
                    bool whichcolor = false;

                    if (chanceornot == 0)
                    {
                        cube2.typeofcube = 0;
                    }
                    else if (chanceornot == 1)
                    {
                        if (hole == i)
                        {
                            cube2.typeofcube = 1;
                        }
                    }
                    else if (chanceornot == 2)
                    {
                        if (hole == i)
                        {
                            cube2.typeofcube = 2;
                            whichcolor       = true;
                            CPoint3D_Node forspikess = (CPoint3D_Node)cube2.L_3D_Pts[0];
                            addspikes(forspikess);
                        }
                    }

                    if (whichcolor == false)
                    {
                        cube2.clr = Color.DarkRed;
                    }
                    else if (whichcolor == true)
                    {
                        cube2.clr = Color.Purple;
                    }
                    startfgroundx += 50;
                    Ground.Add(cube2);
                }

                whichtoadd = false;
            }
        }
Exemplo n.º 18
0
        //public static ArrayList DoPrespectiveProjection(ArrayList L_3D, float focal)
        //{
        //    ArrayList L_2D = new ArrayList();
        //    for (int i = 0; i < L_3D.Count; i++)
        //    {
        //        CPoint3D_Node vw = (CPoint3D_Node)L_3D[i];

        //        PointF pnn = new PointF();
        //        pnn.X = (float)(vw.X * (focal / vw.Z));
        //        pnn.Y = (float)(vw.Y * (focal / vw.Z));

        //        L_2D.Add(pnn);
        //    }
        //    return L_2D;
        //}

        public static void DoPrespectiveProjection(CPoint3D_Node e, CPoint3D_Node n, float focal)
        {
            n.X = focal * e.X / e.Z;
            n.Y = focal * e.Y / e.Z;
            n.Z = focal;
        }
Exemplo n.º 19
0
        private void T_Tick(object sender, EventArgs e)
        {
            for (int i = 0; i < Spikes.Count; i++)
            {
                _3D_Model     tempspike      = (_3D_Model)Spikes[i];
                CPoint3D_Node tempspikepoint = (CPoint3D_Node)tempspike.L_3D_Pts[3];
                if (tempspikepoint.Z < -350)
                {
                    Spikes.RemoveAt(i);
                }
            }

            CPoint3D_Node checkcube   = (CPoint3D_Node)Movingcube.L_3D_Pts[3];
            _3D_Model     checkcube2  = (_3D_Model)Ground[1];
            CPoint3D_Node checkcube22 = (CPoint3D_Node)checkcube2.L_3D_Pts[3];

            if (checkcube.Z < checkcube22.Z)
            {
                falling = true;
            }

            if (spikemove == 15 || spikemove == 30)
            {
                for (int i = 0; i < Spikes.Count; i++)
                {
                    _3D_Model tempspike = (_3D_Model)Spikes[i];
                    if (tempspike.upordown == false)
                    {
                        Transformation_API.TranslateY(ref tempspike.L_3D_Pts, 30);
                        tempspike.upordown = true;
                    }
                    else if (tempspike.upordown == true)
                    {
                        Transformation_API.TranslateY(ref tempspike.L_3D_Pts, -30);
                        tempspike.upordown = false;
                    }
                }

                for (int i = 0; i < Ground.Count; i++)
                {
                    _3D_Model tempspike = (_3D_Model)Ground[i];
                    if (tempspike.typeofcube == 2)
                    {
                        if (tempspike.upordown == false)
                        {
                            tempspike.upordown = true;
                            _3D_Model checkhole = (_3D_Model)Ground[rowmovement];
                            if (checkhole.typeofcube == 2 && checkhole.upordown == true)
                            {
                                crushed = true;
                            }
                        }
                        else if (tempspike.upordown == true)
                        {
                            tempspike.upordown = false;
                        }
                    }
                }
            }

            if (firstclick == true)
            {
                if (falling == false && crushed == false)
                {
                    removeoldrow();
                    if (clickedrotate == true)
                    {
                        if (rotsided == true)
                        {
                            if (rotatecounter < 5)
                            {
                                Movingcube.Rotat_Aroun_Edge(10, 1, 15);
                            }
                            else
                            {
                                rot(6);
                                rotsided      = false;
                                rotsidea      = false;
                                clickedrotate = false;
                                rotatecounter = 0;
                                _3D_Model checkhole = (_3D_Model)Ground[rowmovement];
                                if (checkhole.typeofcube == 1)
                                {
                                    falling = true;
                                }
                                else if (checkhole.typeofcube == 2 && checkhole.upordown == true)
                                {
                                    crushed = true;
                                }
                            }
                            rotatecounter++;
                        }
                        else if (rotsidea == true)
                        {
                            if (rotatecounter < 5)
                            {
                                Movingcube.Rotat_Aroun_Edge(6, 1, 15);
                            }
                            else
                            {
                                rot(5);
                                rotsided      = false;
                                rotsidea      = false;
                                clickedrotate = false;
                                rotatecounter = 0;
                                _3D_Model checkhole = (_3D_Model)Ground[rowmovement];
                                if (checkhole.typeofcube == 1)
                                {
                                    falling = true;
                                }
                                else if (checkhole.typeofcube == 2 && checkhole.upordown == true)
                                {
                                    crushed = true;
                                }
                            }
                            rotatecounter++;
                        }
                    }
                }
                else if (falling == true)
                {
                    if (fallingcubecounter < 20)
                    {
                        if (fallsound == false)
                        {
                            fall.Play();
                            fallsound = true;
                        }
                        Transformation_API.TranslateZ(ref Movingcube.L_3D_Pts, -20);
                    }
                    else
                    {
                        fall.Stop();
                        breaking.Play();
                        buildandreset();
                    }
                    fallingcubecounter++;
                }
                else if (crushed == true)
                {
                    if (fallingcubecounter < 20)
                    {
                        if (fallsound == false)
                        {
                            breaking.Play();
                            fallsound = true;
                        }
                        Transformation_API.Scale(ref Movingcube.L_3D_Pts, (float)0.7, (float)0.7, (float)0.7);
                    }
                    else
                    {
                        breaking.Stop();
                        buildandreset();
                    }
                    fallingcubecounter++;
                }
            }

            spikemove++;
            if (spikemove == 31)
            {
                spikemove = 0;
            }
            cam.BuildNewSystem();
            DrawScene(this.CreateGraphics());
        }
Exemplo n.º 20
0
        public void buildandreset()
        {
            XB = 100;
            YB = 50;
            cx = 0;
            cy = 0;
            Ground.Clear();
            Spikes.Clear();
            Movingcube            = new _3D_Model();
            cam                   = new Camera();
            Cube                  = new _3D_Model();
            x.X                   = 0;
            x.Y                   = 0;
            y.X                   = 0;
            y.Y                   = 0;
            chanceornot           = 0;
            hole                  = 0;
            firstclick            = false;
            whichground           = false;
            whichtoadd            = false;
            dropground            = 0;
            rowmovement           = 41;
            rowmovementcheckspike = 41;
            clickedrotate         = false;
            rotsided              = false;
            rotsidea              = false;
            falling               = false;
            crushed               = false;
            checkdeath            = false;
            rotatecounter         = 0;
            fallingcubecounter    = 0;
            fallsound             = false;
            spikemove             = 0;

            cx = (this.Width - 185);
            cy = (this.Height - 150);

            cam.ceneterX = XB + (cx / 2);
            cam.ceneterY = YB + (cy / 2);
            cam.cxScreen = cx;
            cam.cyScreen = cy;
            cam.cop.Y   += 715;
            cam.cop.Z   -= 360;

            Cube.cam = cam;

            Cube.LoadFromFile("Cube.txt");
            Cube.clr = Color.White;
            Transformation_API.Scale(ref Cube.L_3D_Pts, 1.31f, 1f, 4f);

            float startgroundz = -350;

            for (int j = 0; j < 30; j++)
            {
                float startfgroundx = -75;

                _3D_Model cube3 = new _3D_Model();
                cube3.cam = cam;
                cube3.LoadFromFile("Cubewall.txt");
                cube3.upordown = false;
                Transformation_API.Scale(ref cube3.L_3D_Pts, 0.2f, 0.2f, 0.2f);
                cube3.typeofcube = 3;
                Transformation_API.TranslateZ(ref cube3.L_3D_Pts, startgroundz - (10 + 50));
                Transformation_API.TranslateY(ref cube3.L_3D_Pts, -108);
                Transformation_API.TranslateX(ref cube3.L_3D_Pts, -163);
                cube3.Rotat_Aroun_Edge(3, 0, 90);
                cube3.Rotat_Aroun_Edge(8, 1, 146);
                cube3.Rotat_Aroun_Edge(7, 0, 12);

                cube3.clr = Color.DarkRed;
                Ground.Add(cube3);

                if (j > 10)
                {
                    Random rnd1 = new Random();
                    chanceornot = rnd1.Next(3);
                    Random rnd2 = new Random();
                    hole = rnd2.Next(4);
                }

                for (int i = 0; i < 4; i++)
                {
                    _3D_Model cube2 = new _3D_Model();
                    cube2.cam      = cam;
                    cube2.upordown = false;
                    cube2.LoadFromFile("Cube2.txt");
                    Transformation_API.Scale(ref cube2.L_3D_Pts, 0.2f, 0.005f, 0.2f);
                    Transformation_API.TranslateZ(ref cube2.L_3D_Pts, startgroundz);
                    Transformation_API.TranslateY(ref cube2.L_3D_Pts, -100);
                    Transformation_API.TranslateX(ref cube2.L_3D_Pts, startfgroundx);
                    cube2.Rotat_Aroun_Edge(1, 0, 45);
                    bool changecolor = false;

                    if (j <= 10)
                    {
                        cube2.typeofcube = 0;
                    }
                    else if (j > 10 && chanceornot == 0)
                    {
                        cube2.typeofcube = 0;
                    }
                    else if (j > 10 && hole == i && chanceornot == 1)
                    {
                        cube2.typeofcube = 1;
                    }
                    else if (j > 10 && hole == i && chanceornot == 2)
                    {
                        cube2.typeofcube = 2;
                        changecolor      = true;
                        CPoint3D_Node forspikess = (CPoint3D_Node)cube2.L_3D_Pts[0];
                        addspikes(forspikess);
                    }

                    if (changecolor == false)
                    {
                        cube2.clr = Color.DarkGray;
                    }
                    else
                    {
                        cube2.clr = Color.Purple;
                    }

                    startfgroundx += 50;
                    Ground.Add(cube2);
                }

                cube3     = new _3D_Model();
                cube3.cam = cam;
                cube3.LoadFromFile("Cubewall.txt");
                Transformation_API.Scale(ref cube3.L_3D_Pts, 0.2f, 0.2f, 0.2f);
                cube3.upordown   = false;
                cube3.typeofcube = 3;
                Transformation_API.TranslateZ(ref cube3.L_3D_Pts, startgroundz - 10);
                Transformation_API.TranslateY(ref cube3.L_3D_Pts, -108);
                Transformation_API.TranslateX(ref cube3.L_3D_Pts, 102);
                cube3.Rotat_Aroun_Edge(3, 0, 90);
                cube3.Rotat_Aroun_Edge(8, 0, 45);

                cube3.clr = Color.DarkRed;
                Ground.Add(cube3);

                startgroundz += 27;
                startfgroundx = -100;

                if (j > 10)
                {
                    Random rnd1 = new Random();
                    chanceornot = rnd1.Next(3);
                    Random rnd2 = new Random();
                    hole = rnd2.Next(5);
                }

                for (int i = 0; i < 5; i++)
                {
                    _3D_Model cube2 = new _3D_Model();
                    cube2.cam = cam;
                    cube2.LoadFromFile("Cube2.txt");
                    cube2.upordown = false;
                    Transformation_API.Scale(ref cube2.L_3D_Pts, 0.2f, 0.005f, 0.2f);
                    Transformation_API.TranslateZ(ref cube2.L_3D_Pts, startgroundz);
                    Transformation_API.TranslateY(ref cube2.L_3D_Pts, -100);
                    Transformation_API.TranslateX(ref cube2.L_3D_Pts, startfgroundx);
                    cube2.Rotat_Aroun_Edge(1, 0, 45);

                    bool changecolor = false;

                    if (j <= 10)
                    {
                        cube2.typeofcube = 0;
                    }
                    else if (j > 10 && chanceornot == 0)
                    {
                        cube2.typeofcube = 0;
                    }
                    else if (j > 10 && hole == i && chanceornot == 1)
                    {
                        cube2.typeofcube = 1;
                    }
                    else if (j > 10 && hole == i && chanceornot == 2)
                    {
                        cube2.typeofcube = 2;
                        changecolor      = true;
                        CPoint3D_Node forspikess = (CPoint3D_Node)cube2.L_3D_Pts[0];
                        addspikes(forspikess);
                    }

                    if (changecolor == false)
                    {
                        cube2.clr = cube2.clr = Color.DarkRed;
                    }
                    else
                    {
                        cube2.clr = Color.Purple;
                    }

                    startfgroundx += 50;
                    Ground.Add(cube2);
                }

                startgroundz += 30;
            }

            Movingcube.cam = cam;
            Movingcube.LoadFromFile("Cube2.txt");
            Movingcube.upordown = false;
            Transformation_API.Scale(ref Movingcube.L_3D_Pts, 0.2f, 0.2f, 0.2f);
            _3D_Model tempground = (_3D_Model)Ground[41];

            for (int i = 0; i < Movingcube.L_3D_Pts.Count; i++)
            {
                CPoint3D_Node temp        = (CPoint3D_Node)Movingcube.L_3D_Pts[i];
                CPoint3D_Node tempground2 = (CPoint3D_Node)tempground.L_3D_Pts[i];
                temp.X = tempground2.X;
                temp.Z = tempground2.Z;
            }
            Transformation_API.TranslateY(ref Movingcube.L_3D_Pts, -70);

            Movingcube.clr = Color.Blue;

            cam.BuildNewSystem();

            off = new Bitmap(this.ClientSize.Width, this.ClientSize.Height);
        }