Skip to content

Commit

Permalink
Added: More E2s controlling TA database
Browse files Browse the repository at this point in the history
  • Loading branch information
dvdvideo1234 committed Apr 26, 2018
1 parent c8fc83f commit ec4a967
Show file tree
Hide file tree
Showing 8 changed files with 287 additions and 31 deletions.
130 changes: 130 additions & 0 deletions data/expression2/TA_Active_point_scanner.txt
Original file line number Diff line number Diff line change
@@ -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)
{

}























9 changes: 4 additions & 5 deletions data/expression2/TA_Exporter_Generator.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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
Expand All @@ -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 )
Expand All @@ -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
Expand Down
8 changes: 8 additions & 0 deletions data/expression2/TA_ExtensionTest.txt
Original file line number Diff line number Diff line change
@@ -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")
5 changes: 3 additions & 2 deletions data/expression2/TA_Scan_Generator.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -217,3 +217,4 @@ else
{
if(ExpEn != 0){ Chip:setColor(255,0,0,255) }else{Chip:setColor(255,255,255,255) }
}

59 changes: 36 additions & 23 deletions data/expression2/TA_curve_rotator.txt
Original file line number Diff line number Diff line change
@@ -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()
}


102 changes: 102 additions & 0 deletions data/expression2/Test_Rail_Angler.txt
Original file line number Diff line number Diff line change
@@ -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))







3 changes: 3 additions & 0 deletions data/peaces_manager/peaces_manager.cbp
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@
<Add option="-Wall" />
<Add option="-fexceptions" />
</Compiler>
<Unit filename="common.h" />
<Unit filename="emd.bat" />
<Unit filename="main.cpp" />
<Unit filename="main.h" />
<Unit filename="models_ignored.txt" />
<Unit filename="string_stack.h" />
<Unit filename="struct_entry.h" />
<Unit filename="struct_match.h" />
<Extensions>
<code_completion />
Expand Down
2 changes: 1 addition & 1 deletion lua/autorun/trackassembly_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit ec4a967

Please sign in to comment.