void Start() { TrianglesFromGrid source = new TrianglesFromGrid(radius, width, depth); Matrix4x4d T = Matrix4x4d.Translate(new Vector3d(0.0, height, 0.0)); Matrix4x4d R = Matrix4x4d.Rotate(new Vector3d(0.0, 0.0, 0.0)); Matrix4x4d RT = T * R; Body = new ClothBody3d(source, radius, mass, stretchStiffness, bendStiffness, RT); Body.Dampning = 1.0; Vector3 min = new Vector3((float)(-width / 2 - 0.1), (float)(height - 0.1), (float)(-depth / 2 - 0.1)); Vector3 max = new Vector3((float)(width / 2 + 0.1), (float)(height + 0.1), (float)(-depth / 2 + 0.1)); StaticBounds = new Box3d(min, max); Body.MarkAsStatic(StaticBounds); Solver = new Solver3d(); Solver.AddBody(Body); Solver.AddForce(new GravitationalForce3d()); //Solver.AddCollision(new PlanarCollision3d(Vector3.up, 0)); Solver.SolverIterations = 2; Solver.CollisionIterations = 2; Solver.SleepThreshold = 1; //setting compute shader of solver Solver.ApplyExternalForcesShader = ApplyExternalForces; Solver.EstimatePositionsShader = EstimatePositions; Solver.ResolveCollisionsShader = ResolveCollisions; Solver.ConstraintPositionsShader = ConstraintPositions; Solver.UpdateVelocitiesShader = UpdateVelocities; Solver.ConstraintVelocitiesShader = ConstraintVelocities; Solver.UpdatePositionsShader = UpdatePositions; Solver.GPUmode = GPUmode; Solver.init(); CreateSpheres(); }
void Start() { double stretchStiffness = 0.25; double bendStiffness = 0.5; double mass = 1.0; double radius = 0.125; double width = 5.0; double height = 4.0; double depth = 5.0; TrianglesFromGrid source = new TrianglesFromGrid(radius, width, depth); Matrix4x4d T = Matrix4x4d.Translate(new Vector3d(0.0, height, 0.0)); Matrix4x4d R = Matrix4x4d.Rotate(new Vector3d(0.0, 0.0, 0.0)); Matrix4x4d RT = T * R; Body = new ClothBody3d(source, radius, mass, stretchStiffness, bendStiffness, RT); Body.Dampning = 1.0; Vector3d min = new Vector3d(-width / 2 - 0.1, height - 0.1, -depth / 2 - 0.1); Vector3d max = new Vector3d(width / 2 + 0.1, height + 0.1, -depth / 2 + 0.1); StaticBounds = new Box3d(min, max); Body.MarkAsStatic(StaticBounds); Solver = new Solver3d(); Solver.AddBody(Body); Solver.AddForce(new GravitationalForce3d()); Solver.AddCollision(new PlanarCollision3d(Vector3d.UnitY, 0)); Solver.SolverIterations = 2; Solver.CollisionIterations = 2; Solver.SleepThreshold = 1; RenderEvent.AddRenderEvent(Camera.main, DrawOutline); CreateSpheres(); }