Permalink
Browse files

Update Finger Poser

Added support for Portal 1 Chell, DOG and Vort finger poser, fixed the
"Left Hand" text to reflect the hand and made it white.

Points for non-existent bones now disappear.
  • Loading branch information...
1 parent 20a6ea1 commit be866d2b198eef69b349b47a3247899d36fa8165 @robotboy655 robotboy655 committed Aug 19, 2014
@@ -87,6 +87,104 @@ TranslateTable_Zeno[ "ValveBiped.Bip01_R_Finger4" ] = "Bip01_R_Finger4"
TranslateTable_Zeno[ "ValveBiped.Bip01_R_Finger41" ] = "Bip01_R_Finger41"
TranslateTable_Zeno[ "ValveBiped.Bip01_R_Finger42" ] = "Bip01_R_Finger42"
+local TranslateTable_INS = {}
+TranslateTable_INS[ "ValveBiped.Bip01_L_Finger0" ] = "L Finger0"
+TranslateTable_INS[ "ValveBiped.Bip01_L_Finger01" ] = "L Finger01"
+TranslateTable_INS[ "ValveBiped.Bip01_L_Finger02" ] = "L Finger02"
+TranslateTable_INS[ "ValveBiped.Bip01_L_Finger1" ] = "L Finger1"
+TranslateTable_INS[ "ValveBiped.Bip01_L_Finger11" ] = "L Finger11"
+TranslateTable_INS[ "ValveBiped.Bip01_L_Finger12" ] = "L Finger12"
+TranslateTable_INS[ "ValveBiped.Bip01_L_Finger2" ] = "L Finger2"
+TranslateTable_INS[ "ValveBiped.Bip01_L_Finger21" ] = "L Finger21"
+TranslateTable_INS[ "ValveBiped.Bip01_L_Finger22" ] = "L Finger22"
+TranslateTable_INS[ "ValveBiped.Bip01_L_Finger3" ] = "L Finger3"
+TranslateTable_INS[ "ValveBiped.Bip01_L_Finger31" ] = "L Finger31"
+TranslateTable_INS[ "ValveBiped.Bip01_L_Finger32" ] = "L Finger32"
+TranslateTable_INS[ "ValveBiped.Bip01_L_Finger4" ] = "L Finger4"
+TranslateTable_INS[ "ValveBiped.Bip01_L_Finger41" ] = "L Finger41"
+TranslateTable_INS[ "ValveBiped.Bip01_L_Finger42" ] = "L Finger42"
+TranslateTable_INS[ "ValveBiped.Bip01_R_Finger0" ] = "R Finger0"
+TranslateTable_INS[ "ValveBiped.Bip01_R_Finger01" ] = "R Finger01"
+TranslateTable_INS[ "ValveBiped.Bip01_R_Finger02" ] = "R Finger02"
+TranslateTable_INS[ "ValveBiped.Bip01_R_Finger1" ] = "R Finger1"
+TranslateTable_INS[ "ValveBiped.Bip01_R_Finger11" ] = "R Finger11"
+TranslateTable_INS[ "ValveBiped.Bip01_R_Finger12" ] = "R Finger12"
+TranslateTable_INS[ "ValveBiped.Bip01_R_Finger2" ] = "R Finger2"
+TranslateTable_INS[ "ValveBiped.Bip01_R_Finger21" ] = "R Finger21"
+TranslateTable_INS[ "ValveBiped.Bip01_R_Finger22" ] = "R Finger22"
+TranslateTable_INS[ "ValveBiped.Bip01_R_Finger3" ] = "R Finger3"
+TranslateTable_INS[ "ValveBiped.Bip01_R_Finger31" ] = "R Finger31"
+TranslateTable_INS[ "ValveBiped.Bip01_R_Finger32" ] = "R Finger32"
+TranslateTable_INS[ "ValveBiped.Bip01_R_Finger4" ] = "R Finger4"
+TranslateTable_INS[ "ValveBiped.Bip01_R_Finger41" ] = "R Finger41"
+TranslateTable_INS[ "ValveBiped.Bip01_R_Finger42" ] = "R Finger42"
+
+local TranslateTable_Chell = {}
+TranslateTable_Chell[ "ValveBiped.Bip01_L_Finger0" ] = "thumb_base_L"
+TranslateTable_Chell[ "ValveBiped.Bip01_L_Finger01" ] = "thumb_mid_L"
+TranslateTable_Chell[ "ValveBiped.Bip01_L_Finger02" ] = "thumb_end_L"
+TranslateTable_Chell[ "ValveBiped.Bip01_L_Finger1" ] = "index_base_L"
+TranslateTable_Chell[ "ValveBiped.Bip01_L_Finger11" ] = "index_mid_L"
+TranslateTable_Chell[ "ValveBiped.Bip01_L_Finger12" ] = "index_end_L"
+TranslateTable_Chell[ "ValveBiped.Bip01_L_Finger2" ] = "mid_base_L"
+TranslateTable_Chell[ "ValveBiped.Bip01_L_Finger21" ] = "mid_mid_L"
+TranslateTable_Chell[ "ValveBiped.Bip01_L_Finger22" ] = "mid_end_L"
+TranslateTable_Chell[ "ValveBiped.Bip01_L_Finger3" ] = "ring_base_L"
+TranslateTable_Chell[ "ValveBiped.Bip01_L_Finger31" ] = "ring_mid_L"
+TranslateTable_Chell[ "ValveBiped.Bip01_L_Finger32" ] = "ring_end_L"
+TranslateTable_Chell[ "ValveBiped.Bip01_L_Finger4" ] = "pinky_base_L"
+TranslateTable_Chell[ "ValveBiped.Bip01_L_Finger41" ] = "pinky_mid_L"
+TranslateTable_Chell[ "ValveBiped.Bip01_L_Finger42" ] = "pinky_end_L"
+TranslateTable_Chell[ "ValveBiped.Bip01_R_Finger0" ] = "thumb_base_R"
+TranslateTable_Chell[ "ValveBiped.Bip01_R_Finger01" ] = "thumb_mid_R"
+TranslateTable_Chell[ "ValveBiped.Bip01_R_Finger02" ] = "thumb_end_R"
+TranslateTable_Chell[ "ValveBiped.Bip01_R_Finger1" ] = "index_base_R"
+TranslateTable_Chell[ "ValveBiped.Bip01_R_Finger11" ] = "index_mid_R"
+TranslateTable_Chell[ "ValveBiped.Bip01_R_Finger12" ] = "index_end_R"
+TranslateTable_Chell[ "ValveBiped.Bip01_R_Finger2" ] = "mid_base_R"
+TranslateTable_Chell[ "ValveBiped.Bip01_R_Finger21" ] = "mid_mid_R"
+TranslateTable_Chell[ "ValveBiped.Bip01_R_Finger22" ] = "mid_end_R"
+TranslateTable_Chell[ "ValveBiped.Bip01_R_Finger3" ] = "ring_base_R"
+TranslateTable_Chell[ "ValveBiped.Bip01_R_Finger31" ] = "ring_mid_R"
+TranslateTable_Chell[ "ValveBiped.Bip01_R_Finger32" ] = "ring_end_R"
+TranslateTable_Chell[ "ValveBiped.Bip01_R_Finger4" ] = "pinky_base_R"
+TranslateTable_Chell[ "ValveBiped.Bip01_R_Finger41" ] = "pinky_mid_R"
+TranslateTable_Chell[ "ValveBiped.Bip01_R_Finger42" ] = "pinky_end_R"
+
+local TranslateTable_DOG = {}
+TranslateTable_DOG[ "ValveBiped.Bip01_L_Finger0" ] = "Dog_Model.Thumb1_L"
+TranslateTable_DOG[ "ValveBiped.Bip01_L_Finger01" ] = "Dog_Model.Thumb2_L"
+//TranslateTable_DOG[ "ValveBiped.Bip01_L_Finger02" ] = "Dog_Model.Thumb3_L"
+TranslateTable_DOG[ "ValveBiped.Bip01_L_Finger1" ] = "Dog_Model.Index1_L"
+TranslateTable_DOG[ "ValveBiped.Bip01_L_Finger11" ] = "Dog_Model.Index2_L"
+TranslateTable_DOG[ "ValveBiped.Bip01_L_Finger12" ] = "Dog_Model.Index3_L"
+TranslateTable_DOG[ "ValveBiped.Bip01_L_Finger4" ] = "Dog_Model.Pinky1_L"
+TranslateTable_DOG[ "ValveBiped.Bip01_L_Finger41" ] = "Dog_Model.Pinky2_L"
+TranslateTable_DOG[ "ValveBiped.Bip01_L_Finger42" ] = "Dog_Model.Pinky3_L"
+TranslateTable_DOG[ "ValveBiped.Bip01_R_Finger0" ] = "Dog_Model.Thumb1_R"
+TranslateTable_DOG[ "ValveBiped.Bip01_R_Finger01" ] = "Dog_Model.Thumb2_R"
+TranslateTable_DOG[ "ValveBiped.Bip01_R_Finger02" ] = "Dog_Model.Thumb3_R"
+TranslateTable_DOG[ "ValveBiped.Bip01_R_Finger1" ] = "Dog_Model.Index1_R"
+TranslateTable_DOG[ "ValveBiped.Bip01_R_Finger11" ] = "Dog_Model.Index2_R"
+TranslateTable_DOG[ "ValveBiped.Bip01_R_Finger12" ] = "Dog_Model.Index3_R"
+TranslateTable_DOG[ "ValveBiped.Bip01_R_Finger4" ] = "Dog_Model.Pinky1_R"
+TranslateTable_DOG[ "ValveBiped.Bip01_R_Finger41" ] = "Dog_Model.Pinky2_R"
+TranslateTable_DOG[ "ValveBiped.Bip01_R_Finger42" ] = "Dog_Model.Pinky3_R"
+
+local TranslateTable_VORT = {}
+TranslateTable_VORT[ "ValveBiped.Bip01_L_Finger1" ] = "ValveBiped.index1_L"
+TranslateTable_VORT[ "ValveBiped.Bip01_L_Finger11" ] = "ValveBiped.index2_L"
+TranslateTable_VORT[ "ValveBiped.Bip01_L_Finger12" ] = "ValveBiped.index3_L"
+TranslateTable_VORT[ "ValveBiped.Bip01_L_Finger4" ] = "ValveBiped.pinky1_L"
+TranslateTable_VORT[ "ValveBiped.Bip01_L_Finger41" ] = "ValveBiped.pinky2_L"
+TranslateTable_VORT[ "ValveBiped.Bip01_L_Finger42" ] = "ValveBiped.pinky3_L"
+TranslateTable_VORT[ "ValveBiped.Bip01_R_Finger1" ] = "ValveBiped.index1_R"
+TranslateTable_VORT[ "ValveBiped.Bip01_R_Finger11" ] = "ValveBiped.index2_R"
+TranslateTable_VORT[ "ValveBiped.Bip01_R_Finger12" ] = "ValveBiped.index3_R"
+TranslateTable_VORT[ "ValveBiped.Bip01_R_Finger4" ] = "ValveBiped.pinky1_R"
+TranslateTable_VORT[ "ValveBiped.Bip01_R_Finger41" ] = "ValveBiped.pinky2_R"
+TranslateTable_VORT[ "ValveBiped.Bip01_R_Finger42" ] = "ValveBiped.pinky3_R"
+
--[[---------------------------------------------------------
Name: HandEntity
-----------------------------------------------------------]]
@@ -140,6 +238,38 @@ local function GetFingerBone( self, fingernum, part, hand )
end
---- END Zeno BONE LOOKUP ----------------------------------
+ ---- START DOG BONE LOOKUP ----------------------------------
+ local TranslatedName = TranslateTable_DOG[ Name ]
+ if ( TranslatedName ) then
+ local bone = self:LookupBone( TranslatedName )
+ if ( bone ) then return bone end
+ end
+ ---- END DOG BONE LOOKUP ----------------------------------
+
+ ---- START VORT BONE LOOKUP ----------------------------------
+ local TranslatedName = TranslateTable_VORT[ Name ]
+ if ( TranslatedName ) then
+ local bone = self:LookupBone( TranslatedName )
+ if ( bone ) then return bone end
+ end
+ ---- END VORT BONE LOOKUP ----------------------------------
+
+ ---- START Chell BONE LOOKUP ----------------------------------
+ local TranslatedName = TranslateTable_Chell[ Name ]
+ if ( TranslatedName ) then
+ local bone = self:LookupBone( TranslatedName )
+ if ( bone ) then return bone end
+ end
+ ---- END Chell BONE LOOKUP ----------------------------------
+
+ ---- START Ins BONE LOOKUP ----------------------------------
+ local TranslatedName = TranslateTable_INS[ Name ]
+ if ( TranslatedName ) then
+ local bone = self:LookupBone( TranslatedName )
+ if ( bone ) then return bone end
+ end
+ ---- END Insurgency BONE LOOKUP ----------------------------------
+
end
--[[------------------------------------------------------------
@@ -189,7 +319,7 @@ function TOOL:ApplyValues( pEntity, iHand )
local Ang = nil
if ( bTF2 ) then
-
+
if ( i < 3 ) then
Ang = Angle( 0, tonumber( VecComp[2] ), tonumber( VecComp[1] ) )
else
@@ -222,10 +352,19 @@ function TOOL:GetHandPositions( pEntity )
local LeftHand = pEntity:LookupBone( "ValveBiped.Bip01_L_Hand" )
if ( !LeftHand ) then LeftHand = pEntity:LookupBone( "bip_hand_L" ) end
if ( !LeftHand ) then LeftHand = pEntity:LookupBone( "Bip01_L_Hand" ) end
+ if ( !LeftHand ) then LeftHand = pEntity:LookupBone( "Dog_Model.Hand_L" ) end -- DOG
+ if ( !LeftHand ) then LeftHand = pEntity:LookupBone( "ValveBiped.Hand1_L" ) end -- Vortigaunt
+ if ( !LeftHand ) then LeftHand = pEntity:LookupBone( "wrist_L" ) end -- Chell
+ if ( !LeftHand ) then LeftHand = pEntity:LookupBone( "L Hand" ) end -- Insurgency
local RightHand = pEntity:LookupBone( "ValveBiped.Bip01_R_Hand" )
if ( !RightHand ) then RightHand = pEntity:LookupBone( "bip_hand_R" ) end
if ( !RightHand ) then RightHand = pEntity:LookupBone( "Bip01_R_Hand" ) end
+ if ( !RightHand ) then RightHand = pEntity:LookupBone( "Bip01_R_Hand" ) end
+ if ( !RightHand ) then RightHand = pEntity:LookupBone( "Dog_Model.Hand_R" ) end
+ if ( !RightHand ) then RightHand = pEntity:LookupBone( "ValveBiped.Hand1_R" ) end
+ if ( !RightHand ) then RightHand = pEntity:LookupBone( "wrist_R" ) end
+ if ( !RightHand ) then RightHand = pEntity:LookupBone( "R Hand" ) end
if ( !LeftHand || !RightHand ) then return false end
@@ -234,7 +373,7 @@ function TOOL:GetHandPositions( pEntity )
if ( !LeftHand || !RightHand ) then return false end
return LeftHand, RightHand
-
+
end
--[[------------------------------------------------------------
@@ -247,7 +386,7 @@ function TOOL:LeftClick( trace )
if ( trace.Entity:GetClass() != "prop_ragdoll" && !trace.Entity:IsNPC() ) then return false end
local LeftHand, RightHand = self:GetHandPositions( trace.Entity )
-
+
if ( !LeftHand ) then return false end
if ( CLIENT ) then return true end
@@ -334,7 +473,7 @@ function TOOL:RightClick( trace )
end
end
-
+
-- We don't want to send the finger poses to the client straight away
-- because they will get the old poses that are currently in their convars
-- We need to wait until they convars get updated with the sucked pose
@@ -399,13 +538,13 @@ function TOOL:RebuildControlPanel( hand )
if ( !CPanel ) then return end
CPanel:ClearControls()
- self.BuildCPanel( CPanel, self:HandEntity() )
+ self.BuildCPanel( CPanel, self:HandEntity(), self:HandNum() )
end
local ConVarsDefault = TOOL:BuildConVarList()
-function TOOL.BuildCPanel( CPanel, ent )
+function TOOL.BuildCPanel( CPanel, ent, hand )
CPanel:AddControl( "Header", { Description = "#tool.finger.desc" } )
@@ -416,17 +555,17 @@ function TOOL.BuildCPanel( CPanel, ent )
SetupFingers( ent )
if ( !ent.FingerIndex ) then return end
-
+
-- Detect mitten hands
local NumVars = table.Count( ent.FingerIndex )
-
+
CPanel:AddControl( "fingerposer", { hand = hand, numvars = NumVars } )
CPanel:AddControl( "Checkbox", { Label = "#tool.finger.restrict_axis", Command = "finger_restrict" } )
end
-local FacePoser = surface.GetTextureID( "gui/faceposer_indicator" )
+local FacePoser = surface.GetTextureID( "gui/faceposer_indicator" )
--[[------------------------------------------------------------
Name: DrawHUD
@@ -7,26 +7,26 @@ local ow = 310
local oh = 270
local FingerPositions = {
- { 56 / ow, 230 / oh },
- { 51 / ow, 180 / oh },
- { 59 / ow, 130 / oh },
-
- { 121 / ow, 114 / oh },
- { 132 / ow, 75 / oh },
- { 160 / ow, 34 / oh },
-
- { 165 / ow, 126 / oh },
- { 178 / ow, 92 / oh },
- { 197 / ow, 60 / oh},
-
- { 194 / ow, 156 / oh },
- { 208 / ow, 124 / oh },
- { 228 / ow, 92 / oh},
-
- { 229 / ow, 175 / oh},
- { 244 / ow, 146 / oh},
- { 259 / ow, 115 / oh},
- }
+ { 56 / ow, 230 / oh },
+ { 51 / ow, 180 / oh },
+ { 59 / ow, 130 / oh },
+
+ { 121 / ow, 114 / oh },
+ { 132 / ow, 75 / oh },
+ { 160 / ow, 34 / oh },
+
+ { 165 / ow, 126 / oh },
+ { 178 / ow, 92 / oh },
+ { 197 / ow, 60 / oh },
+
+ { 194 / ow, 156 / oh },
+ { 208 / ow, 124 / oh },
+ { 228 / ow, 92 / oh },
+
+ { 229 / ow, 175 / oh},
+ { 244 / ow, 146 / oh},
+ { 259 / ow, 115 / oh},
+}
--[[---------------------------------------------------------
Name: Init
@@ -36,15 +36,17 @@ function PANEL:Init()
self.Hand = 0
self.FingerVars = {}
+ self.Label:SetBright( true )
+
for i=0, 14 do
if ( self.NumVars == 18 && i > 10 ) then break end
self.FingerVars[ i ] = vgui.Create( "FingerVar", self )
- self.FingerVars[ i ]:SetVarName( "finger_"..i )
+ self.FingerVars[ i ]:SetVarName( "finger_" .. i )
- if ( i > 2 && i%3 != 0 ) then
+ if ( i > 2 && i % 3 != 0 ) then
self.FingerVars[ i ]:SetRestrictX( true )
@@ -54,7 +56,6 @@ function PANEL:Init()
end
-
--[[---------------------------------------------------------
Name: ControlValues
Desc: The keyvalues passed from the control defs
@@ -70,19 +71,7 @@ function PANEL:ControlValues( kv )
end
self.NumVars = kv.numvars
-
- -- Mitten Hand, remove the last 6 vars
- if ( self.NumVars == "18" ) then
-
- for i=9, 14 do
-
- self.FingerVars[ i ]:Remove()
- self.FingerVars[ i ] = nil
-
- end
-
- end
-
+
self:InvalidateLayout( true )
end
@@ -103,7 +92,7 @@ function PANEL:PerformLayout()
for var = 0, 2 do
- local ID = ((finger*3) + var)
+ local ID = ( ( finger * 3 ) + var )
local Pos = FingerPositions[ ID + 1 ]
if ( Pos && self.FingerVars[ ID ] ) then
@@ -118,19 +107,15 @@ function PANEL:PerformLayout()
end
-
-
--[[---------------------------------------------------------
Name: Paint
-----------------------------------------------------------]]
-function PANEL:Paint()
-
- local w, h = self:GetSize()
+function PANEL:Paint( w, h )
surface.SetTexture( MatBackground )
surface.SetDrawColor( 255, 255, 255, 255 )
surface.DrawTexturedRect( 0, 0, w, h )
-
+
return true
end
@@ -159,7 +144,7 @@ function PANEL:UpdateHovered()
local AddX = val[1] * v:GetWide()
local AddY = val[2] * v:GetTall()
- local dist = math.Distance( x, y, v.x + v:GetWide()/2 + AddX, v.y + v:GetTall()/2 + AddY )
+ local dist = math.Distance( x, y, v.x + v:GetWide() / 2 + AddX, v.y + v:GetTall() / 2 + AddY )
if ( dist < distance ) then
hovered = v
distance = dist
@@ -196,4 +181,4 @@ function PANEL:OnMousePressed( mousecode )
end
-vgui.Register( "fingerposer", PANEL, "ContextBase" )
+vgui.Register( "fingerposer", PANEL, "ContextBase" )
Oops, something went wrong.

0 comments on commit be866d2

Please sign in to comment.