mirror of
https://github.com/Winded/StandingPoseTool.git
synced 2025-03-04 03:13:36 -05:00
Initial commit
This commit is contained in:
commit
fa6a626116
5
README.md
Normal file
5
README.md
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
Physgun Undo
|
||||||
|
============
|
||||||
|
|
||||||
|
A Garry's Mod tool to put ragdolls on their model idle pose, which most likely is a stand pose.
|
||||||
|
Pull requests are welcome.
|
6
info.txt
Normal file
6
info.txt
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
"AddonInfo"
|
||||||
|
{
|
||||||
|
"name" "Standing Pose Tool"
|
||||||
|
"author_name" "author"
|
||||||
|
"info" "This small tool can pose a ragdoll to it's model pose, which usually is a standing pose for ragdolls. It does not work properly with all ragdolls, but for most of them it does."
|
||||||
|
}
|
55
lua/autorun/standpose.lua
Normal file
55
lua/autorun/standpose.lua
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
|
||||||
|
local propt = {}
|
||||||
|
|
||||||
|
propt.MenuLabel = "Stand Pose"
|
||||||
|
propt.Order = 5000
|
||||||
|
|
||||||
|
propt.Filter = function( self, ent )
|
||||||
|
if ( !IsValid( ent ) ) then return false end
|
||||||
|
if ( ent:GetClass() != "prop_ragdoll" ) then return false end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
propt.Action = function( self, ent )
|
||||||
|
self:MsgStart()
|
||||||
|
net.WriteEntity( ent )
|
||||||
|
self:MsgEnd()
|
||||||
|
end
|
||||||
|
|
||||||
|
propt.Receive = function( self, length, player )
|
||||||
|
|
||||||
|
local rag = net.ReadEntity()
|
||||||
|
|
||||||
|
if ( !IsValid( rag ) ) then return end
|
||||||
|
if ( !IsValid( player ) ) then return end
|
||||||
|
if ( rag:GetClass() != "prop_ragdoll" ) then return end
|
||||||
|
|
||||||
|
local tr = util.TraceLine({start = rag:GetPos(),endpos = rag:GetPos() - Vector(0,0,3000),filter = rag})
|
||||||
|
|
||||||
|
local ent = ents.Create("prop_dynamic")
|
||||||
|
ent:SetModel(rag:GetModel())
|
||||||
|
ent:SetPos(tr.HitPos)
|
||||||
|
local angle = (tr.HitPos - player:GetPos()):Angle()
|
||||||
|
ent:SetAngles(Angle(0,angle.y-180,0))
|
||||||
|
ent:Spawn()
|
||||||
|
for i=0,rag:GetPhysicsObjectCount()-1 do
|
||||||
|
local phys = rag:GetPhysicsObjectNum(i)
|
||||||
|
local b = rag:TranslatePhysBoneToBone(i)
|
||||||
|
local pos,ang = ent:GetBonePosition(b)
|
||||||
|
phys:EnableMotion(true)
|
||||||
|
phys:Wake()
|
||||||
|
phys:SetPos(pos)
|
||||||
|
phys:SetAngles(ang)
|
||||||
|
if string.sub(rag:GetBoneName(b),1,4) == "prp_" then
|
||||||
|
phys:EnableMotion(true)
|
||||||
|
phys:Wake()
|
||||||
|
else
|
||||||
|
phys:EnableMotion(false)
|
||||||
|
phys:Wake()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
ent:Remove()
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
properties.Add("standpose",propt)
|
73
lua/weapons/gmod_tool/stools/ragdollstand.lua
Normal file
73
lua/weapons/gmod_tool/stools/ragdollstand.lua
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
|
||||||
|
TOOL.Category = "Poser"
|
||||||
|
TOOL.Name = "Stand Pose"
|
||||||
|
TOOL.Command = nil
|
||||||
|
TOOL.ConfigName = nil
|
||||||
|
|
||||||
|
function TOOL:LeftClick(tr)
|
||||||
|
if self:GetStage() == 0 then
|
||||||
|
|
||||||
|
if !IsValid(tr.Entity) then return false end
|
||||||
|
if tr.Entity:GetClass() != "prop_ragdoll" then return false end
|
||||||
|
|
||||||
|
if CLIENT then return true end
|
||||||
|
|
||||||
|
self.SelectedEnt = tr.Entity
|
||||||
|
self:SetStage(1)
|
||||||
|
return true
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
local rag = self.SelectedEnt
|
||||||
|
if !IsValid(rag) then
|
||||||
|
self:SetStage(0)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
if CLIENT then return true end
|
||||||
|
|
||||||
|
local ent = ents.Create("prop_dynamic")
|
||||||
|
ent:SetModel(rag:GetModel())
|
||||||
|
ent:SetPos(tr.HitPos)
|
||||||
|
local angle = (tr.HitPos - self:GetOwner():GetPos()):Angle()
|
||||||
|
ent:SetAngles(Angle(0,angle.y-180,0))
|
||||||
|
ent:Spawn()
|
||||||
|
for i=0,rag:GetPhysicsObjectCount()-1 do
|
||||||
|
local phys = rag:GetPhysicsObjectNum(i)
|
||||||
|
local b = rag:TranslatePhysBoneToBone(i)
|
||||||
|
local pos,ang = ent:GetBonePosition(b)
|
||||||
|
phys:EnableMotion(true)
|
||||||
|
phys:Wake()
|
||||||
|
phys:SetPos(pos)
|
||||||
|
phys:SetAngles(ang)
|
||||||
|
if string.sub(rag:GetBoneName(b),1,4) == "prp_" then
|
||||||
|
phys:EnableMotion(true)
|
||||||
|
phys:Wake()
|
||||||
|
else
|
||||||
|
phys:EnableMotion(false)
|
||||||
|
phys:Wake()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
ent:Remove()
|
||||||
|
self:SetStage(0)
|
||||||
|
return true
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function TOOL:RightClick(tr)
|
||||||
|
if self:GetStage() == 1 then
|
||||||
|
self:SetStage(0)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
if CLIENT then
|
||||||
|
|
||||||
|
language.Add("tool.ragdollstand.name","Stand Pose")
|
||||||
|
language.Add("tool.ragdollstand.desc","Position ragdolls in a standing pose.")
|
||||||
|
language.Add("tool.ragdollstand.0","Left Click to select a ragdoll.")
|
||||||
|
language.Add("tool.ragdollstand.1","Now click on a position where you want the ragdoll to stand or Right Click to cancel.")
|
||||||
|
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user