A Community discussion forum for Halo Custom Edition, Halo 2 Vista, Portal and Halo Machinima

Home  Search Register  Login Member ListRecent Posts
  
 
Viewing User Profile for: gpGlobals
About Contact
Joined: Jan 15, 2020 10:48 PM
Last Post: Jan 26, 2020 11:46 PM
Last Visit: Feb 14, 2020 10:05 PM
Location:
Occupation:
Interests:
Your Age:
What Games do you play:


Send Private Message
Post Statistics
gpGlobals has contributed to 6 posts out of 469751 total posts (0.00%) in 33 days (.18 posts per day).

20 Most recent posts:
Halo CE General Discussion » [Utility] Reclaimer Jan 26, 2020 11:46 PM (Total replies: 29)

Quote: --- Original message by: R93_Sniper
Quote: --- Original message by: gpGlobals
Bone/node rotations are also off in the exports, but I'm pretty much 100% sure that this is due to me not handling the quaternions right when converting them to Eulers.


If you're converting from Max to blender, i've found that 2.81 handles this fine with the right import settings. This is what i use:
https://cdn.discordapp.com/attachments/429392249919373323/665454327913250837/unknown.png

Oh, nah; I wasn't. I actually don't have 3ds max - one of the reasons I took it upon myself to code my script up.
I found out what the issue with the weird bone placement was, and it all comes down to conversion from quaternions -> matrices -> radian euler angles (the latter of which SMD files use) - anyone who's worked with rotational math/programming can probably attest to how much of an absolute hellstorm it is to deal with. Funnily enough, I only just now found an algorithm that seems to work perfectly and get the bone rotations how they should be, in fact!
Edited by gpGlobals on Jan 26, 2020 at 11:46 PM


Quote: --- Original message by: LaikaGlove
I'm in the middle of a big refactor of the code to clean things up for a code release, but it will take some time. What other formats do you want supported?

Also yes I do plan to eventually support halo 4 animations, which may again take some time to reverse engineer because there's another new codec compression implemented for that game. I haven't looked at it but I have a hunch it won't be as difficult as Reach was, but we'll see.

Specifically, I'm looking for .smd export support. I'm currently working on a little personal project to import Halo viewmodels to the Source Engine, and obviously porting the animations is part of that. I actually have a semi-working Lua script up and running to do so that I wrote up, but official support would be a big plus, needless to say.

Halo CE General Discussion » [Utility] Reclaimer Jan 21, 2020 03:45 PM (Total replies: 29)

Quote: --- Original message by: Gravemind

Quote: --- Original message by: gpGlobals
What's really cool is that this script that turns AMFs into SMDs will allow Blender to import Halo models - the Blender Source Tools allow imports of SMDs. (In fact, that's what I was using to check the normals.)

The next update will also include COLLADA and obj/mtl format support as well, though I have no ETA. Once your script is complete I can include it in the OP with the AMF link if you want.

Quote: --- Original message by: gpGlobals
Last edit: I have figured out the issue with normals. My code had zero issues - everything works absolutely perfectly. What the issue apparently was was that Reclaimer does not extract model normals properly. I decided to get a look at what the exact normals should be by exporting the Battle Rifle model from Adjutant in .obj format; my results showed that the normals in the .obj were correct, and the exact same as a direct port to Source I decompiled. I decided to test whether Reclaimer was the issue by exporting a .amf of the Battle Rifle with Adjutant, then reading it with my code; lo and behold, I got the correct normal values.

Based on a quick look in Max the normals seem fine to me, I'll have to compare the actual coordinate values and see what's different and which results are the correct ones.

Edit;
Turns out the normals were getting transformed when they weren't supposed to - I'm not sure how they managed to still look passable instead of completely garbage. I've exported some AMF files here with hopefully correct normals: https://www.mediafire.com/file/lfw3jy6ofysy3st/amf.7z/file
Can you convert them with your script and see if Blender likes them? If so, it'll be fixed in the next update.
Edited by Gravemind on Jan 21, 2020 at 05:47 AM

I can confirm that Blender likes these two; the normals look perfect. As an extra check, I exported these two models to .obj with Adjutant then imported them - identical normals!

And yeah, I'll let you know when the script is complete. As I said, it currently runs off of Garry's Mod - I hope to convert it to a file that can be used with Lua's console application - and I haven't yet implemented proper handling of materials and matrix transformation when necessary. Bone/node rotations are also off in the exports, but I'm pretty much 100% sure that this is due to me not handling the quaternions right when converting them to Eulers.


I know this has been asked a few times, but will the source code ever be released? It'd be incredibly useful to have the methods for reading the animation format so we can extract to formats besides just .jmm/.jmo/etc.

Halo CE General Discussion » [Utility] Reclaimer Jan 18, 2020 08:26 PM (Total replies: 29)

Quote: --- Original message by: Gravemind
Quote: --- Original message by: gpGlobals

Amazing work! Glad to see Adjutant nice and updated.
Thanks to the AMF importer script being in plaintext, I'm currently actually working on an AMF -> SMD exporter (it currently uses Garry's Mod to read/write the files - weird, I know, but I'm just too accustomed to its version of Lua at this point to adapt to making an average console program).
Although, I do have a question - what are all the matrices in the code used for? I've checked a JMS importer script for Max, and it seems to just straight up import the geometry with no matrix scaling or math. For AMF importing, is this optional/only for loading it into 3DS Max, or something that's required?

Okay, little update!
I've made enough progress that exporting geometry from a .amf to a .smd is entirely in working order, and weights are correctly written.
However, the one thing I can't seem to get right is writing normals; I don't know what it is, but the values are just wildly... off.
Decompiling other successfully-exported Halo models that other people have used in Source shows that the normals there are wildly different from what I'm reading from the .amf - what could be going on here?


AMF uses matrices for BSP geometry instances - when multiple objects use the same set of vertices but with a different offset and/or rotation. The matrix defines where the object is placed and how it is rotated. In a few rare cases this is also used in regular models, such as the Halo 3 brute and Halo Reach spartans. If .smd doesn't do transforms you'd need to use the matrices to calculate out the final position of each vertex. This applies to normals too, as they will also be affected by the matrix.

Other than being affected by the matrices, the only thing I can think of for the normals is that the direction might be the same but not the length. Try normalizing both sets of normals and see if they end up the same.

Ah, okay, the issue was just that they weren't normalized - after doing so things look perfect! Thanks for the help, bro.
What's really cool is that this script that turns AMFs into SMDs will allow Blender to import Halo models - the Blender Source Tools allow imports of SMDs. (In fact, that's what I was using to check the normals.)

Edited by gpGlobals on Jan 18, 2020 at 08:26 PM

..ah, okay, nevermind; the situation with the normals actually isn't sorted out. They don't seem to look right when I compare them to other .smd files directly exported from Halo - and I think I know why.

I initially thought that 3DS Max stored its normals on a per-vertex basis, like it would be (excuse the bad pseudocode!)
normalArray[7] = vertexArray[7]'s normals

...but it doesn't seem that's the case. Correct me if I'm wrong, but it looks like the code you used:
if norm do (
max modify mode
normMod = Edit_Normals ()
select newMesh
addModifier newMesh normMod
normMod.selectBy = 1
normMod.SelLevel = #Vertex
normMod.Unify selection:#{1..normMod.GetNumNormals()}
normMod.MakeExplicit selection:#{1..normMod.GetNumNormals()}

for i = 1 to newMesh.numverts do (
sel = #{i}
norms = #{}
normMod.ConvertVertexSelection &sel &norms

for j in norms do (
normMod.SetNormal j normList
)
)

--dont want annoying modifier with lines everywhere
collapseStack newMesh
)

finds a bunch of normals shared by a single vertex, and sets each one to the normList? I just need to find a way to convert this strange format to a per-vertex array without direct access to 3DS Max's functions - any ideas how I could go about this?
Edited by gpGlobals on Jan 19, 2020 at 07:52 PM

Last edit: I have figured out the issue with normals. My code had zero issues - everything works absolutely perfectly. What the issue apparently was was that Reclaimer does not extract model normals properly. I decided to get a look at what the exact normals should be by exporting the Battle Rifle model from Adjutant in .obj format; my results showed that the normals in the .obj were correct, and the exact same as a direct port to Source I decompiled. I decided to test whether Reclaimer was the issue by exporting a .amf of the Battle Rifle with Adjutant, then reading it with my code; lo and behold, I got the correct normal values.
Edited by gpGlobals on Jan 19, 2020 at 10:29 PM
Edited by gpGlobals on Jan 19, 2020 at 10:30 PM

Halo CE General Discussion » [Utility] Reclaimer Jan 15, 2020 10:59 PM (Total replies: 29)

Amazing work! Glad to see Adjutant nice and updated.
Thanks to the AMF importer script being in plaintext, I'm currently actually working on an AMF -> SMD exporter (it currently uses Garry's Mod to read/write the files - weird, I know, but I'm just too accustomed to its version of Lua at this point to adapt to making an average console program).
Although, I do have a question - what are all the matrices in the code used for? I've checked a JMS importer script for Max, and it seems to just straight up import the geometry with no matrix scaling or math. For AMF importing, is this optional/only for loading it into 3DS Max, or something that's required?
Edited by gpGlobals on Jan 15, 2020 at 11:00 PM

Okay, little update!
I've made enough progress that exporting geometry from a .amf to a .smd is entirely in working order, and weights are correctly written.
However, the one thing I can't seem to get right is writing normals; I don't know what it is, but the values are just wildly... off.
Decompiling other successfully-exported Halo models that other people have used in Source shows that the normals there are wildly different from what I'm reading from the .amf - what could be going on here?
Edited by gpGlobals on Jan 18, 2020 at 01:41 AM


Time: Sun February 16, 2020 4:43 PM 109 ms.
A Halo Maps Website