Beispiel #1
0
 public Pgrp(DatDigger.Sections.Model.PgrpChunk pgrp, IndexList idxList, int numVertices)
     : base()
 {
     this.pgrp = pgrp;
     this.idxList = idxList;
     this.numVertices = numVertices;
     this.numTriangles = pgrp.Triangles.Length;
     this.Name = pgrp.PgrpName;
 }
Beispiel #2
0
        public override void Init()
        {
            base.Init();

            StringChunk strChunk = mesh.GetChildOfType<StringChunk>();
            this.ShaderName = strChunk.String;

            StreamChunk indexChunk = mesh.GetChildOfType<StreamChunk>();
            this.indexBufferData = indexChunk.VertexData;
            this.numTriangles = indexChunk.VertexCount / 3;

            StreamChunk dataChunk = mesh.GetChildOfType<StreamChunk>(1);
            this.vertexBufferData = dataChunk.VertexData;
            this.numVertices = dataChunk.VertexCount;
            this.vertexSize = dataChunk.VertexSize;

            this.vertexElements = new VertexElement[dataChunk.NumElements + 1];
            for (var i = 0; i < dataChunk.NumElements; i++)
            {
                this.vertexElements[i] = dataChunk.Elements[i].GenerateVertexElement();
            }
            this.vertexElements[dataChunk.NumElements] = VertexElement.VertexDeclarationEnd;
            this.vertexDecl = new VertexDeclaration(Device, vertexElements);

            vertexBuffer = new VertexBuffer(
                Device,
                vertexBufferData.Length,
                Usage.WriteOnly,
                VertexFormat.Position,
                Pool.Managed
            );

            var stream = vertexBuffer.Lock(0, 0, LockFlags.None);
            stream.WriteRange(vertexBufferData);
            vertexBuffer.Unlock();

            IndexList idxList = new IndexList(indexChunk);

            List<PgrpChunk> pgrpChunks = mesh.GetChildrenOfType<PgrpChunk>();
            foreach (var p in pgrpChunks)
            {
                var pgrp = new Pgrp(p, idxList, numVertices);
                this.pgrps.Add(pgrp);
                pgrp.Init();
                pgrp.DetermineEnableStatus(varEquip);
            }

            if (idxList.AllUsed)
            {
                indexBuffer = null;
            }
            else
            {
                indexBuffer = idxList.BuildRemainder(this.Device);
                numTriangles = idxList.UnusedCount / 3;
            }

            if (RenderSettings.IsSkinning)
            {
                var envdChunks = mesh.GetChildrenOfType<EnvdChunk>();
                List<string> boneNames = new List<string>();
                envdChunks.ForEach(x => boneNames.Add(x.BoneName));
                this.BoneIds = this.RenderSettings.Skeleton.BoneNamesToIds(boneNames);
            }
        }
Beispiel #3
0
        public override void Init()
        {
            base.Init();

            StringChunk strChunk = mesh.GetChildOfType <StringChunk>();

            this.ShaderName = strChunk.String;

            StreamChunk indexChunk = mesh.GetChildOfType <StreamChunk>();

            this.indexBufferData = indexChunk.VertexData;
            this.numTriangles    = indexChunk.VertexCount / 3;

            StreamChunk dataChunk = mesh.GetChildOfType <StreamChunk>(1);

            this.vertexBufferData = dataChunk.VertexData;
            this.numVertices      = dataChunk.VertexCount;
            this.vertexSize       = dataChunk.VertexSize;

            this.vertexElements = new VertexElement[dataChunk.NumElements + 1];
            for (var i = 0; i < dataChunk.NumElements; i++)
            {
                this.vertexElements[i] = dataChunk.Elements[i].GenerateVertexElement();
            }
            this.vertexElements[dataChunk.NumElements] = VertexElement.VertexDeclarationEnd;
            this.vertexDecl = new VertexDeclaration(Device, vertexElements);

            vertexBuffer = new VertexBuffer(
                Device,
                vertexBufferData.Length,
                Usage.WriteOnly,
                VertexFormat.Position,
                Pool.Managed
                );

            var stream = vertexBuffer.Lock(0, 0, LockFlags.None);

            stream.WriteRange(vertexBufferData);
            vertexBuffer.Unlock();

            IndexList idxList = new IndexList(indexChunk);

            List <PgrpChunk> pgrpChunks = mesh.GetChildrenOfType <PgrpChunk>();

            foreach (var p in pgrpChunks)
            {
                var pgrp = new Pgrp(p, idxList, numVertices);
                this.pgrps.Add(pgrp);
                pgrp.Init();
                pgrp.DetermineEnableStatus(varEquip);
            }

            if (idxList.AllUsed)
            {
                indexBuffer = null;
            }
            else
            {
                indexBuffer  = idxList.BuildRemainder(this.Device);
                numTriangles = idxList.UnusedCount / 3;
            }

            if (RenderSettings.IsSkinning)
            {
                var           envdChunks = mesh.GetChildrenOfType <EnvdChunk>();
                List <string> boneNames  = new List <string>();
                envdChunks.ForEach(x => boneNames.Add(x.BoneName));
                this.BoneIds = this.RenderSettings.Skeleton.BoneNamesToIds(boneNames);
            }
        }