private void btnTwoOdd1_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                //PartDNA dnaFuel = new PartDNA() { PartType = FuelTank.PARTTYPE, Position = new Point3D(-1d, 0, 0), Orientation = new Quaternion(new Vector3D(1, 1, 0), 90d), Scale = new Vector3D(.25d, .25d, 4d) };
                //FuelTank fuel = new FuelTank(_editorOptions, _itemOptions, dnaFuel);
                //fuel.QuantityCurrent = fuel.QuantityMax;

                ShipPartDNA dnaEnergy = new ShipPartDNA() { PartType = EnergyTank.PARTTYPE, Position = new Point3D(-1d, 0, 0), Orientation = new Quaternion(new Vector3D(1, 1, 0), 90d), Scale = new Vector3D(.25d, .25d, 4d) };
                //PartDNA dnaEnergy = new PartDNA() { PartType = EnergyTank.PARTTYPE, Position = new Point3D(-1d, 0, 0), Orientation = new Quaternion(new Vector3D(1, 1, 0), 10d), Scale = new Vector3D(4d, 4d, .25d) };
                EnergyTank energy = new EnergyTank(_editorOptions, _itemOptions, dnaEnergy);
                //energy.QuantityCurrent = fuel.QuantityMax;

                ShipPartDNA dnaBrain = new ShipPartDNA() { PartType = Brain.PARTTYPE, Position = new Point3D(0, 0, 0), Orientation = Quaternion.Identity, Scale = new Vector3D(2d, 2d, 2d) };
                Brain brain = new Brain(_editorOptions, _itemOptions, dnaBrain, null);

                //StartScene(new PartBase[] { fuel, brain });
                StartScene(new PartBase[] { energy, brain }, 7);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), this.Title, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        private void btnTwoCubeCylinder_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                bool isEnergy = StaticRandom.Next(2) == 0;

                ShipPartDNA dna1 = new ShipPartDNA() { PartType = isEnergy ? EnergyTank.PARTTYPE : FuelTank.PARTTYPE, Position = new Point3D(-.5, 0, 0), Orientation = Quaternion.Identity, Scale = new Vector3D(4, 4, 3) };
                ShipPartDNA dnaSpin = new ShipPartDNA() { PartType = SensorSpin.PARTTYPE, Position = new Point3D(.5, 0, 0), Orientation = Quaternion.Identity, Scale = new Vector3D(10, 10, 10) };

                PartBase cylinder = null;
                if (isEnergy)
                {
                    cylinder = new EnergyTank(_editorOptions, _itemOptions, dna1);
                }
                else
                {
                    cylinder = new FuelTank(_editorOptions, _itemOptions, dna1);
                }
                SensorSpin spin = new SensorSpin(_editorOptions, _itemOptions, dnaSpin, null);

                StartScene(new PartBase[] { cylinder, spin }, 7);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), this.Title, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        private void btnTwoCylinderCylinder_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                bool isEnergy1 = StaticRandom.Next(2) == 0;
                bool isEnergy2 = StaticRandom.Next(2) == 0;

                ShipPartDNA dna1 = new ShipPartDNA() { PartType = isEnergy1 ? EnergyTank.PARTTYPE : FuelTank.PARTTYPE, Position = new Point3D(-.5, -.1, 0), Orientation = Math3D.GetRandomRotation(), Scale = new Vector3D(4, 4, 3) };
                ShipPartDNA dna2 = new ShipPartDNA() { PartType = isEnergy2 ? EnergyTank.PARTTYPE : FuelTank.PARTTYPE, Position = new Point3D(.5, .1, 0), Orientation = Math3D.GetRandomRotation(), Scale = new Vector3D(4, 4, 3) };

                PartBase cylinder1 = null;
                if (isEnergy1)
                {
                    cylinder1 = new EnergyTank(_editorOptions, _itemOptions, dna1);
                }
                else
                {
                    cylinder1 = new FuelTank(_editorOptions, _itemOptions, dna1);
                }

                PartBase cylinder2 = null;
                if (isEnergy2)
                {
                    cylinder2 = new EnergyTank(_editorOptions, _itemOptions, dna2);
                }
                else
                {
                    cylinder2 = new FuelTank(_editorOptions, _itemOptions, dna2);
                }

                StartScene(new PartBase[] { cylinder1, cylinder2 }, 7);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), this.Title, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        private void btnStandaloneEnergy_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                ShipPartDNA dna = GetDefaultDNA(EnergyTank.PARTTYPE);
                ModifyDNA(dna, chkStandaloneRandSize.IsChecked.Value, chkStandaloneRandOrientation.IsChecked.Value);
                double radius = (dna.Scale.X + dna.Scale.Y) * .5d;
                dna.Scale = new Vector3D(radius, radius, dna.Scale.Z);

                EnergyTank energyTank = new EnergyTank(_editorOptions, _itemOptions, dna);

                BuildStandalonePart(energyTank);

                if (chkStandaloneShowMassBreakdown.IsChecked.Value)
                {
                    double cellSize = Math1D.Max(dna.Scale.X, dna.Scale.Y, dna.Scale.Z) * UtilityCore.GetScaledValue_Capped(.1d, .3d, 0d, 1d, _rand.NextDouble());
                    DrawMassBreakdown(energyTank.GetMassBreakdown(cellSize), cellSize);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), this.Title, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        private void btnRGB_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (_offline1 == null)
                {
                    MessageBox.Show("Start a scene first", this.Title, MessageBoxButton.OK, MessageBoxImage.Warning);
                    return;
                }

                ShipPartDNA energyDNA = new ShipPartDNA() { PartType = EnergyTank.PARTTYPE, Orientation = Quaternion.Identity, Position = new Point3D(), Scale = new Vector3D(10, 10, 10) };
                EnergyTank energy = new EnergyTank(_editorOptions, _itemOptions, energyDNA);
                energy.QuantityCurrent = energy.QuantityMax;

                ShipPartDNA dna = new ShipPartDNA() { PartType = CameraColorRGB.PARTTYPE, Orientation = Quaternion.Identity, Position = new Point3D(0, 0, 0), Scale = new Vector3D(1, 1, 1) };

                CameraColorRGB camera = new CameraColorRGB(_editorOptions, _itemOptions, dna, energy, _cameraPool);

                camera.RequestWorldLocation += new EventHandler<PartRequestWorldLocationArgs>(TestCamera_RequestWorldLocation);

                //var location = camera.GetWorldLocation_Camera();

                //_offline1.SyncCamera(_camera);
                //IBitmapCustom bitmap = UtilityWPF.RenderControl(_offline1.Control, camera.PixelWidthHeight, camera.PixelWidthHeight, true, Colors.Black, false);

                //camera.StoreSnapshot(bitmap);

                camera.Update_MainThread(1);
                camera.Update_AnyThread(1);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), this.Title, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        private void btnSolarPanel_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                ShipPartDNA dna = GetDefaultDNA(EnergyTank.PARTTYPE);
                EnergyTank energyTank = new EnergyTank(_editorOptions, _itemOptions, dna);

                RadiationField radiation = new RadiationField();
                radiation.AmbientRadiation = 1d;

                ConverterRadiationToEnergyDNA dna2 = new ConverterRadiationToEnergyDNA()
                {
                    PartType = ConverterRadiationToEnergy.PARTTYPE,
                    Shape = UtilityCore.GetRandomEnum<SolarPanelShape>(),
                    Position = new Point3D(0, 0, 0),
                    Orientation = Quaternion.Identity,
                    Scale = new Vector3D(1, 1, 1)
                };
                ConverterRadiationToEnergy solar = new ConverterRadiationToEnergy(_editorOptions, _itemOptions, dna2, energyTank, radiation);

                solar.Transfer(1d, Transform3D.Identity);
                solar.Transfer(1d, Transform3D.Identity);
                solar.Transfer(1d, Transform3D.Identity);
                solar.Transfer(1d, Transform3D.Identity);
                solar.Transfer(1d, Transform3D.Identity);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), this.Title, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        private void btnFuelToEnergy_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                ShipPartDNA dna = GetDefaultDNA(FuelTank.PARTTYPE);
                FuelTank fuelTank = new FuelTank(_editorOptions, _itemOptions, dna);

                dna = GetDefaultDNA(EnergyTank.PARTTYPE);
                EnergyTank energyTank = new EnergyTank(_editorOptions, _itemOptions, dna);

                dna = GetDefaultDNA(ConverterFuelToEnergy.PARTTYPE);
                ConverterFuelToEnergy converter = new ConverterFuelToEnergy(_editorOptions, _itemOptions, dna, fuelTank, energyTank);

                fuelTank.QuantityCurrent = fuelTank.QuantityMax;

                double mass = converter.DryMass;
                mass = converter.TotalMass;

                converter.Transfer(1d, .5d);
                converter.Transfer(1d, 1d);
                converter.Transfer(1d, .1d);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), this.Title, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        private void btnEnergyToAmmo_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                ShipPartDNA dna = GetDefaultDNA(EnergyTank.PARTTYPE);
                EnergyTank energyTank = new EnergyTank(_editorOptions, _itemOptions, dna);

                dna = GetDefaultDNA(AmmoBox.PARTTYPE);
                AmmoBox ammoBox = new AmmoBox(_editorOptions, _itemOptions, dna);

                dna = GetDefaultDNA(ConverterEnergyToAmmo.PARTTYPE);
                ConverterEnergyToAmmo converter = new ConverterEnergyToAmmo(_editorOptions, _itemOptions, dna, energyTank, ammoBox);

                energyTank.QuantityCurrent = energyTank.QuantityMax;

                double mass = converter.DryMass;
                mass = converter.TotalMass;

                converter.Transfer(1d, .5d);
                converter.Transfer(1d, 1d);
                converter.Transfer(1d, .1d);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), this.Title, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        private void btnMultiEnergy_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                List<EnergyTank> tanks = new List<EnergyTank>();
                ContainerGroup group = new ContainerGroup();
                group.Ownership = ContainerGroup.ContainerOwnershipType.GroupIsSoleOwner;

                for (int cntr = 0; cntr < 3; cntr++)
                {
                    ShipPartDNA dna = GetDefaultDNA(EnergyTank.PARTTYPE);
                    double xy = _rand.NextDouble() * 3d;
                    double z = _rand.NextDouble() * 3d;
                    dna.Scale = new Vector3D(xy, xy, z);

                    EnergyTank energyTank = new EnergyTank(_editorOptions, _itemOptions, dna);

                    tanks.Add(energyTank);
                    group.AddContainer(energyTank);
                }

                #region Test1

                double max = group.QuantityMax;

                double remainder1 = group.AddQuantity(max * .5d, false);
                double remainder2 = group.RemoveQuantity(max * .25d, false);
                double remainder3 = group.RemoveQuantity(max * .33d, true);		// should fail
                double remainder4 = group.AddQuantity(max, false);		// partial add

                group.QuantityCurrent *= .5d;

                group.RemoveContainer(tanks[0], false);
                group.AddContainer(tanks[0]);

                group.RemoveContainer(tanks[0], true);
                group.AddContainer(tanks[0]);

                #endregion

                //TODO: Finish these
                //TODO: Test setting max (with just regular containers)

                #region Test2

                group.QuantityCurrent = 0d;

                group.Ownership = ContainerGroup.ContainerOwnershipType.GroupIsSoleOwner;
                //group.Ownership = ContainerGroup.ContainerOwnershipType.QuantitiesCanChange;

                tanks[0].QuantityCurrent *= .5d;		// this will make sole owner fail, but the second enum will handle it

                group.QuantityCurrent = max * .75d;

                group.RemoveQuantity(max * .33d, false);
                group.AddQuantity(max * .5d, false);

                group.RemoveContainer(tanks[0], true);
                group.AddContainer(tanks[0]);

                #endregion

                #region Test3

                group.OnlyRemoveMultiples = true;
                group.RemovalMultiple = max * .25d;

                group.QuantityCurrent = group.QuantityMax;

                double rem1 = group.RemoveQuantity(max * .1d, false);
                double rem2 = group.RemoveQuantity(max * .1d, true);

                group.QuantityCurrent = group.QuantityMax;

                double rem3 = group.RemoveQuantity(max * .3d, false);
                double rem4 = group.RemoveQuantity(max * .3d, true);

                #endregion
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), this.Title, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        private void btnSingleEnergy_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                ShipPartDNA dna = GetDefaultDNA(EnergyTank.PARTTYPE);
                EnergyTank energyTank = new EnergyTank(_editorOptions, _itemOptions, dna);

                double mass1 = energyTank.TotalMass;

                double remainder = energyTank.AddQuantity(.05d, false);
                double mass2 = energyTank.TotalMass;

                remainder = energyTank.AddQuantity(500d, false);
                double mass3 = energyTank.TotalMass;

                double output = energyTank.RemoveQuantity(.1d, false);
                double mass4 = energyTank.TotalMass;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), this.Title, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }