public void satisfy(float pdt) { tensionDirection.Set((float)(p1.Pos.X - p2.Pos.X), (float)(p1.Pos.Y - p2.Pos.Y), (float)(p1.Pos.Z - p2.Pos.Z)); springLength = tensionDirection.Length(); if (springLength == 0) { tensionDirection.Set((float)Rand.NextDouble() / 100f - 1 / 50f, (float)Rand.NextDouble() / 100f - 1 / 50f, (float)Rand.NextDouble() / 100f - 1 / 50f); springLength = tensionDirection.Length(); } extension = springLength - rest_length; double tension = StretchStiffness * (extension * inverse_length); tensionDirection *= (float)(tension / springLength); p2.Tension.Add(tensionDirection); p1.Tension.Sub(tensionDirection); p2.TensionDirection.Set(tensionDirection); p1.TensionDirection.Set(-tensionDirection.X, -tensionDirection.Y, -tensionDirection.Z); p1.extension = extension; p2.extension = extension; }
void loadMesh() { Vec3f origin = block1.Pos.ToVec3f() - block2.Pos.ToVec3f(); api.Tesselator.TesselateBlock(api.World.GetBlock(new AssetLocation("temporalengineering:wire")), out wiremesh); wiremesh.Scale(new Vec3f(0.5f, 0.5f, 0.5f), 1 * origin.Length(), 1, 1); float radZ = (float)Math.Atan2(origin.Y, Math.Sqrt(origin.X * origin.X + origin.Z * origin.Z)); wiremesh.Rotate(new Vec3f(0.5f, 0.5f, 0.5f), 0, -(float)Math.Atan2(origin.Z, origin.X), radZ); origin = origin / 2; wiremesh.Translate(-origin.X, -origin.Y, -origin.Z); }