TECH1 TIP: How to Create Helmet Image Renders from Helmet Files

I often get asked how I created the helmet images on the front page of the website. There is a “hidden” endpoint in iRacing which will display a helmet http://localhost:32034/pk_helmet.png

If you supply are size of 2 (range 0-2) and the directory of your helmet TGA file you will get a decent render of your helmet :

eg:

http://localhost:32034/pk_helmet.png?size=2&hlmtCustPaint=C:\Users\username\Documents\iRacing\paint\helmet_XXXXXX.tga

The actual TGA looks like this:

The render looks like this

I have written a simple script to download a render of a helmet in png format.

Step 1: Understanding the PowerShell Parameters

The first part of the script revolves around parameters. Parameters are essentially variables that allow you to pass values to a PowerShell script when executing it. In our case, we have two mandatory parameters:

  1. DriverID: This parameter will hold the identifier of the driver whose custom helmet you want to download.
  2. Outdir: This parameter represents the output directory where the downloaded helmet image will be saved.
  • DriverID: This parameter will hold the identifier of the driver whose custom helmet you want to download.
  • Outdir: This parameter represents the output directory where the downloaded helmet image will be saved.
  • DriverID: This parameter will hold the identifier of the driver whose custom helmet you want to download.
  • Outdir: This parameter represents the output directory where the downloaded helmet image will be saved.

With these parameters, the script will know which helmet to fetch and where to save it.

param(
  [Parameter(Mandatory = $True,Position = 1)]
  [string]$DriverID,
  [Parameter(Mandatory = $True,Position = 2)]
  [string]$Outdir
)

$MyDocs=[environment]::getfolderpath("mydocuments")

$url = "http://localhost:32034/pk_helmet.png?size=2&hlmtCustPaint=$MyDocs\iRacing\paint\helmet_$DriverID.tga"
Invoke-WebRequest -Uri $url -OutFile "$outdir\driverhelmet_$DriverID.png"


This script can be downloaded and saved as Get-Helmet.ps1

Conclusion:

Customizing your driver helmet in iRacing adds a personal touch and makes your virtual racing experience even more enjoyable. With this simplified PowerShell script, you can effortlessly download your custom helmet image by providing your DriverID and Outdir parameters.