Example #1
0
        public override void parse(NIFFile file, NIFObject baseo, BinaryReader ds)
        {
            base.parse(file, baseo, ds);

            loadExtraData(file, ds);
            intExtraData = ds.readInt();
        }
        public override void parse(NIFFile file, NIFObject baseo, BinaryReader ds)
        {
            base.parse(file, baseo, ds);

            m_afValue        = new float[DEGREE + 1];
            this.m_iQuantity = (int)ds.readUInt();
        }
        public override void parse(NIFFile file, NIFObject baseo, BinaryReader ds)
        {
            base.parse(file, baseo, ds);

            loadExtraData(file, ds);
            booleanData = ds.ReadBoolean();
        }
Example #4
0
        public override void parse(NIFFile file, NIFObject baseo, BinaryReader ds)
        {
            base.parse(file, baseo, ds);

            loadExtraData(file, ds);
            stringExtraData = file.loadString(ds);
        }
Example #5
0
        public override void parse(NIFFile file, NIFObject baseo, BinaryReader dis)
        {
            base.parse(file, baseo, dis);
            streamSize  = dis.readInt();
            streamClone = dis.readInt();

            int numRegions = dis.readInt();

            streamRegions = new List <StreamRegion>(numRegions);
            for (int i = 0; i < numRegions; i++)
            {
                streamRegions.Add(new StreamRegion(dis.readInt(), dis.readInt()));
            }
            int numElements = dis.readInt();

            streamElems = new List <NifStreamElement>(numElements);
            elemStride  = 0;
            for (int i = 0; i < numElements; i++)
            {
                int elemData          = dis.readInt();
                NifStreamElement elem = new NifStreamElement((elemData & 0xFF0000) >> 16, (elemData & 0xFF00) >> 8,
                                                             elemData & 0xFF, elemStride);
                elemStride += elem.count * elem.size;
                streamElems.Add(elem);
            }

            streamData = dis.ReadBytes(streamSize);
            streamable = dis.ReadByte() > 0;
        }
Example #6
0
        public override void parse(NIFFile file, NIFObject baseo, BinaryReader ds)
        {
            base.parse(file, baseo, ds);

            this.flags          = ds.readUnsignedShort();
            this.rootBoneLinkID = loadLinkID(ds);

            m_kRootBoneParentToSkinTransform = NITransform.parse(ds);

            this.m_uiBoneCount = ds.readInt();
            for (int i = 0; i < m_uiBoneCount; i++)
            {
                boneLinkIDs.Add(loadLinkID(ds));
            }
            for (int i = 0; i < m_uiBoneCount; i++)
            {
                m_pkSkinToBoneTransforms.Add(NITransform.parse(ds));
            }
            if ((flags & 2) == 0)
            {
                for (int i = 0; i < m_uiBoneCount; i++)
                {
                    Vector3 center = new Vector3(ds.readFloat(), ds.readFloat(), ds.readFloat());
                    float   rad    = ds.readFloat();
                }
            }
        }
 public override void parse(NIFFile file, NIFObject baseo, BinaryReader ds)
 {
     base.parse(file, baseo, ds);
     this.m_fStartTime    = ds.readFloat();
     this.m_fEndTime      = ds.readFloat();
     this.splineDataIndex = ds.readInt();
     this.basisDataIndex  = ds.readInt();
 }
 public override void parse(NIFFile file, NIFObject baseo, BinaryReader ds)
 {
     base.parse(file, baseo, ds);
     for (int i = 0; i < m_afCompScalars.Length; i++)
     {
         m_afCompScalars[i] = ds.readFloat();
     }
 }
Example #9
0
        public override void parse(NIFFile file, NIFObject baseo, BinaryReader ds)
        {
            base.parse(file, baseo, ds);
            loadAVObject(file, ds);
            childLinks = loadLinkIDs(ds);

            loadLinkIDs(ds);
        }
Example #10
0
        public override void parse(NIFFile file, NIFObject baseo, BinaryReader ds)
        {
            base.parse(file, baseo, ds);

            loadExtraData(file, ds);
            r = ds.ReadSingle();
            g = ds.ReadSingle();
            b = ds.ReadSingle();
            a = ds.ReadSingle();
        }
Example #11
0
        public override void parse(NIFFile file, NIFObject baseo, BinaryReader ds)
        {
            base.parse(file, baseo, ds);

            matAmbient       = new Point4f(ds.readFloat(), ds.readFloat(), ds.readFloat(), 1.0f);
            matDiffuse       = new Point4f(ds.readFloat(), ds.readFloat(), ds.readFloat(), 1.0f);
            matSpecular      = new Point4f(ds.readFloat(), ds.readFloat(), ds.readFloat(), 1.0f);
            matEmit          = new Point4f(ds.readFloat(), ds.readFloat(), ds.readFloat(), 1.0f);
            matShine         = ds.readFloat();
            matAlpha         = ds.readFloat();
            hasMaterialProps = true;
        }
        public override void parse(NIFFile file, NIFObject baseo, BinaryReader ds)
        {
            base.parse(file, baseo, ds);
            this.translate = new Vector3(ds.readFloat(), ds.readFloat(), ds.readFloat());
            this.rotate    = new Quaternion(ds.readFloat(), ds.readFloat(), ds.readFloat(), ds.readFloat());
            this.scale     = ds.readFloat();

            // Handles into the NiBSplineData for access to control points
            this.m_kTransCPHandle = ds.readInt();
            this.m_kRotCPHandle   = ds.readInt();
            this.m_kScaleCPHandle = ds.readInt();
        }
        public override void parse(NIFFile file, NIFObject baseo, BinaryReader ds)
        {
            base.parse(file, baseo, ds);
            base.loadObjectNET(file, ds);

            texPropFlags = ds.readUnsignedShort();

            int texListSize = ds.readInt();

            texList = new List <NifTexMap>(texListSize);
            for (int i = 0; i < texListSize; i++)
            {
                NifTexMap tex    = null;
                bool      hasMap = ds.readUnsignedByte() > 0;
                if (hasMap)
                {
                    tex = new NifTexMap();
                    tex.parse(file, baseo, ds);
                    if (i == 5)
                    {
                        tex.bumpLumaScale  = ds.readFloat();
                        tex.bumpLumaOffset = ds.readFloat();
                        tex.bumpMap        = new Point4f(ds.readFloat(), ds.readFloat(), ds.readFloat(), ds.readFloat());
                    }
                    else if (i == 7)
                    {
                        tex.offsetMapOfs = ds.readFloat();
                    }
                }
                else
                {
                    tex = null;
                }
                texList.Add(tex);
            }

            int shaderMapListSize = ds.readInt();

            shaderMapList = new List <NifTexMap>(shaderMapListSize);
            for (int i = 0; i < shaderMapListSize; i++)
            {
                NifTexMap tex    = null;
                bool      hasMap = ds.readUnsignedByte() > 0;
                if (hasMap)
                {
                    tex = new NifTexMap();
                    tex.parse(file, baseo, ds);
                    tex.uniqueID = ds.readInt();
                }
                shaderMapList.Add(tex);
            }
        }
        public override void parse(NIFFile file, NIFObject baseo, BinaryReader ds)
        {
            base.parse(file, baseo, ds);

            this.m_kAVObjectName = ds.readInt();
            this.m_kPropertyType = ds.readInt();
            this.m_kCtlrType     = ds.readInt();
            this.m_kCtlrID       = ds.readInt();
            this.m_kEvaluatorID  = ds.readInt();

            this.m_usSmallHashTableValue = ds.readUnsignedShort();
            this.m_usLargeHashTableValue = ds.readUnsignedShort();
        }
Example #15
0
        public override void parse(NIFFile file, NIFObject baseo, BinaryReader ds)
        {
            base.parse(file, baseo, ds);
            this.seqName = file.loadString(ds);
            var numEval = ds.readUInt();

            this.seqEvalIDList = new List <uint>();
            for (int i = 0; i < numEval; i++)
            {
                this.seqEvalIDList.Add(ds.readUInt());
            }
            file.addSequence(this);
        }
Example #16
0
        public override void parse(NIFFile file, NIFObject baseo, BinaryReader ds)
        {
            base.parse(file, baseo, ds);

            loadExtraData(file, ds);

            int floats = ds.readInt();

            floatData = new float[floats];
            for (int i = 0; i < floats; i++)
            {
                floatData[i] = ds.readFloat();
            }
        }
Example #17
0
        public override void parse(NIFFile file, NIFObject baseo, BinaryReader ds)
        {
            base.parse(file, baseo, ds);
            uint uiSyncCount = ds.readUInt();

            for (int i = 0; i < uiSyncCount; i++)
            {
                m_kSubmitPoints.Add(ds.readUnsignedShort());
            }
            uiSyncCount = ds.readUInt();
            for (int i = 0; i < uiSyncCount; i++)
            {
                m_kCompletePoints.Add(ds.readUnsignedShort());
            }
        }
Example #18
0
        internal NiTexturingProperty getTexturingProperty(NIFFile nf)
        {
            List <int> propIDs = nodePropertyIDs;

            foreach (int propID in propIDs)
            {
                NIFObject obj = nf.getObject(propID);
                if (obj is NiTexturingProperty)
                {
                    NiTexturingProperty propObj = (NiTexturingProperty)obj;
                    return(propObj);
                }
            }
            return(null);
        }
Example #19
0
        public override void parse(NIFFile file, NIFObject baseo, BinaryReader ds)
        {
            base.parse(file, baseo, ds);

            loadExtraData(file, ds);
            binaryDataSize = ds.readInt();
            if (binaryDataSize > 0)
            {
                extraData = ds.ReadBytes(binaryDataSize);

                loadThread          = new System.Threading.Thread(new System.Threading.ThreadStart(tryDecompress));
                loadThread.Priority = System.Threading.ThreadPriority.Lowest;
                loadThread.Start();
            }
        }
Example #20
0
        public void parse(NIFFile file, NIFObject baseo, BinaryReader ds)
        {
            sourceTexLinkID = ds.readInt();
            flags           = ds.readUnsignedShort();
            maxAniso        = ds.readUnsignedShort();
            hasTransform    = ds.readUnsignedByte() > 0;
            if (hasTransform)

            {
                translation = new Point3f(ds.readFloat(), ds.readFloat(), ds.readFloat());
                scale       = ds.readFloat();
                rotate      = ds.readFloat();
                method      = ds.readInt();
                center      = new Point2f(ds.readFloat(), ds.readFloat());
            }
        }
Example #21
0
 protected void loadRenderable(NIFFile file, BinaryReader ds)
 {
     loadAVObject(file, ds);
     numMaterials      = ds.readInt();
     materialExtraData = new List <int>(numMaterials);
     materialNames     = new List <String>(numMaterials);
     for (int i = 0; i < numMaterials; i++)
     {
         int    matNameIndex = ds.readInt();
         String matName      = file.getStringFromTable(matNameIndex);
         materialExtraData.Add(ds.readInt());
         materialNames.Add(matName);
     }
     materialIndex       = ds.readInt();
     materialNeedsUpdate = ds.readUnsignedByte() > 0;
 }
Example #22
0
        protected void loadAVObject(NIFFile file, BinaryReader ds)
        {
            loadObjectNET(file, ds);


            int flags = ds.readUnsignedShort();

            // if hack readUShort
            translation = new Point3f(ds.readFloat(), ds.readFloat(), ds.readFloat());
            matrix      = new Matrix4f(ds.readFloat(), ds.readFloat(), ds.readFloat(), 0,
                                       ds.readFloat(), ds.readFloat(), ds.readFloat(), 0,
                                       ds.readFloat(), ds.readFloat(), ds.readFloat(), 0,
                                       translation.x, translation.y, translation.z, 0);
            scale           = ds.readFloat();
            nodePropertyIDs = loadLinkIDs(ds);

            loadLinkID(ds); // collision node?
            isBone = true;
        }
Example #23
0
        public override void parse(NIFFile file, NIFObject baseo, BinaryReader ds)
        {
            base.parse(file, baseo, ds);

            this.controlPointCount = ds.readUInt();
            this.controlPoints     = new float[this.controlPointCount];

            for (int i = 0; i < controlPointCount; i++)
            {
                controlPoints[i] = ds.readFloat();
            }

            this.compactControlPointCount = ds.readUInt();
            this.compactControlPoints     = new short[compactControlPointCount];
            for (int i = 0; i < compactControlPointCount; i++)
            {
                compactControlPoints[i] = ds.ReadInt16();
            }
        }
Example #24
0
        public override void parse(NIFFile file, NIFObject baseo, BinaryReader ds)
        {
            base.parse(file, baseo, ds);

            loadObjectNET(file, ds);

            externalTex = ds.readUnsignedByte() > 0;
            texFilename = file.loadString(ds);
            pixLinkID   = ds.readInt();
            mipMapped   = ds.readInt();
            alphaFormat = ds.readInt();
            texStatic   = ds.readUnsignedByte() > 0;

            int unk1 = ds.readUnsignedByte();
            int unk2 = ds.readUnsignedByte();

            texIndex = -1;
            file.addTexture(this);
        }
Example #25
0
        public override void parse(NIFFile file, NIFObject baseo, BinaryReader ds)
        {
            base.parse(file, baseo, ds);

            loadRenderable(file, ds);
            meshPrimType  = ds.readInt();
            numSubMeshes  = ds.readUnsignedShort();
            isInstanced   = ds.readUnsignedByte() > 0;
            boundsCenter  = new Point3f(ds.readFloat(), ds.readFloat(), ds.readFloat());
            boundsRad     = ds.readFloat();
            numStreamRefs = ds.readInt();
            streamRefs    = new List <NifMeshStream>();

            for (int i = 0; i < numStreamRefs; i++)
            {
                NifMeshStream meshStream = new NifMeshStream();
                meshStream.parse(file, baseo, ds);
                streamRefs.Add(meshStream);
            }

            modLinks = loadLinkIDs(ds);
            file.addMesh(this);
        }
Example #26
0
        public void parse(NIFFile file, NIFObject baseo, BinaryReader ds)
        {
            streamLinkID = ds.readInt();
            instanced    = ds.readUnsignedByte() > 0;

            int numStreamSubmeshRegionMapEntries = ds.readUnsignedShort();

            submeshRegionMap = new List <int>(numStreamSubmeshRegionMapEntries);
            for (int i = 0; i < numStreamSubmeshRegionMapEntries; i++)
            {
                submeshRegionMap.Add(ds.readUnsignedShort());
            }
            int numElementDescs = ds.readInt();

            elementDescs = new List <Pair <String, int> >(numElementDescs);
            for (int i = 0; i < numElementDescs; i++)
            {
                int    descNameIndex = ds.readInt();
                String descName      = file.getStringFromTable(descNameIndex);
                int    descIndex     = ds.readInt();
                elementDescs.Add(NIF.Pair <String, int> .of(descName, descIndex));
            }
        }
Example #27
0
 public StreamAndElement getStreamAndElement(NIFFile file, String elementName, int preferredIndex)
 {
     foreach (NifMeshStream streamRef in streamRefs)
     {
         for (int i = 0; i < streamRef.elementDescs.Count(); i++)
         {
             Pair <String, int> pair          = streamRef.elementDescs[i];
             String             elemCheckName = pair.getKey();
             int elemCheckIndex = pair.getValue();
             if (preferredIndex == -1 || elemCheckIndex == preferredIndex)
             {
                 if (elemCheckName.StartsWith(elementName))
                 {
                     NiDataStream dataStream = (NiDataStream)file.getObject(streamRef.streamLinkID);
                     if (dataStream == null)
                     {
                         Debug.Log("null dataStream");
                     }
                     if (dataStream.streamElems == null)
                     {
                         Debug.Log("null dataStream.streamElems: " + dataStream);
                     }
                     if (i >= dataStream.streamElems.Count())
                     {
                         Debug.Log("WARNING: Data stream does not have enough elements.");
                     }
                     else
                     {
                         NifStreamElement elem = dataStream.streamElems[i];
                         return(new StreamAndElement(streamRef, elem, dataStream));
                     }
                 }
             }
         }
     }
     return(null);
 }
Example #28
0
        public static MeshData prepareMesh(NIFFile nf, NiMesh mesh)
        {
            bool IS_TERRAIN = (nf.getStringTable().Contains("terrainL1"));

            StreamAndElement indexStreamObj = mesh.getStreamAndElement(nf, "INDEX", -1);
            NifMeshStream    indexStreamRef = indexStreamObj.streamRef;
            NiDataStream     indexStream    = indexStreamObj.dataStream;
            NifStreamElement indexElem      = indexStreamObj.elem;

            StreamAndElement nStreamObj = mesh.getStreamAndElement(nf, "NORMAL", -1);
            NifMeshStream    nStreamRef = nStreamObj.streamRef;
            NiDataStream     nStream    = nStreamObj.dataStream;
            NifStreamElement nElem      = nStreamObj.elem;

            StreamAndElement uvStreamObj  = mesh.getStreamAndElement(nf, "TEXCOORD", -1);
            StreamAndElement uv2StreamObj = mesh.getStreamAndElement(nf, "TEXCOORD", 1);


            StreamAndElement positionStreamObj = mesh.getStreamAndElement(nf, "POSITION", -1);
            NifMeshStream    posStreamRef      = positionStreamObj.streamRef;
            NiDataStream     posStream         = positionStreamObj.dataStream;
            NifStreamElement posElem           = positionStreamObj.elem;
            DataType         indexDataType     = typeForNifDataType(indexStreamObj.elem.dataType);
            DataType         posDataType       = typeForNifDataType(positionStreamObj.elem.dataType);

            if (posDataType != DataType.FLOAT)
            {
                throw new Exception("Unknown position types");
            }

            MeshData           meshData    = new MeshData();
            List <Vector3>     verts       = meshData.verts;
            List <Vector2>     uvs         = meshData.uvs;
            List <List <int> > triangles   = meshData.triangles;
            List <Vector3>     inNormals   = meshData.inNormals;
            List <BoneWeight>  boneWeights = meshData.boneWeights;

            for (int i = 0; i < mesh.numSubMeshes; i++)
            {
                List <int> bonePalette = new List <int>();

                int vOffset = verts.Count;
                /** vertices */
                StreamRegion posRegion     = posStream.streamRegions[posStreamRef.submeshRegionMap[i]];
                int          posOfs        = posRegion.a * posStream.elemStride;
                int          posEnd        = posOfs + posRegion.b * posStream.elemStride;
                byte[]       posStreamData = posStream.streamData;
                using (BinaryReader dis = new BinaryReader(new MemoryStream(posStreamData, posOfs, posEnd - posOfs)))
                {
                    // Debug.Log("\tverts:" + posRegion.b);
                    for (int v = 0; v < (posEnd - posOfs) / posStream.elemStride; v++)
                    {
                        float x = dis.readFloat();
                        float y = dis.readFloat();
                        float z = dis.readFloat();
                        verts.Add(new Vector3(x, y, z));
                    }
                    //Debug.Log("pos: left over: " + (dis.BaseStream.Length - dis.BaseStream.Position));
                }


                /** faces */
                StreamRegion idxRegion     = indexStream.streamRegions[indexStreamRef.submeshRegionMap[i]];
                int          idxOfs        = idxRegion.a * indexStream.elemStride;
                DataType     idxType       = typeForNifDataType(indexStreamObj.elem.dataType);
                int          idxEnd        = idxOfs + idxRegion.b * indexStream.elemStride;
                byte[]       idxStreamData = indexStream.streamData;

                List <int> tris = new List <int>();
                using (BinaryReader dis = new BinaryReader(new MemoryStream(idxStreamData, idxOfs, idxEnd - idxOfs)))
                {
                    for (int idx = 0; idx < (idxEnd - idxOfs) / indexStream.elemStride; idx++)
                    {
                        int v1x = (dis.readUnsignedShort()) + vOffset;
                        tris.Add(v1x);
                    }
                    //Debug.Log("idx left over:" + (dis.BaseStream.Length - dis.BaseStream.Position));
                }
                triangles.Add(tris);
                {
                    /** uvs */
                    if (uvStreamObj != null)
                    {
                        NiDataStream uvStream     = uvStreamObj.dataStream;
                        StreamRegion uvRegion     = uvStreamObj.dataStream.streamRegions[uvStreamObj.streamRef.submeshRegionMap[i]];
                        DataType     uvType       = typeForNifDataType(uvStreamObj.elem.dataType);
                        int          uvOfs        = uvRegion.a * uvStream.elemStride;
                        int          uvEnd        = uvOfs + uvRegion.b * uvStream.elemStride;
                        byte[]       uvStreamData = uvStream.streamData;
                        //Debug.Log("uv datatype:" + uvType + ":" + uvStream.elemStride);
                        using (BinaryReader dis = new BinaryReader(new MemoryStream(uvStreamData, uvOfs, uvEnd - uvOfs)))
                        {
                            for (int uv = 0; uv < (uvEnd - uvOfs) / uvStream.elemStride; uv++)
                            {
                                float u = dis.readFloat();
                                float v = dis.readFloat();
                                uvs.Add(new Vector2(u, v));
                            }
                        }
                    }

                    /** normals */
                    if (nStreamObj != null)
                    {
                        StreamRegion nRegion     = nStreamObj.dataStream.streamRegions[nStreamObj.streamRef.submeshRegionMap[i]];
                        DataType     nType       = typeForNifDataType(nStreamObj.elem.dataType);
                        int          nOfs        = nRegion.a * nStream.elemStride;
                        int          nEnd        = nOfs + nRegion.b * nStream.elemStride;
                        byte[]       nStreamData = nStream.streamData;
                        using (BinaryReader dis = new BinaryReader(new MemoryStream(nStreamData, nOfs, nEnd - nOfs)))
                        {
                            for (int n = 0; n < (nEnd - nOfs) / nStream.elemStride; n++)
                            {
                                float x = dis.readFloat();
                                float y = dis.readFloat();
                                float z = dis.readFloat();
                                inNormals.Add(new Vector3(x, y, z));
                            }
                        }
                    }

                    /** bone palette */
                    {
                        StreamAndElement bonePalStreamObj = mesh.getStreamAndElement(nf, "BONE_PALETTE", -1);
                        if (bonePalStreamObj != null)
                        {
                            NifMeshStream    bonePalStreamRef = bonePalStreamObj.streamRef;
                            NiDataStream     bonePalStream    = bonePalStreamObj.dataStream;
                            NifStreamElement bonePalElem      = bonePalStreamObj.elem;

                            StreamRegion bonePalRegion     = bonePalStreamObj.dataStream.streamRegions[bonePalStreamObj.streamRef.submeshRegionMap[i]];
                            DataType     bonePalType       = typeForNifDataType(bonePalStreamObj.elem.dataType);
                            int          bonePalOfs        = bonePalRegion.a * bonePalStream.elemStride;
                            int          bonePalEnd        = bonePalOfs + bonePalRegion.b * bonePalStream.elemStride;
                            byte[]       bonePalStreamData = bonePalStream.streamData;
                            using (BinaryReader dis = new BinaryReader(new MemoryStream(bonePalStreamData, bonePalOfs, bonePalEnd - bonePalOfs)))
                            {
                                for (int n = 0; n < (bonePalEnd - bonePalOfs) / bonePalStream.elemStride; n++)
                                {
                                    bonePalette.Add(dis.readUnsignedShort());
                                }
                            }
                        }
                    }
                    {
                        /** blend indicies */
                        StreamAndElement StreamObj = mesh.getStreamAndElement(nf, "BLENDINDICES", -1);
                        if (StreamObj != null)
                        {
                            NifMeshStream StreamRef = StreamObj.streamRef;
                            NiDataStream  Stream    = StreamObj.dataStream;

                            StreamRegion Region     = StreamObj.dataStream.streamRegions[StreamObj.streamRef.submeshRegionMap[i]];
                            DataType     type       = typeForNifDataType(StreamObj.elem.dataType);
                            int          Ofs        = Region.a * Stream.elemStride;
                            int          End        = Ofs + Region.b * Stream.elemStride;
                            byte[]       StreamData = Stream.streamData;
                            //Debug.Log("blendi stride:" + Stream.elemStride + ": type:" + type);

                            // each vertex has a blend index
                            using (BinaryReader dis = new BinaryReader(new MemoryStream(StreamData, Ofs, End - Ofs)))
                            {
                                for (int n = 0; n < (End - Ofs) / Stream.elemStride; n++)
                                {
                                    byte       idx1   = dis.ReadByte();
                                    byte       idx2   = dis.ReadByte();
                                    byte       idx3   = dis.ReadByte();
                                    byte       idx4   = dis.ReadByte();
                                    BoneWeight weight = new BoneWeight();
                                    weight.boneIndex0 = bonePalette[idx1];
                                    weight.boneIndex1 = bonePalette[idx2];
                                    weight.boneIndex2 = bonePalette[idx3];
                                    weight.boneIndex3 = bonePalette[idx4];

                                    boneWeights.Add(weight);
                                }
                                //Debug.Log("blend: left over: " + (dis.BaseStream.Length - dis.BaseStream.Position));
                            }
                        }
                    }
                    {
                        /** blend weights */
                        StreamAndElement StreamObj = mesh.getStreamAndElement(nf, "BLENDWEIGHT", -1);
                        if (StreamObj != null)
                        {
                            NifMeshStream StreamRef = StreamObj.streamRef;
                            NiDataStream  Stream    = StreamObj.dataStream;

                            StreamRegion Region     = StreamObj.dataStream.streamRegions[StreamObj.streamRef.submeshRegionMap[i]];
                            DataType     type       = typeForNifDataType(StreamObj.elem.dataType);
                            int          Ofs        = Region.a * Stream.elemStride;
                            int          End        = Ofs + Region.b * Stream.elemStride;
                            byte[]       StreamData = Stream.streamData;

                            using (BinaryReader dis = new BinaryReader(new MemoryStream(StreamData, Ofs, End - Ofs)))
                            {
                                int total = (End - Ofs) / Stream.elemStride;
                                // each vertex has weights
                                for (int n = 0; n < total; n++)
                                {
                                    BoneWeight w = boneWeights[n + vOffset];
                                    w.weight0 = dis.readFloat();
                                    w.weight1 = dis.readFloat();
                                    w.weight2 = dis.readFloat();
                                    w.weight3 = 0;
                                    boneWeights[n + vOffset] = w;
                                }
                            }
                        }
                    }
                }
            }

            if (IS_TERRAIN && uvs.Count == 0)
            {
                for (int i = 0; i < verts.Count; i++)
                {
                    Vector3 vert = verts[i];
                    float   x    = vert.x;
                    float   z    = vert.z;

                    float u = (x / 256.0f);
                    float v = (z / 256.0f);
                    uvs.Add(new Vector2(u, v));
                }
            }

            List <int> trisList = new List <int>();

            for (int i = 0; i < triangles.Count; i++)
            {
                List <int> tris = triangles[i];
                trisList.AddRange(tris);
            }
            meshData.tristest = trisList.ToArray();
            return(meshData);
        }
Example #29
0
 protected virtual void loadObjectNET(NIFFile file, BinaryReader ds)
 {
     name         = file.loadString(ds);
     extraDataIDs = loadLinkIDs(ds);
     loadLinkID(ds);
 }
Example #30
0
 public override void parse(NIFFile file, NIFObject baseo, BinaryReader ds)
 {
     base.parse(file, baseo, ds);
 }