本文整理汇总了C#中SlimDX.UnlockVertexBuffer方法的典型用法代码示例。如果您正苦于以下问题:C# SlimDX.UnlockVertexBuffer方法的具体用法?C# SlimDX.UnlockVertexBuffer怎么用?C# SlimDX.UnlockVertexBuffer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SlimDX
的用法示例。
在下文中一共展示了SlimDX.UnlockVertexBuffer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FillVertexBuffer
private void FillVertexBuffer(SlimDX.Direct3D9.Mesh animationMesh, List<Operations.vVertex> vertexList, int selectedBoneIdx)
{
using (DataStream vertexStream = animationMesh.LockVertexBuffer(LockFlags.None))
{
Color4 col = new Color4(1f, 1f, 1f);
for (int i = 0; i < vertexList.Count; i++)
{
Operations.vVertex vertex = vertexList[i];
vertexStream.Write(vertex.position.X);
vertexStream.Write(vertex.position.Y);
vertexStream.Write(vertex.position.Z);
if (vertex.boneIndices != null)
{
vertexStream.Write(vertex.weights[0]);
vertexStream.Write(vertex.weights[1]);
vertexStream.Write(vertex.weights[2]);
vertexStream.Write((byte)vertex.boneIndices[0]);
vertexStream.Write((byte)vertex.boneIndices[1]);
vertexStream.Write((byte)vertex.boneIndices[2]);
vertexStream.Write((byte)vertex.boneIndices[3]);
}
else
{
vertexStream.Write((float)0);
vertexStream.Write((float)0);
vertexStream.Write((float)0);
vertexStream.Write((byte)0);
vertexStream.Write((byte)0);
vertexStream.Write((byte)0);
vertexStream.Write((byte)0);
}
vertexStream.Write(vertex.normal.X);
vertexStream.Write(vertex.normal.Y);
vertexStream.Write(vertex.normal.Z);
if (selectedBoneIdx >= 0)
{
col.Red = 0f; col.Green = 0f; col.Blue = 0f;
int[] boneIndices = vertex.boneIndices;
float[] boneWeights = vertex.weights;
for (int j = 0; j < boneIndices.Length; j++)
{
if (boneIndices[j] == 0 && boneWeights[j] == 0)
{
continue;
}
int boneIdx = boneIndices[j];
if (boneIdx == selectedBoneIdx)
{
/* switch (cols)
{
case WeightsColourPreset.Greyscale:
col.r = col.g = col.b = boneWeights[j];
break;
case WeightsColourPreset.Metal:
col.r = boneWeights[j] > 0.666f ? 1f : boneWeights[j] * 1.5f;
col.g = boneWeights[j] * boneWeights[j] * boneWeights[j];
break;
WeightsColourPreset.Rainbow:*/
if (boneWeights[j] > 0.75f)
{
col.Red = 1f;
col.Green = (1f - boneWeights[j]) * 2f;
col.Blue = 0f;
}
else if (boneWeights[j] > 0.5f)
{
col.Red = 1f;
col.Green = (1f - boneWeights[j]) * 2f;
col.Blue = 0f;
}
else if (boneWeights[j] > 0.25f)
{
col.Red = (boneWeights[j] - 0.25f) * 4f;
col.Green = 1f;
col.Blue = 0f;
}
else
{
col.Green = boneWeights[j] * 4f;
col.Blue = 1f - boneWeights[j] * 4f;
}
/* break;
}*/
break;
}
}
}
vertexStream.Write(col.ToArgb());
vertexStream.Write(vertex.uv[0]);
vertexStream.Write(vertex.uv[1]);
}
animationMesh.UnlockVertexBuffer();
}
}