{"slug": "making-guns-in-blender-with-llm-agents", "title": "Making guns in Blender with LLM agents", "summary": "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.", "body_md": "# Making guns in Blender with LLM agents\n\nBuilding guns in Blender using LLM agents\n\nAt 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\".\n\nThey died out many years ago, around 2006/7, and were never revived in any serious effort, for a variety of reasons:\n\n- the 2008 financial crisis killing off some studios and projects\n- more popular and templated types of shooter emerging like Call of Duty, Battlefield etc.\n- gaming becoming more accessible and casual, making niche games less appealing for developers.\n\nIn recent years there have been some attempts to bring the tactical shooter back, e.g. Ready or Not, Squad and Ground Branch.\n\nHowever 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.\n\nWhat 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).\n\nIt feels realistic and cerebral but most importantly not boring, well at least not for me.\n\nAs 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.\n\n### Enter LLM\n\nFor 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.\n\nOutside 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.\n\nOne of these ideas was to make a new tactical shooter game..... in Java!\n\n### First Steps\n\nThrowing tokens at a game is easy, and within a day or two I had a basic first person shooter working logically in code.\n\nThe game looked very \"lo-fi\" and was barely a step up in terms of graphics compared to the original Rainbow Six.\n\nThe next logical step was to find free assets on many of the modelling sites online.\n\nThe 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).\n\nOne 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.\n\nI 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.\n\nSome of the models online are rigged and animated in an certain way to work with a specific game engine e.g. Unreal Engine.\n\nHow would I translate these models for my rudimentary game in Java? It seemed a waste of time to backport something that \n\nSo the next question was, could an LLM build it for me, and if so how well could it do it?\n\n### Python\n\nAs 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.\n\nBlender 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.\n\nThese series of commands starts from an empty scene and writes the finished `.blend`. \n\nMultiple Python scripts can be linked together and very soon you have a small arsenel rendered and ready to be added to your game.\n\nThe MP5 ended up as 4,595 lines of Python that I didn't type.\n\nFor tweaking something there were constants defined at the top of each script\n\nThese constants allow for quick changes and regeneration in models.\n\nThese 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.\n\nAnother 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.\n\n```\nblender -b --factory-startup --python magazine.py\nblender -b --factory-startup --python mp5a4.py\nblender -b --factory-startup --python m16.py\n```\n\nInteracting (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.\n\nThis 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).\n\nAny issues, just restore from git and rebuild in a few minutes.\n\n### There is no \"oneshotting\" a gun\n\nAsk for \"an AK47 in Blender\" in one short prompt and you get something AK47 shaped.\n\nIt 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.\n\nIt looks like a gun? **Yes**\n\nIs it an Ak47? **It appear so**\n\nIs it what I want for my game? **No**\n\nVery quickly you realise you need to start iterating and giving an agent small detail checks and fixes.\n\n\"The buttstocks are boxes. Round the top and the edges like the real thing.\" \n\n\"The barrel is solid, I can't see down it.\"\n\n\"The barrel and gas tube are still too blocky.\"\n\n\"The receiver's too narrow.\"\n\nThe 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.\n\nAfter that I decided to try and make some harnesses and tooling to help the LLMs gain more understanding:\n\n1. **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.\n2. **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.\n\nThese tools allowed each iteration to trim and make small tweaks without me having to do it myself, which greatly improved iteration speed.\n\nAfter 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.\n\nThis dogfooding of built up knowledge greatly increased iteration speed however there were still issues along the way being uncovered.\n\nOne 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.\n\nThe 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!\n\nIn 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.\n\nFrom 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.\n\n### Blocking it out\n\nEvery 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.\n\nThe 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).\n\nThen 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.\n\n### Using reference photos or specs\n\nThe 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.\n\nThe 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).\n\nPublished 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.\n\nPhotos 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.\n\nToday 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.\n\n### Componentisation\n\nThis bit is where the software engineer in me had too much fun.\n\nLike 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).\n\nThe 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).\n\nAcross families the jobs are the same anyway. Everything has a receiver, a barrel, a grip, a magazine and something for your shoulder.\n\nRather 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.\n\nIt 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.\n\nIt 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).\n\n### Modelling ~~Love~~  Language\n\nTrying 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.\n\nIf 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.\n\nTo 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. \n\nIn the world of modelling and in particular guns, furniture means the non-mechanical parts of a gun like the grip and wooden handguards.\n\nSo far here are some of the words I have come across and had to pickup during this work.\n\n| **Term** | **Definition & Project Context** | \n| **Furniture** | A gun's wooden or plastic parts, meaning the stock, grip, and handguards. An AK's \"plum furniture\" is not a sideboard. | \n| **Knolling** | Laying parts out square and side by side, at right angles. | \n| **Chamfer** | A flat cut across an edge, at an angle, in place of the sharp corner. | \n| **Fillet** | A rounded edge, the curved cousin of a chamfer. | \n| **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. | \n| **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. | \n| **Chequering** | The same idea cut into wood or moulded into plastic, a crosshatch on a grip. | \n| **Comb** | The top edge of a stock, where your cheek rests. | \n| **Palm swell** | The bulge in a handguard that fills your hand. | \n| **Witness hole** | A hole in a magazine's spine to count the rounds through. | \n| **Follower** | The plate the spring pushes up under the rounds in a magazine. | \n| **Feed lips** | The turned-in edges at the top of a magazine that stop the rounds jumping out. | \n| **Trunnion** | The block the barrel is locked into. You never see it, but everything is measured from it. | \n| **Slant brake** | The AKM's muzzle device, cut at an angle so the escaping gas pushes the muzzle down against the climb. | \n| **Bluing** | A chemical finish that turns steel blue-black and wears to grey where hands rub it. | \n| **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. | \n| **Z-fighting** | Two surfaces in the same place, flickering as the renderer can't decide which one is in front. | \n| **Normal map** | An image that bends the lighting to fake fine relief, such as scratches or chequering, on a flat face. | \n| **Texel density** | How many texture pixels cover each metre of the model. It's the difference between a sharp gun and a blurry one. | \n\nHere is a full list of technical terms I have come across whilst doing these modelling sessions.\n\n### Gun Variations\n\nOnce 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.\n\nThe way this was implemented was using TOML markup language to define variations.\n\n```\n[[variant]]\nname = \"mp5a5_od\"\nflags = [\"--stock\", \"slide\", \"--furniture\", \"od\"]\ntemplate = \"smg_hk_a5\"\n```\n\nThe 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.\n\nVariants 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).\n\nEvery pair of options must fit together, proven by an overlap test on the meshes: the torch clears the suppressor by 0.7 mm.\n\nThe M4 followed the same pattern, with an M68 sight, a KAC suppressor, a torch, the C-Mag and a windowed magazine.\n\n### Is there a better way than Python?\n\nFor 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](https://www.blender.org/lab/mcp-server/?ref=tomaytotomato.com) or through its CLI.\n\nThe MCP route is still Python, just typed into the running session.\n\nText-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.\n\nSo in the world of Blender for the guns I'd still pick Python.\n\nThe 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.\n\nIts a bit like DNA that is being translated into RNA to then make a protein in an organism.\n\n### Conclusion\n\nThis 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.\n\nAnalysing session logs in a few harnesses (Github Copilot, Claude Code and Opencode) using [Pi](https://pi.dev/?ref=tomaytotomato.com).\n\n| Gun (variants) | When | Tokens in and out | Cache reads | Cost | Per variant | \n|---|---|---|---|---|---|\n| MP5 family (7) | 28 Nov to 3 Dec | 15.9M | 294M | £134 | £19 | \n| M4A1 (1) | 29 Nov to 3 Dec | 5.8M | 271M | £79 | £79 | \n| HK USP (1) | 2 to 4 Dec | 1.2M | 63M | £18 | £18 | \n| Glock 17 (1) | 3 to 4 Dec | 0.7M | 30M | £9 | £9 | \n| HK PSG1 (1) | 3 to 4 Dec | 1.5M | 103M | £28 | £28 | \n| Steyr AUG A1 (1) | 3 to 4 Dec | 1.3M | 66M | £21 | £21 | \n| Makarov PM (1) | 4 Dec | 0.7M | 47M | £13 | £13 | \n| AK family (3, unfinished) | 4 Dec | 3.4M | 287M | £71 | £24 | \n| FN FAL (2) | 4 Dec | 0.7M | 49M | £14 | £7 | \n| Skorpion vz. 61 (1) | 4 Dec | 1.1M | 67M | £19 | £19 | \n| IMI Uzi (1) | 4 Dec | 0.8M | 50M | £14 | £14 | \n| Remington 870 (1) | 4 Dec | 1.3M | 72M | £20 | £20 | \n| FN P90 (1) | 4 Dec | 1.0M | 70M | £19 | £19 | \n| Shared: weapon kit, rig templates, holds | 2 to 4 Dec | 10.3M | 308M | £91 |  | \n\nOne 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.\n\nThere 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.\n\nIn 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.\n\nFor a game and what I am looking for, I am happy with that.\n\nAre 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.\n\nThis 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.\n\nWhat 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.\n\nDownloading or buying an MP5 model would have been quicker but I wouldn't know my new favourite word, \"knurling\".", "url": "https://wpnews.pro/news/making-guns-in-blender-with-llm-agents", "canonical_source": "https://tomaytotomato.com/making-guns-in-blender/", "published_at": "2026-12-05 16:29:46+00:00", "updated_at": "2026-12-05 16:47:40.159793+00:00", "lang": "en", "topics": ["ai-agents", "ai-tools", "generative-ai", "large-language-models", "developer-tools"], "entities": ["Blender", "Heckler & Koch MP5", "Java", "SketchUp", "TurboSquid", "Rainbow Six", "Rogue Spear"], "also_reported_by": [], "takeaway": "Driving Blender through LLM-generated Python scripts, with tweakable constants at the top of each script, produced a complete MP5 model in 4,595 lines of code that regenerates quickly when parameters change.", "recommendation": {"advice": "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.", "playbook": "coding-agents", "playbook_url": "https://wpnews.pro/playbooks/coding-agents"}, "alternates": {"html": "https://wpnews.pro/news/making-guns-in-blender-with-llm-agents", "markdown": "https://wpnews.pro/news/making-guns-in-blender-with-llm-agents.md", "text": "https://wpnews.pro/news/making-guns-in-blender-with-llm-agents.txt", "jsonld": "https://wpnews.pro/news/making-guns-in-blender-with-llm-agents.jsonld"}}