Beispiel #1
0
        private void button4_Click(object sender, EventArgs e)
        {
            ClearPictureBox();

            // Setup Orig Vector
            MyVector origVector = new MyVector(9, 0, 0);

            DrawVector(origVector, Color.Silver);

            MyQuaternion multiRotationQuat = new MyQuaternion(new MyVector(0, 0, 0), Utility3D.GetDegreesToRadians(0));

            // Rotate around Z
            MyQuaternion anotherRotationQuat = new MyQuaternion(new MyVector(0, 0, 1), Utility3D.GetDegreesToRadians(1));

            //List<double> lengths = new List<double>();

            for (int outerCntr = 1; outerCntr <= 100000; outerCntr++)
            {
                //lengths.Add(multiRotationQuat.GetMagnitude());
                for (int innerCntr = 1; innerCntr <= 360; innerCntr++)
                {
                    multiRotationQuat = MyQuaternion.Multiply(anotherRotationQuat, multiRotationQuat);
                }
                //multiRotationQuat.BecomeUnitQuaternion();
            }

            // Draw the final output
            MyVector subRotation = multiRotationQuat.GetRotatedVector(origVector, true);

            DrawVector(subRotation, Color.Yellow);
        }
Beispiel #2
0
        private void DrawDot(MyVector centerPoint, double radius, Color color)
        {
            float centerX = Convert.ToSingle(centerPoint.X);
            float centerY = Convert.ToSingle(centerPoint.Y);

            _graphics.FillEllipse(new SolidBrush(color), Convert.ToSingle(centerX - radius), Convert.ToSingle(centerY - radius), Convert.ToSingle(radius) * 2f, Convert.ToSingle(radius) * 2f);
        }
Beispiel #3
0
        private void DrawAttatchment(MyVector offset, AttatchementType attatchment)
        {
            MyVector worldAttatchment = _ship.Ball.Rotation.GetRotatedVector(offset, true);

            worldAttatchment.Add(_ship.Ball.Position);

            switch (attatchment)
            {
            case AttatchementType.Thruster:
                _picturebox.FillCircle(Color.Silver, worldAttatchment, 60d);
                _picturebox.DrawCircle(Color.Black, 1d, worldAttatchment, 60d);
                break;

            case AttatchementType.Tractor:
                _picturebox.FillCircle(Color.Olive, worldAttatchment, 40d);
                _picturebox.DrawCircle(Color.Black, 1d, worldAttatchment, 40d);
                break;

            case AttatchementType.Cannon:
                _picturebox.FillCircle(Color.Brown, worldAttatchment, 30d);
                _picturebox.DrawCircle(Color.Black, 1d, worldAttatchment, 30d);
                break;

            case AttatchementType.MachineGun:
                _picturebox.FillCircle(Color.Brown, worldAttatchment, 25d);
                _picturebox.DrawCircle(Color.Black, 1d, worldAttatchment, 25d);
                break;
            }
        }
Beispiel #4
0
    // Start is called before the first frame update
    void Start()
    {
        Debug.Assert(P0 != null);   // Verify proper setting in the editor
        Debug.Assert(P1 != null);
        Debug.Assert(Pt != null);
        Debug.Assert(Pon != null);

        #region For visualizing the vectors
        // To support visualizing the vectors
        ShowV1 = new MyVector {
            VectorColor = Color.green
        };
        ShowLine = new MyLineSegment
        {
            VectorColor = MyDrawObject.NoCollisionColor,
            LineWidth   = 0.6f
        };
        ShowPv = new MyLineSegment
        {
            VectorColor = Color.black,
            LineWidth   = 0.02f
        };
        ShowPa = new MyLineSegment
        {
            VectorColor = Color.black,
            LineWidth   = 0.02f
        };
        Pt.GetComponent <Renderer>().material.color  = Color.black;
        Pon.GetComponent <Renderer>().material.color = Color.black;
        #endregion
    }
Beispiel #5
0
    // Start is called before the first frame update
    void Start()
    {
        Debug.Assert(P0 != null);   // Verify proper setting in the editor
        Debug.Assert(P1 != null);
        Debug.Assert(P2 != null);

        #region For visualizing the vectors
        // To support visualizing the vectors
        ShowV1 = new MyVector {
            VectorColor = Color.cyan
        };
        ShowV2 = new MyVector
        {
            VectorColor = Color.magenta
        };
        ShowDot = new MyLineSegment
        {
            VectorAt  = Vector3.zero,
            LineWidth = 0.07f
        };
        ShowPlane = new MyXZPlane
        {
            PlaneColor = new Color(0.3f, 0.8f, 0.3f, 0.5f),
            XSize      = 0.5f,
            YSize      = 0.5f,
            ZSize      = 0.5f
        };
        #endregion
    }
Beispiel #6
0
        /// <summary>
        /// This should only be called if _newBallProps.SizeMode is Draw
        /// </summary>
        private void ResizeDrawingObject()
        {
            // Find the vector from the mousedown point to the current point
            MyVector fromToLine = _curMousePoint - _mouseDownPoint;

            // Adjust the radius and mass
            switch (_mode)
            {
            case AddingMode.AddBall:
            case AddingMode.AddSolidBall:
                double newValue = fromToLine.GetMagnitude();
                if (newValue < MINRADIUS)
                {
                    newValue = MINRADIUS;
                }

                _drawingBall.Radius = newValue;
                _drawingBall.Mass   = UtilityCore.GetMassForRadius(newValue, 1d);
                break;

            //case AddingMode.AddRigidBody:
            //    //TODO:  I will need to pull all the point masses out proportionatly, as well as change their masses
            //    break;

            default:
                throw new ApplicationException("Unknown AddingMode: " + _mode.ToString());
            }
        }
Beispiel #7
0
    public GameObject Pe = null;   // Position vector: Pe


    // Start is called before the first frame update
    void Start()
    {
        Debug.Assert(P1 != null);   // Verify proper setting in the editor
        Debug.Assert(P2 != null);
        Debug.Assert(Pd != null);
        Debug.Assert(Pi != null);
        Debug.Assert(Pj != null);
        Debug.Assert(Pe != null);

        // To support visualizing the vectors
        ShowVd = new MyVector {
            VectorColor = Color.black,
            VectorAt    = Vector3.zero  // Always draw Vd from the origin
        };
        ShowVdAtP1 = new MyVector
        {
            VectorColor = new Color(0.9f, 0.9f, 0.9f)
        };

        // To support show vector from Pi to Pj as position vector
        ShowVe = new MyVector
        {
            VectorColor = new Color(0.2f, 0.0f, 0.2f),
            VectorAt    = Vector3.zero // Always draw Ve from the origin
        };
        ShowVeAtPi = new MyVector()
        {
            VectorColor = new Color(0.9f, 0.2f, 0.9f)
        };
    }
Beispiel #8
0
 public void FillTriangle(Color color, MyVector point1, MyVector point2, MyVector point3)
 {
     using (SolidBrush brush = new SolidBrush(color))
     {
         FillTriangle(brush, point1, point2, point3);
     }
 }
Beispiel #9
0
    public static Vector2 DrawLine(MyTexture OutTex, Brush _Brush, Color DrawColor, Vector2 Pos0, Vector2 Pos1)
    {
        MyVector Vect = new MyVector();

        DrawLine(OutTex, _Brush, new ByteColor(DrawColor), (int)Pos0.x, (int)Pos0.y, (int)Pos1.x, (int)Pos1.y, ref Vect);
        return(Vect);
    }
Beispiel #10
0
 public void FillPie(Color color, MyVector centerPoint, double radius, MyVector centerLine, double sweepRadians)
 {
     using (SolidBrush brush = new SolidBrush(color))
     {
         FillPie(brush, centerPoint, radius, centerLine, sweepRadians);
     }
 }
Beispiel #11
0
 public void FillPie(Color color, MyVector centerPoint, double radius, double startDegrees, double sweepDegrees)
 {
     using (SolidBrush brush = new SolidBrush(color))
     {
         FillPie(brush, centerPoint, radius, startDegrees, sweepDegrees);
     }
 }
Beispiel #12
0
 public void FillRectangle(Color color, MyVector lower, MyVector upper)
 {
     using (SolidBrush brush = new SolidBrush(color))
     {
         FillRectangle(brush, lower, upper);
     }
 }
Beispiel #13
0
 public void FillCircle(Color color, MyVector centerPoint, double radius)
 {
     using (SolidBrush brush = new SolidBrush(color))
     {
         FillCircle(brush, centerPoint, radius);
     }
 }
Beispiel #14
0
        private void radPolygon_CheckedChanged(object sender, EventArgs e)
        {
            const double POLYSIZE = 200d;

            lblNotes.Text = "";

            MyPolygon poly = null;

            // Get the polygon
            if (radCube.Checked)
            {
                poly = MyPolygon.CreateCube(POLYSIZE, true);
            }
            else if (radTetrahedron.Checked)
            {
                poly          = MyPolygon.CreateTetrahedron(POLYSIZE, true);
                lblNotes.Text = "Lengths:\n0,1=" + MyVector.Subtract(poly.UniquePoints[1], poly.UniquePoints[0]).GetMagnitude().ToString() + "\n0,2=" + MyVector.Subtract(poly.UniquePoints[2], poly.UniquePoints[0]).GetMagnitude().ToString() + "\n0,3=" + MyVector.Subtract(poly.UniquePoints[3], poly.UniquePoints[0]).GetMagnitude().ToString() + "\n1,2=" + MyVector.Subtract(poly.UniquePoints[2], poly.UniquePoints[1]).GetMagnitude().ToString() + "\n1,3=" + MyVector.Subtract(poly.UniquePoints[3], poly.UniquePoints[1]).GetMagnitude().ToString() + "\n2,3=" + MyVector.Subtract(poly.UniquePoints[3], poly.UniquePoints[2]).GetMagnitude().ToString();
            }
            else
            {
                _polygon = null;
                MessageBox.Show("Unknown Polygon", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Make a new solidball
            _polygon = new SolidBallPolygon(new MyVector(0, 0, 0), new DoubleVector(1, 0, 0, 0, 1, 0), poly, 10, 10);
        }
Beispiel #15
0
    private MyVector ShowPositionVector; // Position vector at the origin


    // Start is called before the first frame update
    void Start()
    {
        Debug.Assert(P1 != null);   // Check for proper setup in the editor
        Debug.Assert(P2 != null);
        Debug.Assert(SphereAtOrigin != null);

        // To support show position ad vector at P1
        ShowVa = new MyVector
        {
            VectorColor = Color.black
        };
        ShowNorm = new MyVector
        {
            VectorColor = new Color(0.9f, 0.9f, 0.9f)
        };
        ShowVaScaled = new MyVector
        {
            VectorColor = new Color(0.9f, 0.4f, 0.9f)
        };
        ShowPositionVector = new MyVector
        {
            VectorColor = new Color(0.4f, 0.9f, 0.9f),
            VectorAt    = Vector3.zero  // Position Vector at the origin
        };
    }
Beispiel #16
0
    public static Vector2 DrawLineWithTex(MyTexture OutTex, MyTexture PatternsTex, Brush _Brush, Vector2 Pos0, Vector2 Pos1)
    {
        MyVector Vect = new MyVector();

        DrawLineWithTex(OutTex, _Brush, PatternsTex, (int)Pos0.x, (int)Pos0.y, (int)Pos1.x, (int)Pos1.y, ref Vect);
        return(Vect);
    }
Beispiel #17
0
        void picturebox_MouseUp(object sender, MouseEventArgs e)
        {
            if (_mode == AddingMode.Inactive)
            {
                return;
            }

            if (_isMouseDown && e.Button == MouseButtons.Left)
            {
                _isMouseDown    = false;
                _mouseDownPoint = _picturebox.GetPositionViewToWorld(new MyVector(e.X, e.Y, 0));

                if (_drawingBall == null)
                {
                    _drawingBall = BuildObject();
                }

                if (_newBallProps.SizeMode == BallProps.SizeModes.Draw)
                {
                    CommitObject();
                }
                else
                {
                    _drawingBall.Position.StoreNewValues(_curMousePoint);

                    if (!WillCollide(_drawingBall) || !_createdBallDuringMouseDrag)
                    {
                        // It won't collide, or nothing has been created yet
                        CommitObject();         // I don't care about the draw rate during mouse up
                    }
                }

                _drawingBall = null;            // even if I didn't commit it, I still need to kill it now
            }
        }
Beispiel #18
0
        private void ResetFieldSprtSwirl(bool goLeft)
        {
            // Init the grid
            _grid = new MyVector[_squaresPerSideX * _squaresPerSideY];

            // I'm going to rotate everything 90 degrees
            MyVector rotateAxis = new MyVector(0, 0, 1);
            double   radians    = Math.PI / 2d;

            if (goLeft)
            {
                radians *= -1d;
            }

            foreach (MyVector center in GetGridCenters())
            {
                // Get the local position
                MyVector localPosition = center - _position;

                // Turn that into a constant length, pointing in or out
                MyVector fieldLine = localPosition.Clone();
                fieldLine.BecomeUnitVector();
                fieldLine.Multiply(_strength);
                fieldLine.RotateAroundAxis(rotateAxis, radians);

                // Store it
                _grid[GetIndexForLocalPosition(localPosition)] = fieldLine;
            }
        }
Beispiel #19
0
        private void StoreAngularVelocity(Ball ball)
        {
            if (!(ball is TorqueBall))
            {
                return;
            }

            MyVector angularVelocity;

            #region Calculate Angular Velocity

            switch (_newBallProps.AngularVelocityMode)
            {
            case BallProps.AngularVelocityModes.Fixed:
                angularVelocity = new MyVector(0, 0, _newBallProps.AngularVelocityIfFixed);
                break;

            case BallProps.AngularVelocityModes.Random:
                angularVelocity = new MyVector(0, 0, UtilityCore.GetScaledValue(_newBallProps.MinRandAngularVelocity, _newBallProps.MaxRandAngularVelocity, 0, 1, _rand.NextDouble()));
                break;

            default:
                throw new ApplicationException("Unknown BallProps.AngularVelocityModes: " + _newBallProps.AngularVelocityMode.ToString());
            }

            #endregion

            // Apply Angular Velocity
            ((TorqueBall)ball).SetAngularVelocity(angularVelocity);
        }
Beispiel #20
0
    // Start is called before the first frame update
    void Start()
    {
        Debug.Assert(Pn != null);   // Verify proper setting in the editor
        Debug.Assert(P0 != null);
        Debug.Assert(P1 != null);
        Debug.Assert(Pon != null);

        #region For visualizing the vectors
        // To support visualizing the vectors
        ShowNormal = new MyVector {
            VectorColor = Color.white
        };
        ShowPlane = new MyXZPlane
        {
            PlaneColor = new Color(0.8f, 0.3f, 0.3f, 1.0f),
            XSize      = 0.5f,
            YSize      = 0.5f,
            ZSize      = 0.5f
        };
        ShowLine = new MyLineSegment
        {
            VectorColor = Color.black,
            LineWidth   = 0.05f
        };
        ShowRestOfLine = new MyLineSegment
        {
            VectorColor = Color.red,
            LineWidth   = 0.05f
        };
        #endregion
    }
Beispiel #21
0
    // Start is called before the first frame update
    void Start()
    {
        Debug.Assert(P0 != null);   // Verify proper setting in the editor
        Debug.Assert(P1 != null);
        Debug.Assert(Pt != null);
        Debug.Assert(Pon != null);

        #region For visualizing the lines
        // To support visualizing the lines
        ShowLine = new MyLineSegment
        {
            VectorColor = MyDrawObject.NoCollisionColor,
            LineWidth   = 0.6f
        };
        ShowVc = new MyLineSegment
        {
            VectorColor = Color.black,
            LineWidth   = 0.05f
        };
        ShowV1 = new MyVector
        {
            VectorColor = Color.green
        };
        #endregion
    }
Beispiel #22
0
        static bool ParseCoords(string input, out MyVector vector, out string message)
        {
            vector = null;
            //Содержит числа введенные пользователем
            List <double> digits = new List <double>();

            string[] splitInput = input.Split(';', StringSplitOptions.RemoveEmptyEntries);

            if (splitInput.Length != 3)
            {
                message = "Неверное количество введенных чисел. Пожалуйста, введите 3 числа.";
                return(false);
            }

            foreach (var digitStr in splitInput)
            {
                if (!double.TryParse(digitStr, out var digit))
                {
                    message = $"Не удалось распознать число.\nПозиция: {input.IndexOf(digitStr) + 1}\nВвод: {digitStr}";
                    digits.Clear();
                    return(false);
                }
                digits.Add(digit);
            }

            message = null;
            vector  = new MyVector(digits[0], digits[1], digits[2]);

            return(true);
        }
Beispiel #23
0
    // Start is called before the first frame update
    void Start()
    {
        Debug.Assert(P0 != null);   // Verify proper setting in the editor
        Debug.Assert(P1 != null);
        Debug.Assert(P2 != null);

        #region For visualizing the vectors
        // To support visualizing the vectors
        ShowV1 = new MyVector {
            VectorColor = Color.cyan
        };
        ShowV2 = new MyVector
        {
            VectorColor = Color.magenta
        };
        ShowProjected = new MyLineSegment
        {
            VectorColor = PositiveColor
        };
        ShowProjectedAlone = new MyLineSegment
        {
            VectorColor = PositiveColor,
            VectorAt    = Vector3.zero,
            Direction   = Vector3.up
        };
        #endregion
    }
Beispiel #24
0
    public GameObject P2 = null;   // Position P2

    // Start is called before the first frame update
    void Start()
    {
        Debug.Assert(P0 != null);   // Verify proper setting in the editor
        Debug.Assert(P1 != null);
        Debug.Assert(P2 != null);

        #region For visualizing the vectors
        // To support visualizing the vectors
        ShowV1 = new MyVector {
            VectorColor = Color.cyan
        };
        ShowV2 = new MyVector
        {
            VectorColor = Color.magenta
        };
        ShowNV2 = new MyVector
        {
            VectorColor = Color.red
        };
        ShowV1_V2 = new MyVector
        {
            VectorColor = Color.gray
        };
        ShowV1_V2_Pos = new MyVector
        {
            VectorColor = Color.gray
        };

        #endregion
    }
Beispiel #25
0
        private void ThrusterBuildingTick()
        {
            MyVector centerPoint = GetMiddlePoint();

            DrawShipDesign(Color.DimGray, Color.Silver);

            if (_isMouseJustReleased)
            {
                _isMouseJustReleased = false;

                // They just created a thruster.  Add it to the list
                MyVector offset = new MyVector(_mouseDownPoint) - centerPoint;
                MyVector force  = new MyVector(_curMousePoint) - new MyVector(_mouseDownPoint);

                if (!_thrustersCustom.ContainsKey(_addThrusterTo))
                {
                    _thrustersCustom.Add(_addThrusterTo, new List <MyVector[]>());
                }

                _thrustersCustom[_addThrusterTo].Add(new MyVector[] { offset, force });
            }

            DrawThrustDesign(Color.Black, 1d);

            if (_isMouseDown)
            {
                DrawVector(new MyVector(_mouseDownPoint), new MyVector(_curMousePoint), Color.Yellow);
            }
        }
 /// <summary>
 /// Constructor that generates the neural network
 /// </summary>
 /// <param name="sizes">The list ``sizes`` contains the number of neurons in the respective
 ///  layers of the network.  For example, if the list was [2, 3, 1]
 ///  then it would be a three-layer network, with the first layer
 ///  containing 2 neurons, the second layer 3 neurons, and the
 ///  third layer 1 neuron.</param>
 public NeuralNetwork(int[] sizes)
 {
     //Initialize each weight using a Gaussian distribution with mean 0
     //and standard deviation 1 over the square root of the number of
     //weights connecting to the same neuron.  Initialize the biases
     //using a Gaussian distribution with mean 0 and standard
     //deviation 1.
     //Note that the first layer is assumed to be an input layer, and
     //by convention we won't set any biases for those neurons, since
     //biases are only ever used in computing the outputs from later
     //layers.
     m_biases    = new MyVector[sizes.Length];
     m_weights   = new My2DMatrix[sizes.Length];
     m_biases[0] = new MyVector(sizes[0]); // Just for the NumOfNeuronsInLayer
     for (int i = 1; i < sizes.Length; i++)
     {
         m_biases[i]  = new MyVector(sizes[i]);
         m_weights[i] = new My2DMatrix(sizes[i], sizes[i - 1]);
         for (int j = 0; j < sizes[i]; j++)
         {
             m_biases[i][j] = NextGaussianDistribution();
             for (int k = 0; k < sizes[i - 1]; k++)
             {
                 m_weights[i][j, k] = NextGaussianDistribution(0, 1.0 / Math.Sqrt(sizes[i - 1]));
             }
         }
     }
 }
Beispiel #27
0
        private void DrawShipRunning(Color massColor, Color massOutlineColor)
        {
            // Radius
            pictureBox1.DrawCircle(UtilityGDI.AlphaBlend(Color.DarkCyan, Color.Black, .5d), .5d, _ship.Position, _ship.Radius);

            // Point Masses
            SolidBrush massBrush = new SolidBrush(massColor);

            foreach (PointMass pointMass in _ship.PointMasses)
            {
                MyVector rotatedMass = _ship.Rotation.GetRotatedVector(pointMass.Position, true);

                pictureBox1.FillCircle(massBrush, _ship.Position + rotatedMass, pointMass.Mass);
                pictureBox1.DrawCircle(massOutlineColor, 1, _ship.Position + rotatedMass, pointMass.Mass);
            }

            massBrush.Dispose();

            // Orientation
            pictureBox1.DrawLine(Color.FromArgb(64, 64, 64), 1, _ship.Position, _ship.Position + (_ship.DirectionFacing.Standard * 100d));
            pictureBox1.DrawLine(Color.FromArgb(32, 32, 32), 1, _ship.Position, _ship.Position + (_ship.DirectionFacing.Orth * 100d));

            MyVector rotatedCenterMass = _ship.Rotation.GetRotatedVector(_ship.CenterOfMass, true);

            // Line from centerpoint to centermass
            pictureBox1.DrawLine(UtilityGDI.AlphaBlend(Color.DarkMagenta, Color.Black, .4d), 1, _ship.Position, _ship.Position + rotatedCenterMass);

            // Center Point
            pictureBox1.FillCircle(Color.DarkMagenta, _ship.Position, 2);

            // Center Mass
            pictureBox1.FillCircle(Color.HotPink, _ship.Position + rotatedCenterMass, 2);
        }
            public static MyVector UnitVector(int size, int index)
            {
                MyVector result = new MyVector(size);

                result[index] = 1;
                return(result);
            }
Beispiel #29
0
        private void PropsChangedSprtThrusters()
        {
            if (_type != ShipTypeQual.SolidBall)
            {
                return;  // the ball just has the thruster in the center
            }

            MyVector thrusterSeed = new MyVector(0, _ship.Ball.Radius, 0);
            MyVector zAxis        = new MyVector(0, 0, 1);

            // Bottom Thrusters
            _thrusterOffset_BottomRight = thrusterSeed.Clone();
            _thrusterOffset_BottomRight.RotateAroundAxis(zAxis, Utility3D.GetDegreesToRadians(_thrusterAngle * -1));

            _thrusterOffset_BottomLeft = thrusterSeed.Clone();
            _thrusterOffset_BottomLeft.RotateAroundAxis(zAxis, Utility3D.GetDegreesToRadians(_thrusterAngle));

            // Top Thrusters
            thrusterSeed             = new MyVector(0, _ship.Ball.Radius * -1, 0);
            _thrusterOffset_TopRight = thrusterSeed.Clone();
            _thrusterOffset_TopRight.RotateAroundAxis(zAxis, Utility3D.GetDegreesToRadians(_thrusterAngle));

            _thrusterOffset_TopLeft = thrusterSeed.Clone();
            _thrusterOffset_TopLeft.RotateAroundAxis(zAxis, Utility3D.GetDegreesToRadians(_thrusterAngle * -1));
        }
Beispiel #30
0
        private void AddMultiBall(double radius, double mass)
        {
            // Physical Ball
            MyVector     pos       = Utility3D.GetRandomVector(BOUNDRY);
            DoubleVector dirFacing = new DoubleVector(1, 0, 0, 0, 1, 0);

            Ball ball = new Ball(pos, dirFacing, radius, mass, ELASTICITY, KINETICFRICTION, STATICFRICTION, _boundryLower, _boundryUpper);

            BallBlip blip = new BallBlip(ball, CollisionStyle.Standard, RadarBlipQual.BallUserDefined00, TokenGenerator.NextToken());

            _map.Add(blip);

            // WPF Rendering
            Geometry3D      geometry      = UtilityWPF.GetSphere(5, radius);
            Material        material      = new DiffuseMaterial(new SolidColorBrush(Color.FromArgb(255, Convert.ToByte(_rand.Next(256)), Convert.ToByte(_rand.Next(256)), Convert.ToByte(_rand.Next(256)))));
            GeometryModel3D geometryModel = new GeometryModel3D(geometry, material);

            geometryModel.Transform = new Transform3DGroup();

            //TODO:  Tie this transform directly to the ball's velocity (the shpere class should take the transform group)
            Transform3DGroup group = geometryModel.Transform as Transform3DGroup;

            group.Children.Clear();
            group.Children.Add(new TranslateTransform3D(pos.X, pos.Y, pos.Z));

            _geometries.Add(geometryModel);
            _modelGroup.Children.Add(geometryModel);
        }