mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Polygon and line drawings
This commit is contained in:
parent
9862c32378
commit
54fb9deb3e
@ -416,10 +416,14 @@ do -- Zones and Pathlines
|
|||||||
for objectID, objectData in pairs(layerData.objects or {}) do
|
for objectID, objectData in pairs(layerData.objects or {}) do
|
||||||
|
|
||||||
-- Check for polygon which has at least 4 points (we would need 3 but the origin seems to be there twice)
|
-- Check for polygon which has at least 4 points (we would need 3 but the origin seems to be there twice)
|
||||||
if objectData.polygonMode and objectData.polygonMode=="free" and objectData.points and #objectData.points>=4 then
|
if objectData.polygonMode and (objectData.polygonMode=="free") and objectData.points and #objectData.points>=4 then
|
||||||
|
|
||||||
|
---
|
||||||
|
-- Drawing: Polygon free
|
||||||
|
---
|
||||||
|
|
||||||
-- Name of the zone.
|
-- Name of the zone.
|
||||||
local ZoneName=objectData.name or "Unknown Drawing"
|
local ZoneName=objectData.name or "Unknown free Polygon Drawing"
|
||||||
|
|
||||||
-- Reference point. All other points need to be translated by this.
|
-- Reference point. All other points need to be translated by this.
|
||||||
local vec2={x=objectData.mapX, y=objectData.mapY}
|
local vec2={x=objectData.mapX, y=objectData.mapY}
|
||||||
@ -442,7 +446,48 @@ do -- Zones and Pathlines
|
|||||||
table.remove(points, #points)
|
table.remove(points, #points)
|
||||||
|
|
||||||
-- Debug output
|
-- Debug output
|
||||||
self:I(string.format("Register ZONE: %s (Polygon drawing with %d vertices)", ZoneName, #points))
|
self:I(string.format("Register ZONE: %s (Polygon (free) drawing with %d vertices)", ZoneName, #points))
|
||||||
|
|
||||||
|
-- Create new polygon zone.
|
||||||
|
local Zone=ZONE_POLYGON:NewFromPointsArray(ZoneName, points)
|
||||||
|
|
||||||
|
-- Set color.
|
||||||
|
Zone:SetColor({1, 0, 0}, 0.15)
|
||||||
|
|
||||||
|
-- Store in DB.
|
||||||
|
self.ZONENAMES[ZoneName] = ZoneName
|
||||||
|
|
||||||
|
-- Add zone.
|
||||||
|
self:AddZone(ZoneName, Zone)
|
||||||
|
|
||||||
|
-- Check for polygon which has at least 4 points (we would need 3 but the origin seems to be there twice)
|
||||||
|
elseif objectData.polygonMode and objectData.polygonMode=="rect" then
|
||||||
|
|
||||||
|
---
|
||||||
|
-- Drawing: Polygon rect
|
||||||
|
---
|
||||||
|
|
||||||
|
-- Name of the zone.
|
||||||
|
local ZoneName=objectData.name or "Unknown rect Polygon Drawing"
|
||||||
|
|
||||||
|
-- Reference point (center of the rectangle).
|
||||||
|
local vec2={x=objectData.mapX, y=objectData.mapY}
|
||||||
|
|
||||||
|
-- For a rectangular polygon drawing, we have the width (y) and height (x).
|
||||||
|
local w=objectData.width
|
||||||
|
local h=objectData.height
|
||||||
|
|
||||||
|
-- Create points from center using with and height (width for y and height for x is a bit confusing, but this is how ED implemented it).
|
||||||
|
local points={}
|
||||||
|
points[1]={x=vec2.x-h/2, y=vec2.y+w/2} --Upper left
|
||||||
|
points[2]={x=vec2.x+h/2, y=vec2.y+w/2} --Upper right
|
||||||
|
points[3]={x=vec2.x+h/2, y=vec2.y-w/2} --Lower right
|
||||||
|
points[4]={x=vec2.x-h/2, y=vec2.y-w/2} --Lower left
|
||||||
|
|
||||||
|
--local coord=COORDINATE:NewFromVec2(vec2):MarkToAll("MapX, MapY")
|
||||||
|
|
||||||
|
-- Debug output
|
||||||
|
self:I(string.format("Register ZONE: %s (Polygon (rect) drawing with %d vertices)", ZoneName, #points))
|
||||||
|
|
||||||
-- Create new polygon zone.
|
-- Create new polygon zone.
|
||||||
local Zone=ZONE_POLYGON:NewFromPointsArray(ZoneName, points)
|
local Zone=ZONE_POLYGON:NewFromPointsArray(ZoneName, points)
|
||||||
@ -458,6 +503,10 @@ do -- Zones and Pathlines
|
|||||||
|
|
||||||
elseif objectData.lineMode and (objectData.lineMode=="segments" or objectData.lineMode=="segment" or objectData.lineMode=="free") and objectData.points and #objectData.points>=2 then
|
elseif objectData.lineMode and (objectData.lineMode=="segments" or objectData.lineMode=="segment" or objectData.lineMode=="free") and objectData.points and #objectData.points>=2 then
|
||||||
|
|
||||||
|
---
|
||||||
|
-- Drawing: Line (segments, segment or free)
|
||||||
|
---
|
||||||
|
|
||||||
-- Name of the zone.
|
-- Name of the zone.
|
||||||
local Name=objectData.name or "Unknown Line Drawing"
|
local Name=objectData.name or "Unknown Line Drawing"
|
||||||
|
|
||||||
@ -473,7 +522,6 @@ do -- Zones and Pathlines
|
|||||||
points[i]=UTILS.Vec2Add(point, vec2)
|
points[i]=UTILS.Vec2Add(point, vec2)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Debug output
|
-- Debug output
|
||||||
self:I(string.format("Register PATHLINE: %s (Line drawing with %d points)", Name, #points))
|
self:I(string.format("Register PATHLINE: %s (Line drawing with %d points)", Name, #points))
|
||||||
|
|
||||||
|
|||||||
@ -23,17 +23,36 @@
|
|||||||
-- @field #table points List of 3D points defining the path.
|
-- @field #table points List of 3D points defining the path.
|
||||||
-- @extends Core.Base#BASE
|
-- @extends Core.Base#BASE
|
||||||
|
|
||||||
--- *When nothing goes right... Go left!*
|
--- *The shortest distance between two points is a straight line.* -- Archimedes
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
-- # The PATHLINE Concept
|
-- # The PATHLINE Concept
|
||||||
--
|
--
|
||||||
-- List of points defining a path from A to B.
|
-- List of points defining a path from A to B. The pathline can consist of multiple points. Each point holds the information of its position, the surface type, the land height
|
||||||
|
-- and the water depth (if over sea).
|
||||||
--
|
--
|
||||||
-- Line drawings created in the mission editor are automatically registered as pathlines and stored in the MOOSE database.
|
-- Line drawings created in the mission editor are automatically registered as pathlines and stored in the MOOSE database.
|
||||||
-- They can be accessed with the @{#PATHLINE.FindByName) function.
|
-- They can be accessed with the @{#PATHLINE.FindByName) function.
|
||||||
--
|
--
|
||||||
|
-- # Constructor
|
||||||
|
--
|
||||||
|
-- The @{PATHLINE.New) function creates a new PATHLINE object. This does not hold any points. Points can be added with the @{#PATHLINE.AddPointFromVec2} and @{#PATHLINE.AddPointFromVec3}
|
||||||
|
--
|
||||||
|
-- For a given table of 2D or 3D positions, a new PATHLINE object can be created with the @{#PATHLINE.NewFromVec2Array} or @{#PATHLINE.NewFromVec3Array}, respectively.
|
||||||
|
--
|
||||||
|
-- # Line Drawings
|
||||||
|
--
|
||||||
|
-- The most convenient way to create a pathline is the draw panel feature in the DCS mission editor. You can select "Line" and then "Segments", "Segment" or "Free" to draw your lines.
|
||||||
|
-- These line drawings are then automatically added to the MOOSE database as PATHLINE objects and can be retrieved with the @{#PATHLINE.FindByName) function, where the name is the one
|
||||||
|
-- you specify in the draw panel.
|
||||||
|
--
|
||||||
|
-- # Mark on F10 map
|
||||||
|
--
|
||||||
|
-- The ponints of the PATHLINE can be marked on the F10 map with the @{#PATHLINE.MarkPoints}(`true`) function. The mark points contain information of the surface type, land height and
|
||||||
|
-- water depth.
|
||||||
|
--
|
||||||
|
-- To remove the marks, use @{#PATHLINE.MarkPoints}(`false`).
|
||||||
--
|
--
|
||||||
-- @field #PATHLINE
|
-- @field #PATHLINE
|
||||||
PATHLINE = {
|
PATHLINE = {
|
||||||
@ -54,7 +73,7 @@ PATHLINE = {
|
|||||||
|
|
||||||
--- PATHLINE class version.
|
--- PATHLINE class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
PATHLINE.version="0.0.1"
|
PATHLINE.version="0.1.0"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- TODO list
|
-- TODO list
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user