Wednesday, 27 June 2018

Monster Modelling Mayhem

Apparently the UK is under a LEVEL 2 HEATWAVE WARNING ... not that I'd know about such things as I am covered in a blanket of fog with a chill wind coming from Svalbard, to the extent that I am expecting angry undead lepers to start banging on the windows demanding their stolen gold back. But as this is not the Weather Channel, on with the show ...

 Not the heatwave you are looking for ...

I am currently at the stage of development were I am replacing the beloved placeholder cubes with actual models, thus creating unique enemies per level with their own abilities and statistics. So far I had wanted to introduce the player with some familiar enemies for level 1 in the shape of 3 different types of zombies (it appears I am the only person on Earth who has never really been into zombies, Day Of The Dead being the only zombie movie I ever had any interest in). After this I had some rather spiffing Velociraptors and even gave one type the ability to shoot "frickin laser beams" out of their mouths as a long range special attack.

Everyone loves dinosaurs ... until they're eating you ...

For some later levels I had thought about going for a riff on the classic black knight look. I came up with the idea of interdimensional knights who suffer instability, constantly being dragged in and out of their own dimension. To this purpose I used an animated texture with various changes to alpha and a patterned diffuse with the edges of the various elements of the model picked out in colour.


There are 2 types of Shadow Knight, Axeman model shown here

The Warp takes me! It's feels slightly off putting ...

Spawning, pre audio effect

These still need animating. Whilst the models were of good quality (though needed a fair bit of work to make them useable through Blender) their stock animations were a bit ... average, so I intend to go through my huge library of mocap BVH files to find something more exciting. As interdimensional entities I'm thinking that they might just float around rather than run.

Noting that most of my game enemies are melee based, I came up with a plasma rifle toting "Mantisman" alien. This is an actual Torque model by GarageGames back when they still made game engines so you'd think that it would be set up the same as the other stock stuff. Alas no, as it was plagued with various inconsistencies such as strange bone settings whilst used the animation files to fix the baffling rotational default offsets. Needless to say this really made it not just a pain in the arse to modify the base mesh but also meant that it's animation were not compatible with the other GG models. In the end I scrapped trying to retrofit the multiple death animations and came up with a simple solution - just make the damn thing explode on death. Problem solved. Another major issue was that the stnadard aiming animation method just did not work at all. Flcuk knows why but I ended up having to use the old Mark 1 Eyeball with trial and error adjustments which ended up with around a 20% offset from -85 degrees (which is the stock downwards aiming constraint). The alien rifle needed a good remodelling too.

Mantisman in action, and now renamed "Kralmok Warrior" after the gun

Initially I just used a variation of the zombie explosion death, using the engine automated "blowUp" function. With MantismanKralmok Warriro being a larger model than the zombies and thus splaying further forwards so that it's not centralized to it's origin (another inconstitency that made me wonder what were they thinking) it ends up looking a bit obvious when the mesh disappears and goo rains down. To get around this annoyance I made a custom explosion debris featuring various recognisable body parts of the main model.

Boom Splat!

The plasma rifle got a remodel and some custom projectiles. I also gave it a long range special attack that features a barrage of bullets with long tails, whilst the standard shot it an energy ball.

So, next up, more modelling. The Shadown Knight's need animations and the Kralmok Warrior needs a bit of tweaking and multiple skins/textures for some variation. Next enemy on the list - Spiders! Cos everyone loves spiders!

Sunday, 20 May 2018

Dinosaurs With Frickin Laser Beams

The last month has been entirely dedicated to the long and winding road which is replacing placeholder cubes with actual art assets. This has required me to finally upgrade my 2007 version of the free/open source Blender3D modeling app, to the all new, all singing, all dancing 2018 version. Thankfully, very little has changed in hotkeys, but boy has a lot changed elsewhere - especially animation - all of it for the good.

Last month I discovered - completely by accident - that I could convert FBX models to a more useable DAE/COLLADA format through Visual Studio. The lastest version of Blender (2.78c) also has an FBX importer, though I found it doesn't always import correctly, especially with animations. This seems to be down to the specific type/build/version which the model was exported with in FBX. Some work fine, such as the GarageGames Zombies and Solder content packs at https://github.com/GarageGames/ContentPacks whilst others require saving out as DAE through Visual Studio. Either way, it seems that I have a solution for compatibility.

Original on the left, Blender export on the Right - are you boys related?

Talking of GG's content packs on Github, I got them working with Blender and then exported with animation et al quite nicely. Whilst the basic rigging of the armature/skeleton is similar, there are some differences in the arms between zombies and soldier models, which meant that to get the extra death animations working with the zombie armature required a bit of manual rejigging in Blender's animation system. A quick read through the online manual was enough to bring me up to speed on how modern Blender differs from the 11 year old version I am more accustomed to. Turns out the Animation Action Key Editor was hidden under something called Dope Sheet Editor ... whatever one of those are ...

Anyhow, here's a big long thread on my exciting and occaisonally confusing adventure into successfully exporting FBX through Blender3D into a Torque3D compatible DAE format.

 The (FBX) Thing That Came From Blender ...
I decided on 3 types of zombie models, each with 4 different coloured outfits for variation. I also exported my models with seperate head meshes and scripted a decapitation system, as well as a body exploding system to add some extra gore and variation to destroyed enemies. There are 3 different animations for spawning, all of which are crawling out of the ground with 4 different effects for particles and audio. There are differing animations for root, run, sprints and various attacks, all helping to make things visually more interesting.

Testing zombies spawning from underground

So then came dinosaurs .... with frickin' laser beams attached to their heads.

You got dinosaurs instead

I found a rather nice Velociraptor which had full animations to license. It required a bit tweeking for what I wanted. Rather like the GG zombies on github it was highly detailed in bones and my isometric/top-down Swag 'Em Up does not really require all these fingers and knuckles to be clearly visible in animations. I cut down the tail, real velociraptors might have found a massively long tail great for balancing but I thought it just got the way when they turned around in game - halved the tail bones and merged all toes and fingers into single bone per hand/foot whilst reparenting all of the required vertex groups (or else they would be a hell of a mess when the mesh deformed and found it had no parent bone). This removed nearly half the armature and would thus save on overhead in game - something which you should always thing about if you are likely to have "a lot of stuff on screen" - and player's like "stuff".

Dino a-cute!

Like the zombies, I reworked animations to create new spawning and root animations, randomized attack animations and created various different coloured skins (all of which are a bit brighter than the original) to keep everything looking different. Velociraptors are also exported with a seperate head mesh allowing for decapiations and they can completely explode too. One extra thing which I wanted was for the some raptors to have a rather unexpected range attack - literally frickin laser beams. I modified the roar animation to be used to fire an energy beam with a randomized colour from their mouth.

Fricken Laser Beams!

So ... that was a very productive month with plenty of things that are more interesting to show than just me saying "I did some code". Next up I want to make a couple more death animations from scratch for the raptors, and add more obvious magus/liche type character for the zombies with the magic projectile attack, possibly with a Hadouken style attack animation. After that we are on to more enemies of varied and different types ... anyone got a fear of spiders? [cue evil laughter]

Friday, 20 April 2018

How To Import FBX Into Blender3D Using Visual Studio

FBX is a popular format, mostly because Autodesk have spent the last 100 years ruthlessly (look at how many companies they've bought out over the years) pushing 3DS Max as the industry standard for 3D modeling. This means that a lot of 3D artists use it, which in turn means that a lot commercially licensable models are FBX. Autodesk are well known for jealously guarding the source code of the format like some ancient sacred text - which to be honest, it probably is, as it's made them a fortune and cemented them as the standard format/app for the whole video game industry. This completes the circle of life where they become king of the hill, are anointed with their gold crown, and have peasants throw money at them to use not just their 3D modeling app, but also their propriety format (which they bought off someone else in 2006).

 How I imagine Autodesk

This means that they don't let any Tom, Dick or Heinrich have access to import/export code of the format, especially free software like the plebs over at Blender3D (though recently they have partnered with Epic for UE4 integration. Epic wanting UE4 to be the game engine equivelant of 3DS Max - cue KA-CHING sound!). Blender has a lot of things going for it. It's free, it has on going development, it's free, it has a somewhat strange and awkward interface compare to commercial modeling apps, it's free. People can and do write their own import/export scripts in Python (hello whitespace!). 

Blender does have an FBX importer on the Blender Wiki, but it mangles the hell out of bone transforms. There is a custom amde importer created by a Blender user which brings through everything correctly ... everything except animations. Not too useful if you've got a shop bought character model and want more than just a static mesh.

Autodesk do have a free FBX Viewer and Converter. This sounds great, right up until you export as a COLLADA DAE format (something Blender3D likes) and the resulting file comes out empty. (T-thanks Autodesk). This leaves OBJ format, which again, is just a static mesh, leaving all weight painting, armature, animations, etc behind.

And then I discovered a new way which actually works ---- completely by accident.

Whilst making a list of enemies for my current Twin Stick Swag 'Em Up, I started going through the models which I already have to see which matched the descriptions of enemies in the list I was making. Now I had previously licensed some shop bought FBX format characters. Having forgotten what they looked like I wanted a quick glance at them in Autodesk Viewer/Converter. So I double clicked the FBX file and was rather annoyed when Visual Studio 2013 booted up instead. As I hovered my mouse in the screen corner ready to close VS, I was somewhat surprised to see the model displaying. I had no idea Visual Studio had a 3D viewer. I checked export options and was intrigued to see "export as DAE" available - so I did, then booted up Blender3D 2.78b and imported the DAE file leaving all import options set to the default off. 

And there it was, sitting with correct transforms and rotations, parented correctly via weight paint to the armature skeleton. I pressed right cursor key to cycle through key frames and was ecstatic to see the animation play correctly. The one thing to note is that diffuse and specular for the material default to black rather than white, but that's easy enough to change.

 FBX to DAE (via Visual Studio) to Blender3D and Torque3D

So I imported it into Torque3D as a static mesh to see what it looked like in-game, and set up the engine material file. Lo-and-behold it even played the ambient animation correctly. After a bit more quick and dirty testing, I got an AiPlayer character set up - note: the jerky animations are because I didn't bother blending or movement settings for this quick and especially dirty test.


Quick and dirty test - accidentally recorded SpaceX launch audio in background :P

After this success I went off searching for other models to try this FBX-VS-DAE conversion with. There are plenty of free (and usually quite poor quality) models available on the interwebz, but I found this rather nice one at TurboSquid (though it was made of like 20 meshes, each with their own material when surely just 1 or 2 would have sufficed, but hey it's free and looks great).



There you go. Maybe someone else knew that you could get Visual Studio to convert FBX into a Blender3D useable DAE format with correct rotations and full animations, but I haven't found it on the internet - so here it is now!

To recap:
  1. Load FBX file into Visual Studio
  2. Save as DAE (COLLADA)
  3. And that's it, loads perfectly into Blender3D