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


C# SoftBody.AppendMaterial方法代码示例

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


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

示例1: CreateFromIndexedMesh

        SoftBody CreateFromIndexedMesh(Vector3Array vertexArray, IntArray triangleVertexIndexArray, bool createBendLinks)
        {
            SoftBody softBody = new SoftBody(SoftWorld.WorldInfo, vertexArray, null);
            Material structuralMaterial = softBody.AppendMaterial();
            Material bendMaterial;
            if (createBendLinks)
            {
                bendMaterial = softBody.AppendMaterial();
                bendMaterial.Lst = 0.7f;
            }
            else
            {
                bendMaterial = null;
            }
            structuralMaterial.Lst = 1.0f;

            int numVertices = vertexArray.Count;
            int numTriangles = triangleVertexIndexArray.Count / 3;

            // List of values for each link saying which triangle is associated with that link
            // -1 to start. Once a value is entered we know the "other" triangle
            // and can add a link across the link
            AlignedIntArray triangleForLinks = new AlignedIntArray();
            triangleForLinks.Resize(numVertices * numVertices, -1);

            for (int triangle = 0; triangle < numTriangles; ++triangle)
            {
                int[] index = new int[] { triangleVertexIndexArray[triangle * 3], triangleVertexIndexArray[triangle * 3 + 1], triangleVertexIndexArray[triangle * 3 + 2] };
                softBody.AppendFace(index[0], index[1], index[2]);

                // Generate the structural links directly from the triangles
                TestAndAddLink(triangleForLinks, softBody, triangle, triangleVertexIndexArray, numVertices, index[0], index[1], index[2], structuralMaterial, createBendLinks, bendMaterial);
                TestAndAddLink(triangleForLinks, softBody, triangle, triangleVertexIndexArray, numVertices, index[1], index[2], index[0], structuralMaterial, createBendLinks, bendMaterial);
                TestAndAddLink(triangleForLinks, softBody, triangle, triangleVertexIndexArray, numVertices, index[2], index[0], index[1], structuralMaterial, createBendLinks, bendMaterial);
            }

            return softBody;
        }
开发者ID:WebFreak001,项目名称:BulletSharp,代码行数:38,代码来源:Physics.cs


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