<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Gregory Felix</title>
    <description>The latest articles on DEV Community by Gregory Felix (@gregborin).</description>
    <link>https://dev.to/gregborin</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4206248%2Fbd50e284-3802-45aa-8f39-0879020e70da.jpg</url>
      <title>DEV Community: Gregory Felix</title>
      <link>https://dev.to/gregborin</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/gregborin"/>
    <language>en</language>
    <item>
      <title>I decoded The Sims 4 animations outside the game. The hard part wasn't the animation</title>
      <dc:creator>Gregory Felix</dc:creator>
      <pubDate>Sun, 25 Oct 2026 09:58:27 +0000</pubDate>
      <link>https://dev.to/gregborin/i-decoded-the-sims-4-animations-outside-the-game-the-hard-part-wasnt-the-animation-3l6h</link>
      <guid>https://dev.to/gregborin/i-decoded-the-sims-4-animations-outside-the-game-the-hard-part-wasnt-the-animation-3l6h</guid>
      <description>&lt;p&gt;It started with a PowerShell script that computed SHA-256 hashes of &lt;code&gt;.package&lt;/code&gt; files to find duplicates in my wife's Mods folder. It worked. Then I made the classic mistake: I started wondering what was &lt;strong&gt;inside&lt;/strong&gt; those files.&lt;/p&gt;

&lt;p&gt;A few nights later, this was running in my browser: a Sim animated by a real game clip, wearing a textured CC outfit, assembled from the raw bytes of game and mod packages — no game running, no internet, no Blender.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fatjiodvmpwatdhz3siww.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fatjiodvmpwatdhz3siww.png" alt="The assembled figure: a CC outfit with real texture, EA base head and EA hair — all posed by a real game clip in my WebGL renderer" width="594" height="934"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This post is about the road there. It's not a complete tutorial and it's not a discovery claim — almost everything I used already existed as code scattered across repositories. What didn't exist was anyone telling the story of how the pieces fit. That's the post I wished existed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Piece 1: the CLIP (the animation)
&lt;/h2&gt;

&lt;p&gt;TS4 animation resources have type &lt;code&gt;0x6B20C4F3&lt;/code&gt;. The header is friendly: version 14, duration, rig name, clip events. The interesting part is the S3CLIP payload — per-bone channels with sparse, quantized keyframes.&lt;/p&gt;

&lt;p&gt;The detail that cost me hours: orientation indices aren't 16-bit. They're &lt;strong&gt;12-bit&lt;/strong&gt;, and the &lt;strong&gt;sign of each quaternion component is not in the index&lt;/strong&gt; — it lives in the frame's &lt;code&gt;flags&lt;/code&gt; field. The community encoder stores &lt;code&gt;|v| × 4095&lt;/code&gt; and parks the sign elsewhere. Read the index as &lt;code&gt;idx/65535&lt;/code&gt; and you get an abomination: quaternions with norms around 0.93 and a skeleton that looks like an accident.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fiq9oi2i05ture7rovl2a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fiq9oi2i05ture7rovl2a.png" alt="The skeleton after a wrong quaternion decode — contorted limbs, detached head, blue bone lines crossing the body" width="676" height="885"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The fix came from reading Sims 4 Studio's Blender-side decoder, not from guessing formulas. Once it was right, every single quaternion norm hit &lt;strong&gt;exactly 1.000&lt;/strong&gt; — that's how you know a decoder is correct.&lt;/p&gt;

&lt;h2&gt;
  
  
  Piece 2: the rig and the skin
&lt;/h2&gt;

&lt;p&gt;EA's humanoid rig (type &lt;code&gt;0x8EAF13DE&lt;/code&gt;, "Clear format") has 165 bones. Clip channels match by bone-name hash. Then came GEOM (&lt;code&gt;0x015A1849&lt;/code&gt;): positions, normals, UVs, and the essential part — blend indices and weights, with the bone table at the end of the resource. Linear blend skinning: &lt;code&gt;delta = W_pose ∘ W_bind⁻¹&lt;/code&gt; per bone.&lt;/p&gt;

&lt;p&gt;Result: a real CC outfit (8,113 vertices) deforming for real as the bones move.&lt;/p&gt;

&lt;h2&gt;
  
  
  Piece 3: the texture — the part that nearly killed me
&lt;/h2&gt;

&lt;p&gt;The package held an image &lt;code&gt;0x00B2D882&lt;/code&gt; with &lt;code&gt;fourCC = "DST5"&lt;/code&gt;. I decoded it as regular DXT5. The result was one of the ugliest things I've ever produced: structured gray noise in a grid, with pink blotches.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fdwtybk4r6u7arpsssur1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fdwtybk4r6u7arpsssur1.png" alt="DST5 decoded as plain DXT5: a grid of gray noise with pink static blotches" width="512" height="512"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F41tl4kzszpxycc4v69f8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F41tl4kzszpxycc4v69f8.png" alt="The corrupted texture applied to the mesh — moiré skin with red wounds" width="800" height="915"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Wrong hypotheses I tested: UV flip, channel order, mip boundaries. The answer lived in an s4pi file called &lt;code&gt;DSTResource.cs&lt;/code&gt;, method &lt;code&gt;Unshuffle&lt;/code&gt;: &lt;strong&gt;DST5 is not contiguous-block DXT5.&lt;/strong&gt; EA splits the fields into four planes spanning the &lt;em&gt;entire mip chain&lt;/em&gt; — all alpha endpoints first, then color endpoints, then alpha indices, then color indices. Unshuffle the planes and a standard DXT5 stream falls out, which any decoder can eat.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fr2fnclx592lq7la3zrbv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fr2fnclx592lq7la3zrbv.png" alt="The same texture after plane unshuffling: a clean black-and-white UV atlas" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That was the moment of the night. Nightmare noise → clean UV atlas in a ~20-line change — after finding the right source.&lt;/p&gt;

&lt;h2&gt;
  
  
  Piece 4: turning resources into "parts"
&lt;/h2&gt;

&lt;p&gt;A package is a bag of resources with no obvious hierarchy. The piece that ties it together is the CASP (&lt;code&gt;0x034AEECB&lt;/code&gt;): a UTF-16 name in the header and a TGI reference list at the tail — entries pointing at GEOMs, textures, MODLs, thumbnails. Following the TGI list of a CASP named &lt;code&gt;yfHead&lt;/code&gt; got me the game's base head mesh. The TGI-list trick: entries are contiguous 16-byte &lt;code&gt;[instance][group][type]&lt;/code&gt; records running to EOF — find them by walking backwards while the fields stay valid.&lt;/p&gt;

&lt;p&gt;Stacking three meshes — the mod's outfit, EA's head, EA's hair — on the same animated rig produced the "human" from the opening image. A slightly unsettling mannequin, honestly, but ours.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's still missing (honesty section)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Generic face: a real Sim's face is base mesh + dozens of BGEO morph deltas from CAS sliders — a whole other system&lt;/li&gt;
&lt;li&gt;No real skin texture: TS4 skin tone is a composition pipeline, not a DDS&lt;/li&gt;
&lt;li&gt;No eyes/teeth (separate CASPs), no IK, no cross-clip blending&lt;/li&gt;
&lt;li&gt;Two-actor clips (a1/a2) currently render on top of each other&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What I learned (worth more than the code)
&lt;/h2&gt;

&lt;p&gt;Every time I guessed a format, I lost hours. Every breakthrough came from finding the &lt;strong&gt;authoritative source&lt;/strong&gt;: the codec from S4S's &lt;code&gt;animation/__init__.py&lt;/code&gt;, DST5 from s4pi's &lt;code&gt;DSTResource.cs&lt;/code&gt;, CASP layout from &lt;code&gt;catalog.py&lt;/code&gt;. The modding community has mapped almost everything — but almost none of it exists as prose. It's scattered as code across dozens of repos.&lt;/p&gt;

&lt;p&gt;If this post saves someone my wasted hours, it did its job.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Tools consulted: Sims 4 Studio (Blender scripts), s4pi/s4pe, and a lot of hex reading. Everything ran locally — not a single byte left my machine.&lt;/em&gt;&lt;/p&gt;




</description>
      <category>reverseengineering</category>
      <category>gamedev</category>
      <category>sims4</category>
      <category>codenewbie</category>
    </item>
  </channel>
</rss>
