Code: Select all
unit_created(){
for each piece in s3d model
clone piece
compose transformation from default values
instantiate
}
unit_update(){
if unit script changes transform (aim from weapon, walk, etc)
flag dirty
recursively update model pieces
compose piece matrix from script Euler Angles
Draw(glMatrix)
}
Instead of the following members
Code: Select all
float3 pos; // translation relative to parent LMP, *INITIALLY* equal to original->offset
float3 rot; // orientation relative to parent LMP, in radians (updated by scripts)
float3 dir; // direction from vertex[0] to vertex[1] (constant!)
CMatrix44f pieceSpaceMat; // transform relative to parent LMP (SYNCED), combines <pos> and <rot>
CMatrix44f modelSpaceMat; // transform relative to root LMP (SYNCED)
this would allow customization of how rotation are handled, be it euler angle concatenation or matrix multiply == give game developers control over speed/memory tradeoffs in calculations
My concern is that certain callouts for handling unit states are entirely dependent on LocalModelPiece position/rotation, so much of the weapon aiming system/collisions system needs to be reworked as well.
===========
im going to dump some ideas here
AFAIK the two methods for calculating important weapon-related positions are
[code]
relWeaponPos = owner->script->GetPiecePos(owner->script->AimFromWeapon(weaponNum));
weaponPos = owner->GetObjectSpacePos(relWeaponPos);
[/code]
..which respectively return...
[code]
return (modelSpaceMat.GetPos() * WORLD_TO_OBJECT_SPACE); // combined translation/rotation/scale matrix4x4
and
return ((pos + (frontdir * p.z) + (rightdir * p.x) + (updir * p.y)); //float3 pos very bottom of Object
[/code]