Hey guys, I was going through tutorials on knockoutjs.com and thought I might as well make something that could be useful to people in the process. So to that end, I have created a unit statistic viewing and unit comparison tool which is attached to this post. To install, copy the unit_viewer folder to your PA installation directory then open unit_viewer.html in your browser. The way this works is that I have created a PHP script which compiles a massive json file, that builds up a tree structure of all the units and their associated json files. So for example the unit model field has a field in it called animtree which is a reference to a json file. This is loaded into the array under animtree_data. To regenerate this file run "php create_json.php" from the command line. The unit comparison page allows you to compare fields of your choosing by entering a value in the heading which is a representation of the units tree structure using a full stop (period) as a delimiter to symbolise the next level in the tree structure. So if you wanted to compare all unit speeds, you would enter navigation.move_speed into the table header. If you wanted to compare the damage of all the unit's "tools" you would enter tools.spec_id_data.ammo_id_data.damage The sorting on the comparison table breaks at the moment after the columns refresh. I'm still trying to fix this one. If this is useful to anyone and you would like to see a new feature added, feel free to PM me. Version 0.4 Terrain models added. The file is too big for the forum now. Download from my website below. Download
Minor thing, but you should include the display_name along with unit_name in the heading of each unit (such as "Assault Bot - Scamper"), as that's what people see in game. Awesome work! Edit: The default unit_comparison_list.json did not work for me, I had to re-gen it (after which it worked fine). The re-generated file for 49303 is attached - it's only about half the size of the default one.
Nope, Windows. I did run the json formatter on my media directory though (viewtopic.php?f=72&t=47529), could this have affected it?
Possibly, but it *shouldn't* affect it. I'll have to run the formatter and try it myself when I get a minute.
Minor little thing. Where you used pathnames for the javascript files in /media/ui/alpha/shared you used "../PA/media/ui/alpha/shared/js/*" which assumes the person has their installation folder named "PA". This problem is in unit_comparison.html and unit_viewer.html. Also, it shows up in line 80 of create_json.php as That aside, thanks for putting this together. It is pretty awesome.
Maybe I can help you get it working. What browser are you using? Do you get any JavaScript errors? If so what were they? Did you put the unit_viewer folder in the root installation directory? The folder structure should look something like this: Program Files (x86) | Planetary Annihilation | | cache | | PA (Apparently this isn't always named PA? which would cause a problem) | | unit_viewer | | PALauncher.exe Lastly, do you have PHP installed and did you try running the generator script? Recently I've put in an addition that allows you to view a 3d model of the selected unit with WebGL. It makes use of Raevn's awesome blender importer, then I export into three.js format [http://threejs.org/] to get the model data to work in the browser. I'm looking for a way to automate this process with Blender's command line tools, but I haven't really had much time to look that far into it yet. So if anyone reading this knows how to do that let me know please!
Ah thanks, I put it inside the PA folder not the root Planetary Annihilation folder. I'll give it a go when I get home.
Hey Guys, I've just uploaded version 2. This includes 3D models visible in the browser. A few things to note are: 1. I needed to put unit_viewer.html outside the folder as the javascript wasnt allowing me to get the image textures using "../PA/" 2. Currently works best in FireFox. Chrome/WebKit has a cross domain policy which prevents the json model file and textures being loaded in dynamically. You can get around this however by starting Chrome like this: "chrome.exe --allow-file-access-from-files". Although this still doesn't seem to work 100% For people wanting to re-generate models/unit data. The following is required. 1. Blender 2. Raevn's papa Import/Exporter found here 3. The Three.js Blender Import/Exporter found here You must then edit the create_json.php file and change the two path constants up the top which point to Blender and your PA installation. Then run the script with "php create_json -gm" (Generate Models) Have fun! and any feedback much appreciated.
This is so cool Two small things: 1. Somewhere in the data files, bones can be turned off - notice the battleship has AA guns in the viewer, for example, but not in-game. Not sure where this visibility state is set. 2. I managed to make models spawn on top of each other (Click on Beast then Imperial commanders, you get both)
Couldn't have done it without you my friend I've uploaded a small update, It now has a colour picker for primary and secondary unit colours. Also fixed the issue where multiple units could stack. You won't be able to load a unit now until the last one has finished loading. As for the bones and AA guns thing.... whoosh! way over my head. I had a look at the generated json files and your python importer code, and I have no idea where to even start I wanted to make a new section for terrain features (decals?) but the import doesn't like those papa files. It complains about bones which is probably because those models don't have them! I'm guessing these would be simpler to generate? But again Python aint my thang. I've seen some talk about fbx, and it sounds like I'll be able to do conversions from fbx files in future? which will probably be easier. Cheers
I had another look at the file format, this time using Papadump to provide more of an insight into the structure. I found that the terrain models use a different Vertex structure, so I've updated the Blender importer and was able to open them - I'll upload it shortly. The metal terrain pieces aren't that exciting . Just some trenches and walkways. Uber released papatran.exe, which converts fbx -> papa, but there's no official extractor to convert the other way. Edit: Air > Missile is actually a tool blueprint. Usually, these have or inherit a "tool_type": "TOOL_Weapon", but this does not, so I'm not sure how you'd go about excluding this from the unit list. No unit has a "damage" attribute, so you could maybe use that as a fallback? Also, the new version of the Blender importer should fix the corrupted model. False > wreckage is actually a different type of blueprint altogether, which I am starting to document (It's a "feature" blueprint, same as trees & rocks and things).
Got it, and added the new terrain page. Thanks! I'll look into excluding those non-units in the next release, thanks for pointing that out. In the current release there's a few things to mention. 1. You can generate terrain objects in the same manner as units with php create_terrain_models.php -gm. -gm generates the models, without it just the json list which drives the UI will be generated. 2. There doesn't seem to be any real naming convention or reference in the json files on which texture to use. So what my code does is attempt to find the texture using the same conventions as the Unit Viewer, if it doesn't find it it will look at a name/texture mapping object I've created in terrain_texture_map.json. If it's not there you have a nice black model to look at. Code: var terrainTextureMap = { 'jungle_palm':'jungle_palm_01_diffuse.png', 'jungle_fern':'jungle_fern_01_diffuse.png', 'jungle_rock':'jungle_rock_02_diffuse.png', 'grass_tree':'evergreen_01.png', 'metal_':'metal_csg_01_diffuse.png', 'mountain_crack':'mountain_crack_05_diffuse.png', 'mountain_mountain_01':'mountain_01_diffuse.png', }; In the example above any papa filename with the string 'jungle_palm' in it will load the jungle_palm_01_diffuse.png texture etc. The next logical step I see for all this will be to develop a "Scene Creator" that will allow people to construct a PA scene and save it as a picture.
For terrain features, texture information is inside the .papa file, but the importer doesn't read them yet (on the to-do list). You can see them using papadump, however: Code: c:\Program Files (x86)\Planetary Annihilation\PA\tools>papadump.exe metal_cap_01.papa 2 textures: 0: name: "/pa/terrain/metal/textures/metal_csg_02_diffuse.png" format: TextureFormat(20) width: 0 height: 0 mips: 0 1: name: "/pa/terrain/metal/textures/metal_csg_02_normal.png" format: TextureFormat(20) width: 0 height: 0 mips: 0 <snip the rest> Some of the terrain features are actually inverse (negative) representations; that is, when generating planets it carves out the shape of the feature. Things like cracks in the ground, for example. It's kind of out of scope for this, but you can see whether something is added (like a mountain) or subtracted (like a crevass) within the biome blueprints, in PA\media\pa\terrain\<biome name>\<biome name>.json, under "brushes". Each brush as an "op" value of BO_Add or BO_Subtract.