Jump to content

Trying to make a "Big Head" mod - works ok in barracks but not in tactical


SpazmoJones

Recommended Posts

Hi

 

I'm trying to make a "big head" mod for XCom. So far it works ok while viewing soldiers in the barracks:

http://imgur.com/a/nsgJn

 

The problem is the head scaling does weird things when applied to soldiers in the tactical game. From what I can tell the head mesh is positioned to line up exactly with the body mesh, so when it's scaled, the Z co-ordinates get scaled up as well and the head ends up much higher. I work around this in the barracks view by using a SetTranslation on the mesh to move the scaled head "back down" so it lines up with the body. This doesn't seem to work with the tactical game and the scaled heads end up floating around weirdly, like this:

http://imgur.com/AJ9R2hU

 

If I adjust the translation to position the head correctly for the "standing" animation, it doesn't appear in the correct place when the soldier is crouching or taking cover.

 

I think I can make this work if I can find a way to set the origin/pivot point of the head mesh around (0,0,0) or something similar so that it scales in size without moving, and then "translate" it back to it sits back where the head should be. The problem is I can't seem to find a way to change the pivot point of a mesh using UnrealScript.

 

Does anyone have any idea if this is possible?

Edited by SpazmoJones
Link to comment
Share on other sites

Haha, that looks fun, good job so far :)

 

And you're right, the head meshes share the same origin as the body meshes, i.e. they're anchored to (0,0,0) which is at the base of the body between the feet. Typically you don't want to scale the head mesh directly, but the bone its attached to in the soldier pawn's skeletal hierarchy - I don't know if this is feasible though. There is such a thing as Skeletal Controllers in UE3, so maybe you could look into those to find a way to adjust bone scale on the fly.

Link to comment
Share on other sites

Haha, that looks fun, good job so far :smile:

 

And you're right, the head meshes share the same origin as the body meshes, i.e. they're anchored to (0,0,0) which is at the base of the body between the feet. Typically you don't want to scale the head mesh directly, but the bone its attached to in the soldier pawn's skeletal hierarchy - I don't know if this is feasible though. There is such a thing as Skeletal Controllers in UE3, so maybe you could look into those to find a way to adjust bone scale on the fly.

 

Thanks for the info. I can only find references to skeletal controllers for the left and right hands - nothing for the head. There is a 'HeadBoneName' reference but I haven't had any luck getting it to scale in any way. The only function I could find that looked like it might work is 'AttachComponent' which allows you to set the relative location, rotation and scale. I tried using this function to re-attach the head mesh to the headbone but it didn't seem to have any effect. The helmet scaling works fine however, so I've made a mod that just scales helmets for now:

http://www.nexusmods.com/xcom/mods/600/?

Link to comment
Share on other sites

I'm giving up on this for now. I've tried pretty much everything I can think of but I'm not getting anywhere.

 

If I detach the head mesh in the code then the head disappears as expected, so that function works. If I then reattach it using the "AttachComponent" function it appears again (attempting to attach it to the "head bone"), but it ignores any scaling, location or rotation transformations sent via the function. From my limited understanding of Unreal it seems that the model has to be set up to support scaling or this sort of thing won't work. If somebody manages to crack the problem of updating the in game models then I might look at this again as I think that's what it's going to take.

 

If the head models meshes could be adjusted so that they sit on the origin instead of floating up in the air then the scaling problem would go away but that doesn't seem to be possible using UnrealScript. Sigh. :(

Link to comment
Share on other sites

Looking through some UnrealScript documentation I'm seeing a few hints that could be useful. Instances of the SkeletalMeshComponent class maintain lists named LocalAtoms that store AnimNode.BoneAtom structs. The LocalAtoms list is described as a

Temporary array of local-space (ie relative to parent bone) rotation/translation for each bone.

and sure enough the BoneAtom struct contains members for rotation, translation and scale, i.e.

struct BoneAtom
{
    var quat Rotation;
    var float Scale;
    var vector Translation;
}; 

I'm thinking it might be possible to look up the index of the desired bone by its name, grab the corresponding BoneAtom and modify its Scale property. Maybe something along the lines of this:

    local array<name> names;
    local int index;
    local BoneAtom atom;
	
    meshComp.GetBoneNames(names);
    index = names.Find("RigHead");
    atom = meshComp.LocalAtoms[index];
    atom.Scale = 2.0f;

Could very well be that the BoneAtom structs are read-only and changing their member values has no effect, but it might be worth a shot.

Edited by XMarksTheSpot
Link to comment
Share on other sites

I'm trying to access it inside the XComHumanPawn.OnHeadLoaded function.

 

If I need to call a function or access a variable I normally search the existing code for examples where they are being used in the way I want to use them. I then decompile those functions using the HexToPseudocode utility and then reference them in a similar way in my mod. I haven't found any references to LocalAtoms anywhere in the code.

 

How would you do it?

Link to comment
Share on other sites

I don't use PatchUPK and wouldn't know about its pseudocode syntax. What I would do in case there is no precedence to using a specific variable is to grab a similar line of script code that is accessing a different instance variable and altering the value of the InstanceVariableToken (0x01) inside it to point to the desired variable instead. The InstanceVariableToken value seems to be a (typically negative) 4-byte integer, so most likely an index of sorts. I can't really make out how to determine the correct index for a specific instance variable (I suspected it to be related to the position in the Export table, but I don't see a correlation), but you could always just brute force it via trial and error, i.e. playing around with the value until you close in on the desired variable. Not really an elegant solution, I admit.

 

Maybe someone else can shed some light on what the InstanceVariableToken value refers to.

Edited by XMarksTheSpot
Link to comment
Share on other sites

I don't use PatchUPK and wouldn't know about its pseudocode syntax. What I would do in case there is no precedence to using a specific variable is to grab a similar line of script code that is accessing a different instance variable and altering the value of the InstanceVariableToken (0x01) inside it to point to the desired variable instead. The InstanceVariableToken value seems to be a (typically negative) 4-byte integer, so most likely an index of sorts. I can't really make out how to determine the correct index for a specific instance variable (I suspected it to be related to the position in the Export table, but I don't see a correlation), but you could always just brute force it via trial and error, i.e. playing around with the value until you close in on the desired variable. Not really an elegant solution, I admit.

 

Maybe someone else can shed some light on what the InstanceVariableToken value refers to.

 

Yikes, that sounds horrendous. I think I'll pass. :)

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...