Showing posts with label mesh. Show all posts
Showing posts with label mesh. Show all posts

Wednesday, September 19, 2012

Lining up LODs

This is a prime example of why a public jira is a VERY GOOD THING.  I would have been thoroughly perplexed by the entire problem AND would have taken much longer (if ever) finding the solution without the ability to browse preexisting jiras for this problem.  (I made an assumption that was incorrect, because it made logical sense to work that way, and no logical sense to work the way it does.  And computers are all about logic, right?)

The problem: you can upload multiple separate mesh objects at once into one linked object (this is great for, say, everything already being in the right place instead of having to line shit up!  Hooray!).  HOWEVER, when one does this and attempts to also upload your own custom LODs and physics shapes, the objects do not always line up!  This leads to lower LODs being wacky shapes, or just plain saying "nope, not doing it" if you don't have the same material setup on them all (texture faces).  So....you can upload multiple items and have them all in the right places in respect to each other OR you can have control over your LODs.  Not both.  (As an aside, the auto generated LODs seem to trim off the objects semi randomly- sometimes one object will get the LOD jacked down a lot, and the other will be barely touched, it doesn't seem to do it evenly.)

The Real problem: the collada exporters just randomly decide on an order for your objects in the file, not based on order selected or any other criteria over which you have control.  This definitely holds true for the blender 2.62 exporter- but it is not alone, other programs also have this issue.

The solution: reorder your collada file by hand.  First step, in your modeling program, before exporting, name all your objects useful names.  You need to be able to distinguish what is the same object in different LODs by name only, so keep that nice and consistent!  Export your collada file now that everything is named and easy to tell apart blind.  Use a basic basic text editor (WordPad works perfectly), open up your dae file.  It's a bunch of xml code in there, nested <type> <subtype>.  Now, you're on your own here a bit, because collada files vary WILDLY in what they call things and how they're ordered.

There's going to be material data in there (probably), which you can just skip by.  You're looking for geometry or something similar.  In my current exporter, I'm looking for <geometry id="object_name" name="object_name"> (Note: those names don't have to be the same, and they are things you set, so you should know what names you're looking for).  There will be a bunch of nested attributes, and then a close geometry tag, and then another open tag with a new name for the next data block.  Find out what order your data blocks are in there!  Then open up another LOD file, scroll down to the same geometry blocks, and reorder each entire block into the same order as the first file- repeat for all LODs (the ENTIRE block needs to be moved, from start to end tag for an object).  Save the newly reordered files (just as text, don't let it do anything fancy, don't rename from .dae).  Now they should line up so the objects agree across LODs instead of randomly assigning!

Friday, December 30, 2011

Adventures in Exporting

This is a run down of my personal glitches with the collada exporters in Blender. Your builds may not have the same problems, but I had to stumble around in the dark to find the ways around mine, so if these issues are plaguing you too, might be worth a try. This is not telling you how to export in Blender, or how to use Blender, it assumes you know that already- just that you are having these particular export glitches when doing it.

I primarily use Blender 2.49 (an old Jass build, that's long since not been available for download. It's comfortable for me, it predates Primstar, and it doesn't have some of the other glitches/intentional refusing to do what I want that was introduced that messed up my workflow). I haven't really jumped on the 2.5 bandwagon much yet, 2.49 does what I want, how I want it, and I haven't spent the time to find the way to work around 2.5 (just trying to cam around in it irks me with the new settings, and I haven't spent the time to get used to it or change it!)

Around half the time, exporting with the collada 1.4 exporter works just fine. The other half...it randomly divides out a few faces and assigns them to new texture space (the closest to tracking down any reason behind which faces it chooses I've come to is that sometimes, but only sometimes, when I merge edges, it glitches some of the faces to one side into a new texture space). This is NOT visible in Blender- it assigns texture faces just as you would expect, you only find out when uploading the collada and either the uploader fails because your models do not all have the same texture faces (or have too many- also note that you actually have to have all the _same_ textures assigned, not just the same number as well- or at least I do!), or you get it uploaded and find out you've got some straggler faces sprinkled around here and there that have a different texture face.

I've tried all sorts of ridiculous and time consuming experimentation with trying to track those down, fix them, replaced my collada exporting scripts with new versions, all to no avail. Finally I found one thing that actually fixed it: opening that blend file in Blender 2.5, and exporting in there.

BUT. The collada exporter in Blender 2.5 is twitchier. You MUST always make sure to tick the "export only selected" box in the file popup or it will export your entire blender scene with all pages in one piece (with my workflow, extra pages have the other LODs and collision and in progress working bits, so it's an enormous mess). ADDITIONALLY. IT ONLY SOMETIMES DOES NOT EXPORT THE UNSELECTED THINGS ANYWAY. This last go round, it would export around half of the rest of the stuff that had nothing to do with what I wanted to export, even though it wasn't selected! It was a consistent half, but it was not a helpful half.

So, time for making a copy of your blend file so you don't save over and lose everything. Open that in Blender 2.5. Delete everything on ALL the other pages. Delete everything you DO NOT NEED on the page with what you want to export. IF YOU ARE EXPORTING RIGGED MESH, DO NOT DELETE THE SKELETON. It needs that for the skeleton data. The body you're building around? All that can go, but not the skeleton itself. (And make sure it's the right skeleton if you've duplicated things for alternate working versions, of course.)

Last note: current version of the SL mesh uploader seems to require the collision object to have the same number of texture faces (and the same textures!) assigned as the LODs. Previous versions of the uploader did not, future versions may not again. There is no reason for collision to require textures assigned, and there is no helpful red error message, the button to calculate and upload just silently disables itself.