private PhysicsOutput[] readOutputs(CubismPhysicsSetting.PhysicsSetting.OutputSetting[] settings) { var data = new PhysicsOutput[settings.Length]; for (int i = 0; i < data.Length; ++i) { data[i] = new PhysicsOutput { Destination = model.Parameters.Get(settings[i].Destination.Id), DestinationId = settings[i].Destination.Id, ParticleIndex = settings[i].VertexIndex, TranslationScale = Vector2.Zero, AngleScale = settings[i].Scale, Weight = settings[i].Weight, SourceComponent = Enum.Parse <PhysicsSource>(settings[i].Type), IsInverted = settings[i].Reflect, ValueBelowMinimum = 0.0f, ValueExceededMaximum = 0.0f, UseAngleCorrection = UseAngleCorrection, }; } return(data); }
private void updateOutputParameterValue(CubismParameter parameter, float translation, PhysicsOutput output) { float outputScale = 1.0f; outputScale = output.GetScale(); float value = translation * outputScale; if (value < parameter.Minimum) { if (value < output.ValueBelowMinimum) { output.ValueBelowMinimum = value; } value = parameter.Minimum; } else if (value > parameter.Maximum) { if (value > output.ValueExceededMaximum) { output.ValueExceededMaximum = value; } value = parameter.Maximum; } float weight = output.Weight / CubismPhysics.MaximumWeight; if (weight >= 1.0f) { parameter.Value = value; } else { value = (parameter.Value * (1.0f - weight)) + (value * weight); parameter.Value = value; } }