public void UpdateShake(float timeStep, ref Vector3 outPos, ref Vector3 outDir)
        {
            if (!m_Shake)
            {
                return;
            }

            // camera shake (dir,up,pos)
            m_ShakePos.X *= MyMwcUtils.GetRandomSign();
            m_ShakePos.Y *= MyMwcUtils.GetRandomSign();
            m_ShakePos.Z *= MyMwcUtils.GetRandomSign();

            outPos.X += m_ShakePos.X * (Math.Abs(m_ShakePos.X)) * m_Reduction;
            outPos.Y += m_ShakePos.Y * (Math.Abs(m_ShakePos.Y)) * m_Reduction;
            outPos.Z += m_ShakePos.Z * (Math.Abs(m_ShakePos.Z)) * m_Reduction;

            m_ShakeDir.X *= MyMwcUtils.GetRandomSign();
            m_ShakeDir.Y *= MyMwcUtils.GetRandomSign();
            m_ShakeDir.Z *= MyMwcUtils.GetRandomSign();

            outDir.X += m_ShakeDir.X * (Math.Abs(m_ShakeDir.X)) * 100;
            outDir.Y += m_ShakeDir.Y * (Math.Abs(m_ShakeDir.Y)) * 100;
            outDir.Z += m_ShakeDir.Z * (Math.Abs(m_ShakeDir.Z)) * 100;

            outDir *= m_Reduction;

            m_CurrentShakePosPower *= (float)Math.Pow(m_Damping, timeStep * 60.0f);
            m_CurrentShakeDirPower *= (float)Math.Pow(m_Damping, timeStep * 60.0f);

            if (m_CurrentShakeDirPower < 0.0f)
            {
                m_CurrentShakeDirPower = 0.0f;
            }

            if (m_CurrentShakePosPower < 0.0f)
            {
                m_CurrentShakePosPower = 0.0f;
            }

            m_ShakePos = new Vector3(m_CurrentShakePosPower * m_MaxShakePos, m_CurrentShakePosPower * m_MaxShakePos, m_CurrentShakePosPower * m_MaxShakePos);
            m_ShakeDir = new Vector3(m_CurrentShakeDirPower * m_MaxShakeDir, 0.0f, m_CurrentShakeDirPower * m_MaxShakeDir);

            if (m_CurrentShakeDirPower < m_OffConstant && m_CurrentShakePosPower < m_OffConstant)
            {
                m_CurrentShakeDirPower = 0.0f;
                m_CurrentShakePosPower = 0.0f;
                m_Shake = false;
            }
        }
Beispiel #2
0
        public static void LoadContent()
        {
            MyMwcLog.WriteLine("MySunWind.LoadContent() - START");
            MyMwcLog.IncreaseIndent();
            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("MySunwind::LoadContent");

            //  Large billboards
            m_largeBillboards = new MySunWindBillboard[MySunWindConstants.LARGE_BILLBOARDS_SIZE.X][];
            for (int x = 0; x < MySunWindConstants.LARGE_BILLBOARDS_SIZE.X; x++)
            {
                m_largeBillboards[x] = new MySunWindBillboard[MySunWindConstants.LARGE_BILLBOARDS_SIZE.Y];
                for (int y = 0; y < MySunWindConstants.LARGE_BILLBOARDS_SIZE.Y; y++)
                {
                    m_largeBillboards[x][y] = new MySunWindBillboard();
                    MySunWindBillboard billboard = m_largeBillboards[x][y];

                    billboard.Radius        = MyMwcUtils.GetRandomFloat(MySunWindConstants.LARGE_BILLBOARD_RADIUS_MIN, MySunWindConstants.LARGE_BILLBOARD_RADIUS_MAX);
                    billboard.InitialAngle  = MyMwcUtils.GetRandomRadian();
                    billboard.RotationSpeed = MyMwcUtils.GetRandomSign() * MyMwcUtils.GetRandomFloat(MySunWindConstants.LARGE_BILLBOARD_ROTATION_SPEED_MIN, MySunWindConstants.LARGE_BILLBOARD_ROTATION_SPEED_MAX);

                    //billboard.Color = MySunWindConstants.BILLBOARD_COLOR;
                    //billboard.Color.X = MyMwcUtils.GetRandomFloat(0.5f, 3);
                    //billboard.Color.Y = MyMwcUtils.GetRandomFloat(0.5f, 2);
                    //billboard.Color.Z = MyMwcUtils.GetRandomFloat(0.5f, 2);
                    //billboard.Color.W = MyMwcUtils.GetRandomFloat(0.5f, 2);
                    billboard.Color.X = MyMwcUtils.GetRandomFloat(0.5f, 3);
                    billboard.Color.Y = MyMwcUtils.GetRandomFloat(0.5f, 1);
                    billboard.Color.Z = MyMwcUtils.GetRandomFloat(0.5f, 1);
                    billboard.Color.W = MyMwcUtils.GetRandomFloat(0.5f, 1);
                }
            }

            //  Small billboards
            m_smallBillboards = new MySunWindBillboardSmall[MySunWindConstants.SMALL_BILLBOARDS_SIZE.X][];
            for (int x = 0; x < MySunWindConstants.SMALL_BILLBOARDS_SIZE.X; x++)
            {
                m_smallBillboards[x] = new MySunWindBillboardSmall[MySunWindConstants.SMALL_BILLBOARDS_SIZE.Y];
                for (int y = 0; y < MySunWindConstants.SMALL_BILLBOARDS_SIZE.Y; y++)
                {
                    m_smallBillboards[x][y] = new MySunWindBillboardSmall();
                    MySunWindBillboardSmall billboard = m_smallBillboards[x][y];

                    billboard.Radius        = MyMwcUtils.GetRandomFloat(MySunWindConstants.SMALL_BILLBOARD_RADIUS_MIN, MySunWindConstants.SMALL_BILLBOARD_RADIUS_MAX);
                    billboard.InitialAngle  = MyMwcUtils.GetRandomRadian();
                    billboard.RotationSpeed = MyMwcUtils.GetRandomSign() * MyMwcUtils.GetRandomFloat(MySunWindConstants.SMALL_BILLBOARD_ROTATION_SPEED_MIN, MySunWindConstants.SMALL_BILLBOARD_ROTATION_SPEED_MAX);

                    //billboard.Color = MySunWindConstants.BILLBOARD_COLOR;
                    billboard.Color.X = MyMwcUtils.GetRandomFloat(0.5f, 1);
                    billboard.Color.Y = MyMwcUtils.GetRandomFloat(0.2f, 0.5f);
                    billboard.Color.Z = MyMwcUtils.GetRandomFloat(0.2f, 0.5f);
                    billboard.Color.W = MyMwcUtils.GetRandomFloat(0.1f, 0.5f);

                    billboard.TailBillboardsCount    = MyMwcUtils.GetRandomInt(MySunWindConstants.SMALL_BILLBOARD_TAIL_COUNT_MIN, MySunWindConstants.SMALL_BILLBOARD_TAIL_COUNT_MAX);
                    billboard.TailBillboardsDistance = MyMwcUtils.GetRandomFloat(MySunWindConstants.SMALL_BILLBOARD_TAIL_DISTANCE_MIN, MySunWindConstants.SMALL_BILLBOARD_TAIL_DISTANCE_MAX);

                    billboard.RadiusScales = new float[billboard.TailBillboardsCount];
                    for (int i = 0; i < billboard.TailBillboardsCount; i++)
                    {
                        billboard.RadiusScales[i] = MyMwcUtils.GetRandomFloat(0.7f, 1.0f);
                    }
                }
            }

            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();
            MyMwcLog.DecreaseIndent();
            MyMwcLog.WriteLine("MySunWind.LoadContent() - END");
        }