示例#1
0
        private void CenterMass_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (CenterMass.Content == null)
                {
                    Point3D point = BP.GetCenterOffMass().Item1;

                    Material material    = new DiffuseMaterial(new SolidColorBrush(Color.FromArgb(255, 230, 30, 30)));
                    var      meshBuilder = new MeshBuilder(false, false);

                    meshBuilder.AddSphere(point, 0.3);
                    var Mesh = meshBuilder.ToMesh(true);
                    CenterMass.Content = new GeometryModel3D {
                        Geometry = Mesh, Material = material
                    };
                }
                else
                {
                    CenterMass.Content = null;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }