本文整理汇总了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)
//.........这里部分代码省略.........