Beispiel #1
0
        public override void UpdateViewMatrix()
        {
            Vector3 rel    = SphereHelper.BuildVector(m_theata, m_phi, m_radius);
            Vector3 camPos = m_targetPos + rel;

            // Get Up Vector
            Vector3 up;

            if (m_theata < 0.1)
            {
                double alteredPhi = m_phi + MathHelper.Pi;
                if (alteredPhi > MathHelper.TwoPi)
                {
                    alteredPhi -= MathHelper.TwoPi;
                }

                up = SphereHelper.BuildVector(m_theata, alteredPhi, m_radius);
            }
            else
            {
                double alteredTheate = m_theata - 0.1f;
                up = SphereHelper.BuildVector(alteredTheate, m_phi, m_radius);
            }

            up -= rel;
            up.Normalize();

            m_viewMatrix = Matrix.CreateLookAt(camPos, m_targetPos, up);
        }
Beispiel #2
0
        private void UpdateSetup(GameTime gameTime)
        {
            attempts++;

            // Spawn Balls
            while (m_BallList.Count < BALL_COUNT)
            {
                // Get Radius
                double rad = m_random.NextDouble() + 0.6;
                rad = CRUST_RADIUS; // Math.Sin(rad * rad) * CRUST_RADIUS;

                // Get Theta (3 o clock)
                double theta = m_random.NextDouble() * MathHelper.Pi;
                double phi   = m_random.NextDouble() * MathHelper.TwoPi;

                m_BallList.Add(new StickyBall(SphereHelper.BuildVector(theta, phi, rad)));
            }

            if (UpdateIslandConfig(gameTime, 1) == false)
            {
                return;
            }

            float minForce = -1;
            float maxForce = -1;

            for (int x = 0; x < 40; x++)
            {
                for (int y = 0; y < 40; y++)
                {
                    for (int z = 0; z < 40; z++)
                    {
                        Vector3 tPoint = new Vector3(
                            x * 5.0f - 100.0f,
                            y * 5.0f - 100.0f,
                            z * 5.0f - 100.0f);

                        m_GravityPoints[x, y, z] = CalcGravity(tPoint);

                        float strength = m_GravityPoints[x, y, z].Length();
                        m_GravityPoints[x, y, z].Normalize();

                        if (maxForce < 0)
                        {
                            minForce = strength;
                            maxForce = strength;
                        }
                        else
                        {
                            if (minForce > strength)
                            {
                                minForce = strength;
                            }
                            if (maxForce < strength)
                            {
                                maxForce = strength;
                            }
                        }
                    }
                }
            }

            // UpdateIslandConfig(gameTime, 10);

            m_eGameState = eGameState.GS_Playing;
        }