示例#1
0
        //TODO: Make a static method off of Ship, and don't rely on world: public static Visual3D CreateVisual(ShipDNA dna, bool isDesign)
        private void RenderShipAsync(NewtonDynamics.World world)
        {
            ShipExtraArgs args = new ShipExtraArgs()
            {
                RunNeural           = false,
                RepairPartPositions = false,
            };

            //using (Ship ship = await Ship.GetNewShipAsync(this.ShipDNA, world, 0, null, args))
            using (Bot bot = new Bot(BotConstructor.ConstructBot(this.ShipDNA, new ShipCoreArgs()
            {
                World = world
            }, args)))
            {
                if (bot.PhysicsBody.Visuals != null)            // this will never be null
                {
                    // The model coords may not be centered, so move the ship so that it's centered on the origin
                    Point3D minPoint, maxPoint;
                    bot.PhysicsBody.GetAABB(out minPoint, out maxPoint);
                    Vector3D offset = (minPoint + ((maxPoint - minPoint) / 2d)).ToVector();

                    bot.PhysicsBody.Position = (-offset).ToPoint();

                    // Add the visuals
                    foreach (Visual3D visual in bot.PhysicsBody.Visuals)
                    {
                        _viewport.Children.Add(visual);
                    }

                    // Pull the camera back to a good distance
                    _camera.Position = (_camera.Position.ToVector().ToUnit() * (bot.Radius * 2.1d)).ToPoint();
                }
            }
        }
示例#2
0
        private ShipSelectorWindow(NewtonDynamics.World world)
        {
            InitializeComponent();

            this.Background = SystemColors.ControlBrush;

            _world = world;
        }
示例#3
0
        private void FinishLoadingShipAsync(NewtonDynamics.World world)
        {
            // Show the ship
            RenderShipAsync(world);

            // Lights
            InitializeLight();
        }
        private ShipSelectorWindow(NewtonDynamics.World world)
        {
            InitializeComponent();

            this.Background = SystemColors.ControlBrush;

            _world = world;
        }
示例#5
0
        public ShipSelectorWindow(string foldername, NewtonDynamics.World world)
            : this(world)
        {
            grdFolder.Visibility = Visibility.Visible;
            lblStatus.Visibility = Visibility.Visible;

            // Let the textchange event load the listbox
            txtFoldername.Text = foldername;
        }
示例#6
0
        public ShipSelectorWindow(ShipDNA[] dna, NewtonDynamics.World world)
            : this(world)
        {
            grdFolder.Visibility = Visibility.Collapsed;
            lblStatus.Visibility = Visibility.Collapsed;

            foreach (ShipDNA item in dna)
            {
                AddItem(item, null);
            }
        }
示例#7
0
        public Icon3D(string name, ShipDNA dna, NewtonDynamics.World world)
        {
            InitializeComponent();

            this.ItemName = name;
            this.ShipDNA  = dna;

            lblName.Text       = name;
            lblName.Visibility = _showName ? Visibility.Visible : Visibility.Collapsed;

            InitializeTrackball();

            // Load the ship asyncronously
            FinishLoadingShipAsync(world);
        }