DarklightGames / DarkestHour

Darkest Hour: Europe '44-'45
https://store.steampowered.com/app/1280/Darkest_Hour_Europe_4445/
67 stars 20 forks source link

Flak 38 first-person camera is not aligned to sights #391

Closed cmbasnett closed 8 years ago

cmbasnett commented 9 years ago

Originally reported by: Colin Basnett (Bitbucket: cmbasnett, GitHub: cmbasnett)


The Flakvierling 38 has a bone called Object002, which matches the pitch of the turret. Note also that the Camera_com bone is a child of the SightBone, so that it moves with it.

In the class DH_Flakvierling38Cannon, this bone is referenced as the SightBone, and is updated in the following function.

#!unrealscript

// New function to update sight & aiming wheel rotation, called by cannon pawn when gun moves
simulated function UpdateSightAndWheelRotation()
{
    local rotator SightRotation, ElevationWheelRotation, TraverseWheelRotation;

    SightRotation.Pitch = -CurrentAim.Pitch;
    SetBoneRotation(SightBone, SightRotation, 1);

    ElevationWheelRotation.Roll = -CurrentAim.Pitch * 32;
    SetBoneRotation(ElevationWheelBone, ElevationWheelRotation, 1);

    TraverseWheelRotation.Pitch = CurrentAim.Yaw * 32;
    SetBoneRotation(TraverseWheelBone, TraverseWheelRotation, 1);
}

I notice the Flak 38 doesn't have this bone, so the rig will need to be altered to match the functionality of the Flakvierling 38.


cmbasnett commented 9 years ago

Original comment by Colin Basnett (Bitbucket: cmbasnett, GitHub: cmbasnett):


Note also that there is a Elevation and Traverse wheel bone; this is fluff more than anything and can be ignored.

cmbasnett commented 9 years ago

Original comment by Bitbucket: Matt_UK, GitHub: Matt_UK:


I'll re-rig and re-make the animations after Peter has re-scaled the meshes.

Making animations like these is pretty straightforward, although it's fiddly and annoying.

Rigging a vehicle-related mesh is also pretty simply, but unfortunately MilkShape uses different axes, which can't be altered to match the Unreal engine. As soon as you touch anything to do with the bones in MS, it screws up the mesh & all anims (specifically it screws up all the bone's initial rotations, so they are no longer zeroed on the correct axes). I've found a way of getting over that, by exporting the rigged mesh as a text-based .SMD file format, then manually correcting the bone rotations as text values, then re-importing the .SMD back into MS & exporting as .psk Unreal skeletal mesh file. Very fiddly & a frankly a big pain in the arse, but it works ! I'm only going to do it once ........

I'll include traverse & elevation wheel bones, like the flakvierling. It is fluff and it looks like unnecessary processing, but it's only on the client (which can easily cope). And I've moved the bone rotation update code from Tick() into HandleTurretRotation() and only running if there has been a cannon yaw or pitch change, so most of the time nothing is happening & it's efficient.

cmbasnett commented 8 years ago

Original comment by Bitbucket: Matt_UK, GitHub: Matt_UK:


Fixed in commit b4d703e and SVN revision 761, as part of re-make of the FlaK 38 animation file, including re-scale of meshes, re-rigging & re-making all animations.

Meshes re-scaled with 50% increase. I scaled against barrel length of existing flakvierling mesh and needed exactly 50% increase to match that. Which is almost too much to be a coincidence; looks like model was made to two thirds scale. This of course assumes FV model is correct scale, but both models look & feel about right to me.

Re-rigged, with camera bone parented to sight arm, so camera position is now correct on open sights. Also added traverse and elevation wheel bones and added rotation functionality in code, similar to flakvierling.

Stripped skeletons of all 3 meshes down to a functional minimum, to avoid clutter and processing load (including on server, as has to track movement, position & rotation of all bones). Bones deleted:

I've left the currently unused wheel bones in the trailer base. No current function but would allow the wheels to be animated if Peter gets a mobile FlaK 38 later ! :)

Centred all meshes in X & Y, then removing unnecessary X & Y bone offsets on bones that centre on X and/or Y.

Added new anims for transitioning to/from the gunsight optics.

Included 3 firing anims, using new generic functionality added to cannon class ('closed', new intermediate, & 'open').

Also renamed the firing anims on the flakvierling for consistency. Flakvierling would benefit from some attention, but will handle separately, with a 'polycrunched' version of the FV turret by Peter.