import @"../visuals/AlgoryxLunarCruiser_Wheel.obj" as WheelVisual
import @"../visuals/WheelDiffuse.png" as WheelDiffuse

const WheelVisualMaterial is Visuals.Materials.Material:
    with Visuals.Materials.SurfaceFeatures.BaseColor
    base_color_map: WheelDiffuse

# Using Wheel will set up a OneBodyTire in AGX
Wheel is Vehicles.Wheels.Base:
    rim becomes Vehicles.Wheels.Rim:
        radius: 0.72
        width: 0.7
        geometry:
            local_transform.rotation: Math.Quat.from_to(Math.Vec3.Y_AXIS(), Math.Vec3.X_AXIS())
            material: WheelMaterial
        inertia.mass: 20  # Set wheel mass
        visual is WheelVisual with Visuals.Materials.VisualMaterialOverrideTrait:
            material_override: WheelVisualMaterial
    connector:
        .agx_debug_render_frame: true
        main_axis: { -1, 0, 0 }
        normal: { 0, 1, 0 }

# Wheel system to set up wheel, connectors and suspension for all cruiser wheels
# chassis_connector must be set to the correct one for that wheel
WheelSystem is Physics3D.System:
    wheel is Wheel
    chassis_connector is Physics3D.Interactions.MateConnector reference
    suspension is Vehicles.Suspensions.SingleMate.LinearSpringDamper:
        chassis_connector: chassis_connector
        attachment_connector: wheel.connector
        mate.spring_constant.stiffness: 25000
        mate.spring_damping.damping_constant: 2/60 * suspension.mate.spring_constant.stiffness * 5
        range:
            start: -0.25
            end: 0.25
