コード例 #1
0
        private void SetupRenderElement(MyLodTypeEnum lodTypeEnum, List <MyRender.MyRenderElement> elements)
        {
            if (lodTypeEnum != MyLodTypeEnum.LOD0)
            {
                return;
            }

            MyRender.MyRenderElement renderElement;
            MyRender.AllocateRenderElement(out renderElement);
            if (MyRender.IsRenderOverloaded)
            {
                return;
            }

            renderElement.VertexBuffer      = m_vertexBuffer;
            renderElement.VertexCount       = m_vertices.Length;
            renderElement.VertexStride      = MyVertexFormatPositionNormalTextureTangent.Stride;
            renderElement.VertexDeclaration = MyVertexFormatPositionNormalTextureTangent.VertexDeclaration;

            renderElement.IndexBuffer = m_indexBuffer;
            renderElement.IndexStart  = 0;
            renderElement.TriCount    = m_indices.Length / 3;

            renderElement.InstanceBuffer = null;
            MatrixD.CreateTranslation(ref m_worldPosition, out renderElement.WorldMatrix);
            MatrixD.Multiply(ref renderElement.WorldMatrix, ref MyRenderCamera.InversePositionTranslationMatrix, out renderElement.WorldMatrixForDraw);
            renderElement.DrawTechnique = MyMeshDrawTechnique.MESH;
            renderElement.Material      = m_ropeMaterial;
            renderElement.RenderObject  = this;
            renderElement.Color         = new Vector3(1f, 0.93f, 0.42f);

            elements.Add(renderElement);
        }