Skip to content

Commit

Permalink
Added buildings, trees and persistence to the Virtual World Scene
Browse files Browse the repository at this point in the history
  • Loading branch information
Selinux24 committed Aug 1, 2024
1 parent 8b473d6 commit eff41a4
Show file tree
Hide file tree
Showing 37 changed files with 974 additions and 159 deletions.
8 changes: 8 additions & 0 deletions Samples/05 AISamples/05 AISamples.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

<ItemGroup>
<None Remove="Common\Resources\Markings.png" />
<None Remove="Common\Resources\Tree\Tree1.dae" />
<None Remove="Common\Resources\Tree\tree1.json" />
<None Remove="SceneCWRSelfDrivingCar\Resources\dirt002.dds" />
<None Remove="SceneCWRSelfDrivingCar\Resources\normal001.dds" />
<None Remove="SceneStart\pointer.png" />
Expand All @@ -29,6 +31,12 @@
<Content Include="Common\Resources\Markings.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Common\Resources\Tree\Tree1.dae">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Common\Resources\Tree\tree1.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="SceneCWRSelfDrivingCar\Resources\dirt002.dds">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
Expand Down
2 changes: 2 additions & 0 deletions Samples/05 AISamples/Common/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ static class Constants
{
public const string CommonResourcesFolder = "Common/Resources/";
public const string MarkingsTexture = CommonResourcesFolder + "markings.png";
public const string TreesResourcesFolder = CommonResourcesFolder + "Tree/";
public const string TreesModel = "Tree1.json";

const float Width = 2000f;
const float Height = 1600f;
Expand Down
130 changes: 130 additions & 0 deletions Samples/05 AISamples/Common/Resources/Tree/Tree1.dae

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions Samples/05 AISamples/Common/Resources/Tree/tree1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"modelFilename": "tree1.dae"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

namespace AISamples.SceneCWRVirtualWorld.Content
{
struct BuildingFile
{
public PolygonFile Polygon { get; set; }
public float Height { get; set; }
}
}
29 changes: 29 additions & 0 deletions Samples/05 AISamples/SceneCWRVirtualWorld/Content/CrossingFile.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using AISamples.SceneCWRVirtualWorld.Markings;
using System;

namespace AISamples.SceneCWRVirtualWorld.Content
{
struct CrossingFile : IMarkingFile
{
public string Type { get; set; }
public Vector2File Position { get; set; }
public Vector2File Direction { get; set; }
public float Width { get; set; }
public float Height { get; set; }
public bool Is3D { get; set; }

public readonly Marking FromMarkingFile()
{
if (Type != nameof(Crossing))
{
throw new ArgumentException("Invalid marking file type");
}

return new Crossing(
Vector2File.FromVector2File(Position),
Vector2File.FromVector2File(Direction),
Width,
Height);
}
}
}
11 changes: 11 additions & 0 deletions Samples/05 AISamples/SceneCWRVirtualWorld/Content/EnvelopeFile.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

namespace AISamples.SceneCWRVirtualWorld.Content
{
struct EnvelopeFile
{
public Segment2File Skeleton { get; set; }
public float Width { get; set; }
public int Roundness { get; set; }
public PolygonFile Polygon { get; set; }
}
}
23 changes: 1 addition & 22 deletions Samples/05 AISamples/SceneCWRVirtualWorld/Content/GraphFile.cs
Original file line number Diff line number Diff line change
@@ -1,30 +1,9 @@
using System.Linq;


namespace AISamples.SceneCWRVirtualWorld.Content
{
struct GraphFile
{
public Vector2File[] Points { get; set; }
public Segment2File[] Segments { get; set; }

public static GraphFile FromGraph(Graph graph)
{
var points = graph.GetPoints().Select(Vector2File.FromVector2).ToArray();
var segments = graph.GetSegments().Select(Segment2File.FromSegment).ToArray();

return new()
{
Points = points,
Segments = segments,
};
}

public static Graph FromGraphFile(GraphFile graph)
{
var points = graph.Points.Select(Vector2File.FromVector2File).ToArray();
var segments = graph.Segments.Select(Segment2File.FromSegmentFile).ToArray();

return new(points, segments);
}
}
}
16 changes: 16 additions & 0 deletions Samples/05 AISamples/SceneCWRVirtualWorld/Content/IMarkingFile.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using AISamples.SceneCWRVirtualWorld.Markings;

namespace AISamples.SceneCWRVirtualWorld.Content
{
interface IMarkingFile
{
string Type { get; set; }
Vector2File Position { get; set; }
Vector2File Direction { get; set; }
float Width { get; set; }
float Height { get; set; }
bool Is3D { get; set; }

Marking FromMarkingFile();
}
}
35 changes: 35 additions & 0 deletions Samples/05 AISamples/SceneCWRVirtualWorld/Content/LightFile.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using AISamples.SceneCWRVirtualWorld.Markings;
using System;

namespace AISamples.SceneCWRVirtualWorld.Content
{
struct LightFile : IMarkingFile
{
public string Type { get; set; }
public Vector2File Position { get; set; }
public Vector2File Direction { get; set; }
public float Width { get; set; }
public float Height { get; set; }
public bool Is3D { get; set; }
public LightState LightState { get; set; }
public float RedDuration { get; set; }
public float YellowDuration { get; set; }
public float GreenDuration { get; set; }

public readonly Marking FromMarkingFile()
{
if (Type != nameof(Light))
{
throw new ArgumentException("Invalid marking file type");
}

return new Light(Vector2File.FromVector2File(Position), Vector2File.FromVector2File(Direction), Width, Height)
{
LightState = LightState,
RedDuration = RedDuration,
YellowDuration = YellowDuration,
GreenDuration = GreenDuration
};
}
}
}
29 changes: 29 additions & 0 deletions Samples/05 AISamples/SceneCWRVirtualWorld/Content/ParkingFile.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using AISamples.SceneCWRVirtualWorld.Markings;
using System;

namespace AISamples.SceneCWRVirtualWorld.Content
{
struct ParkingFile : IMarkingFile
{
public string Type { get; set; }
public Vector2File Position { get; set; }
public Vector2File Direction { get; set; }
public float Width { get; set; }
public float Height { get; set; }
public bool Is3D { get; set; }

public readonly Marking FromMarkingFile()
{
if (Type != nameof(Parking))
{
throw new ArgumentException("Invalid marking file type");
}

return new Parking(
Vector2File.FromVector2File(Position),
Vector2File.FromVector2File(Direction),
Width,
Height);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

namespace AISamples.SceneCWRVirtualWorld.Content
{
struct PolygonFile
{
public Vector2File[] Vertices { get; set; }
public Segment2File[] Segments { get; set; }
}
}
16 changes: 0 additions & 16 deletions Samples/05 AISamples/SceneCWRVirtualWorld/Content/Segment2File.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,9 @@

using AISamples.SceneCWRVirtualWorld.Primitives;

namespace AISamples.SceneCWRVirtualWorld.Content
{
struct Segment2File
{
public Vector2File P1 { get; set; }
public Vector2File P2 { get; set; }

public static Segment2File FromSegment(Segment2 segment)
{
return new()
{
P1 = Vector2File.FromVector2(segment.P1),
P2 = Vector2File.FromVector2(segment.P2),
};
}

public static Segment2 FromSegmentFile(Segment2File segment)
{
return new(Vector2File.FromVector2File(segment.P1), Vector2File.FromVector2File(segment.P2));
}
}
}
29 changes: 29 additions & 0 deletions Samples/05 AISamples/SceneCWRVirtualWorld/Content/StartFile.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using AISamples.SceneCWRVirtualWorld.Markings;
using System;

namespace AISamples.SceneCWRVirtualWorld.Content
{
struct StartFile : IMarkingFile
{
public string Type { get; set; }
public Vector2File Position { get; set; }
public Vector2File Direction { get; set; }
public float Width { get; set; }
public float Height { get; set; }
public bool Is3D { get; set; }

public readonly Marking FromMarkingFile()
{
if (Type != nameof(Start))
{
throw new ArgumentException("Invalid marking file type");
}

return new Start(
Vector2File.FromVector2File(Position),
Vector2File.FromVector2File(Direction),
Width,
Height);
}
}
}
29 changes: 29 additions & 0 deletions Samples/05 AISamples/SceneCWRVirtualWorld/Content/StopFile.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using AISamples.SceneCWRVirtualWorld.Markings;
using System;

namespace AISamples.SceneCWRVirtualWorld.Content
{
struct StopFile : IMarkingFile
{
public string Type { get; set; }
public Vector2File Position { get; set; }
public Vector2File Direction { get; set; }
public float Width { get; set; }
public float Height { get; set; }
public bool Is3D { get; set; }

public readonly Marking FromMarkingFile()
{
if (Type != nameof(Stop))
{
throw new ArgumentException("Invalid marking file type");
}

return new Stop(
Vector2File.FromVector2File(Position),
Vector2File.FromVector2File(Direction),
Width,
Height);
}
}
}
29 changes: 29 additions & 0 deletions Samples/05 AISamples/SceneCWRVirtualWorld/Content/TargetFile.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using AISamples.SceneCWRVirtualWorld.Markings;
using System;

namespace AISamples.SceneCWRVirtualWorld.Content
{
struct TargetFile : IMarkingFile
{
public string Type { get; set; }
public Vector2File Position { get; set; }
public Vector2File Direction { get; set; }
public float Width { get; set; }
public float Height { get; set; }
public bool Is3D { get; set; }

public readonly Marking FromMarkingFile()
{
if (Type != nameof(Target))
{
throw new ArgumentException("Invalid marking file type");
}

return new Target(
Vector2File.FromVector2File(Position),
Vector2File.FromVector2File(Direction),
Width,
Height);
}
}
}
10 changes: 10 additions & 0 deletions Samples/05 AISamples/SceneCWRVirtualWorld/Content/TreeFile.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

namespace AISamples.SceneCWRVirtualWorld.Content
{
struct TreeFile
{
public Vector3File Position { get; set; }
public float Radius { get; set; }
public float Height { get; set; }
}
}
26 changes: 26 additions & 0 deletions Samples/05 AISamples/SceneCWRVirtualWorld/Content/Vector3File.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using SharpDX;

namespace AISamples.SceneCWRVirtualWorld.Content
{
struct Vector3File
{
public float X { get; set; }
public float Y { get; set; }
public float Z { get; set; }

public static Vector3File FromVector3(Vector3 vector)
{
return new()
{
X = vector.X,
Y = vector.Y,
Z = vector.Z
};
}

public static Vector3 FromVector3File(Vector3File vector)
{
return new(vector.X, vector.Y, vector.Z);
}
}
}
18 changes: 18 additions & 0 deletions Samples/05 AISamples/SceneCWRVirtualWorld/Content/WorldFile.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System;

namespace AISamples.SceneCWRVirtualWorld.Content
{
struct WorldFile
{
public GraphFile Graph { get; set; }
public float Height { get; set; }
public Guid Version { get; set; }
public EnvelopeFile[] Envelopes { get; set; }
public EnvelopeFile[] RoadEnvelopes { get; set; }
public Segment2File[] RoadBorders { get; set; }
public BuildingFile[] Buildings { get; set; }
public TreeFile[] Trees { get; set; }
public Segment2File[] LaneGuides { get; set; }
public IMarkingFile[] Markings { get; set; }
}
}
Loading

0 comments on commit eff41a4

Please sign in to comment.