Пример #1
0
        //  Add decal and all surounding triangles for model intersection
        internal static void AddDecal(MyRenderObject renderObject, ref MyDecalTriangle_Data triangle, int trianglesToAdd, MyDecalTexturesEnum decalTexture,
                                      Vector3D position, float lightSize, float emissivity)
        {
            IMyDecalsBuffer decalsBuffer = null;

            if (renderObject is MyRenderVoxelCell)
            {
                //  If we get null, buffer is full so no new decals can't be placed
                decalsBuffer = m_decalsForVoxels.GetTrianglesBuffer(renderObject as MyRenderVoxelCell, decalTexture);
            }
            else
            if (renderObject is MyRenderTransformObject)
            {
                decalsBuffer = m_decalsForModels.GetTrianglesBuffer(renderObject, decalTexture);
            }

            if (renderObject is MyManualCullableRenderObject)
            {
                decalsBuffer = m_decalsForModels.GetTrianglesBuffer(renderObject, decalTexture);
            }


            //  If we get null, buffer is full so no new decals can't be placed
            if (decalsBuffer == null)
            {
                return;
            }

            if (decalsBuffer.CanAddTriangles(trianglesToAdd))
            {
                Vector3 normalSum = Vector3.Zero;

                decalsBuffer.Add(triangle, trianglesToAdd, position, lightSize, emissivity);
            }
        }
        public void Add(MyDecalTriangle_Data triangle, int remainingTrianglesOfThisDecal, Vector3D position, float lightSize, float emissivity)
        {
            //  We can't add triangles while fading out
            //if (m_status == MyDecalsBufferState.FADING_OUT) return;

            MyDecalTriangle decalTriangle = m_freeTriangles.Pop();

            decalTriangle.Start(lightSize);
            decalTriangle.Emissivity = emissivity;
            //decalTriangle.RandomOffset = MyMwcUtils.GetRandomFloat(0.0f, MathHelper.Pi);
            decalTriangle.RandomOffset = (float)MyRender.RenderTimeInMS;
            decalTriangle.Position     = position;

            // We must repack vertex positions before copying to new triange, to avoid Z-fight.
            decalTriangle.Position0 = triangle.Vertexes.Vertex0;
            decalTriangle.Position1 = triangle.Vertexes.Vertex1;
            decalTriangle.Position2 = triangle.Vertexes.Vertex2;

            //  Texture coords
            decalTriangle.TexCoord0 = triangle.TexCoords.TexCoord0;
            decalTriangle.TexCoord1 = triangle.TexCoords.TexCoord1;
            decalTriangle.TexCoord2 = triangle.TexCoords.TexCoord2;


            //  Alpha
            decalTriangle.Color0 = triangle.Colors.Color0;
            decalTriangle.Color1 = triangle.Colors.Color1;
            decalTriangle.Color2 = triangle.Colors.Color2;

            //AdjustAlphaByDistance(normal, decalSize, position, decalTriangle);

            //  Bump mapping
            decalTriangle.Normal0 = triangle.Normals.Normal0;
            decalTriangle.Normal1 = triangle.Normals.Normal1;
            decalTriangle.Normal2 = triangle.Normals.Normal2;

            /*
             * decalTriangle.Tangent0 = triangle.Tangents.Normal0;
             * decalTriangle.Tangent1 = triangle.Tangents.Normal1;
             * decalTriangle.Tangent2 = triangle.Tangents.Normal2;
             */
            decalTriangle.RemainingTrianglesOfThisDecal = remainingTrianglesOfThisDecal;

            m_trianglesQueue.Enqueue(decalTriangle);
        }
        public void Add(MyDecalTriangle_Data triangle, int remainingTrianglesOfThisDecal, Vector3D position, float lightSize, float emissivity)
        {
            MyDecalTriangle decalTriangle = m_freeTriangles.Pop();

            decalTriangle.Start(lightSize);
            decalTriangle.Emissivity = emissivity;
            //decalTriangle.RandomOffset = MyMwcUtils.GetRandomFloat(0.0f, MathHelper.Pi);
            decalTriangle.RandomOffset = MyRender.RenderTimeInMS;
            decalTriangle.Position     = position;

            // We must repack vertex positions before copying to new triange, to avoid Z-fight.
            decalTriangle.Position0 = triangle.Vertexes.Vertex0;
            decalTriangle.Position1 = triangle.Vertexes.Vertex1;
            decalTriangle.Position2 = triangle.Vertexes.Vertex2;

            //  Texture coords
            decalTriangle.TexCoord0 = triangle.TexCoords.TexCoord0;
            decalTriangle.TexCoord1 = triangle.TexCoords.TexCoord1;
            decalTriangle.TexCoord2 = triangle.TexCoords.TexCoord2;

            //  Alpha
            decalTriangle.Color0 = triangle.Colors.Color0;
            decalTriangle.Color1 = triangle.Colors.Color1;
            decalTriangle.Color2 = triangle.Colors.Color2;

            //  Bump mapping
            decalTriangle.Normal0 = triangle.Normals.Normal0;
            decalTriangle.Normal1 = triangle.Normals.Normal1;
            decalTriangle.Normal2 = triangle.Normals.Normal2;

            /*
             * decalTriangle.Tangent0 = triangle.Tangents.Normal0;
             * decalTriangle.Tangent1 = triangle.Tangents.Normal1;
             * decalTriangle.Tangent2 = triangle.Tangents.Normal2;
             */
            decalTriangle.Draw = true;
            decalTriangle.RemainingTrianglesOfThisDecal = remainingTrianglesOfThisDecal;

            m_trianglesQueue.Enqueue(decalTriangle);
        }
        public void Add(MyDecalTriangle_Data triangle, int remainingTrianglesOfThisDecal, Vector3D position, float lightSize, float emissivity)
        {
            MyDecalTriangle decalTriangle = m_freeTriangles.Pop();
            
            decalTriangle.Start(lightSize);
            decalTriangle.Emissivity = emissivity;
            //decalTriangle.RandomOffset = MyMwcUtils.GetRandomFloat(0.0f, MathHelper.Pi);
            decalTriangle.RandomOffset = MyRender.RenderTimeInMS;
            decalTriangle.Position = position;

            // We must repack vertex positions before copying to new triange, to avoid Z-fight.
            decalTriangle.Position0 = triangle.Vertexes.Vertex0;
            decalTriangle.Position1 = triangle.Vertexes.Vertex1;
            decalTriangle.Position2 = triangle.Vertexes.Vertex2;
   
            //  Texture coords
            decalTriangle.TexCoord0 = triangle.TexCoords.TexCoord0;
            decalTriangle.TexCoord1= triangle.TexCoords.TexCoord1;
            decalTriangle.TexCoord2 = triangle.TexCoords.TexCoord2;

            //  Alpha
            decalTriangle.Color0 = triangle.Colors.Color0;
            decalTriangle.Color1 = triangle.Colors.Color1;
            decalTriangle.Color2 = triangle.Colors.Color2;

            //  Bump mapping
            decalTriangle.Normal0 = triangle.Normals.Normal0;
            decalTriangle.Normal1 = triangle.Normals.Normal1;
            decalTriangle.Normal2 = triangle.Normals.Normal2;
            /*
            decalTriangle.Tangent0 = triangle.Tangents.Normal0;
            decalTriangle.Tangent1 = triangle.Tangents.Normal1;
            decalTriangle.Tangent2 = triangle.Tangents.Normal2;
            */
            decalTriangle.Draw = true;
            decalTriangle.RemainingTrianglesOfThisDecal = remainingTrianglesOfThisDecal;

            m_trianglesQueue.Enqueue(decalTriangle);
        }
Пример #5
0
        //  Add decal and all surounding triangles for model intersection
        internal static void AddDecal(MyRenderObject renderObject, ref MyDecalTriangle_Data triangle, int trianglesToAdd, MyDecalTexturesEnum decalTexture, 
            Vector3D position, float lightSize, float emissivity)
        {
            IMyDecalsBuffer decalsBuffer = null;
            if (renderObject is MyRenderVoxelCell)
                    //  If we get null, buffer is full so no new decals can't be placed
                decalsBuffer = m_decalsForVoxels.GetTrianglesBuffer(renderObject as MyRenderVoxelCell, decalTexture);
            else
                if (renderObject is MyRenderTransformObject)
                    decalsBuffer = m_decalsForModels.GetTrianglesBuffer(renderObject, decalTexture);

            if (renderObject is MyManualCullableRenderObject)
            {
                decalsBuffer = m_decalsForModels.GetTrianglesBuffer(renderObject, decalTexture);
            }
                

            //  If we get null, buffer is full so no new decals can't be placed
            if (decalsBuffer == null) return;

            if (decalsBuffer.CanAddTriangles(trianglesToAdd))
            {
                Vector3 normalSum = Vector3.Zero;

                decalsBuffer.Add(triangle, trianglesToAdd, position, lightSize, emissivity);
            }
        }