mirror of
https://github.com/dvdvideo1234/TrackAssemblyTool.git
synced 2025-03-04 03:13:32 -05:00
Added: Projection location is utilized in case only one node is active point
Updated: Drawing HUD to include ray projection
This commit is contained in:
parent
ea73412e4d
commit
e6e6287886
@ -91,7 +91,7 @@ local asmlib = trackasmlib; if(not asmlib) then -- Module present
|
||||
------------ CONFIGURE ASMLIB ------------
|
||||
|
||||
asmlib.InitBase("track","assembly")
|
||||
asmlib.SetOpVar("TOOL_VERSION","8.684")
|
||||
asmlib.SetOpVar("TOOL_VERSION","8.685")
|
||||
asmlib.SetIndexes("V" ,1,2,3)
|
||||
asmlib.SetIndexes("A" ,1,2,3)
|
||||
asmlib.SetIndexes("WV",1,2,3)
|
||||
|
@ -4215,6 +4215,18 @@ function GetTraceEntityPoint(trEnt, ivPoID, nLen)
|
||||
return utilTraceLine(trDt), trDt
|
||||
end
|
||||
|
||||
--[[
|
||||
* Projects a point over a defined ray
|
||||
* vO > Ray origin location
|
||||
* vD > Ray direction vector
|
||||
* vP > Position vector to be projected
|
||||
]]--
|
||||
function ProjectRay(vO, vD, vP)
|
||||
local vR = Vector(vP); vR:Sub(vO)
|
||||
local nD = vD:Dot(vR); vR:Set(vD); vR:Mul(nD)
|
||||
return vR -- Return ray projection point
|
||||
end
|
||||
|
||||
--[[
|
||||
* This function calculates 3x3 determinant of the arguments below
|
||||
* Takes three row vectors as arguments:
|
||||
|
@ -781,20 +781,30 @@ function TOOL:SelectModel(sModel)
|
||||
asmlib.LogInstance("Success <"..sModel..">",gtLogs); return true
|
||||
end
|
||||
|
||||
function TOOL:GetNodeIntersect(iD, bM)
|
||||
function TOOL:GetCurveNodeActive(iD, bM)
|
||||
local ply = self:GetOwner()
|
||||
local tC = asmlib.GetCacheCurve(ply)
|
||||
if(iD <= 1) then -- Cannot chose first ID to intersect
|
||||
if(not bM) then asmlib.Notify(ply,"Node intersect uses first !","ERROR") end; return end
|
||||
if(not bM) then asmlib.Notify(ply,"Node point uses prev !","ERROR") end; return end
|
||||
if(iD >= tC.Size) then -- Cannot chose last ID to intersect
|
||||
if(not bM) then asmlib.Notify(ply,"Node intersect uses final !","ERROR") end; return end
|
||||
local tS = tC.Rays[iD - 1]; if(not tS[3]) then -- Read previous ray
|
||||
if(not bM) then asmlib.Notify(ply,"Node intersect wrong past !","ERROR") end; return end
|
||||
local tE = tC.Rays[iD + 1]; if(not tE[3]) then -- Read next ray
|
||||
if(not bM) then asmlib.Notify(ply,"Node intersect wrong next !","ERROR") end; return end
|
||||
local sD, eD = tS[2]:Forward(), tE[2]:Forward()
|
||||
local f1, f2, x1, x2, xx = asmlib.IntersectRayPair(tS[1], sD, tE[1], eD)
|
||||
return xx -- Both are active ponts and return ray intersection
|
||||
if(not bM) then asmlib.Notify(ply,"Node point uses next !","ERROR") end; return end
|
||||
local iS, iE = (iD - 1), (iD + 1) -- Previous and next node indeces
|
||||
local tS, tE = tC.Rays[iS], tC.Rays[iE] -- Previous and next node rays
|
||||
if(tS and tE) then
|
||||
local sD, eD = tS[2]:Forward(), tE[2]:Forward()
|
||||
local f1, f2, x1, x2, xx = asmlib.IntersectRayPair(tS[1], sD, tE[1], eD)
|
||||
return xx, true -- Both are active ponts and return ray intersection
|
||||
else
|
||||
if(tS) then -- Previous is an active point
|
||||
if(not bM) then asmlib.Notify(ply,"Node projection prev !","HINT") end
|
||||
return asmlib.ProjectRay(tS[1], tS[2]:Forward(), tC.Node[iD]), false
|
||||
elseif(tE) then -- Next is an active point
|
||||
if(not bM) then asmlib.Notify(ply,"Node projection next !","HINT") end
|
||||
return asmlib.ProjectRay(tE[1], tE[2]:Forward(), tC.Node[iD]), false
|
||||
else -- None of the previous and next nodes are active points
|
||||
if(not bM) then asmlib.Notify(ply,"Node intersect wrong ray !","ERROR") end; return end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function TOOL:CurveClear(bAll, bMute)
|
||||
@ -919,7 +929,7 @@ function TOOL:CurveUpdate(stTrace, bPnt, bMute)
|
||||
tC.Rays[mD][3] = (tData.POA ~= nil)
|
||||
-- Adjust node according to intersection
|
||||
if(bPnt and not tData.POA) then
|
||||
local xx = self:GetNodeIntersect(mD)
|
||||
local xx = self:GetCurveNodeActive(mD)
|
||||
if(xx) then
|
||||
tC.Node[mD]:Set(xx)
|
||||
tC.Norm[mD]:Set(tC.Norm[mD - 1])
|
||||
@ -1920,11 +1930,16 @@ function TOOL:DrawCurveNode(oScreen, oPly, stTrace)
|
||||
local xyN = tC.Node[mD]:ToScreen()
|
||||
oScreen:DrawLine(xyO, xyN, "r")
|
||||
if(bPnt and not tData.POA) then
|
||||
local xx = self:GetNodeIntersect(mD, true)
|
||||
local xx, sx = self:GetCurveNodeActive(mD, true)
|
||||
if(xx) then
|
||||
local xyX = xx:ToScreen()
|
||||
oScreen:DrawLine(xyX, xyH, "ry")
|
||||
oScreen:DrawCircle(xyX, asmlib.GetViewRadius(oPly, xx), "b")
|
||||
if(sx) then
|
||||
oScreen:DrawLine(xyX, xyH, "ry")
|
||||
oScreen:DrawCircle(xyX, asmlib.GetViewRadius(oPly, xx), "b")
|
||||
else
|
||||
oScreen:DrawLine(xyX, xyH, "ry")
|
||||
oScreen:DrawCircle(xyX, asmlib.GetViewRadius(oPly, xx), "g")
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user