Esempio n. 1
0
 /// <summary>
 /// Set SoftBody material properties
 /// </summary>
 /// <param name="softBody"></param>
 /// <returns></returns>
 public void SetSBMaterial(BulletSharp.SoftBody.Material mat)
 {
     mat.AngularStiffness = AngularStiffness;
     mat.LinearStiffness  = LinearStiffness;
     mat.VolumeStiffness  = VolumeStiffness;
     mat.Flags            = Flags;
 }
 /// <summary>
 /// Set SoftBody material properties
 /// </summary>
 /// <param name="softBody"></param>
 /// <returns></returns>
 public void SetSBMaterial(BulletSharp.SoftBody.Material mat)
 {
     mat.Ast   = AST;
     mat.Lst   = LST;
     mat.Vst   = VST;
     mat.Flags = Flags;
 }
Esempio n. 3
0
        /// <summary>
        /// Apply these SoftBody settings to this SoftBody
        /// </summary>
        /// <param name="softBody"></param>
        public void ConfigureSoftBody(SoftBody softBody)
        {
            softBody.Scale(scale.ToBullet());

            BulletSharp.SoftBody.Material pm = softBody.Materials[0];

            sBMaterial.SetSBMaterial(pm);

            config.CopyToBulletSBConfig(softBody.Cfg);

            if (allNodeBendingConstraints)
            {
                for (int i = 0; i < softBody.Nodes.Count - 1; ++i)
                {
                    softBody.GenerateBendingConstraints(1 + i);
                }
            }
            else
            {
                softBody.GenerateBendingConstraints(bendingConstraintDistance, pm);
            }

            if (randomizeConstraints)
            {
                softBody.RandomizeConstraints();
            }

            if (generateClusters)
            {
                softBody.GenerateClusters(0);
            }

            softBody.SetTotalMass(totalMass, fromFaces);

            softBody.SetPose(bvolume, bframe);
        }
		public int GenerateBendingConstraints(int distance, Material mat)
		{
			return btSoftBody_generateBendingConstraints2(_native, distance, mat._native);
		}
		public void AppendTetra(int node0, int node1, int node2, int node3, Material mat)
		{
			btSoftBody_appendTetra3(_native, node0, node1, node2, node3, mat._native);
		}
		public void AppendTetra(int model, Material mat)
		{
			btSoftBody_appendTetra(_native, model, mat._native);
		}
		public void AppendLink(Node node0, Node node1, Material mat, bool checkExist)
		{
            btSoftBody_appendLink9(_native, node0._native, node1._native, (mat != null) ? mat._native : IntPtr.Zero, checkExist);
		}
		public void AppendLink(Node node0, Node node1, Material mat)
		{
            btSoftBody_appendLink8(_native, node0._native, node1._native, (mat != null) ? mat._native : IntPtr.Zero);
		}
		public void AppendLink(int model, Material mat)
		{
            btSoftBody_appendLink6(_native, model, (mat != null) ? mat._native : IntPtr.Zero);
		}
Esempio n. 10
0
		public void AppendLink(int node0, int node1, Material mat)
		{
			btSoftBody_appendLink2(_native, node0, node1, (mat != null) ? mat._native : IntPtr.Zero);
		}
Esempio n. 11
0
		public void AppendFace(int node0, int node1, int node2, Material mat)
		{
			btSoftBody_appendFace5(_native, node0, node1, node2, mat._native);
		}
Esempio n. 12
0
		public void AppendFace(int model, Material mat)
		{
			btSoftBody_appendFace3(_native, model, mat._native);
		}
Esempio n. 13
0
        // Helper to test and add links correctly.
        // Records links that have already been generated
        static bool TestAndAddLink(AlignedIntArray trianglesForLinks, SoftBody softBody, int triangle, IntArray triangleVertexIndexArray, int numVertices, int vertex0, int vertex1, int nonLinkVertex, Material structuralMaterial, bool createBendLinks, Material bendMaterial)
        {
            if (trianglesForLinks[numVertices * vertex0 + vertex1] >= 0 && createBendLinks)
            {
                // Already have link so find other triangle and generate cross link

                int otherTriangle = trianglesForLinks[numVertices * vertex0 + vertex1];
                int[] otherIndices = new int[] { triangleVertexIndexArray[otherTriangle * 3], triangleVertexIndexArray[otherTriangle * 3 + 1], triangleVertexIndexArray[otherTriangle * 3 + 2] };

                int nodeA = 0;
                // Test all links of the other triangle against this link. The one that's not part of it is what we want.
                if (otherIndices[0] != vertex0 && otherIndices[0] != vertex1)
                    nodeA = otherIndices[0];
                if (otherIndices[1] != vertex0 && otherIndices[1] != vertex1)
                    nodeA = otherIndices[1];
                if (otherIndices[2] != vertex0 && otherIndices[2] != vertex1)
                    nodeA = otherIndices[2];

                softBody.AppendLink(nodeA, nonLinkVertex, bendMaterial);
            }
            else
            {
                // Don't yet have link so create it
                softBody.AppendLink(vertex0, vertex1, structuralMaterial);

                // If we added a new link, set the triangle array
                trianglesForLinks[numVertices * vertex0 + vertex1] = triangle;
                trianglesForLinks[numVertices * vertex1 + vertex0] = triangle;

            }

            return true;
        }