import @"../RigidBodyDefinitions/HM400/fr_wheel.obj" as ImportedTireVisual

Wheel is Vehicles.Wheels.ElasticWheel:
    .doc: """
    Elastic wheel model with tire dimension 29.5 R25.
    This is the standard tire for the Komatsu HM400-5
    """
    # Based on tire size of 29.5 R25 which is the standard size for the Komatsu HM400-5
    # articulated dump truck

    rim.radius: 25.00 * 25.4e-3 / 2
    rim.width:  25.00 * 25.4e-3
    rim.inertia.mass:   257.0


    tire.outer_radius:  1.870/2
    tire.width:         0.750
    tire.inertia.mass:  520.0

    flexibility:
        along_radial.stiffness:   1.6e6
        along_axial.stiffness:    3.0e6
        around_radial.stiffness:  3.0e6
        around_axial.stiffness:   2.0e6

    dissipation:
        along_radial.damping_constant:   8.0e4
        along_axial.damping_constant:    8.0e4
        around_radial.damping_constant:  8.0e4
        around_axial.damping_constant:   3.0e4

    rim becomes Vehicles.Wheels.Rim:
        geometry:
            material: KomatsuHM400.Assets.Properties.Materials.Rim
            local_transform.rotation: Math.Quat.from_to({1, 0, 0}, {0, 0, 1})

    tire becomes Vehicles.Wheels.Tire:
        inner_radius: rim.radius

        geometry:
            radius: tire.outer_radius
            height: tire.width
            material: KomatsuHM400.Assets.Properties.Materials.Tire
            local_transform.rotation: Math.Quat.from_to({1, 0, 0}, {0, 0, 1})
        visual is ImportedTireVisual

    connector:
        main_axis: -Math.Vec3.Y_AXIS()
        normal: Math.Vec3.Z_AXIS()


Wheel_L is Wheel:
    connector:
        main_axis: -Math.Vec3.Y_AXIS()
        normal: Math.Vec3.Z_AXIS()


Wheel_R is Wheel:
    connector:
        main_axis: Math.Vec3.Y_AXIS()
        normal: Math.Vec3.Z_AXIS()

    # Mirror tire geometry if tire tread has a specific rotational direction
    tire.geometry.local_transform.rotation: Math.Quat.from_to({0, 1, 0}, {0, -1, 0})
    tire.visual.local_transform.rotation: tire.geometry.local_transform.rotation
