Bone translation, scaling, and rotation in Lua
Hello,
I would greatly appreciate it if a Spark engine developer added the following method:
CoordsArray:Set(boneNum, coords)
Example usage:
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:
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.
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.
Comments
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:
To add:
Along with the C++ definition for:
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..
I look forward to playing with it
Thanks for bringing this back up!
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
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.