//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(); } } }
private ShipSelectorWindow(NewtonDynamics.World world) { InitializeComponent(); this.Background = SystemColors.ControlBrush; _world = world; }
private void FinishLoadingShipAsync(NewtonDynamics.World world) { // Show the ship RenderShipAsync(world); // Lights InitializeLight(); }
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; }
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); } }
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); }