IEnumerator Start() { while (!softVolume.Ready()) { yield return(null); } Vector3[] vertices = softVolume.GetWireFrameVertices(); Partix.VehiclePointLoad[] loads = softVolume.GetPointLoads(); // boundingbox BoundingBox bb = new BoundingBox(vertices); for (int i = 0; i < vertices.Length; i++) { Vector3 v = vertices[i]; Vector3 np = bb.CalculateNormalizedPosition(v); loads[i].friction = 0.2f; loads[i].fix_target = np.y < 0.1f ? 1 : 0; // loads[i].fix_target = 0; } softVolume.SetPointLoads(loads); Partix.EntityFeatures ef = new Partix.EntityFeatures(); ef.stretch_factor = 0.1f; ef.restore_factor = 0.8f; ef.alive = 1; ef.positive = 1; ef.influential = 1; ef.auto_freezing = 1; ef.frozen = 1; // ef.auto_freezing = 0; // ef.frozen = 0; softVolume.SetFeatures(ef); }
IEnumerator Start() { while (!sv.Ready()) { yield return(null); } Vector3[] vertices = sv.GetWireFrameVertices(); Partix.VehiclePointLoad[] loads = sv.GetPointLoads(); // boundingbox BoundingBox bb = new BoundingBox(vertices); // weight設定 for (int i = 0; i < vertices.Length; i++) { Vector3 np = bb.CalculateNormalizedPosition(vertices[i]); float w = 1.0f; float z = 1.0f - np.z; float y = 1.0f - np.y; w += z * z * y * 6.0f; loads[i].weight = w * 0.2f; loads[i].friction = w * 0.2f; loads[i].fix_target = 0; } sv.SetPointLoads(loads); }
void Update() { if (!softVolume.Ready()) { return; } if (photonView.isMine) { position = softVolume.currOrientation.GetColumn(3); prevPosition = softVolume.prevOrientation.GetColumn(3); orientation = GetOrientation(softVolume.currOrientation); prevOrientation = GetOrientation(softVolume.prevOrientation); } else { var t = PhotonNetwork.time - sendTime; var z = (float)(t / softVolume.world.deltaTime); Vector3 v = position - prevPosition; Vector3 p = position + v * z; Quaternion q = Quaternion.SlerpUnclamped(prevOrientation, orientation, z); Matrix4x4 m = Matrix4x4.TRS(p, q, Vector3.one); matrix = m; softVolume.BlendPosition(m, blendFactor, velocityBlendFactor); } }
IEnumerator Start() { while (!softVolume.Ready()) { yield return(null); } Misc.Fix(softVolume, 0.2f, 0.2f); var ef = new Partix.EntityFeatures(); ef.stretch_factor = 0.6f; ef.restore_factor = 0.6f; ef.alive = 1; ef.positive = 1; ef.influential = 1; ef.auto_freezing = 0; ef.frozen = 0; softVolume.SetFeatures(ef); }
void Update() { if (!Application.isPlaying) { if (usedVolume == softVolume.volume && usedScale == softVolume.partixScale) { return; } usedVolume = softVolume.volume; usedScale = softVolume.partixScale; if (usedVolume != null) { SetUpFromStaticData(); } } else { if (!softVolume.Ready()) { return; } int[] indices = softVolume.GetWireFrameIndices(); mesh.vertices = softVolume.GetWireFrameVertices(); mesh.SetIndices(indices, MeshTopology.Lines, 0); VehiclePointLoad[] vpl = softVolume.GetPointLoads(); colors = new Color[vpl.Length]; for (int i = 0; i < colors.Length; i++) { var c = new Color(0, 0, 0); if (renderWeight) { c.r = vpl[i].weight; } if (renderFriction) { c.g = vpl[i].friction; } if (renderAccel) { c.b = vpl[i].accel; } colors[i] = c; } mesh.colors = colors; } }