From ec4a967141b7bee4e8d56a2fa7f6dca18b984f52 Mon Sep 17 00:00:00 2001 From: Deyan Dobromirov Date: Thu, 26 Apr 2018 21:39:22 +0300 Subject: [PATCH] Added: More E2s controlling TA database --- data/expression2/TA_Active_point_scanner.txt | 130 +++++++++++++++++++ data/expression2/TA_Exporter_Generator.txt | 9 +- data/expression2/TA_ExtensionTest.txt | 8 ++ data/expression2/TA_Scan_Generator.txt | 5 +- data/expression2/TA_curve_rotator.txt | 59 +++++---- data/expression2/Test_Rail_Angler.txt | 102 +++++++++++++++ data/peaces_manager/peaces_manager.cbp | 3 + lua/autorun/trackassembly_init.lua | 2 +- 8 files changed, 287 insertions(+), 31 deletions(-) create mode 100644 data/expression2/TA_Active_point_scanner.txt create mode 100644 data/expression2/TA_ExtensionTest.txt create mode 100644 data/expression2/Test_Rail_Angler.txt diff --git a/data/expression2/TA_Active_point_scanner.txt b/data/expression2/TA_Active_point_scanner.txt new file mode 100644 index 00000000..b4195239 --- /dev/null +++ b/data/expression2/TA_Active_point_scanner.txt @@ -0,0 +1,130 @@ +@name TA Active point scanner +@inputs +@outputs Piece:entity Position:vector +@persist Scanner:entity [F U C S Position]:vector +@persist Delta ScanDepth ScanSizeW ScanSizeH PntCount Stage +@trigger none +@model models/props_phx/construct/metal_wire1x1.mdl + +@outputs StepDistant DstU DstD S:vector +@outputs [SufU SufD]:vector + +if(first() || dupefinished()) +{ + # Scan size. Most rails are more wider than higher + # For PHX two bean rails W > H + ScanSizeW = 80 # Scans across left/right with sensors up/down + ScanSizeH = 40 # Scans across up/down with sensors left/right + + # Scanning depth + ScanDepth = 8 + + # How fast it will scan the piece edge + Delta = 0.1 + + # Local oriantation vectors + F = vec(0,0,1) + U = vec(1,0,0) + C = vec(0,0,0) + S = vec(0,0,0) + + # Automatic stuff + runOnTick(1) + Stage = 0 # Must start from zero ( initialization stage ) + PntCount = 0 # Howm many points are registered for avarage + StepDistant = 0 # The current distrance while scanning. Resets in every stage + Scanner = entity() + + holoCreate(1), holoColor(1,vec(255,0,0)), holoScale(1,0.1*vec(1,1,1)) holoModel(1,"cone") + holoCreate(2), holoColor(2,vec(0,0,255)), holoScale(2,0.1*vec(1,1,1)) holoModel(2,"cone") + holoCreate(3), holoColor(3,vec(0,0,255)), holoScale(3,0.1*vec(1,1,1)) holoModel(3,"cube") +} + + +An = Scanner:angles() +Fw = F:rotate(An) +Up = U:rotate(An) +Rg = Fw:cross(Up) +Cn = C:rotate(An) + Scanner:pos() + +if(Stage == 0) +{ + Stage++ + StepDistant = 0 +} +elseif(Stage == 1) +{ + Stage++ + StepDistant = (-ScanSizeW / 2) +} +elseif(Stage == 2) +{ + SyzeH2 = (ScanSizeH / 2) + + PosU = Cn + StepDistant * Rg + ScanDepth * Fw + SyzeH2 * Up + PosD = Cn + StepDistant * Rg + ScanDepth * Fw - SyzeH2 * Up + + holoPos(1,PosU) + holoAng(1,(-Up):toAngle(-Fw):rotateAroundAxis(Rg,90)) + holoPos(2,PosD) + holoAng(2, Up:toAngle(-Fw):rotateAroundAxis(Rg,-90)) + + DstU = rangerOffset(SyzeH2, PosU, -Up):distance() + DstD = rangerOffset(SyzeH2, PosD, Up):distance() + + if(DstU < SyzeH2) + { + SufU = (-DstU * Up) + PosU + S = S + (-DstU * Up) + PntCount++ + } + + if(DstD < SyzeH2) + { + SufD = (DstD * Up) + PosD + S = S + (DstD * Up) + PntCount++ + } + + + if(StepDistant > (ScanSizeW / 2)) + { + Position = -(S / PntCount) + Cn + holoPos(3,Position) + PntCount = 0 + S = vec(0,0,0) + StepDistant = (-ScanSizeH / 2) + Stage++ + } + else + { + StepDistant = StepDistant + Delta + } +} +elseif(Stage == 3) +{ + +} + + + + + + + + + + + + + + + + + + + + + + + diff --git a/data/expression2/TA_Exporter_Generator.txt b/data/expression2/TA_Exporter_Generator.txt index fe0c7885..c618cf67 100644 --- a/data/expression2/TA_Exporter_Generator.txt +++ b/data/expression2/TA_Exporter_Generator.txt @@ -89,8 +89,7 @@ function void printPoint(Type:string, Name:string, Mode:string, Hash:string, Poi "\""+StrPnt+"\""+Del+ "\""+StrOrg+"\""+Del+ "\""+StrAng+"\""+Del+ - "\""+StrCls+"\""+Del - "})" + "\""+StrCls+"\""+"})" } print(_HUD_PRINTTALK,Ins) @@ -104,7 +103,7 @@ if(first() || dupefinished()) # Piece type that you are using. It is mandatory # It is usually derived from the addon mame # that you are exporting - PieceType = "AlexCookie's 2ft Track Pack" + PieceType = "#" # Piece name that you are using. This is actually # how the track piece will be called in the TA panel @@ -116,7 +115,7 @@ if(first() || dupefinished()) # Set this to <>0 to use point generation via iterative binary search # Set this to positive to make the algorithm trace forward # Set this to negative to make the algorithm trace backwards - PointID = 1 + PointID = 0 # What segment type are we processing # road --> Roads ( PHX roads ) @@ -129,7 +128,7 @@ if(first() || dupefinished()) OverrideZ = 0 # What mode will the point be exportet as - InsertTypeDB = "DSV" + InsertTypeDB = "INS" # Automatically managed via the point ID # If positive uses direct point generation diff --git a/data/expression2/TA_ExtensionTest.txt b/data/expression2/TA_ExtensionTest.txt new file mode 100644 index 00000000..060839ee --- /dev/null +++ b/data/expression2/TA_ExtensionTest.txt @@ -0,0 +1,8 @@ +@name +@inputs UCS:wirelink +@outputs T:string +@persist +@trigger +@model models/props_phx/trains/tracks/track_1x.mdl + +T = entity():trackasmlibGenActivePointINS(UCS:entity(),"Test","Test",1,"AAA") diff --git a/data/expression2/TA_Scan_Generator.txt b/data/expression2/TA_Scan_Generator.txt index d226901f..d70a538f 100644 --- a/data/expression2/TA_Scan_Generator.txt +++ b/data/expression2/TA_Scan_Generator.txt @@ -109,9 +109,9 @@ if(first() || dupefinished()) # Track piece width and height # The bigger the numbers the more cross section your track piece has # The width of the rail. It has to wrap the rail on width - PieceW = 50 + PieceW = 120 # The height of the rail. It has to wrap the rail on height - PieceH = 20 + PieceH = 35 # This tells the algorithm how deep should it search for rail surface PieceD = 24 # This is an additional inset for the traces will use to hit the rail hull @@ -217,3 +217,4 @@ else { if(ExpEn != 0){ Chip:setColor(255,0,0,255) }else{Chip:setColor(255,255,255,255) } } + diff --git a/data/expression2/TA_curve_rotator.txt b/data/expression2/TA_curve_rotator.txt index 6bbd22be..6a08bd94 100644 --- a/data/expression2/TA_curve_rotator.txt +++ b/data/expression2/TA_curve_rotator.txt @@ -1,32 +1,45 @@ @name TA_curve_rotator -@inputs +@inputs @outputs -@persist [O V R]:vector2 SignAng Length Iter -@trigger +@persist [O V R]:vector SignAng Length Iter +@trigger runOnTick(1) if(first() || dupefinished()) { - # The length of the curve goes here - Length = 198.5 - - # The angle sign it will be rotated to - SignAng = -1 - - # Origin of the rotation - O = vec2(Length,0) - - # Initial vector to be rotated - V = vec2(-Length,0) - - # Do not touch - print("\n\n") - print("R 225: "+toString(V:rotate(SignAng * 22.5) + O)) - print("R 450: "+toString(V:rotate(SignAng * 45.0) + O)) - print("R 900: "+toString(V:rotate(SignAng * 90.0) + O)) - + ########## Globals part ! ########## + E = entity():isConstrainedTo("weld") + EA = E:angles() + EP = E:pos() + ########## Parameter section ########## + # Local rotation axis + X = vec(0,0,1) + # Rotation origin from the primary edge + # Usually where point ID 1 is located + O = vec(0, -2048, 0) + # Point location as local vector + P = vec(0,-46,6.625) + # How much amgle to apply + D = 45 + + + ########## Formula for the local arm vector roatated ########## + V = (P - O):rotate(EA) + + ########## Automatic part ! ########## + RO = O:rotate(EA) + RX = X:rotate(EA) + RP = P:rotate(EA) + PO = RO + E:pos() + print("Str: "+toString(V)+" <"+toString(E:toLocal(V+PO))+">") + + + RA = EA:rotateAroundAxis(RX,D) + V = V:rotate(RA) + print("End: "+toString(V)) + V = E:toLocal(V+PO) + print("Out: "+toString(V)) + selfDestruct() } - - diff --git a/data/expression2/Test_Rail_Angler.txt b/data/expression2/Test_Rail_Angler.txt new file mode 100644 index 00000000..b58c6cad --- /dev/null +++ b/data/expression2/Test_Rail_Angler.txt @@ -0,0 +1,102 @@ +@name Test Rail Angler +@inputs [Rail]:wirelink +@outputs Pitch PitchSign Roll RollSign Yaw [RailPos]:vector +@outputs Err:vector [AngSet RAngle UAngle]:angle +@outputs [BF BR BU TF TR TU]:vector +@outputs [BaF BaR BaU TrF TrR TrU AngEx]:angle +@persist [Base Track]:entity Ang:angle [Off Err]:vector +@trigger +@model models/props_phx/trains/monorail1.mdl + + +if(first() || dupefinished()) +{ + runOnTick(1) + Base = entity() + Track = Rail:entity() + #Ang = ang(0,180,0) + #Off = vec(0.080 , 605.6, -13.153) + Track:setMass(1000) + holoCreate(1,vec(1,1,1),0.3*vec(1,1,1)) + holoCreate(2,vec(1,1,1),0.2*vec(1,1,1)) + holoCreate(3,vec(1,1,1),0.2*vec(1,1,1)) + holoCreate(4,vec(1,1,1),0.2*vec(1,1,1)) +} +BF = Base:forward() +BU = Base:up() +BR = BF:cross(BU) + +AxisLen = 40 + +Dest = (250 * BF + 13.4405 * BU) + Base:pos() +holoPos(1,Dest) +Dest = Dest + (Off:x() * BF + Off:y() * BR + Off:z() * BU) +#Track:setPos(Dest) + +#Err = (Dest - Track:pos()) +#Track:applyForce(25000*Err + 38000*$Err) + +Vec = Base:pos() + 50*BU + AxisLen*BF +holoPos(2,Vec) +holoAng(2,BF:toAngle()) +holoColor(2,vec(255,0,0)) + +Vec = Base:pos() + 50*BU + AxisLen*BR +holoPos(3,Vec) +holoAng(3,BR:toAngle()) +holoColor(3,vec(0,255,0)) + +Vec = Base:pos() + 50*BU + AxisLen*BU +holoPos(4,Vec) +holoAng(4,BR:toAngle()) +holoColor(4,vec(0,0,255)) + + +#Track:setAng(ang(0,0,0)) +TF = vec(1,1,0):rotate(Track:angles()) +TU = vec(0,0,1):rotate(Track:angles()) +TR = TF:cross(TU) +#Base + + +BaF = BF:toAngle() +BaR = BR:toAngle() +BaU = BU:toAngle() + +TrF = TF:toAngle() +TrR = TR:toAngle() +TrU = TU:toAngle() + + +#Pitch +Pitch = -BaF:pitch() +#Yaw +Yaw = BaF:yaw() +# Roll +Roll = BaR:pitch() +UAngOff = ang(Pitch,Yaw,-Roll) +######################### + + + + +BaF:setYaw(-BaF:yaw()) + + + +AngSet = angnorm(ang(0,0,0)) + +# Track:setAng(AngSet) +TF = vec(1,1,0):rotate(Track:angles()) +TU = vec(0,0,1):rotate(Track:angles()) +TR = TF:cross(TU) + + +AngEx = vec(0,0,100):getAngleEx(vec(0,0,0)) + + + + + + + diff --git a/data/peaces_manager/peaces_manager.cbp b/data/peaces_manager/peaces_manager.cbp index e7b2dc30..63a68889 100644 --- a/data/peaces_manager/peaces_manager.cbp +++ b/data/peaces_manager/peaces_manager.cbp @@ -20,10 +20,13 @@ + + + diff --git a/lua/autorun/trackassembly_init.lua b/lua/autorun/trackassembly_init.lua index 63e88c74..bf7f5103 100644 --- a/lua/autorun/trackassembly_init.lua +++ b/lua/autorun/trackassembly_init.lua @@ -35,7 +35,7 @@ local asmlib = trackasmlib ------ CONFIGURE ASMLIB ------ asmlib.InitBase("track","assembly") -asmlib.SetOpVar("TOOL_VERSION","5.441") +asmlib.SetOpVar("TOOL_VERSION","5.442") asmlib.SetIndexes("V",1,2,3) asmlib.SetIndexes("A",1,2,3) asmlib.SetIndexes("S",4,5,6,7)