Beispiel #1
0
        public void DisplayMesh(Data.Mesh mesh, bool clear = true)
        {
            if (clear)
            {
                ClearDisplay();
            }

            meshes.Add(mesh);
        }
Beispiel #2
0
        public static List <Data.Mesh> Generate(GBODChunk gbodChunk, DX dx)
        {
            List <Data.Mesh> meshes = new List <Data.Mesh>();

            foreach (var child in gbodChunk.Children)
            {
                if (child is GSKNChunk)
                {
                    GPCEChunk gpceChunk = (child as GSKNChunk).Geometry;

                    // Tabula Rasa uses 'LOD'. Auto Assault uses 'LODLevel'
                    var lods = gpceChunk.USDA.Values.Where(kv => kv.Item1 == "LOD" || kv.Item1 == "LODLevel").ToList();
                    if (lods.Count > 0 && lods[0].Item2 != "0")
                    {
                        continue;
                    }

                    Data.Mesh mesh = Generate((GSKNChunk)child, dx);
                    meshes.Add(mesh);
                }

                if (child is GPCEChunk)
                {
                    GPCEChunk gpceChunk = child as GPCEChunk;

                    // Tabula Rasa uses 'LOD'. Auto Assault uses 'LODLevel'
                    var lods = gpceChunk.USDA.Values.Where(kv => kv.Item1 == "LOD" || kv.Item1 == "LODLevel").ToList();
                    if (lods.Count > 0 && lods[0].Item2 != "0")
                    {
                        continue;
                    }

                    Data.Mesh mesh = Generate(gpceChunk, dx);
                    meshes.Add(mesh);
                }
            }

            return(meshes);
        }
Beispiel #3
0
        private void drawMesh(Matrix worldMatrix, Matrix viewProjMatrix, Data.Mesh mesh, D3D9.Effect effect)
        {
            Matrix worldMatrix2        = worldMatrix * mesh.Rotation * mesh.Position;
            Matrix worldViewProjMatrix = worldMatrix2 * viewProjMatrix;

            Matrix worldInverseTranspose = Matrix.Invert(worldMatrix2);

            worldInverseTranspose = Matrix.Transpose(worldInverseTranspose);

            effect.SetValue("gWorldViewProj", worldViewProjMatrix);
            effect.SetValue("gWorldInvTrans", worldInverseTranspose);
            effect.SetTexture("gDiffuseTexture", mesh.DiffuseTexture);
            effect.CommitChanges();

            DX.Device.SetStreamSource(0, mesh.VertexBuffer, 0, mesh.VertexDeclStride);
            DX.Device.VertexDeclaration = mesh.VertexDecl;
            DX.Device.Indices           = mesh.IndexBuffer;

            Int32 primitiveCount = mesh.IndexCount / (mesh.Primitive == D3D9.PrimitiveType.LineList ? 2 : 3);

            DX.Device.DrawIndexedPrimitive(mesh.Primitive, 0, 0, mesh.VertexCount, 0, primitiveCount);
        }