当前位置: 首页>>代码示例>>C#>>正文


C# BitPack.UnpackUInt方法代码示例

本文整理汇总了C#中BitPack.UnpackUInt方法的典型用法代码示例。如果您正苦于以下问题:C# BitPack.UnpackUInt方法的具体用法?C# BitPack.UnpackUInt怎么用?C# BitPack.UnpackUInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BitPack的用法示例。


在下文中一共展示了BitPack.UnpackUInt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LoadMesh

        public virtual void LoadMesh(string filename)
        {
            byte[] buffer = File.ReadAllBytes(filename);
            BitPack input = new BitPack(buffer, 0);

            _header = TrimAt0(input.UnpackString(24));
            if (!String.Equals(_header, MESH_HEADER))
                return;

            // Populate base mesh variables
            _hasWeights = (input.UnpackByte() != 0);
            _hasDetailTexCoords = (input.UnpackByte() != 0);
            _position = new Vector3(input.UnpackFloat(), input.UnpackFloat(), input.UnpackFloat());
            _rotationAngles = new Vector3(input.UnpackFloat(), input.UnpackFloat(), input.UnpackFloat());
            _rotationOrder = input.UnpackByte();
            _scale = new Vector3(input.UnpackFloat(), input.UnpackFloat(), input.UnpackFloat());
            _numVertices = (ushort)input.UnpackUShort();

            // Populate the vertex array
            _vertices = new Vertex[_numVertices];

            for (int i = 0; i < _numVertices; i++)
                _vertices[i].Coord = new Vector3(input.UnpackFloat(), input.UnpackFloat(), input.UnpackFloat());

            for (int i = 0; i < _numVertices; i++)
                _vertices[i].Normal = new Vector3(input.UnpackFloat(), input.UnpackFloat(), input.UnpackFloat());

            for (int i = 0; i < _numVertices; i++)
                _vertices[i].BiNormal = new Vector3(input.UnpackFloat(), input.UnpackFloat(), input.UnpackFloat());

            for (int i = 0; i < _numVertices; i++)
                _vertices[i].TexCoord = new Vector2(input.UnpackFloat(), input.UnpackFloat());

            if (_hasDetailTexCoords)
            {
                for (int i = 0; i < _numVertices; i++)
                    _vertices[i].DetailTexCoord = new Vector2(input.UnpackFloat(), input.UnpackFloat());
            }

            if (_hasWeights)
            {
                for (int i = 0; i < _numVertices; i++)
                    _vertices[i].Weight = input.UnpackFloat();
            }

            _numFaces = input.UnpackUShort();

            _faces = new Face[_numFaces];

            for (int i = 0; i < _numFaces; i++)
                _faces[i].Indices = new short[] { input.UnpackShort(), input.UnpackShort(), input.UnpackShort() };

            if (_hasWeights)
            {
                _numSkinJoints = input.UnpackUShort();
                _skinJoints = new string[_numSkinJoints];

                for (int i = 0; i < _numSkinJoints; i++)
                {
                    _skinJoints[i] = TrimAt0(input.UnpackString(64));
                }
            }
            else
            {
                _numSkinJoints = 0;
                _skinJoints = new string[0];
            }

            // Grab morphs
            List<Morph> morphs = new List<Morph>();
            string morphName = TrimAt0(input.UnpackString(64));

            while (morphName != MORPH_FOOTER)
            {
                if (input.BytePos + 48 >= input.Data.Length) throw new FileLoadException("Encountered end of file while parsing morphs");

                Morph morph = new Morph();
                morph.Name = morphName;
                morph.NumVertices = input.UnpackInt();
                morph.Vertices = new MorphVertex[morph.NumVertices];

                for (int i = 0; i < morph.NumVertices; i++)
                {
                    morph.Vertices[i].VertexIndex = input.UnpackUInt();
                    morph.Vertices[i].Coord = new Vector3(input.UnpackFloat(), input.UnpackFloat(), input.UnpackFloat());
                    morph.Vertices[i].Normal = new Vector3(input.UnpackFloat(), input.UnpackFloat(), input.UnpackFloat());
                    morph.Vertices[i].BiNormal = new Vector3(input.UnpackFloat(), input.UnpackFloat(), input.UnpackFloat());
                    morph.Vertices[i].TexCoord = new Vector2(input.UnpackFloat(), input.UnpackFloat());
                }

                morphs.Add(morph);

                // Grab the next name
                morphName = TrimAt0(input.UnpackString(64));
            }

            _morphs = morphs.ToArray();

            // Check if there are remaps or if we're at the end of the file
            if (input.BytePos < input.Data.Length - 1)
//.........这里部分代码省略.........
开发者ID:justincc,项目名称:libopenmetaverse,代码行数:101,代码来源:LindenMesh.cs


注:本文中的BitPack.UnpackUInt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。