cd /news/ai-agents/making-guns-in-blender-with-llm-agen… · home › topics › ai-agents › article
[ARTICLE · art-182495] src=tomaytotomato.com ↗ pub= topic=ai-agents verified=true sentiment=↑ positive

Making guns in Blender with LLM agents

A developer building a Java-based tactical shooter used LLM agents to generate Blender Python scripts that model weapons, producing a Heckler & Koch MP5 as 4,595 lines of Python the developer did not type. The developer turned to LLM-generated Blender scripts after finding free 3D assets on sites like SketchUp and TurboSquid were stolen or poorly optimized, and the scripts start from an empty scene and write the finished .blend file, with constants at the top of each script for quick regeneration. The approach matters as a hands-on test of whether LLM agents can produce usable 3D modeling code for game development.

recommendation

Have coding agents generate Blender Python scripts from an empty scene to a finished .blend, and expose model parameters as top-of-file constants so changes regenerate the asset without manual GUI work.

more in playbook: Working with AI coding agents
by read18 min views6 publishedDec 5, 2026
Making guns in Blender with LLM agents
Image: Tomaytotomato (auto-discovered)

Building guns in Blender using LLM agents

At the moment I am trying to build a game that fits a niche which is no longer popular in the world of gaming; the "tactical shooter".

They died out many years ago, around 2006/7, and were never revived in any serious effort, for a variety of reasons:

  • the 2008 financial crisis killing off some studios and projects
  • more popular and templated types of shooter emerging like Call of Duty, Battlefield etc.
  • gaming becoming more accessible and casual, making niche games less appealing for developers.

In recent years there have been some attempts to bring the tactical shooter back, e.g. Ready or Not, Squad and Ground Branch.

However they are about the shooting and what I like to call "tactical Barbie dress up", rather than about mission planning and quick fast paced missions.

What I was after was a remake of the original Rainbow Six, which was made in 1998 and quickly followed up with a sequel, "Rogue Spear" in 1999. Rogue Spear is like a cross between a football manager game and an FPS. You pick a squad of operatives and give them a mission plan based off a briefing (hostage rescue, disarm a bomb and so on).

It feels realistic and cerebral but most importantly not boring, well at least not for me.

As you can see from the screenshots; the game is showing its age and despite a small but not insignificant following there has only been some sporadic modding and map making in the years since.

Enter LLM

For the last few years I have become immersed in using LLMs, and in my day job I can't see myself going back to mashing the keyboard and writing out for loops, maps and if/elses.

Outside of work the temptation to use LLMs has grown too, so much so that I have been using them to mod games or play around with ideas.

One of these ideas was to make a new tactical shooter game..... in Java!

First Steps

Throwing tokens at a game is easy, and within a day or two I had a basic first person shooter working logically in code.

The game looked very "lo-fi" and was barely a step up in terms of graphics compared to the original Rainbow Six.

The next logical step was to find free assets on many of the modelling sites online.

The problem was that the "free" assets you soon discover on sites like sketchup.com or TurboSquid were either stolen or not optimised for my idea (they were too big in size or too low in detail).

One of the main guns I wanted in the game was the Heckler & Koch MP5. Which is an iconic gun in a lot of tactical shooters and movies because it's the de-facto gun of police and special forces.

I could easily download one of these guns and drop it into my game, but I had no real idea how these models work under the hood.

Some of the models online are rigged and animated in an certain way to work with a specific game engine e.g. Unreal Engine.

How would I translate these models for my rudimentary game in Java? It seemed a waste of time to backport something that

So the next question was, could an LLM build it for me, and if so how well could it do it?

Python

As a complete novice to 3D modelling my only reference point was that Blender is a "popular" and open sourced tool for designing and animating objects.

Blender is a very is a very feature rich tool and with that comes a steep learning curve and lots of time to perfect it. Thankfully there is a shortcut with Python which can drive Blender rather than by a human through its GUI.

These series of commands starts from an empty scene and writes the finished .blend.

Multiple Python scripts can be linked together and very soon you have a small arsenel rendered and ready to be added to your game.

The MP5 ended up as 4,595 lines of Python that I didn't type.

For tweaking something there were constants defined at the top of each script

These constants allow for quick changes and regeneration in models.

These constants could be pulled from websites like Wikipedia, Internet Movie Firearms database and DuckDuckGo's MCP server to pull in information to fill these values.

Another nifty feature of Blender and using Python is that it can accept these modelling scripts in a headless way, without the need for its GUI tool or direct human interaction.

blender -b --factory-startup --python magazine.py
blender -b --factory-startup --python mp5a4.py
blender -b --factory-startup --python m16.py

Interacting (or more accurately having an LLM interact) with Blender this way is similar to how DNA works in an organism. There is a codified expression of something that is made, it can be modified but it will always return the same result.

This came in handy a few times when crashes or accidental deletes of worktrees on git occurred. If the models were deleted they can just be regenerated from the Python scripts behind them (assuming they don't get nuked).

Any issues, just restore from git and rebuild in a few minutes.

There is no "oneshotting" a gun

Ask for "an AK47 in Blender" in one short prompt and you get something AK47 shaped.

It will look about 60% correct but it will be roughly shaped, missing details and some parts won't be connected correctly. Like a kid who has been tasked to make a complex shape with Lego blocks.

It looks like a gun? Yes

Is it an Ak47? It appear so

Is it what I want for my game? No

Very quickly you realise you need to start iterating and giving an agent small detail checks and fixes.

"The buttstocks are boxes. Round the top and the edges like the real thing."

"The barrel is solid, I can't see down it."

"The barrel and gas tube are still too blocky."

"The receiver's too narrow."

The first gun I modelled was the MP5 and that took took thirteen stages and 35 commits over a day and half, it was a lot of watching and waiting and giving it nudges.

After that I decided to try and make some harnesses and tooling to help the LLMs gain more understanding:

  1. Virtual Calipers : allow an LLM to measure a reference photo (with or without scaling) and then compare parts of the model's measurements and adjust accordingly.
  2. Silhouetting : overlay a model on-top of a photo or diagram and see what parts are not aligned or overshooting the photo, then trim those parts.

These tools allowed each iteration to trim and make small tweaks without me having to do it myself, which greatly improved iteration speed.

After each iteration it was also important to bake new skills and rebake existing skills with insights and lessons learned, a basic self learning loop. This information acted like a nice body of information that can be reloaded for other gun modelling sessions and speeds up iteration.

This dogfooding of built up knowledge greatly increased iteration speed however there were still issues along the way being uncovered.

One hilarious discovery was near the end of the iterations on the MP5 model occurred when I wanted to add in the option of a Beta C-Mag for the gun.

The reviewers reviewed the component magazine and found other issues apart from one glaringly obvious one (for a human), the drums of the magazine were orientated the wrong way!

In summary even if the LLM is driving and has a rough idea mathematically and geometrically, it still cannot "see" like us; it has no taste and does not always have common sense, it will get you 60-70% of the way. This is where you have to build it those tools and skills to get it to that 90% part.

From 90% on-wards its a lot harder and you have to decide whether you leave it at that point or continue on with another model. Getting to 100% might be easier learning or becoming a 3D graphics designer, although I am skeptical they can get 100% accuracy either.

Blocking it out

Every gun starts as a blockout: grey shapes at real size, in real metres, before any detail. The MP5's published figures (680 x 260 x 50 mm, a 225 mm barrel, a 340 mm sight radius) went in on day one. The origin sits on the trigger hand's grip point, so the game knows where a hand goes.

The budgets go in at the blockout too. Up to 25,000 triangles with the magazine (the MP5A4 is 17,850), textures painted at 2K and shipped at 1K, and a limit on draw calls, which cost more than triangles at 4K. I forgot a file size budget on the MP5. Its export came out at 17 MB, against the 250 KB model the game had been using (it's 5.4 MB now).

Then it's a pass per part. The LLM rebuilds, renders the same cameras every time and drops a preview into a file my Blender reloads. I watch the gun change and say what's wrong with it.

Using reference photos or specs

The biggest lesson from the MP5 was that one picture is not enough. I gave it one side view, and every defect I found was in something a side view can't show (a cross-section, the underside, a join). The LLM had guessed. Every gun now needs references from at least three views before the blockout starts.

The research is scripted too. A small Node tool pulls the specification from Wikipedia and IMFDB with a source on every number, fetches reference images with their licence, and lists the views it still hasn't got. Free pictures of long guns are nearly all of the right-hand side (for the M4, my left side was a Tokyo Marui product shot).

Published figures disagree with each other as well. So I made a ruling: a length within 25 mm or 5% of the published figure is close enough, and not worth asking me about. A stock that still folds beats an exact overall length.

Photos can lie in subtler ways. A blockout traced from one M4 photograph put the takedown pin 21 mm out and still scored well, because it had faithfully traced the photo's blur and shadow.

Today it's the AK family, studied against a CC0 AKM by an author called Dmitry. The LLM may measure it but not import it. The stock went from a box with 8 mm corners to the model's rounded comb, matched at four depths. One pass it refused to take: the model and the photograph disagreed about the top cover, so it backed the change out and asked me. I picked the model.

Componentisation

This bit is where the software engineer in me had too much fun.

Like any other product that is engineered, guns are assembled from components. Often times these components are re-used and assembled together in many variants or archetypes (families).

The M16 and the AK47 each started a family: the M4 is a shorter M16, and the AK-74 and AKS-74U are AKs with a smaller round (and in the 74U's case, a lot less of everything).

Across families the jobs are the same anyway. Everything has a receiver, a barrel, a grip, a magazine and something for your shoulder.

Rather than getting an LLM to model each gun from scratch, once the MP5 was done we lifted everything that wasn't MP5-specific into a shared kit.

It holds the shape primitives (extruded profiles, rounded slabs, lofts, lathes), the materials and baking, the export, the review renders and the rig templates. A new gun supplies its own frame, parts, textures and sockets, and copies nothing from the MP5.

It behaves like any other library. Shared magazines (the STANAG, for one) are models of their own that no gun's build may touch. Rigs come from a template per class: HK sub-machine gun, M4-style rifle, bullpup, pistol. And any change to the kit is checked against a fingerprint of the MP5's output, which is a regression test for a 3D model (I enjoyed that more than I should have).

Modelling Love Language

Trying to talk to an LLM to describe and direct how it is modelling an object requires good vocabulary and an articulate way of talking about ideas or things to implement.

If you are vague or non-specific the chances are the LLM will just change a part of the model you don't want changed, or do alter it in a way you don't like.

To make it even more complicated/fun, the contextual use of words in modelling vs. other scenarios. For example when you see the word, "furniture" you immediately think of sofas, tables etc.

In the world of modelling and in particular guns, furniture means the non-mechanical parts of a gun like the grip and wooden handguards.

So far here are some of the words I have come across and had to pickup during this work.

| Term | Definition & Project Context | | Furniture | A gun's wooden or plastic parts, meaning the stock, grip, and handguards. An AK's "plum furniture" is not a sideboard. | | Knolling | Laying parts out square and side by side, at right angles. | | Chamfer | A flat cut across an edge, at an angle, in place of the sharp corner. | | Fillet | A rounded edge, the curved cousin of a chamfer. | | Loft | A shape pulled through a series of cross-sections, like a boat's hull through its frames. The MP5's handguard was a box until it was lofted. | | Knurling | A grip pattern rolled or cut into metal, as small diamonds or straight ridges. The AK's selector has it on its finger tab. | | Chequering | The same idea cut into wood or moulded into plastic, a crosshatch on a grip. | | Comb | The top edge of a stock, where your cheek rests. | | Palm swell | The bulge in a handguard that fills your hand. | | Witness hole | A hole in a magazine's spine to count the rounds through. | | Follower | The plate the spring pushes up under the rounds in a magazine. | | Feed lips | The turned-in edges at the top of a magazine that stop the rounds jumping out. | | Trunnion | The block the barrel is locked into. You never see it, but everything is measured from it. | | Slant brake | The AKM's muzzle device, cut at an angle so the escaping gas pushes the muzzle down against the climb. | | Bluing | A chemical finish that turns steel blue-black and wears to grey where hands rub it. | | Face soup | A pile of faces that share no edges, so nothing knows which side is out. Ask Blender to fix one and it will guess wrong; ours turned three stair treads into walls. | | Z-fighting | Two surfaces in the same place, flickering as the renderer can't decide which one is in front. | | Normal map | An image that bends the lighting to fake fine relief, such as scratches or chequering, on a flat face. | | Texel density | How many texture pixels cover each metre of the model. It's the difference between a sharp gun and a blurry one. |

Here is a full list of technical terms I have come across whilst doing these modelling sessions.

Gun Variations

Once you have perfected the base model of a gun and some components, it is now time to have fun with variations. Changing the buttstock, the grips, the magazines, the accessories.

The way this was implemented was using TOML markup language to define variations.

[[variant]]
name = "mp5a5_od"
flags = ["--stock", "slide", "--furniture", "od"]
template = "smg_hk_a5"

The MP5 has ten: the A4 and A5 (fixed and sliding stock) in black, olive drab and with the light forend, plus the K, the K-PDW, the SD6 and the SD5. On top of those sit the option parts: the C-Mag, a dot sight, a suppressor and a torch.

Variants are where I did most of my correcting. Each model has its own trigger pictograms, the MP5 PDW has its real triangular folding stock, and HK's naming has rules (an SD6 with a fixed stock is an SD5).

Every pair of options must fit together, proven by an overlap test on the meshes: the torch clears the suppressor by 0.7 mm.

The M4 followed the same pattern, with an M68 sight, a KAC suppressor, a torch, the C-Mag and a windowed magazine.

Is there a better way than Python?

For Blender and making guns, there doesn't appear to be a better way at this time, whether you are using Blender through the MCP plugin or through its CLI.

The MCP route is still Python, just typed into the running session.

Text-to-3D generators like Meshy.ai or Tripo can bypass this and will hand you a textured model in a couple of minutes. However for deeper animations or interactions they are lacking. However I still use those services for generating objects and clutter for maps.

So in the world of Blender for the guns I'd still pick Python.

The beauty is that you can actually see diffs on git for tweaks to the models and slowly glean information on what is going on to make those shapes.

Its a bit like DNA that is being translated into RNA to then make a protein in an organism.

Conclusion

This is not wholly scientific but the approximate token cost per gun has been about £23-25 for the first few models, and has decreased down a bit. Partly with reducing complexity and with re-use.

Analysing session logs in a few harnesses (Github Copilot, Claude Code and Opencode) using Pi.

Gun (variants) When Tokens in and out Cache reads Cost Per variant
MP5 family (7) 28 Nov to 3 Dec 15.9M 294M £134 £19
M4A1 (1) 29 Nov to 3 Dec 5.8M 271M £79 £79
HK USP (1) 2 to 4 Dec 1.2M 63M £18 £18
Glock 17 (1) 3 to 4 Dec 0.7M 30M £9 £9
HK PSG1 (1) 3 to 4 Dec 1.5M 103M £28 £28
Steyr AUG A1 (1) 3 to 4 Dec 1.3M 66M £21 £21
Makarov PM (1) 4 Dec 0.7M 47M £13 £13
AK family (3, unfinished) 4 Dec 3.4M 287M £71 £24
FN FAL (2) 4 Dec 0.7M 49M £14 £7
Skorpion vz. 61 (1) 4 Dec 1.1M 67M £19 £19
IMI Uzi (1) 4 Dec 0.8M 50M £14 £14
Remington 870 (1) 4 Dec 1.3M 72M £20 £20
FN P90 (1) 4 Dec 1.0M 70M £19 £19
Shared: weapon kit, rig templates, holds 2 to 4 Dec 10.3M 308M £91

One caveat is that some subscriptions are subsidising tokens and that how efficient you are depends on re-using knowledge with skills and how efficient your harness is with caching and prompts.

There is a decline in cost, perhaps not as much as I was hoping for. There probably is an element of diminishing returns in efficiency, but I will continue to model more weapons and see how the costs go.

In terms of accuracy of the guns, using the reference photos, technical specs (where available) and some guess work, I would say they are about 80 to 90% accurate.

For a game and what I am looking for, I am happy with that.

Are other games 100% accurate? I am not sure. I believe all modelling artists apply these same principles and fill in the gaps, I just used an LLM to do that, is all.

This worked for me because I'm a developer. I don't know modelling, and I don't have the time to learn it properly. I didn't want to steal a model, or just copy one I'd found online.

What I wanted was a small taste of how a gun gets authored, and having it built as code meant I could follow every change the way I'd follow a pull request.

Down or buying an MP5 model would have been quicker but I wouldn't know my new favourite word, "knurling".

── more in #ai-agents 4 stories · sorted by recency
── more on @blender 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/making-guns-in-blend…] indexed:0 read:18min 2026-12-05 · —