Esempio n. 1
0
        /// <summary>
        /// Create native friction model given solve type and friction model type.
        /// </summary>
        /// <param name="type">Friction model type.</param>
        /// <param name="solveType">Solve type.</param>
        /// <returns>New native instance.</returns>
        public agx.FrictionModel CreateNative(EType type,
                                              ESolveType solveType)
        {
            agx.Frame referenceFrame = null;
            if (m_orientedFrictionReferenceObject != null)
            {
                referenceFrame = m_orientedFrictionReferenceObject.GetComponent <RigidBody>() != null?
                                 m_orientedFrictionReferenceObject.GetComponent <RigidBody>().Native.getFrame() :
                                     m_orientedFrictionReferenceObject.GetComponent <Collide.Shape>() != null?
                                     m_orientedFrictionReferenceObject.GetComponent <Collide.Shape>().NativeGeometry.getFrame() :
                                         null;
            }

            agx.FrictionModel frictionModel = null;
            if (type == EType.IterativeProjectedFriction)
            {
                frictionModel = referenceFrame != null ?
                                new agx.OrientedIterativeProjectedConeFrictionModel(referenceFrame,
                                                                                    Convert(m_orientedFrictionPrimaryDirection).ToHandedVec3(),
                                                                                    Convert(solveType)) :
                                new agx.IterativeProjectedConeFriction(Convert(solveType));
            }
            else if (type == EType.ScaleBoxFriction)
            {
                frictionModel = referenceFrame != null ?
                                new agx.OrientedScaleBoxFrictionModel(referenceFrame,
                                                                      Convert(m_orientedFrictionPrimaryDirection).ToHandedVec3(),
                                                                      Convert(solveType)) :
                                new agx.ScaleBoxFrictionModel(Convert(solveType));
            }
            else if (type == EType.BoxFriction)
            {
                frictionModel = referenceFrame != null ?
                                new agx.OrientedBoxFrictionModel(referenceFrame,
                                                                 Convert(m_orientedFrictionPrimaryDirection).ToHandedVec3(),
                                                                 Convert(solveType)) :
                                new agx.BoxFrictionModel(Convert(solveType));
            }
            else if (type == EType.ConstantNormalForceBoxFriction)
            {
                frictionModel = new agx.ConstantNormalForceOrientedBoxFrictionModel(NormalForceMagnitude,
                                                                                    referenceFrame,
                                                                                    Convert(m_orientedFrictionPrimaryDirection).ToHandedVec3(),
                                                                                    Convert(solveType),
                                                                                    ScaleNormalForceWithDepth);
            }

            return(frictionModel);
        }
Esempio n. 2
0
        /// <summary>
        /// Create native friction model given solve type and friction model type.
        /// </summary>
        /// <param name="type">Friction model type.</param>
        /// <param name="solveType">Solve type.</param>
        /// <returns>New native instance.</returns>
        public static agx.FrictionModel CreateNative(EType type, ESolveType solveType)
        {
            agx.FrictionModel frictionModel = null;
            if (type == EType.IterativeProjectedFriction)
            {
                frictionModel = new agx.IterativeProjectedConeFriction(Convert(solveType));
            }
            else if (type == EType.ScaleBoxFriction)
            {
                frictionModel = new agx.ScaleBoxFrictionModel(Convert(solveType));
            }
            else if (type == EType.BoxFriction)
            {
                frictionModel = new agx.BoxFrictionModel(Convert(solveType));
            }

            return(frictionModel);
        }
Esempio n. 3
0
        /// <summary>
        /// Converts ESolveType to agx.FrictionModel.SolveType.
        /// </summary>
        /// <param name="solveType">Input ESolveType.</param>
        /// <returns>Output agx.FrictionModel.SolveType.</returns>
        public static agx.FrictionModel.SolveType Convert(ESolveType solveType)
        {
            if (solveType == ESolveType.Direct)
            {
                return(agx.FrictionModel.SolveType.DIRECT);
            }
            else if (solveType == ESolveType.Iterative)
            {
                return(agx.FrictionModel.SolveType.ITERATIVE);
            }
            else if (solveType == ESolveType.Split)
            {
                return(agx.FrictionModel.SolveType.SPLIT);
            }
            else if (solveType == ESolveType.DirectAndIterative)
            {
                return(agx.FrictionModel.SolveType.DIRECT_AND_ITERATIVE);
            }

            return(agx.FrictionModel.SolveType.NOT_DEFINED);
        }
Esempio n. 4
0
 /// <summary>
 /// Converts constraint solve type to native version.
 /// </summary>
 /// <param name="solveType">Constraint solve type.</param>
 /// <returns>Native solve type.</returns>
 public static agx.Constraint.SolveType Convert(ESolveType solveType)
 {
     return(solveType == ESolveType.Direct    ? agx.Constraint.SolveType.DIRECT :
            solveType == ESolveType.Iterative ? agx.Constraint.SolveType.ITERATIVE :
            agx.Constraint.SolveType.DIRECT_AND_ITERATIVE);
 }
Esempio n. 5
0
 protected override void Construct()
 {
     m_type      = EType.IterativeProjectedFriction;
     m_solveType = ESolveType.Split;
 }