Exemplo n.º 1
0
 public MyFactionProperties(
     MyTextsWrapperEnum NameEnum,
     MyTextsWrapperEnum DescriptionEnum,
     MyTransparentMaterialEnum? SolarMapIcon)
 {
     this.NameEnum = NameEnum;
     this.DescriptionEnum = DescriptionEnum;
     this.SolarMapIcon = SolarMapIcon;
 }
Exemplo n.º 2
0
 //  This method initializes parameters common for all type of particle
 void Start(MyTransparentMaterialEnum material, int lifespanInMiliseconds,
     Vector3 startPosition, Vector3 velocity, Vector4 startColor, Vector4 endColor)
 {
     m_timeStarted = MyMinerGame.TotalGamePlayTimeInMilliseconds;
     m_lifespanInMiliseconds = lifespanInMiliseconds;
     m_startPosition = startPosition;
     m_velocity = velocity;
     m_startColor = startColor;
     m_endColor = endColor;
     m_materialEnum = material;
 }
Exemplo n.º 3
0
 //  This method initializes parameters common for all type of particle
 void Start(MyTransparentMaterialEnum material, int lifespanInMiliseconds,
            Vector3 startPosition, Vector3 velocity, Vector4 startColor, Vector4 endColor)
 {
     m_timeStarted           = MyMinerGame.TotalGamePlayTimeInMilliseconds;
     m_lifespanInMiliseconds = lifespanInMiliseconds;
     m_startPosition         = startPosition;
     m_velocity     = velocity;
     m_startColor   = startColor;
     m_endColor     = endColor;
     m_materialEnum = material;
 }
Exemplo n.º 4
0
 public MySolarSystemMapNavigationMark(MyMwcVector3Int sector, string name, MyMissionID?missionID, Color color, MyTransparentMaterialEnum texture)
 {
     Sector           = sector;
     Name             = name;
     Color            = color;
     Texture          = texture;
     Importance       = 1;
     DrawVerticalLine = true;
     MissionID        = missionID;
     Font             = MyGuiManager.GetFontMinerWarsWhite();
 }
Exemplo n.º 5
0
        //  This method realy initiates/starts the particle
        //  IMPORTANT: Direction vector must be normalized!
        public void StartPointParticle(
            MyTransparentMaterialEnum material, int lifespanInMiliseconds, Vector3 startPosition, Vector3 velocity, 
            Vector4 startColor, Vector4 endColor, float startAngle, float startRadius, float endRadius, float rotationSpeed)
        {
            Start(material, lifespanInMiliseconds, startPosition, velocity, startColor, endColor);

            m_type = MyParticleType.POINT_PARTICLE;
            m_pointSpecific_startAngle = startAngle;
            m_pointSpecific_startRadius = startRadius;
            m_pointSpecific_endRadius = endRadius;
            m_pointSpecific_rotationSpeed = rotationSpeed;
        }
Exemplo n.º 6
0
        //  This method realy initiates/starts the particle
        //  IMPORTANT: Direction vector must be normalized!
        public void StartLineParticle(
            MyTransparentMaterialEnum material, int lifespanInMiliseconds, Vector3 startPosition, Vector3 velocity,
            Vector4 startColor, Vector4 endColor, Vector3 directionNormalized, float thickness, float startLength, float endLength)
        {
            Start(material, lifespanInMiliseconds, startPosition, velocity, startColor, endColor);

            m_type = MyParticleType.LINE_PARTICLE;
            m_lineSpecific_directionNormalized = directionNormalized;
            m_lineSpecific_thickness           = thickness;
            m_lineSpecific_startLength         = startLength;
            m_lineSpecific_endLength           = endLength;
        }
Exemplo n.º 7
0
        //  This method realy initiates/starts the particle
        //  IMPORTANT: Direction vector must be normalized!
        public void StartPointParticle(
            MyTransparentMaterialEnum material, int lifespanInMiliseconds, Vector3 startPosition, Vector3 velocity,
            Vector4 startColor, Vector4 endColor, float startAngle, float startRadius, float endRadius, float rotationSpeed)
        {
            Start(material, lifespanInMiliseconds, startPosition, velocity, startColor, endColor);

            m_type = MyParticleType.POINT_PARTICLE;
            m_pointSpecific_startAngle    = startAngle;
            m_pointSpecific_startRadius   = startRadius;
            m_pointSpecific_endRadius     = endRadius;
            m_pointSpecific_rotationSpeed = rotationSpeed;
        }
Exemplo n.º 8
0
        //  This method realy initiates/starts the particle
        //  IMPORTANT: Direction vector must be normalized!
        public void StartLineParticleRelativeToPhysObject(
            MyTransparentMaterialEnum material, int lifespanInMiliseconds, Vector3 startPosition, Vector3 velocity,
            Vector4 startColor, Vector4 endColor, Vector3 directionNormalized, float thickness, float startLength, float endLength,
            MyEntity physObject)
        {
            Start(material, lifespanInMiliseconds, startPosition, velocity, startColor, endColor);

            m_type = MyParticleType.LINE_PARTICLE_RELATIVE_TO_PHYS_OBJECT;
            m_lineSpecific_directionNormalized = directionNormalized;
            m_lineSpecific_thickness           = thickness;
            m_lineSpecific_startLength         = startLength;
            m_lineSpecific_endLength           = endLength;
            m_physObject = physObject;
        }
Exemplo n.º 9
0
        //  This method realy initiates/starts the particle
        //  IMPORTANT: Direction vector must be normalized!
        public void StartPointParticleRelativeToPhysObject(
            MyTransparentMaterialEnum material, int lifespanInMiliseconds, Vector3 startPosition, Vector3 velocity,
            Vector4 startColor, Vector4 endColor, float startAngle, float startRadius, float endRadius, float rotationSpeed,
            MyEntity physObject)
        {
            Start(material, lifespanInMiliseconds, startPosition, velocity, startColor, endColor);

            m_type = MyParticleType.POINT_PARTICLE_RELATIVE_TO_PHYS_OBJECT;
            m_pointSpecific_startAngle    = startAngle;
            m_pointSpecific_startRadius   = startRadius;
            m_pointSpecific_endRadius     = endRadius;
            m_pointSpecific_rotationSpeed = rotationSpeed;

            m_physObject = physObject;
        }
Exemplo n.º 10
0
        //  This method is like a constructor (which we can't use because billboards are allocated from a pool).
        //  It starts/initializes a billboard. Refs used only for optimalization
        public void Start(ref MyQuad quad, MyTransparentMaterialEnum materialEnum, MyTransparentMaterialEnum blendMaterial, float textureBlendRatio,
                          ref Vector4 color, ref Vector3 origin, Vector2 uvOffset, bool colorize = false, bool near = false, bool lowres = false)
        {
            MaterialEnum      = materialEnum;
            BlendMaterial     = blendMaterial;
            BlendTextureRatio = textureBlendRatio;

            MyUtils.AssertIsValid(quad.Point0);
            MyUtils.AssertIsValid(quad.Point1);
            MyUtils.AssertIsValid(quad.Point2);
            MyUtils.AssertIsValid(quad.Point3);


            //  Billboard vertexes
            Position0 = quad.Point0;
            Position1 = quad.Point1;
            Position2 = quad.Point2;
            Position3 = quad.Point3;

            UVOffset = uvOffset;

            EnableColorize = colorize;

            if (EnableColorize)
            {
                Size = (Position0 - Position2).Length();
            }

            //  Distance for sorting
            //  IMPORTANT: Must be calculated before we do color and alpha misting, because we need distance there
            DistanceSquared = Vector3.DistanceSquared(MyCamera.Position, origin);

            //  Color
            Color = color;

            Near   = near;
            Lowres = lowres;

            //  Alpha depends on distance to camera. Very close bilboards are more transparent, so player won't see billboard errors or rotating billboards
            var mat = MyTransparentMaterialConstants.GetMaterialProperties(MaterialEnum);

            if (mat.AlphaMistingEnable)
            {
                Color *= MathHelper.Clamp(((float)Math.Sqrt(DistanceSquared) - mat.AlphaMistingStart) / (mat.AlphaMistingEnd - mat.AlphaMistingStart), 0, 1);
            }

            ContainedBillboards.Clear();
        }
Exemplo n.º 11
0
        //  This method is like a constructor (which we can't use because billboards are allocated from a pool).
        //  It starts/initializes a billboard. Refs used only for optimalization
        public void Start(ref MyQuad quad, MyTransparentMaterialEnum materialEnum, MyTransparentMaterialEnum blendMaterial, float textureBlendRatio,
        ref Vector4 color, ref Vector3 origin, Vector2 uvOffset, bool colorize = false, bool near = false, bool lowres = false)
        {
            MaterialEnum = materialEnum;
            BlendMaterial = blendMaterial;
            BlendTextureRatio = textureBlendRatio;

            MyUtils.AssertIsValid(quad.Point0);
            MyUtils.AssertIsValid(quad.Point1);
            MyUtils.AssertIsValid(quad.Point2);
            MyUtils.AssertIsValid(quad.Point3);
            

            //  Billboard vertexes
            Position0 = quad.Point0;
            Position1 = quad.Point1;
            Position2 = quad.Point2;
            Position3 = quad.Point3;

            UVOffset = uvOffset;

            EnableColorize = colorize;

            if (EnableColorize)
                Size = (Position0 - Position2).Length();

            //  Distance for sorting
            //  IMPORTANT: Must be calculated before we do color and alpha misting, because we need distance there
            DistanceSquared = Vector3.DistanceSquared(MyCamera.Position, origin);

            //  Color
            Color = color;

            Near = near;
            Lowres = lowres;

            //  Alpha depends on distance to camera. Very close bilboards are more transparent, so player won't see billboard errors or rotating billboards
            var mat = MyTransparentMaterialConstants.GetMaterialProperties(MaterialEnum);
            if (mat.AlphaMistingEnable)
                Color *= MathHelper.Clamp(((float)Math.Sqrt(DistanceSquared) - mat.AlphaMistingStart) / (mat.AlphaMistingEnd - mat.AlphaMistingStart), 0, 1);

            ContainedBillboards.Clear();
        }
Exemplo n.º 12
0
        public static void DrawTransparentCylinder(ref Matrix worldMatrix, float radius1, float radius2, float length, ref Vector4 vctColor, bool bWireFramed, int wireDivideRatio, float thickness, MyTransparentMaterialEnum? lineMaterial = null)
        {
            Vector3 vertexEnd = Vector3.Zero;
            Vector3 vertexStart = Vector3.Zero;

            Vector3 previousEnd = Vector3.Zero;
            Vector3 previousStart = Vector3.Zero;

            float angleStep = 360.0f / (float)wireDivideRatio;
            float alpha = 0;

            for (int i = 0; i <= wireDivideRatio; i++)
            {
                alpha = (float)i * angleStep;

                vertexEnd.X = (float)(radius1 * Math.Cos(MathHelper.ToRadians(alpha)));
                vertexEnd.Y = length/2;
                vertexEnd.Z = (float)(radius1 * Math.Sin(MathHelper.ToRadians(alpha)));

                vertexStart.X = (float)(radius2 * Math.Cos(MathHelper.ToRadians(alpha)));
                vertexStart.Y = -length / 2;
                vertexStart.Z = (float)(radius2 * Math.Sin(MathHelper.ToRadians(alpha)));

                vertexEnd = Vector3.Transform(vertexEnd, worldMatrix);
                vertexStart = Vector3.Transform(vertexStart, worldMatrix);

                DrawLine(vertexStart, vertexEnd, lineMaterial ?? MyTransparentMaterialEnum.ProjectileTrailLine, ref vctColor, thickness);

                if (i > 0)
                {
                    DrawLine(previousStart, vertexStart, lineMaterial ?? MyTransparentMaterialEnum.ProjectileTrailLine, ref vctColor, thickness);
                    DrawLine(previousEnd, vertexEnd, lineMaterial ?? MyTransparentMaterialEnum.ProjectileTrailLine, ref vctColor, thickness);
                }

                previousStart = vertexStart;
                previousEnd = vertexEnd;
            }
        }
Exemplo n.º 13
0
        public static void DrawLine(Vector3 start, Vector3 end, MyTransparentMaterialEnum? material, ref Vector4 color, float thickness)
        {
            Vector3 dir = end - start;
            float len = dir.Length();
            if (len > 0.1f)
            {
                dir = MyMwcUtils.Normalize(dir);

                MyTransparentGeometry.AddLineBillboard(material ?? MyTransparentMaterialEnum.ProjectileTrailLine, color, start, dir, len, thickness);
            }        
        }
Exemplo n.º 14
0
        //  This method realy initiates/starts the particle
        //  IMPORTANT: Direction vector must be normalized!
        public void StartPointParticleRelativeToPhysObject(
            MyTransparentMaterialEnum material, int lifespanInMiliseconds, Vector3 startPosition, Vector3 velocity, 
            Vector4 startColor, Vector4 endColor, float startAngle, float startRadius, float endRadius, float rotationSpeed, 
            MyEntity physObject)
        {
            Start(material, lifespanInMiliseconds, startPosition, velocity, startColor, endColor);

            m_type = MyParticleType.POINT_PARTICLE_RELATIVE_TO_PHYS_OBJECT;
            m_pointSpecific_startAngle = startAngle;
            m_pointSpecific_startRadius = startRadius;
            m_pointSpecific_endRadius = endRadius;
            m_pointSpecific_rotationSpeed = rotationSpeed;

            m_physObject = physObject;
        }
Exemplo n.º 15
0
        public static void DrawTransparentPyramid(ref Vector3 start, ref MyQuad backQuad, ref Vector4 vctColor, int divideRatio, float thickness, MyTransparentMaterialEnum? lineMaterial = null) 
        {
            Vector3 vctZero = Vector3.Zero;            
            m_lineBuffer.Clear();
            GenerateLines(start, backQuad.Point0, backQuad.Point1, ref m_lineBuffer, divideRatio);
            GenerateLines(start, backQuad.Point1, backQuad.Point2, ref m_lineBuffer, divideRatio);
            GenerateLines(start, backQuad.Point2, backQuad.Point3, ref m_lineBuffer, divideRatio);
            GenerateLines(start, backQuad.Point3, backQuad.Point0, ref m_lineBuffer, divideRatio);

            foreach (MyLine line in m_lineBuffer) 
            {
                Vector3 dir = line.To - line.From;
                float len = dir.Length();
                if (len > 0.1f)
                {
                    dir = MyMwcUtils.Normalize(dir);

                    MyTransparentGeometry.AddLineBillboard(lineMaterial ?? MyTransparentMaterialEnum.ProjectileTrailLine, vctColor, line.From, dir, len, thickness);
                }
            }
        }
Exemplo n.º 16
0
 public void Start(ref MyQuad quad, MyTransparentMaterialEnum materialEnum, MyTransparentMaterialEnum blendMaterial, float textureBlendRatio,
 ref Vector4 color, ref Vector3 origin, bool colorize = false, bool near = false, bool lowres = false)
 {
     Start(ref quad, materialEnum, blendMaterial, textureBlendRatio, ref color, ref origin, Vector2.Zero, colorize, near, lowres);
 }
Exemplo n.º 17
0
        private void AddLineBillboardUnscaling(MyTransparentMaterialEnum material,
            Vector4 color, Vector3 origin, Vector3 directionNormalized, float length, float thicknessWhen1mFromCamera, float minDistFromCamera, int priority = 0)
        {
            Vector3 linePtB = origin + directionNormalized * length;
            Vector3 cameraPos = Vector3.Zero;

            float dist = MyUtils.GetPointLineDistance(ref origin, ref linePtB, ref cameraPos);
            if (dist < minDistFromCamera)
            {
                return;
            }

            //float thickness = (m_setup.CameraPosition.Value - origin).Length() * thicknessWhen1mFromCamera;
            float thickness = dist * thicknessWhen1mFromCamera;
            thickness = Math.Max(0.0000005f, thickness);
            MyTransparentGeometry.AddLineBillboard(material, color, origin, directionNormalized, length, thickness, priority);
        }
Exemplo n.º 18
0
        //  This method realy initiates/starts the particle
        //  IMPORTANT: Direction vector must be normalized!
        public void StartLineParticle(
            MyTransparentMaterialEnum material, int lifespanInMiliseconds, Vector3 startPosition, Vector3 velocity, 
            Vector4 startColor, Vector4 endColor, Vector3 directionNormalized, float thickness, float startLength, float endLength)
        {
            Start(material, lifespanInMiliseconds, startPosition, velocity, startColor, endColor);

            m_type = MyParticleType.LINE_PARTICLE;
            m_lineSpecific_directionNormalized = directionNormalized;
            m_lineSpecific_thickness = thickness;
            m_lineSpecific_startLength = startLength;
            m_lineSpecific_endLength = endLength;
        }
Exemplo n.º 19
0
        /// <summary>
        /// DrawTransparentSphere
        /// </summary>
        /// <param name="vctPos"></param>
        /// <param name="radius"></param>
        /// <param name="vctColor"></param>
        /// <param name="bWireFramed"></param>
        /// <param name="wireDivideRatio"></param>
        public static void DrawTransparentSphere(ref Matrix worldMatrix, float radius, ref Vector4 vctColor, bool bWireFramed, int wireDivideRatio, MyTransparentMaterialEnum? faceMaterial = null, MyTransparentMaterialEnum? lineMaterial = null)
        {
            if (!lineMaterial.HasValue)
            {
                lineMaterial = MyTransparentMaterialEnum.ProjectileTrailLine;
            }

            m_verticesBuffer.Clear();
            MyMeshHelper.GenerateSphere(ref worldMatrix, radius, wireDivideRatio, m_verticesBuffer);
            Vector3 vctZero = Vector3.Zero;

            float thickness = radius * 0.01f;
            int i = 0;
            for (i = 0; i < m_verticesBuffer.Count; i += 4)
            {
                MyQuad quad;
                quad.Point0 = m_verticesBuffer[i + 1];
                quad.Point1 = m_verticesBuffer[i + 3];
                quad.Point2 = m_verticesBuffer[i + 2];
                quad.Point3 = m_verticesBuffer[i];

                MyTransparentGeometry.AddQuad(faceMaterial ?? MyTransparentMaterialEnum.ContainerBorder, ref quad, ref vctColor, ref vctZero);
                if (bWireFramed)
                {

                    //@ 20 - lifespan for 1 update in 60FPPS
                    Vector3 start = quad.Point0;
                    Vector3 dir = quad.Point1 - start;
                    float len = dir.Length();
                    if (len > 0.1f)
                    {
                        dir = MyMwcUtils.Normalize(dir);

                        MyTransparentGeometry.AddLineBillboard(lineMaterial.Value, vctColor, start, dir,len,thickness);
                    }

                    start = quad.Point1;
                    dir = quad.Point2 - start;
                    len = dir.Length();
                    if (len > 0.1f)
                    {
                        dir = MyMwcUtils.Normalize(dir);

                        MyTransparentGeometry.AddLineBillboard(lineMaterial.Value, vctColor, start, dir, len, thickness);
                    }

                    /*start = quad.Point2;
                    dir = quad.Point3 - start;
                    len = dir.Length();
                    if (len > 0.1f)
                    {
                        dir = MyMwcUtils.Normalize(dir);
                        newParticle3.StartLineParticle(lineMaterial.Value, false, 20, start, Vector3.Zero, vctColor, vctColor, dir, thickness, len, len, false, MyParticlesConstants.SOFT_PARTICLE_DISTANCE_SCALE_FOR_HARD_PARTICLES);
                    }

                    start = quad.Point3;
                    dir = quad.Point1 - start;
                    len = dir.Length();
                    if (len > 0.1f)
                    {
                        dir = MyMwcUtils.Normalize(dir);
                        newParticle4.StartLineParticle(lineMaterial.Value, false, 20, start, Vector3.Zero, vctColor, vctColor, dir, thickness, len, len, false, MyParticlesConstants.SOFT_PARTICLE_DISTANCE_SCALE_FOR_HARD_PARTICLES);
                    }*/
                }
            }
        }
Exemplo n.º 20
0
 private void AddPointBillboardOrientedUnscaling(MyTransparentMaterialEnum material, Vector4 color, Vector3 origin, Vector3 left, Vector3 up, float radiusWhen1mFromCamera, float angle, int priority = 0)
 {
     float radius = MySolarSystemUtils.CalculateDistanceUnscaling(origin, radiusWhen1mFromCamera);
     MyTransparentGeometry.AddBillboardOriented(material, color, origin, left, up, radius, priority);
 }
Exemplo n.º 21
0
        /// <summary>
        /// DrawWireFramedBox
        /// </summary>
        /// <param name="worldMatrix"></param>
        /// <param name="localbox"></param>
        /// <param name="vctColor"></param>
        /// <param name="bWireFramed"></param>
        /// <param name="wireDivideRatio"></param>
        /// <param name="wireDivideRatio"></param>
        public static void DrawWireFramedBox(ref Matrix worldMatrix, ref BoundingBox localbox, ref Vector4 vctColor, float fThickRatio, int wireDivideRatio, MyTransparentMaterialEnum? lineMaterial = null)
        {
            if (!lineMaterial.HasValue)
            {
                lineMaterial = MyTransparentMaterialEnum.ProjectileTrailLine;
            }

            m_lineBuffer.Clear();

            //@ generate linnes for Front Side
            Vector3 translation = worldMatrix.Translation;

            Matrix orientation = Matrix.Identity;
            orientation.Forward = worldMatrix.Forward;
            orientation.Up = worldMatrix.Up;
            orientation.Right = worldMatrix.Right;

            float width = System.Math.Max(0.1f, localbox.Max.X - localbox.Min.X);
            float height = System.Math.Max(0.1f, localbox.Max.Y - localbox.Min.Y);
            float deep = System.Math.Max(0.1f, localbox.Max.Z - localbox.Min.Z);

            //@ ForntSide
            Vector3 vctStart = localbox.Min;
            Vector3 vctEnd = vctStart + Vector3.Up * height;
            Vector3 vctSideStep = Vector3.Right * (width / wireDivideRatio);
            GenerateLines(vctStart, vctEnd, ref vctSideStep, ref worldMatrix, ref m_lineBuffer, wireDivideRatio);
            // BackSide
            vctStart += Vector3.Backward * deep;
            vctEnd = vctStart + Vector3.Up * height;
            GenerateLines(vctStart, vctEnd, ref vctSideStep, ref worldMatrix, ref m_lineBuffer, wireDivideRatio);

            //@ FrontSide
            vctStart = localbox.Min;
            vctEnd = vctStart + Vector3.Right * width;
            vctSideStep = Vector3.Up * (height / wireDivideRatio);
            GenerateLines(vctStart, vctEnd, ref vctSideStep, ref worldMatrix, ref m_lineBuffer, wireDivideRatio);
            //@ BactSide
            vctStart += Vector3.Backward * deep;
            vctEnd += Vector3.Backward * deep;
            GenerateLines(vctStart, vctEnd, ref vctSideStep, ref worldMatrix, ref m_lineBuffer, wireDivideRatio);



            Matrix rotMat = Matrix.CreateRotationY(MathHelper.ToRadians(90f));
            Matrix rotated = rotMat * worldMatrix;

            //@ LeftSide
            vctStart = localbox.Min;
            vctEnd = vctStart + Vector3.Backward * deep;
            vctSideStep = Vector3.Up * (height / wireDivideRatio);
            GenerateLines(vctStart, vctEnd, ref vctSideStep, ref worldMatrix, ref m_lineBuffer, wireDivideRatio);
            // RightSide
            vctStart = localbox.Min;
            vctStart += Vector3.Right * width;
            vctEnd = vctStart + Vector3.Backward * deep;
            GenerateLines(vctStart, vctEnd, ref vctSideStep, ref worldMatrix, ref m_lineBuffer, wireDivideRatio);

            //@ LeftSide
            vctStart = localbox.Min;
            vctEnd = vctStart + Vector3.Up * height;
            vctSideStep = Vector3.Backward * (deep / wireDivideRatio);
            GenerateLines(vctStart, vctEnd, ref vctSideStep, ref worldMatrix, ref m_lineBuffer, wireDivideRatio);
            // RightSide
            vctStart += Vector3.Right * width;
            vctEnd += Vector3.Right * width;
            GenerateLines(vctStart, vctEnd, ref vctSideStep, ref worldMatrix, ref m_lineBuffer, wireDivideRatio);


            if (wireDivideRatio > 1)
            {
                //@ TopSide
                vctStart = localbox.Min;
                vctEnd = vctStart + Vector3.Right * width;
                vctSideStep = Vector3.Backward * (deep / wireDivideRatio);
                GenerateLines(vctStart, vctEnd, ref vctSideStep, ref worldMatrix, ref m_lineBuffer, wireDivideRatio);
                // BottomSide
                vctStart += Vector3.Up * height;
                vctEnd += Vector3.Up * height;
                GenerateLines(vctStart, vctEnd, ref vctSideStep, ref worldMatrix, ref m_lineBuffer, wireDivideRatio);

                //@ TopSide
                vctStart = localbox.Min;
                vctEnd = vctStart + Vector3.Backward * deep;
                vctSideStep = Vector3.Right * (width / wireDivideRatio);
                GenerateLines(vctStart, vctEnd, ref vctSideStep, ref worldMatrix, ref m_lineBuffer, wireDivideRatio);
                // BottomSide
                vctStart += Vector3.Up * height;
                vctEnd += Vector3.Up * height;
                GenerateLines(vctStart, vctEnd, ref vctSideStep, ref worldMatrix, ref m_lineBuffer, wireDivideRatio);
            }


            Vector3 size = new Vector3(localbox.Max.X - localbox.Min.X, localbox.Max.Y - localbox.Min.Y, localbox.Max.Z - localbox.Min.Z);
            float thickness = MathHelper.Max(1, MathHelper.Min(MathHelper.Min(size.X, size.Y), size.Z));
            thickness *= fThickRatio;
            //billboard
            foreach (MyLine line in m_lineBuffer)
            {

                //@ 16 - lifespan for 1 update in 60FPS
                MyTransparentGeometry.AddLineBillboard(lineMaterial.Value, vctColor, line.From, line.Direction, line.Length, thickness);
                
            }
        }
Exemplo n.º 22
0
 public void Start(ref MyQuad quad, MyTransparentMaterialEnum materialEnum,
                   ref Vector4 color, ref Vector3 origin, Vector2 uvOffset, bool colorize = false, bool near = false, bool lowres = false)
 {
     Start(ref quad, materialEnum, MyTransparentMaterialEnum.Test, 0, ref color, ref origin, uvOffset, colorize, near, lowres);
 }
Exemplo n.º 23
0
        void AddIcon(Vector3 pos, float radius, MyTransparentMaterialEnum texture, Color color, string textDown, string textUp, float textSize, bool highlight, Vector3 offset, MyGuiFont font = null, float? importance = null)
        {
            if (font == null)
                font = MyGuiManager.GetFontMinerWarsWhite();

            float scaledRadius = MySolarSystemUtils.CalculateDistanceUnscalingTo(pos, radius, MySolarSystemMapNavigationMark.SCALE_DISTANCE_FROM);

            float textScale = 1 / MySolarSystemUtils.CalculateDistanceUnscalingFrom(pos, 1 / 0.7f, MySolarSystemMapNavigationMark.SCALE_DISTANCE_FROM);// 1;// radius / scaledRadius / 2;

            Vector4 iconColor = Vector4.One;
            if (highlight)
            {
                iconColor *= 1.5f;
            }

            textSize = 1.35f;
            var position = pos + offset * scaledRadius + Vector3.Up / 2 * scaledRadius;
            MyTransparentGeometry.AddBillboardOriented(texture, iconColor, position, m_currentCamera.Up, m_currentCamera.Left, scaledRadius, 0200 + (int)importance);

            if (textUp != null)
            {
                AddText(position, textUp, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_TOP, textSize * textScale, color, font, new Vector2(0, -90) * textScale);
            }

            if (textDown != null)
            {
                AddText(position, textDown, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_TOP, textSize * textScale, color, font, new Vector2(0, -60) * textScale);
            }
        }
Exemplo n.º 24
0
 void AddIcon(Vector3 pos, float radius, MyTransparentMaterialEnum texture, Vector4 color, string textDown, string textUp, float textSize, bool highlight, Vector3 offset, MyGuiFont font = null, float? importance = null)
 {
     AddIcon(pos, radius, texture, new Color(color), textDown, textUp, textSize, highlight, offset, font, importance);
 }
Exemplo n.º 25
0
 public static void DrawTransparentCuboid(ref Matrix worldMatrix, MyCuboid cuboid, ref Vector4 vctColor, bool bWireFramed, float thickness, MyTransparentMaterialEnum? lineMaterial = null)
 {
     foreach (MyLine line in cuboid.UniqueLines)
     {
         Vector3 from = Vector3.Transform(line.From, worldMatrix);
         Vector3 to = Vector3.Transform(line.To, worldMatrix);
         DrawLine(from, to, lineMaterial ?? MyTransparentMaterialEnum.ProjectileTrailLine, ref vctColor, thickness);
     }
 }
Exemplo n.º 26
0
        //  This method realy initiates/starts the particle
        //  IMPORTANT: Direction vector must be normalized!
        public void StartLineParticleRelativeToPhysObject(
            MyTransparentMaterialEnum material, int lifespanInMiliseconds, Vector3 startPosition, Vector3 velocity,
            Vector4 startColor, Vector4 endColor, Vector3 directionNormalized, float thickness, float startLength, float endLength,  
            MyEntity physObject)
        {
            Start(material, lifespanInMiliseconds, startPosition, velocity, startColor, endColor);

            m_type = MyParticleType.LINE_PARTICLE_RELATIVE_TO_PHYS_OBJECT;
            m_lineSpecific_directionNormalized = directionNormalized;
            m_lineSpecific_thickness = thickness;
            m_lineSpecific_startLength = startLength;
            m_lineSpecific_endLength = endLength;
            m_physObject = physObject;
        }
Exemplo n.º 27
0
        public static void DrawTransparentCone(ref Matrix worldMatrix, float coneLength, float radiusBackSide, ref Vector4 vctColor, bool bWireFramed, int wireDivideRatio, float thickness, MyTransparentMaterialEnum? lineMaterial = null) 
        {            
            Vector3 vertex;            
            Vector3 start = Vector3.Transform(Vector3.Zero, worldMatrix);

            float angleStep = 360.0f / (float)wireDivideRatio;
            float alpha = 0;

            for (int i = 0; i <= wireDivideRatio; i++) 
            {   
                alpha = (float)i * angleStep;

                vertex.X = (float)(radiusBackSide * Math.Cos(MathHelper.ToRadians(alpha)));
                vertex.Y = (float)(radiusBackSide * Math.Sin(MathHelper.ToRadians(alpha)));
                vertex.Z = coneLength;
                vertex = Vector3.Transform(vertex, worldMatrix);

                DrawLine(start, vertex, lineMaterial ?? MyTransparentMaterialEnum.ProjectileTrailLine, ref vctColor, thickness);
            }            
        }
Exemplo n.º 28
0
 private void AddPointBillboardUnscaling(MyTransparentMaterialEnum material, Vector4 color, Vector3 origin, float radiusWhen1mFromCamera, float angle, int priority = 0, bool colorize = true)
 {
     float radius = MySolarSystemUtils.CalculateDistanceUnscaling(origin, radiusWhen1mFromCamera);
     MyTransparentGeometry.AddPointBillboard(material, color, origin, radius, angle, priority, colorize);
 }
Exemplo n.º 29
0
 public void Start(ref MyQuad quad, MyTransparentMaterialEnum materialEnum,
     ref Vector4 color, ref Vector3 origin, Vector2 uvOffset, bool colorize = false, bool near = false, bool lowres = false)
 {
     Start(ref quad, materialEnum, MyTransparentMaterialEnum.Test, 0, ref color, ref origin, uvOffset, colorize, near, lowres);
 }
 public static MyTransparentMaterialProperties GetMaterialProperties(MyTransparentMaterialEnum materialType)
 {
     return MaterialProperties[(int)materialType];
 }
Exemplo n.º 31
0
 public void Start(ref MyQuad quad, MyTransparentMaterialEnum materialEnum, MyTransparentMaterialEnum blendMaterial, float textureBlendRatio,
                   ref Vector4 color, ref Vector3 origin, bool colorize = false, bool near = false, bool lowres = false)
 {
     Start(ref quad, materialEnum, blendMaterial, textureBlendRatio, ref color, ref origin, Vector2.Zero, colorize, near, lowres);
 }
Exemplo n.º 32
0
 /// <summary>
 /// Adds point billboard, when billboard is far from camera, it stops shrinking.
 /// </summary>
 private void AddPointBillboardUnscalingFromDistance(MyTransparentMaterialEnum material, Vector4 color, Vector3 origin, float radius, float angle, float fixedSizeDistance, int priority = 0, bool colorize = true)
 {
     colorize = false;
     radius = MySolarSystemUtils.CalculateDistanceUnscalingFrom(origin, radius, fixedSizeDistance);
     MyTransparentGeometry.AddPointBillboard(material, color, origin, radius, angle, priority, colorize);
 }
Exemplo n.º 33
0
        private void SetTransparentParameters(out Vector4 color, out MyTransparentMaterialEnum? faceMaterial, out MyTransparentMaterialEnum? lineMaterial)
        {
            if (Game.Editor.MyEditor.Static.IsActive())
            {
                faceMaterial = MyTransparentMaterialEnum.ObjectiveDummyFace;
                lineMaterial = MyTransparentMaterialEnum.ObjectiveDummyLine;
            }
            else 
            {
                faceMaterial = null;
                lineMaterial = null;
            }

            if(MyMissions.IsMissionEntity(this))
            {                
                color = MyHudConstants.MISSION_CUBE_COLOR;
            }
            else
            {
                MyFactionRelationEnum status = MyFactions.GetFactionsRelation(this, MySession.PlayerShip);
                switch(status) {
                    case MyFactionRelationEnum.Friend:
                        color = MyHudConstants.FRIEND_CUBE_COLOR;
                        break;
                    case MyFactionRelationEnum.Enemy:
                        color = MyHudConstants.ENEMY_CUBE_COLOR;
                        break;
                    case MyFactionRelationEnum.Neutral:
                        color = MyHudConstants.NEUTRAL_CUBE_COLOR;
                        break;
                    default:
                        throw new MyMwcExceptionApplicationShouldNotGetHere();
                }                
            }
        }        
Exemplo n.º 34
0
        /// <summary>
        /// DrawTransparentBox
        /// </summary>
        public static void DrawTransparentBox(ref Matrix worldMatrix, ref BoundingBox localbox, ref Vector4 vctColor, bool bWireFramed, int wireDivideRatio, MyTransparentMaterialEnum? faceMaterial = null, MyTransparentMaterialEnum? lineMaterial = null)
        {
            if (!faceMaterial.HasValue)
            {
                faceMaterial = MyTransparentMaterialEnum.ContainerBorder;
            }

            Vector3 vctMin = localbox.Min;
            Vector3 vctMax = localbox.Max;

            //@ CreateQuads
            Vector3 translation = worldMatrix.Translation;
            MyQuad quad;

            Matrix orientation = Matrix.Identity;
            orientation.Forward = worldMatrix.Forward;
            orientation.Up = worldMatrix.Up;
            orientation.Right = worldMatrix.Right;

            float halfWidth = (localbox.Max.X - localbox.Min.X) / 2f;
            float halfHeight = (localbox.Max.Y - localbox.Min.Y) / 2f;
            float halfDeep = (localbox.Max.Z - localbox.Min.Z) / 2f;

            //@ Front side
            Vector3 faceNorm = Vector3.Transform(Vector3.Forward, orientation);
            faceNorm *= halfDeep;
            Vector3 vctPos = translation + faceNorm;
            MyUtils.GenerateQuad(out quad, ref vctPos, halfWidth, halfHeight, ref worldMatrix);
            MyTransparentGeometry.AddQuad(faceMaterial.Value, ref quad, ref vctColor, ref translation);

            //@ Back side
            vctPos = translation - faceNorm;
            MyUtils.GenerateQuad(out quad, ref vctPos, halfWidth, halfHeight, ref worldMatrix);
            MyTransparentGeometry.AddQuad(faceMaterial.Value, ref quad, ref vctColor, ref translation);

            //@ Left side
            Matrix rotMat = Matrix.CreateRotationY(MathHelper.ToRadians(90f));
            Matrix rotated = rotMat * worldMatrix;
            faceNorm = Vector3.Transform(Vector3.Left, orientation);
            faceNorm *= halfWidth;
            vctPos = translation + faceNorm;
            MyUtils.GenerateQuad(out quad, ref vctPos, halfDeep, halfHeight, ref rotated);
            MyTransparentGeometry.AddQuad(faceMaterial.Value, ref quad, ref vctColor, ref translation);

            //@ Right side
            vctPos = translation - faceNorm;
            MyUtils.GenerateQuad(out quad, ref vctPos, halfDeep, halfHeight, ref rotated);
            MyTransparentGeometry.AddQuad(faceMaterial.Value, ref quad, ref vctColor, ref translation);

            //@ Top side
            rotMat = Matrix.CreateRotationX(MathHelper.ToRadians(90f));
            rotated = rotMat * worldMatrix;
            faceNorm = Vector3.Transform(Vector3.Up, orientation);
            faceNorm *= ((localbox.Max.Y - localbox.Min.Y) / 2f);
            vctPos = translation + faceNorm;
            MyUtils.GenerateQuad(out quad, ref vctPos, halfWidth, halfDeep, ref rotated);
            MyTransparentGeometry.AddQuad(faceMaterial.Value, ref quad, ref vctColor, ref translation);

            //@ Bottom side
            vctPos = translation - faceNorm;
            MyUtils.GenerateQuad(out quad, ref vctPos, halfWidth, halfDeep, ref rotated);
            MyTransparentGeometry.AddQuad(faceMaterial.Value, ref quad, ref vctColor, ref translation);

            if (bWireFramed)
            {
                Vector4 vctWireColor = vctColor;
                vctWireColor *= 1.3f;
                DrawWireFramedBox(ref worldMatrix, ref localbox, ref vctWireColor, 0.02f, wireDivideRatio, lineMaterial);
            }
        }