Exemple #1
0
        public static float UpdateDecalEmissivity(MyDecalTriangle decalTriangle, float alpha, MyRenderObject renderObject)
        {
            float emisivity = 0;

            if (decalTriangle.Emissivity > 0)
            {
                //emisivity = (float)(Math.Sin(decalTriangle.RandomOffset + decalTriangle.RandomOffset * MySandboxGame.TotalGamePlayTimeInMilliseconds / 1000.0f)) * 0.4f + 0.7f;

                // 2 seconds default, more emissive lit longer
                float stableLength = 2000 * decalTriangle.Emissivity;
                if ((MyRender.RenderTimeInMS - decalTriangle.RandomOffset) < stableLength)
                {
                    emisivity = 1;
                }
                else
                {
                    emisivity = (float)(500 - (MyRender.RenderTimeInMS - stableLength - decalTriangle.RandomOffset)) / 500.0f;
                    if (emisivity < 0)
                    {
                        emisivity = 0;
                    }
                }

                emisivity *= decalTriangle.Emissivity;

                if (emisivity > 0)
                {
                    Color color = MyDecalsConstants.PROJECTILE_DECAL_COLOR;

                    Vector3D position;
                    MyRenderTransformObject transformObject = renderObject as MyRenderTransformObject;
                    if (transformObject != null)
                    {
                        position = Vector3D.Transform(decalTriangle.Position, transformObject.WorldMatrix);
                    }
                    else
                    if (renderObject is MyManualCullableRenderObject)
                    {
                        position = Vector3D.Transform(decalTriangle.Position, (renderObject as MyManualCullableRenderObject).WorldMatrix);
                    }
                    else
                    {
                        position = decalTriangle.Position;
                    }

                    MyTransparentGeometry.AddPointBillboard(
                        "DecalGlare",
                        color * alpha,
                        (Vector3)position,
                        1.5f * emisivity,
                        0);

                    if (decalTriangle.Light != null)
                    {
                        decalTriangle.Light.Color = color;
                        decalTriangle.Light.SetPosition(position);

                        float range = Math.Max(3 * emisivity * alpha, 0.1f);
                        decalTriangle.Light.Range = range;
                    }
                }
            }

            return(emisivity);
        }
 /// <summary>
 /// Removes decals from the specified entity (NOT voxel map).
 /// E.g. when the entity is destroyed (destructible prefab).
 /// </summary>
 /// <param name="renderObject">The entity from which we want to remove decals. NOT MyVoxelMap!</param>
 public static void RemoveModelDecals(MyRenderTransformObject renderObject)
 {
     m_decalsForModels.ReturnTrianglesBuffer(renderObject);
 }    
Exemple #3
0
 /// <summary>
 /// Removes decals from the specified entity (NOT voxel map).
 /// E.g. when the entity is destroyed (destructible prefab).
 /// </summary>
 /// <param name="renderObject">The entity from which we want to remove decals. NOT MyVoxelMap!</param>
 public static void RemoveModelDecals(MyRenderTransformObject renderObject)
 {
     m_decalsForModels.ReturnTrianglesBuffer(renderObject);
 }