示例#1
0
 private void lbModels_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (MathboxModel3D.TryGetModel(lbModels.SelectedItem as Mathbox.Mesh, out var model))
     {
         SelectedModel = model;
     }
 }
 static MathboxModel3D()
 {
     foreach (var m in Mathbox.Mesh.MeshList)
     {
         Lookup[m] = new MathboxModel3D(m);
     }
 }
 static public bool TryGetModel(UInt16 address, out MathboxModel3D model)
 {
     model = null;
     if (Mathbox.Mesh.TryGetMeshAt(address, out var m))
     {
         return(TryGetModel(m, out model));
     }
     return(false);
 }
        public MainWindow()
        {
            InitializeComponent();

            // add the starfield to the background
            ModelVisual3D starfield = new StarfieldModel3D();

            starfield.Transform = StarfieldRotMatrix;
            Viewport.Children.Add(starfield);

            // add standard light sources
            Viewport.Children.Add(new ModelVisual3D()
            {
                Content = AmbientLight
            });
            Viewport.Children.Add(new ModelVisual3D()
            {
                Content = DirectionalLight
            });

            // add the playfield model
            ModelVisual3D    playfield   = PlayfieldModel;
            Transform3DGroup xform_group = new Transform3DGroup();

            xform_group.Children.Add(ModelRotate);
            xform_group.Children.Add(ModelTranslate);
            xform_group.Children.Add(ModelScale);
            playfield.Transform = xform_group;
            Viewport.Children.Add(playfield);

#if DEBUG
            // throw in big brother
            if (MathboxModel3D.TryGetModel(Mathbox.Mesh.BIG_BROTHER_MOUTH_CLOSED, out var big_bro))
            {
                ModelVisual3D b = new ModelVisual3D();
                b.Content   = big_bro;
                b.Transform = xform_group;
                Viewport.Children.Add(b);
            }
#endif

            // populate the list view with available levels
            foreach (var level in Levels)
            {
                lbLevels.Items.Add(level);
            }
            lbLevels.SelectedIndex = 0;

            // start our timer
            DispatcherTimer timer = new DispatcherTimer();
            timer.Interval = TimeSpan.FromSeconds(0.05);
            timer.Tick    += timer_Tick;
            timer.Start();
        }
        private void ShowMathboxModels_Click(object sender, RoutedEventArgs e)
        {
            MathboxModelWindow window = new MathboxModelWindow();

            window.Owner = this;

            if (MathboxModel3D.TryGetModel(Mathbox.Mesh.BIG_BROTHER_MOUTH_CLOSED, out var model))
            {
                window.SelectedModel = model;
            }

            window.Show();
        }
示例#6
0
        void AddMathboxObject(UInt16 addr, Point3D v, double yaw = 0, double pitch = 0, double roll = 0)
        {
            if (MathboxModel3D.TryGetModel(addr, out var model))
            {
                Model3DGroup g = new Model3DGroup();
                g.Children.Add(model);

                MatrixTransform3D matrix = new MatrixTransform3D();
                Matrix3D          m      = Matrix3D.Identity;
                m.Rotate(new Quaternion(new Vector3D(0, 0, 1), roll));
                m.Rotate(new Quaternion(new Vector3D(1, 0, 0) * m, pitch));
                m.Rotate(new Quaternion(new Vector3D(0, 1, 0) * m, yaw));
                m.Translate(new Vector3D(v.X, v.Y, v.Z));
                matrix.Matrix = m;
                g.Transform   = matrix;
                Group.Children.Add(g);
            }
        }
 static public bool TryGetModel(Mathbox.Mesh m, out MathboxModel3D model)
 {
     return(Lookup.TryGetValue(m, out model));
 }