b3dFinalizeVehicle

Finalizes vehicle configuration and activates vehicle physics simulation. Takes vehicleHandle (vehicle from b3dCreateVehicle with wheels/engine/transmission configured). Returns nothing.

3D Graphics

Parameters & Returns

Parameters

vehicleHandle Int

Returns

Void

Quick Summary

Finalizes vehicle configuration and activates vehicle physics simulation. Takes vehicleHandle (vehicle from b3dCreateVehicle with wheels/engine/transmission configured). Returns nothing.

Technical Exegesis...

Finalizes vehicle configuration and activates vehicle physics simulation. Takes vehicleHandle (vehicle created with b3dCreateVehicle, must have wheels added with b3dAddVehicleWheel, engine configured with b3dSetVehicleEngine, and optionally transmission/differentials/brakes configured). Returns nothing. Commits vehicle configuration to Jolt physics system and begins physics simulation.

Example

Example.bam
; Complete vehicle setup and finalization
mesh = b3dLoadMesh("car.glb", 1, 0)
b3dPositionEntity(mesh, 0, 5, 0)

; Create vehicle
vehicle = b3dCreateVehicle(mesh, 1500.0, 0.3, 0.5, 2.0, 0.6, 0.0)

; Add 4 wheels
wheelFL = b3dAddVehicleWheel(vehicle, -0.9, 0.0,  1.5, 0.4, 0.3, 0.3, 0.5, 2.0, 0.6)
wheelFR = b3dAddVehicleWheel(vehicle,  0.9, 0.0,  1.5, 0.4, 0.3, 0.3, 0.5, 2.0, 0.6)
wheelRL = b3dAddVehicleWheel(vehicle, -0.9, 0.0, -1.5, 0.4, 0.3, 0.3, 0.5, 2.0, 0.6)
wheelRR = b3dAddVehicleWheel(vehicle,  0.9, 0.0, -1.5, 0.4, 0.3, 0.3, 0.5, 2.0, 0.6)

; Configure engine
b3dSetVehicleEngine(vehicle, 400.0, 1000.0, 6000.0)

; Configure transmission
b3dSetVehicleTransmission(vehicle, 0.5)

; Add differentials
b3dAddVehicleDifferential(vehicle, wheelFL, wheelFR, 1.5)  ; Front
b3dAddVehicleDifferential(vehicle, wheelRL, wheelRR, 3.0)  ; Rear

; Configure steering on front wheels
b3dSetVehicleWheelSteering(vehicle, wheelFL, 35.0)
b3dSetVehicleWheelSteering(vehicle, wheelFR, 35.0)

; Configure braking on all wheels
For i = 0 To 3
    b3dSetVehicleWheelBraking(vehicle, i, 1500.0, 3000.0)
Next

; FINALIZE VEHICLE - Activate physics
b3dFinalizeVehicle(vehicle)

; Now vehicle is ready for control
Repeat
    forward = BBR_GetKey(200) - BBR_GetKey(208)
    right = BBR_GetKey(205) - BBR_GetKey(203)
    handBrake = BBR_GetKey(57)

    b3dSetVehicleInput(vehicle, forward, right, handBrake)

    b3dRenderWorld()
    BBR_Flip()
Until BBR_GetKey(1)