Skip to content

Commit

Permalink
Finished implementation of Ring visualization for admin menu
Browse files Browse the repository at this point in the history
  • Loading branch information
thorwin99 committed Feb 29, 2020
1 parent fda5939 commit 34a8b0e
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 5 deletions.
25 changes: 25 additions & 0 deletions SEWorldGenPlugin/Draw/RenderSphere.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using VRage.Game;
using VRageMath;

namespace SEWorldGenPlugin.Draw
{
public class RenderSphere : IRenderObject
{
private Vector3D m_position;
private float m_radius;
private Color m_color;

public RenderSphere(Vector3D position, float radius, Color color)
{
m_position = position;
m_radius = radius;
m_color = color;
}

public void Draw()
{
MatrixD wm = MatrixD.CreateWorld(m_position);
MySimpleObjectDraw.DrawTransparentSphere(ref wm, m_radius, ref m_color, MySimpleObjectRasterizer.Solid, 20);
}
}
}
12 changes: 10 additions & 2 deletions SEWorldGenPlugin/GUI/PluginAdminMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -558,22 +558,30 @@ private void UpdateRingVisual()
PluginDrawSession.Static.AddRenderObject(m_selectedPlanet.GetHashCode(), new RenderHollowCylinder(shape.worldMatrix, (float)shape.radius + shape.width, (float)shape.radius, shape.height, Color.LightGreen.ToVector4()));
}

private void UpdatePlanetVisual()
{

}

private void OnTeleportToRingButton(MyGuiControlButton button)
{
if(MySession.Static.CameraController != MySession.Static.LocalCharacter)
{
CloseScreen();
AsteroidRingShape shape = AsteroidRingShape.CreateFromRingItem(m_selectedPlanet.PlanetRing);

MyMultiplayer.TeleportControlledEntity(shape.LocationInRing(0));
m_attachedEntity = 0L;
m_selectedPlanet = null;
MyGuiScreenGamePlay.SetCameraController();
CloseScreen();

}
}

public override bool CloseScreen()
{
PluginDrawSession.Static.RemoveRenderObject(0);
if(m_selectedPlanet != null)
PluginDrawSession.Static.RemoveRenderObject(m_selectedPlanet.GetHashCode());
return base.CloseScreen();
}

Expand Down
7 changes: 5 additions & 2 deletions SEWorldGenPlugin/Generator/Asteroids/AsteroidRingShape.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,11 @@ public ContainmentType Contains(Vector3D point)

public Vector3D LocationInRing(int angle)
{
double rad = radius + width / 2f;
return center + (new Vector3D(rotation.X * rad * Math.Cos(angle), rotation.Y * rad * Math.Cos(angle), Math.Sin(angle) * rad));
Vector3D pos = Vector3D.Zero;
pos.X = (float)((radius + width / 2) * Math.Cos(MathHelper.ToRadians(angle)));
pos.Y = 0;
pos.Z = (float)((radius + width / 2) * Math.Sin(MathHelper.ToRadians(angle)));
return Vector3D.Transform(pos, worldMatrix);
}

private double GetHeightAtRad(double rad)
Expand Down
2 changes: 2 additions & 0 deletions SEWorldGenPlugin/SEWorldGenPlugin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@
<Compile Include="Draw\RenderCylinder.cs" />
<Compile Include="Draw\IRenderObject.cs" />
<Compile Include="Draw\RenderHollowCylinder.cs" />
<Compile Include="Draw\RenderSphere.cs" />
<Compile Include="Generator\Asteroids\AsteroidBeltShape.cs" />
<Compile Include="Generator\Asteroids\AsteroidRingShape.cs" />
<Compile Include="Generator\ProceduralGen\EntityExtension.cs" />
Expand Down Expand Up @@ -222,6 +223,7 @@
<Compile Include="Session\GlobalGpsManager.cs" />
<Compile Include="Session\PlayerTracker.cs" />
<Compile Include="Session\PluginDrawSession.cs" />
<Compile Include="Session\PluginItemsClipboard.cs" />
<Compile Include="Session\SettingsSession.cs" />
<Compile Include="Startup.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
Expand Down
2 changes: 1 addition & 1 deletion SEWorldGenPlugin/Session/PluginDrawSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace SEWorldGenPlugin.Session
{
[MySessionComponentDescriptor(MyUpdateOrder.NoUpdate)]
[MySessionComponentDescriptor(MyUpdateOrder.BeforeSimulation)]
public class PluginDrawSession : MySessionComponentBase
{
public static PluginDrawSession Static;
Expand Down
14 changes: 14 additions & 0 deletions SEWorldGenPlugin/Session/PluginItemsClipboard.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VRage.Game.Components;

namespace SEWorldGenPlugin.Session
{
[MySessionComponentDescriptor(MyUpdateOrder.BeforeSimulation)]
public class PluginItemsClipboard : MySessionComponentBase
{
}
}

0 comments on commit 34a8b0e

Please sign in to comment.