protected override bool Initialize() { if (Material1 == null || Material2 == null) { Debug.LogWarning(name + ": Trying to create contact material with at least one unreferenced ShapeMaterial.", this); return(false); } agx.Material m1 = Material1.GetInitialized <ShapeMaterial>().Native; agx.Material m2 = Material2.GetInitialized <ShapeMaterial>().Native; agx.ContactMaterial old = GetSimulation().getMaterialManager().getContactMaterial(m1, m2); if (old != null) { Debug.LogWarning(name + ": Material manager already contains a contact material with this material pair. Ignoring this contact material.", this); return(false); } m_contactMaterial = GetSimulation().getMaterialManager().getOrCreateContactMaterial(m1, m2); if (FrictionModel != null) { m_contactMaterial.setFrictionModel(FrictionModel.GetInitialized <FrictionModel>().Native); // When the user changes friction model type (enum = BoxFriction, ScaleBoxFriction etc.) // the friction model object will create a new native instance. We'll receive callbacks // when this happens so we can assign it to our native contact material. FrictionModel.OnNativeInstanceChanged += OnFrictionModelNativeInstanceChanged; } return(true); }
private Node GetOrCreateContactMaterial(agx.ContactMaterial contactMaterial) { return(GetOrCreateNode(NodeType.ContactMaterial, contactMaterial.getUuid(), true, () => m_contactMaterials.Add(contactMaterial.getUuid(), contactMaterial))); }
public override void Destroy() { if (GetSimulation() != null) { GetSimulation().getMaterialManager().remove(m_contactMaterial); } m_contactMaterial = null; }
public ContactMaterial RestoreLocalDataFrom(agx.ContactMaterial contactMaterial) { YoungsModulus = Convert.ToSingle(contactMaterial.getYoungsModulus()); SurfaceViscosity = new Vector2(Convert.ToSingle(contactMaterial.getSurfaceViscosity(agx.ContactMaterial.FrictionDirection.PRIMARY_DIRECTION)), Convert.ToSingle(contactMaterial.getSurfaceViscosity(agx.ContactMaterial.FrictionDirection.SECONDARY_DIRECTION))); FrictionCoefficients = new Vector2(Convert.ToSingle(contactMaterial.getFrictionCoefficient(agx.ContactMaterial.FrictionDirection.PRIMARY_DIRECTION)), Convert.ToSingle(contactMaterial.getFrictionCoefficient(agx.ContactMaterial.FrictionDirection.SECONDARY_DIRECTION))); Restitution = Convert.ToSingle(contactMaterial.getRestitution()); return(this); }
public static void AddContactMaterial(string a, string b, double restitution, double friction, double youngsModulus) { var material_A = new agx.Material(a); var material_B = new agx.Material(b); var contact_material = new agx.ContactMaterial(material_A, material_B); contact_material.setFrictionCoefficient(restitution); contact_material.setRestitution(friction); contact_material.setYoungsModulus(youngsModulus); sim_Instance.add(material_A); sim_Instance.add(material_B); sim_Instance.add(contact_material); }
public ContactMaterial RestoreLocalDataFrom(agx.ContactMaterial contactMaterial) { YoungsModulus = Convert.ToSingle(contactMaterial.getYoungsModulus()); SurfaceViscosity = new Vector2(Convert.ToSingle(contactMaterial.getSurfaceViscosity(agx.ContactMaterial.FrictionDirection.PRIMARY_DIRECTION)), Convert.ToSingle(contactMaterial.getSurfaceViscosity(agx.ContactMaterial.FrictionDirection.SECONDARY_DIRECTION))); FrictionCoefficients = new Vector2(Convert.ToSingle(contactMaterial.getFrictionCoefficient(agx.ContactMaterial.FrictionDirection.PRIMARY_DIRECTION)), Convert.ToSingle(contactMaterial.getFrictionCoefficient(agx.ContactMaterial.FrictionDirection.SECONDARY_DIRECTION))); Restitution = Convert.ToSingle(contactMaterial.getRestitution()); Damping = Convert.ToSingle(contactMaterial.getDamping()); AdhesiveForce = Convert.ToSingle(contactMaterial.getAdhesion()); AdhesiveOverlap = Convert.ToSingle(contactMaterial.getAdhesiveOverlap()); UseContactArea = contactMaterial.getUseContactAreaApproach(); ContactReductionMode = (ContactReductionType)contactMaterial.getContactReductionMode(); var binResolution = Convert.ToInt32(contactMaterial.getContactReductionBinResolution()); ContactReductionLevel = binResolution == 3 ? ContactReductionLevelType.Minimal : binResolution == 2 ? ContactReductionLevelType.Moderate : ContactReductionLevelType.Aggressive; return(this); }