mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
commit
caaee4f551
@ -2456,15 +2456,18 @@ do -- COORDINATE
|
||||
-- Write command as string and execute that. Idea by Grimes https://forum.dcs.world/topic/324201-mark-to-all-function/#comment-5273793
|
||||
local s=string.format("trigger.action.markupToAll(7, %d, %d,", Coalition, MarkID)
|
||||
for _,vec in pairs(vecs) do
|
||||
s=s..string.format("%s,", UTILS._OneLineSerialize(vec))
|
||||
--s=s..string.format("%s,", UTILS._OneLineSerialize(vec))
|
||||
s=s..string.format("{x=%.1f, y=%.1f, z=%.1f},", vec.x, vec.y, vec.z)
|
||||
end
|
||||
s=s..string.format("%s, %s, %s, %s", UTILS._OneLineSerialize(Color), UTILS._OneLineSerialize(FillColor), tostring(LineType), tostring(ReadOnly))
|
||||
if Text and Text~="" then
|
||||
s=s..string.format(", \"%s\"", Text)
|
||||
s=s..string.format("{%.3f, %.3f, %.3f, %.3f},", Color[1], Color[2], Color[3], Color[4])
|
||||
s=s..string.format("{%.3f, %.3f, %.3f, %.3f},", FillColor[1], FillColor[2], FillColor[3], FillColor[4])
|
||||
s=s..string.format("%d,", LineType or 1)
|
||||
s=s..string.format("%s", tostring(ReadOnly))
|
||||
if Text and type(Text)=="string" and string.len(Text)>0 then
|
||||
s=s..string.format(", \"%s\"", tostring(Text))
|
||||
end
|
||||
s=s..")"
|
||||
|
||||
|
||||
-- Execute string command
|
||||
local success=UTILS.DoString(s)
|
||||
|
||||
|
||||
@ -2114,7 +2114,7 @@ end
|
||||
function _ZONE_TRIANGLE:Fill(Coalition, FillColor, FillAlpha, ReadOnly)
|
||||
Coalition=Coalition or -1
|
||||
FillColor = FillColor
|
||||
FillAlpha = FillAlpha
|
||||
FillAlpha = FillAlpha
|
||||
local newID = self.Coords[1]:MarkupToAllFreeForm({self.Coords[2],self.Coords[3]},Coalition,nil,nil,FillColor,FillAlpha,0,nil)
|
||||
self.DrawID[#self.DrawID+1] = newID
|
||||
return self.DrawID
|
||||
@ -2194,7 +2194,7 @@ function ZONE_POLYGON_BASE:New( ZoneName, PointsArray )
|
||||
self._Triangles = self:_Triangulate()
|
||||
-- set the polygon's surface area
|
||||
self.SurfaceArea = self:_CalculateSurfaceArea()
|
||||
|
||||
|
||||
end
|
||||
|
||||
return self
|
||||
@ -2495,6 +2495,7 @@ end
|
||||
-- @param #boolean ReadOnly (Optional) Mark is readonly and cannot be removed by users. Default false.s
|
||||
-- @return #ZONE_POLYGON_BASE self
|
||||
function ZONE_POLYGON_BASE:DrawZone(Coalition, Color, Alpha, FillColor, FillAlpha, LineType, ReadOnly, IncludeTriangles)
|
||||
|
||||
|
||||
if self._.Polygon and #self._.Polygon >= 3 then
|
||||
Coalition = Coalition or self:GetDrawCoalition()
|
||||
@ -2516,7 +2517,22 @@ function ZONE_POLYGON_BASE:DrawZone(Coalition, Color, Alpha, FillColor, FillAlph
|
||||
self:ReDrawBorderline(Color,Alpha,LineType)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
if false then
|
||||
local coords = self:GetVerticiesCoordinates()
|
||||
|
||||
local coord=coords[1] --Core.Point#COORDINATE
|
||||
|
||||
table.remove(coords, 1)
|
||||
|
||||
coord:MarkupToAllFreeForm(coords, Coalition, Color, Alpha, FillColor, FillAlpha, LineType, ReadOnly, "Drew Polygon")
|
||||
|
||||
if true then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
@ -3117,18 +3133,18 @@ function ZONE_POLYGON:Scan( ObjectCategories, UnitCategories )
|
||||
self.ScanData.Scenery = {}
|
||||
self.ScanData.SceneryTable = {}
|
||||
self.ScanData.Units = {}
|
||||
|
||||
|
||||
local vectors = self:GetBoundingSquare()
|
||||
|
||||
|
||||
local minVec3 = {x=vectors.x1, y=0, z=vectors.y1}
|
||||
local maxVec3 = {x=vectors.x2, y=0, z=vectors.y2}
|
||||
|
||||
|
||||
local minmarkcoord = COORDINATE:NewFromVec3(minVec3)
|
||||
local maxmarkcoord = COORDINATE:NewFromVec3(maxVec3)
|
||||
local ZoneRadius = minmarkcoord:Get2DDistance(maxmarkcoord)/2
|
||||
-- self:I("Scan Radius:" ..ZoneRadius)
|
||||
local CenterVec3 = self:GetCoordinate():GetVec3()
|
||||
|
||||
|
||||
--[[ this a bit shaky in functionality it seems
|
||||
local VolumeBox = {
|
||||
id = world.VolumeType.BOX,
|
||||
@ -3138,7 +3154,7 @@ function ZONE_POLYGON:Scan( ObjectCategories, UnitCategories )
|
||||
}
|
||||
}
|
||||
--]]
|
||||
|
||||
|
||||
local SphereSearch = {
|
||||
id = world.VolumeType.SPHERE,
|
||||
params = {
|
||||
@ -3146,13 +3162,13 @@ function ZONE_POLYGON:Scan( ObjectCategories, UnitCategories )
|
||||
radius = ZoneRadius,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
local function EvaluateZone( ZoneObject )
|
||||
|
||||
if ZoneObject then
|
||||
|
||||
local ObjectCategory = Object.getCategory(ZoneObject)
|
||||
|
||||
|
||||
if ( ObjectCategory == Object.Category.UNIT and ZoneObject:isExist() and ZoneObject:isActive() ) or (ObjectCategory == Object.Category.STATIC and ZoneObject:isExist()) then
|
||||
|
||||
local CoalitionDCSUnit = ZoneObject:getCoalition()
|
||||
@ -3186,7 +3202,7 @@ function ZONE_POLYGON:Scan( ObjectCategories, UnitCategories )
|
||||
self:F2( { Name = ZoneObject:getName(), Coalition = CoalitionDCSUnit } )
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- trying with box search
|
||||
if ObjectCategory == Object.Category.SCENERY and self:IsVec3InZone(ZoneObject:getPoint()) then
|
||||
local SceneryType = ZoneObject:getTypeName()
|
||||
@ -3205,7 +3221,7 @@ function ZONE_POLYGON:Scan( ObjectCategories, UnitCategories )
|
||||
-- Search objects.
|
||||
local inzoneunits = SET_UNIT:New():FilterZones({self}):FilterOnce()
|
||||
local inzonestatics = SET_STATIC:New():FilterZones({self}):FilterOnce()
|
||||
|
||||
|
||||
inzoneunits:ForEach(
|
||||
function(unit)
|
||||
local Unit = unit --Wrapper.Unit#UNIT
|
||||
@ -3213,7 +3229,7 @@ function ZONE_POLYGON:Scan( ObjectCategories, UnitCategories )
|
||||
EvaluateZone(DCS)
|
||||
end
|
||||
)
|
||||
|
||||
|
||||
inzonestatics:ForEach(
|
||||
function(static)
|
||||
local Static = static --Wrapper.Static#STATIC
|
||||
@ -3221,19 +3237,19 @@ function ZONE_POLYGON:Scan( ObjectCategories, UnitCategories )
|
||||
EvaluateZone(DCS)
|
||||
end
|
||||
)
|
||||
|
||||
|
||||
local searchscenery = false
|
||||
for _,_type in pairs(ObjectCategories) do
|
||||
if _type == Object.Category.SCENERY then
|
||||
searchscenery = true
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if searchscenery then
|
||||
-- Search objects.
|
||||
world.searchObjects({Object.Category.SCENERY}, SphereSearch, EvaluateZone )
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
--- Count the number of different coalitions inside the zone.
|
||||
@ -3449,7 +3465,7 @@ end
|
||||
end
|
||||
|
||||
do -- ZONE_ELASTIC
|
||||
|
||||
|
||||
---
|
||||
-- @type ZONE_ELASTIC
|
||||
-- @field #table points Points in 2D.
|
||||
@ -3476,14 +3492,14 @@ do -- ZONE_ELASTIC
|
||||
function ZONE_ELASTIC:New(ZoneName, Points)
|
||||
|
||||
local self=BASE:Inherit(self, ZONE_POLYGON_BASE:New(ZoneName, Points)) --#ZONE_ELASTIC
|
||||
|
||||
|
||||
-- Zone objects are added to the _DATABASE and SET_ZONE objects.
|
||||
_EVENTDISPATCHER:CreateEventNewZone( self )
|
||||
|
||||
|
||||
if Points then
|
||||
self.points=Points
|
||||
end
|
||||
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
@ -3492,10 +3508,10 @@ do -- ZONE_ELASTIC
|
||||
-- @param DCS#Vec2 Vec2 Point in 2D (with x and y coordinates).
|
||||
-- @return #ZONE_ELASTIC self
|
||||
function ZONE_ELASTIC:AddVertex2D(Vec2)
|
||||
|
||||
|
||||
-- Add vec2 to points.
|
||||
table.insert(self.points, Vec2)
|
||||
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
@ -3505,10 +3521,10 @@ do -- ZONE_ELASTIC
|
||||
-- @param DCS#Vec3 Vec3 Point in 3D (with x, y and z coordinates). Only the x and z coordinates are used.
|
||||
-- @return #ZONE_ELASTIC self
|
||||
function ZONE_ELASTIC:AddVertex3D(Vec3)
|
||||
|
||||
|
||||
-- Add vec2 from vec3 to points.
|
||||
table.insert(self.points, {x=Vec3.x, y=Vec3.z})
|
||||
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
@ -3518,10 +3534,10 @@ do -- ZONE_ELASTIC
|
||||
-- @param Core.Set#SET_GROUP GroupSet Set of groups.
|
||||
-- @return #ZONE_ELASTIC self
|
||||
function ZONE_ELASTIC:AddSetGroup(GroupSet)
|
||||
|
||||
|
||||
-- Add set to table.
|
||||
table.insert(self.setGroups, GroupSet)
|
||||
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
@ -3533,13 +3549,13 @@ do -- ZONE_ELASTIC
|
||||
-- @param #boolean Draw Draw the zone. Default `nil`.
|
||||
-- @return #ZONE_ELASTIC self
|
||||
function ZONE_ELASTIC:Update(Delay, Draw)
|
||||
|
||||
|
||||
-- Debug info.
|
||||
self:T(string.format("Updating ZONE_ELASTIC %s", tostring(self.ZoneName)))
|
||||
|
||||
|
||||
-- Copy all points.
|
||||
local points=UTILS.DeepCopy(self.points or {})
|
||||
|
||||
|
||||
if self.setGroups then
|
||||
for _,_setGroup in pairs(self.setGroups) do
|
||||
local setGroup=_setGroup --Core.Set#SET_GROUP
|
||||
@ -3554,7 +3570,7 @@ do -- ZONE_ELASTIC
|
||||
|
||||
-- Update polygon verticies from points.
|
||||
self._.Polygon=self:_ConvexHull(points)
|
||||
|
||||
|
||||
if Draw~=false then
|
||||
if self.DrawID or Draw==true then
|
||||
self:UndrawZone()
|
||||
@ -3564,7 +3580,7 @@ do -- ZONE_ELASTIC
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
--- Start the updating scheduler.
|
||||
-- @param #ZONE_ELASTIC self
|
||||
-- @param #number Tstart Time in seconds before the updating starts.
|
||||
@ -3573,9 +3589,9 @@ do -- ZONE_ELASTIC
|
||||
-- @param #boolean Draw Draw the zone. Default `nil`.
|
||||
-- @return #ZONE_ELASTIC self
|
||||
function ZONE_ELASTIC:StartUpdate(Tstart, dT, Tstop, Draw)
|
||||
|
||||
|
||||
self.updateID=self:ScheduleRepeat(Tstart, dT, 0, Tstop, ZONE_ELASTIC.Update, self, 0, Draw)
|
||||
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
@ -3584,46 +3600,46 @@ do -- ZONE_ELASTIC
|
||||
-- @param #number Delay Delay in seconds before the scheduler will be stopped. Default 0.
|
||||
-- @return #ZONE_ELASTIC self
|
||||
function ZONE_ELASTIC:StopUpdate(Delay)
|
||||
|
||||
|
||||
if Delay and Delay>0 then
|
||||
self:ScheduleOnce(Delay, ZONE_ELASTIC.StopUpdate, self)
|
||||
else
|
||||
|
||||
|
||||
if self.updateID then
|
||||
|
||||
|
||||
self:ScheduleStop(self.updateID)
|
||||
|
||||
|
||||
self.updateID=nil
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
|
||||
--- Create a convec hull.
|
||||
-- @param #ZONE_ELASTIC self
|
||||
-- @param #table pl Points
|
||||
-- @return #table Points
|
||||
function ZONE_ELASTIC:_ConvexHull(pl)
|
||||
|
||||
|
||||
if #pl == 0 then
|
||||
return {}
|
||||
end
|
||||
|
||||
|
||||
table.sort(pl, function(left,right)
|
||||
return left.x < right.x
|
||||
end)
|
||||
|
||||
|
||||
local h = {}
|
||||
|
||||
|
||||
-- Function: ccw > 0 if three points make a counter-clockwise turn, clockwise if ccw < 0, and collinear if ccw = 0.
|
||||
local function ccw(a,b,c)
|
||||
return (b.x - a.x) * (c.y - a.y) > (b.y - a.y) * (c.x - a.x)
|
||||
end
|
||||
|
||||
|
||||
-- lower hull
|
||||
for i,pt in pairs(pl) do
|
||||
while #h >= 2 and not ccw(h[#h-1], h[#h], pt) do
|
||||
@ -3631,7 +3647,7 @@ do -- ZONE_ELASTIC
|
||||
end
|
||||
table.insert(h,pt)
|
||||
end
|
||||
|
||||
|
||||
-- upper hull
|
||||
local t = #h + 1
|
||||
for i=#pl, 1, -1 do
|
||||
@ -3641,12 +3657,12 @@ do -- ZONE_ELASTIC
|
||||
end
|
||||
table.insert(h, pt)
|
||||
end
|
||||
|
||||
|
||||
table.remove(h, #h)
|
||||
|
||||
|
||||
return h
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
@ -3673,13 +3689,17 @@ ZONE_OVAL = {
|
||||
|
||||
--- Creates a new ZONE_OVAL from a center point, major axis, minor axis, and angle.
|
||||
--- ported from https://github.com/nielsvaes/CCMOOSE/blob/master/Moose%20Development/Moose/Shapes/Oval.lua
|
||||
-- @param #ZONE_OVAL self
|
||||
-- @param #string name Name of the zone.
|
||||
-- @param #table vec2 The center point of the oval
|
||||
-- @param #number major_axis The major axis of the oval
|
||||
-- @param #number minor_axis The minor axis of the oval
|
||||
-- @param #number angle The angle of the oval
|
||||
-- @return #ZONE_OVAL The new oval
|
||||
function ZONE_OVAL:New(name, vec2, major_axis, minor_axis, angle)
|
||||
|
||||
self = BASE:Inherit(self, ZONE_BASE:New())
|
||||
|
||||
self.ZoneName = name
|
||||
self.CenterVec2 = vec2
|
||||
self.MajorAxis = major_axis
|
||||
@ -3717,7 +3737,7 @@ function ZONE_OVAL:NewFromDrawing(DrawingName)
|
||||
return self
|
||||
end
|
||||
|
||||
--- Gets the major axis of the oval.
|
||||
--- Gets the major axis of the oval.
|
||||
-- @param #ZONE_OVAL self
|
||||
-- @return #number The major axis of the oval
|
||||
function ZONE_OVAL:GetMajorAxis()
|
||||
@ -3913,7 +3933,7 @@ do -- ZONE_AIRBASE
|
||||
|
||||
self._.ZoneAirbase = Airbase
|
||||
self._.ZoneVec2Cache = self._.ZoneAirbase:GetVec2()
|
||||
|
||||
|
||||
if Airbase:IsShip() then
|
||||
self.isShip=true
|
||||
self.isHelipad=false
|
||||
@ -3921,11 +3941,11 @@ do -- ZONE_AIRBASE
|
||||
elseif Airbase:IsHelipad() then
|
||||
self.isShip=false
|
||||
self.isHelipad=true
|
||||
self.isAirdrome=false
|
||||
self.isAirdrome=false
|
||||
elseif Airbase:IsAirdrome() then
|
||||
self.isShip=false
|
||||
self.isHelipad=false
|
||||
self.isAirdrome=true
|
||||
self.isAirdrome=true
|
||||
end
|
||||
|
||||
-- Zone objects are added to the _DATABASE and SET_ZONE objects.
|
||||
|
||||
@ -890,7 +890,7 @@ _ATIS = {}
|
||||
|
||||
--- ATIS class version.
|
||||
-- @field #string version
|
||||
ATIS.version = "0.10.4"
|
||||
ATIS.version = "1.0.0"
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- TODO list
|
||||
@ -1528,12 +1528,12 @@ end
|
||||
|
||||
--- Use SRS Simple-Text-To-Speech for transmissions. No sound files necessary.
|
||||
-- @param #ATIS self
|
||||
-- @param #string PathToSRS Path to SRS directory.
|
||||
-- @param #string PathToSRS Path to SRS directory (only necessary if SRS exe backend is used).
|
||||
-- @param #string Gender Gender: "male" or "female" (default).
|
||||
-- @param #string Culture Culture, e.g. "en-GB" (default).
|
||||
-- @param #string Voice Specific voice. Overrides `Gender` and `Culture`.
|
||||
-- @param #number Port SRS port. Default 5002.
|
||||
-- @param #string GoogleKey Path to Google JSON-Key.
|
||||
-- @param #string GoogleKey Path to Google JSON-Key (SRS exe backend) or Google API key (DCS-gRPC backend).
|
||||
-- @return #ATIS self
|
||||
function ATIS:SetSRS(PathToSRS, Gender, Culture, Voice, Port, GoogleKey)
|
||||
if PathToSRS or MSRS.path then
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user