コード例 #1
0
ファイル: Figures.cs プロジェクト: kioltk/super3dproject
        public static Body MultiCylinder(int circlePointsCount, double firstRadius, double secondRadius, double height)
        {
            Body newCube = new Body()
            {
                name = "MultiCylinder"
            };

            double alfa = 2 * Math.PI / circlePointsCount;
            double padding;
            if (firstRadius > secondRadius)
                padding = firstRadius;
            else
                padding = secondRadius;

            var firstConnection = new Connection();
            var secondConnection = new Connection();

            Point firstPoint, secondPoint;
            Connection heightConnection;
            for (int i = 0; i < circlePointsCount; i++)
            {

                heightConnection = new Connection();
                firstPoint = new Point()
                {
                    X = padding + firstRadius * Math.Cos(alfa * i),
                    Y = padding + firstRadius * Math.Sin(alfa * i),
                    Z = 0
                };

                secondPoint = new Point()
                {
                    X = padding + secondRadius * Math.Cos(alfa * i),
                    Y = padding + secondRadius * Math.Sin(alfa * i),
                    Z = height
                };

                heightConnection.points.Add(secondPoint);
                heightConnection.points.Add(firstPoint);

                firstConnection.points.Add(firstPoint);
                secondConnection.points.Add(secondPoint);

                newCube.connections.Add(heightConnection);
                newCube.points.Add(firstPoint);
                newCube.points.Add(secondPoint);
            }

            firstConnection.points.Add(firstConnection.points.First());
            secondConnection.points.Add(secondConnection.points.First());
            newCube.connections.Add(firstConnection);
            newCube.connections.Add(secondConnection);

            newCube.GenerateAxles();
            newCube.ReloadBody();
            return newCube;
        }
コード例 #2
0
        public void AbramsLoading()
        {
            //    abrams.LoadingFromResource("sources/Abrams/base.txt", true);

            var abramsTurret = new Body();
               abramsTurret.LoadingFromResource("sources/Abrams/turret.txt", true);
               abramsTurret.ReloadBody();
               abramsTurret.name = "turret";
               abrams.details.Add(abramsTurret);
               abrams.ReloadBody();

            var gun = Figures.Cylinder(8, 10, 270);
            gun.name = "gun";
            var gunMatrix = Matrix.Rotation(gun.axles.Y, Math.PI / 2);
            gun.EmbedMatrix(gunMatrix);
            gunMatrix = Matrix.Rotation(gun.axles.X, -Math.PI / 32);
            gun.EmbedMatrix(gunMatrix);
            gunMatrix = Matrix.Movement(new Models.Point()
                {
                    X = -120,
                    Y = 20,
                    Z = -20
                });
            gun.EmbedMatrix(gunMatrix);

            abrams["turret"].details.Add(gun);
            var abramsMatrix = Matrix.Movement(new Models.Point()
            {
                X = 1000,
                Y = 500,
                Z = 000
            });
            abrams.EmbedMatrix(abramsMatrix);

            abramsMatrix = Matrix.Scaling(1, new Models.Point() { X = 0, Y = 0, Z = 0 });
            abrams.EmbedMatrix(abramsMatrix);

            abramsMatrix = Matrix.Rotation(abrams.axles.Y, Math.PI / -2);
            abrams.EmbedMatrix(abramsMatrix);
        }
コード例 #3
0
ファイル: Body.cs プロジェクト: kioltk/super3dproject
        public Body CutDetailFromBody(string name, string[] connectionNames)
        {
            Body newDetailFromBody = new Body() { name = name };
            foreach (var connection in connections.Where(x=>connectionNames.Contains(x.name)))
            {
                newDetailFromBody.connections.Add(connection);
                foreach (var point in connection.points)
                {

                    newDetailFromBody.points.Add(point);
                    points.Remove(point);
                }
            }

            foreach (var deleteConnection in newDetailFromBody.connections)
            {
                connections.Remove(deleteConnection);
            }

            newDetailFromBody.GenerateAxles();
            newDetailFromBody.ReloadBody();
            return newDetailFromBody;
        }
コード例 #4
0
ファイル: Body.cs プロジェクト: kioltk/super3dproject
        /// <summary>
        /// Вырезает соединения из тела и возвращает тело из этих соединений. Аккуратнее с этой функцией.
        /// </summary>
        public Body CutDetailFromBody(string name, int[] connectionNumbers)
        {
            Body newDetailFromBody = new Body() { name = name };
            foreach (var connectionNumber in connectionNumbers)
            {
                var connection = connections[connectionNumber];
                newDetailFromBody.connections.Add(connection);
                foreach (var point in connection.points)
                {

                    newDetailFromBody.points.Add(point);
                    points.Remove(point);
                }
            }

            foreach (var deleteConnection in newDetailFromBody.connections)
            {
                connections.Remove(deleteConnection);
            }

            newDetailFromBody.GenerateAxles();
            newDetailFromBody.ReloadBody();
            return newDetailFromBody;
        }
コード例 #5
0
        public void PicturePrint()
        {
            Image.Children.Clear();

            {
                var abramsCopy = abrams.export();
                abramsCopy.EmbedMatrix(cameraMovementMatrix);
                abramsCopy.EmbedMatrix(cameraRotationMatrix);
                abramsCopy.EmbedMatrix(cameraPerspectiveMatrix);
                foreach (var line in abramsCopy.GetPolylines())
                {
                    Image.Children.Add(line);
                }
            }

            if (!hideCar)
            {
                copycar = car.export();
                copycar.EmbedMatrix(cameraMovementMatrix);
                copycar.EmbedMatrix(cameraRotationMatrix);
                copycar.EmbedMatrix(cameraPerspectiveMatrix);
                foreach (var line in copycar.GetPolylines())
                {
                    Image.Children.Add(line);
                }
            }
            if (!hideIron)
            {

                var helmetCopy = helmet.export();
                helmetCopy.EmbedMatrix(cameraMovementMatrix);
                helmetCopy.EmbedMatrix(cameraRotationMatrix);
                helmetCopy.EmbedMatrix(cameraPerspectiveMatrix);

                foreach (var line in helmetCopy.GetPolylines())
                {
                    Image.Children.Add(line);
                }
            }
        }
コード例 #6
0
        public void CarLoading()
        {
            Matrix carMatrix;
            car.LoadingFromResource("sources/mustang.txt", false);
            car.GenerateAxles();

            wheel = Figures.Cylinder(32, 130, 100);
            wheel.name = "wheel";
            var wheelMatrix = Matrix.Movement(new Models.Point()
            {
                X = 210,
                Y = 250,
                Z = 25
            });
            wheel.EmbedMatrix(wheelMatrix);

            car.details.Add(wheel);

            var wheelYAxle = wheel.axles.Y.export();
            wheelYAxle.info = "wheelYAxle";
            car.axles.customs.Add(wheelYAxle);

            var gun = Figures.Cylinder(10, 100, 300);
            var gunMatrix = Matrix.Movement(new Models.Point()
            {
                X = 860,
                Y = -250,
                Z = 75
            });
            gun.EmbedMatrix(gunMatrix);
            gunMatrix = Matrix.Rotation(gun.axles.Y, Math.PI / 2);
            gun.EmbedMatrix(gunMatrix);
            gunMatrix = Matrix.Rotation(gun.axles.X, -Math.PI / 4);
            gun.EmbedMatrix(gunMatrix);
            gun.name = "gun";
            var secondGun = gun.export();
            gunMatrix = Matrix.Movement(new Models.Point()
            {
                X = 0,
                Y = 0,
                Z = 225
            });
            gun.EmbedMatrix(gunMatrix);
            gun.details.Add(secondGun);
            car.details.Add(gun);
            var gunZAxle = gun.axles.Z.export();
            gunZAxle.info = "gunZAxle";
            car.axles.customs.Add(gunZAxle);

            var gunBase = Figures.MultiCylinder(4, 150, 100, 100);
            var gunBaseMatrix = Matrix.Rotation(gunBase.axles.X, Math.PI / 2);
            gunBase.EmbedMatrix(gunBaseMatrix);
            gunBaseMatrix = Matrix.Movement(new Models.Point()
            {
                X = 850,
                Y = -140,
                Z = 275
            });
            gunBase.EmbedMatrix(gunBaseMatrix);
            car.details.Add(gunBase);

            var hoodOpenAxle = car.axles["HoodOpen"].export();
            hood = car.CutDetailFromBody("hood", new string[] { "Hood" });
            car.details.Add(hood);
            car.ReloadBody();
            carMatrix = Matrix.Scaling(0.5, new Models.Point() { X = 0, Y = 0, Z = 0 });
            car.EmbedMatrix(carMatrix);
            carMatrix = Matrix.Movement(new Models.Point()
            {
                X = -300,
                Y = 500,
                Z = 100
            });
            car.EmbedMatrix(carMatrix);
            carMatrix = Matrix.Rotation(car.axles.Y, Math.PI / 2);
            car.EmbedMatrix(carMatrix);
        }
コード例 #7
0
ファイル: Body.cs プロジェクト: kioltk/super3dproject
        /// <summary>
        /// Копия тела, включая все точки, соединения и оси. 
        /// </summary>
        public Body export()
        {
            List<Point> newPoints = new List<Point>();
            List<Connection> newConnections = new List<Connection>();
            foreach (var connection in connections)
            {
                var newConnection = connection.export();

                newConnections.Add(newConnection);
            }

            var result = new Body()                                                           // инициализируем новый обьект, заносим данные, выводим
            {
                name = name + "copy",
                connections = newConnections,
                axles = axles.export(),                                                 //аналогично
                details = details.Select(x => x.export()).ToList()
            };
            result.ReloadBody();
            return result;
        }