Bone translation, scaling, and rotation in Lua

DecoDeco Join Date: 2010-04-10 Member: 71288Members, WC 2013 - Shadow
edited February 2014 in Modding
Hello,

I would greatly appreciate it if a Spark engine developer added the following method:

CoordsArray:Set(boneNum, coords)

Example usage:
function Player:GetForbidModelCoordsUpdate()
    local renderModel = self._renderModel
    if renderModel ~= nil then
        local boneCoords = self.boneCoords
        for i = 0, boneCoords:GetSize()-1 do
            local coords = boneCoords:Get(i)
            coords.yAxis = coords.yAxis*math.random() -- Randomly scale each bone vertically
            boneCoords:Set(i, coords)
        end
        RenderModel.SetBoneCoords(renderModel, boneCoords)
        RenderModel.SetCoords(renderModel, self._modelCoords)
        RenderModel.SetIsVisible(renderModel, self:GetIsVisible())
    end
    return true
end

This would allow Lua modders to programmatically "rearrange" models without the need to make new models and animation graphs.

An example application is moving the fingers of an exo, such as Scatter requires for his exo-shield (the fingers will fold back and emit blue light).

Another application is model-splicing. Setting the scale of a bone to zero and attaching another render model in its place allows modders to mix-and-match models. This would make a dual-claw exo possible without needing to create a new model and animation graph.
It would also allow for hiding the exo's fist for a rocket-fist mod.

An alternative to adding CoordsArray:Set, is to inform us of the FFI C-definition of the CoordsArray struct. That way we can do this:
local coords1 = Coords.GetIdentity()
local coords2 = Coords.GetIdentity()
local coordsArray = ffi.new("CoordsArray", { someVariableName = { coords1, coords2, ... } })
...

Where "someVariableName" is the field name we need to know to initialise a CoordsArray.

Please consider this request,
Thank you,
Declan W.

P.S: Model transformation and splicing is used very frequently in Garry's Mod, namely in the Player Appearance Customizer addon. There is little, if any, affect on performance.
theoddbreen.png

Comments

  • IronHorseIronHorse Developer, QA Manager, Technical Support & contributor Join Date: 2010-05-08 Member: 71669Members, Super Administrators, Forum Admins, Forum Moderators, NS2 Developer, NS2 Playtester, Squad Five Blue, Subnautica Playtester, Subnautica PT Lead, Pistachionauts
    Forwarding this to the devs, thanks!
  • DecoDeco Join Date: 2010-04-10 Member: 71288Members, WC 2013 - Shadow
    Looks like this didn't get to the devs... thanks anyway, IronHorse :)

    Does anyone know how to get their attention? This is an extremely easy method to add and would open up many modding avenues.

    In NS2.exe already:
    function CoordsArray:GetSize()
        return (pkg.CoordsArray_GetSize(self))
    end
    
    function CoordsArray:Get(i)
        local __cdataOut = Coords()
        pkg.CoordsArray_Get(self, i, __cdataOut)
    
        return __cdataOut
    end
    

    To add:
    function CoordsArray:Set(i, coords)
        pkg.CoordsArray_Set(self, i, coords)
    end
    

    Along with the C++ definition for:
    void CoordsArray_Set(CoordsArray& self, int i, const Coords& coords);
    
  • JimWestJimWest Join Date: 2010-01-03 Member: 69865Members, Reinforced - Silver
    edited March 2014
    Mhm whats the difference from the thing you want to the function
     "name": "SetBoneCoords",
                        "arguments": [
                            {
                                "type": "CoordsArray",
                                "name": "boneCoords"
                            }
                        ]
    
    
  • DecoDeco Join Date: 2010-04-10 Member: 71288Members, WC 2013 - Shadow
    You can use that to set the bone coords of a RenderModel to the values in a CoordsArray.
    But, you can only set the values of that CoordsArray from the "poses" of the RenderModel or the positions of the bones in the PhysicsModel.
    There's no way to set individual bone values.

    (that is, CoordsArray is "const" on the Lua side, and can only be set by the engine, due to the lack of CoordsArray:Set(boneNum, coords) .)

    If there was, it would be possible to scale the marine's head to zero, and put a skulk's head there.
    Or rotate the fingers of an exo.
    Or scale the size of a lerk's wings.
    etc, etc..
  • DecoDeco Join Date: 2010-04-10 Member: 71288Members, WC 2013 - Shadow
    @IronHorse: Did the devs ever get around to this?
  • SamusDroidSamusDroid Colorado Join Date: 2013-05-13 Member: 185219Members, Forum Moderators, NS2 Developer, NS2 Playtester, Squad Five Gold, Subnautica Playtester, NS2 Community Developer, Pistachionauts
    edited November 2014
    I forwarded this to people who can do something about this on the CDT
  • DecoDeco Join Date: 2010-04-10 Member: 71288Members, WC 2013 - Shadow
    Thanks! :)

    I look forward to playing with it :D
  • IronHorseIronHorse Developer, QA Manager, Technical Support & contributor Join Date: 2010-05-08 Member: 71669Members, Super Administrators, Forum Admins, Forum Moderators, NS2 Developer, NS2 Playtester, Squad Five Blue, Subnautica Playtester, Subnautica PT Lead, Pistachionauts
    Ya development was in a weird place back then, everything was in flux / limbo. But now the CDT is at the helm and is quite effective :)
    Thanks for bringing this back up!
  • matsomatso Master of Patches Join Date: 2002-11-05 Member: 7000Members, Forum Moderators, NS2 Developer, Constellation, NS2 Playtester, Squad Five Blue, Squad Five Silver, Squad Five Gold, Reinforced - Shadow, NS2 Community Developer
  • NordicNordic Long term camping in Kodiak Join Date: 2012-05-13 Member: 151995Members, NS2 Playtester, NS2 Map Tester, Reinforced - Supporter, Reinforced - Silver, Reinforced - Shadow
    I am interested to see how people might end up using this.
  • matsomatso Master of Patches Join Date: 2002-11-05 Member: 7000Members, Forum Moderators, NS2 Developer, Constellation, NS2 Playtester, Squad Five Blue, Squad Five Silver, Squad Five Gold, Reinforced - Shadow, NS2 Community Developer
    You could use it for a simplified inverse-kinematics driven animation of legs : change the leg joints to move the feet so they touch the ground the skulk is clinging on ... the current animation driven one just assume the skulk is hanging on a flat surface. Looks really silly in the wrong place.
  • Soul_RiderSoul_Rider Mod Bean Join Date: 2004-06-19 Member: 29388Members, Constellation, Squad Five Blue
    You could also make really simple mutations etc for zombies, or deform/transform the bones of current models to make them look differntly basic on changes in the game etc. Basically, the possibilities are endless, though for me this all comes a little late in the day.

    Though I really appreciate the work the CDT is doing for NS2, the constant development of the engine and game means large scale mods, particularly full-game mods, still get broken like clockwork with a patch. This might not be such a problem for bigger teams, but for a single modder, having to fix your mod for updates all the time eventually breaks your will to develop for the engine anymore.

    While I think it is great this is being added, we really needed it when it was being asked for :)
  • ScatterScatter Join Date: 2012-09-02 Member: 157341Members, Squad Five Blue
    Is this still being included in 273 ?
  • GhoulofGSG9GhoulofGSG9 Join Date: 2013-03-31 Member: 184566Members, Super Administrators, Forum Admins, Forum Moderators, NS2 Developer, NS2 Playtester, Squad Five Blue, Squad Five Silver, Reinforced - Supporter, WC 2013 - Supporter, Pistachionauts
    edited January 2015
    Scatter wrote: »
    Is this still being included in 273 ?

    Have a look at the trello board it's hanging in approved( 274 ) ;) So atm we sadly didn't had time to look at it. There is just so much stuff to do and so less time and devs.

Sign In or Register to comment.