Beispiel #1
0
        public static void Bunny(Model model)
        {
            ReadFile readFile = new ReadFile(MainWindow.GetAssetsPath() + "Bunny.eye");

            readFile.DoWork();

            // scales file contents by 100
            foreach (Entity entity in readFile.Entities)
            {
                entity.Scale(100, 100, 100);
            }

            readFile.AddToScene(model);

            if (model.Entities.Count > 0 && model.Entities[0] is FastPointCloud)
            {
                FastPointCloud fpc = (FastPointCloud)model.Entities[0];

                fpc.Rotate(Math.PI / 2, Vector3D.AxisX, Point3D.Origin);

                model.Entities.Regen();

                model.ZoomFit();

                BallPivoting bp = new BallPivoting(fpc);

                model.StartWork(bp);
            }
        }
Beispiel #2
0
        private void openButton_Click(object sender, EventArgs e)
        {
            using (var openFileDialog1 = new System.Windows.Forms.OpenFileDialog())
            {
                openFileDialog1.Filter           = "Eyeshot (*.eye)|*.eye";
                openFileDialog1.Multiselect      = false;
                openFileDialog1.AddExtension     = true;
                openFileDialog1.CheckFileExists  = true;
                openFileDialog1.CheckPathExists  = true;
                openFileDialog1.DereferenceLinks = true;
                openFileDialog1.ShowHelp         = true;


                _openFileAddOn = new OpenFileAddOn();
                _openFileAddOn.EventFileNameChanged += OpenFileAddOn_EventFileNameChanged;

                if (openFileDialog1.ShowDialog(_openFileAddOn, null) == System.Windows.Forms.DialogResult.OK)
                {
                    model1.Clear();
                    ReadFile readFile = new ReadFile(openFileDialog1.FileName, false, (contentType)_openFileAddOn.ContentOption);
                    if (OpenSaveAsync)
                    {
                        model1.StartWork(readFile);
                        SetButtonEnabled(false);
                    }
                    else
                    {
                        readFile.DoWork();
                        AddToScene(readFile);
                        ShowLog(readFile);
                    }
                }

                _openFileAddOn.EventFileNameChanged -= OpenFileAddOn_EventFileNameChanged;
                _openFileAddOn.Dispose();
                _openFileAddOn = null;
            }
        }
Beispiel #3
0
        protected override void OnContentRendered(EventArgs e)
        {
            model1.Rendered.EdgeColorMethod = edgeColorMethodType.EntityColor;
            model1.Rendered.EdgeThickness   = 1;

            model1.GetGrid().Min      = new Point3D(-150, -100);
            model1.GetGrid().Max      = new Point3D(+200, +100);
            model1.GetGrid().Step     = 20;
            model1.GetGrid().AutoSize = false;


            Block b = new Block("CrankShaft");

            LinearPath lp = new LinearPath(6);

            lp.Vertices[0] = new Point3D(0, -50, 0);
            lp.Vertices[1] = new Point3D(0, -20, 0);
            lp.Vertices[2] = new Point3D(50, -20, 0);
            lp.Vertices[3] = new Point3D(50, +20, 0);
            lp.Vertices[4] = new Point3D(0, +20, 0);
            lp.Vertices[5] = new Point3D(0, +50, 0);

            lp.ColorMethod      = colorMethodType.byEntity;
            lp.Color            = System.Drawing.Color.Blue;
            lp.LineWeightMethod = colorMethodType.byEntity;
            lp.LineWeight       = 1.5f;

            b.Entities.Add(lp);

            model1.Blocks.Add(b);

            model1.Entities.Add(new Rotating("CrankShaft"));


            b = new Block("ConnectingRod");

            Plane XZ = new Plane(Point3D.Origin, Vector3D.AxisX, Vector3D.AxisZ);

            b.Entities.Add(new Circle(XZ, Point2D.Origin, 8));
            b.Entities.Add(new Circle(XZ, Point2D.Origin, 6));
            b.Entities.Add(new Circle(XZ, new Point2D(120, 0), 15));
            b.Entities.Add(new Circle(XZ, new Point2D(120, 0), 10));
            b.Entities.Add(new Line(XZ, new Point2D(6.928, 4), new Point2D(105.543, 4)));
            b.Entities.Add(new Line(XZ, new Point2D(6.928, -4), new Point2D(105.543, -4)));
            b.Entities.Add(new Line(XZ, new Point2D(-2, 0), new Point2D(2, 0)));
            b.Entities.Add(new Line(XZ, new Point2D(0, -2), new Point2D(0, 2)));
            b.Entities.Add(new Line(XZ, new Point2D(120 - 3, 0), new Point2D(120 + 3, 0)));
            b.Entities.Add(new Line(XZ, new Point2D(120, -3), new Point2D(120, 3)));

            foreach (Entity ent in b.Entities)
            {
                ent.ColorMethod = colorMethodType.byEntity;
                ent.Color       = System.Drawing.Color.Red;
            }

            model1.Blocks.Add(b);

            model1.Entities.Add(new Oscillating("ConnectingRod"));


            b = new Block("Axis");

            Line line = new Line(0, +30, 0, -30);

            line.ColorMethod = colorMethodType.byEntity;
            line.Color       = System.Drawing.Color.Black;

            b.Entities.Add(line);

            model1.Blocks.Add(b);

            model1.Entities.Add(new Translating("Axis"));


            b = new Block("Piston");

            ReadFile readFile = new ReadFile("../../../../../../dataset/Assets/Piston.eye");

            readFile.DoWork();

            Mesh m = (Mesh)readFile.Entities[0];

            m.EdgeStyle   = Mesh.edgeStyleType.Sharp;
            m.ColorMethod = colorMethodType.byEntity;
            m.Color       = System.Drawing.Color.DarkGray;

            b.Entities.Add(m);

            model1.Blocks.Add(b);

            model1.Entities.Add(new Translating("Piston"));

            // Bounding box override
            model1.BoundingBox.Min = new Point3D(-110, -50, -70);
            model1.BoundingBox.Max = new Point3D(+170, +50, +70);
            model1.BoundingBox.OverrideSceneExtents = true;

            // Shadows are not currently supported in animations
            model1.Rendered.ShadowMode = shadowType.None;

            model1.StartAnimation(1);

            model1.ZoomFit();

            model1.Invalidate();

            base.OnContentRendered(e);
        }