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


C# SlimDX.UnlockVertexBuffer方法代码示例

本文整理汇总了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();
            }
        }
开发者ID:hejob,项目名称:SB3Utility,代码行数:95,代码来源:RenderObjectUnity.cs


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