Orthographic projection mode with dynamic near/far.

This commit is contained in:
fortsnek9348 2022-03-02 00:52:04 +00:00
parent 0834aff9f4
commit 8fafc54f90
70 changed files with 2548 additions and 244 deletions

View file

@ -34,6 +34,7 @@ using MatterHackers.Agg;
using MatterHackers.Agg.UI;
using MatterHackers.RenderOpenGl;
using MatterHackers.RenderOpenGl.OpenGl;
using MatterHackers.VectorMath;
namespace MatterHackers.GCodeVisualizer
{
@ -330,12 +331,11 @@ namespace MatterHackers.GCodeVisualizer
}
}
}
public void Render3D(GCodeRenderInfo renderInfo, DrawEventArgs e)
bool PrepareForGeometryGeneration(GCodeRenderInfo renderInfo)
{
if (renderInfo == null)
{
return;
return false;
}
if (layerVertexBuffer == null)
@ -359,7 +359,12 @@ namespace MatterHackers.GCodeVisualizer
lastRenderType = renderInfo.CurrentRenderType;
}
if (all.layers.Count > 0)
return all.layers.Count > 0;
}
public void Render3D(GCodeRenderInfo renderInfo, DrawEventArgs e)
{
if (PrepareForGeometryGeneration(renderInfo))
{
for (int i = renderInfo.EndLayerIndex - 1; i >= renderInfo.StartLayerIndex; i--)
{
@ -425,5 +430,28 @@ namespace MatterHackers.GCodeVisualizer
GL.PopAttrib();
}
}
public AxisAlignedBoundingBox GetAabbOfRender3D(GCodeRenderInfo renderInfo)
{
var box = AxisAlignedBoundingBox.Empty();
if (PrepareForGeometryGeneration(renderInfo))
{
for (int i = renderInfo.EndLayerIndex - 1; i >= renderInfo.StartLayerIndex; i--)
{
if (i < layerVertexBuffer.Count)
{
if (layerVertexBuffer[i] == null)
{
layerVertexBuffer[i] = Create3DDataForLayer(i, renderInfo);
}
box = AxisAlignedBoundingBox.Union(box, layerVertexBuffer[i].BoundingBox);
}
}
}
return box;
}
}
}

View file

@ -33,6 +33,7 @@ using MatterHackers.Agg;
using MatterHackers.Agg.UI;
using MatterHackers.RenderOpenGl;
using MatterHackers.RenderOpenGl.OpenGl;
using MatterHackers.VectorMath;
namespace MatterHackers.GCodeVisualizer
{
@ -48,6 +49,10 @@ namespace MatterHackers.GCodeVisualizer
private ColorVertexData[] colorVertexData;
private AxisAlignedBoundingBox boundingBox = AxisAlignedBoundingBox.Empty();
public AxisAlignedBoundingBox BoundingBox { get { return new AxisAlignedBoundingBox(boundingBox.MinXYZ, boundingBox.MaxXYZ); } }
/// <summary>
/// Create a new VertexBuffer
/// </summary>
@ -136,6 +141,13 @@ namespace MatterHackers.GCodeVisualizer
}
}
}
boundingBox = AxisAlignedBoundingBox.Empty();
foreach (int i in indexData)
{
var v = colorData[i];
boundingBox.ExpandToInclude(new Vector3Float(v.positionX, v.positionY, v.positionZ));
}
}
public void RenderRange(int offset, int count)