improving bed rendering
This commit is contained in:
parent
bc5edc00e4
commit
e7f22f1895
3 changed files with 33 additions and 9 deletions
|
|
@ -89,8 +89,9 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
public DrawStage DrawStage { get; } = DrawStage.First;
|
||||
|
||||
public bool LookingDownOnBed { get; set; }
|
||||
public bool SelectedObjectUnderBed { get; set; }
|
||||
|
||||
public void Draw(GuiWidget sender, DrawEventArgs e, Matrix4X4 itemMaxtrix, WorldView world)
|
||||
public void Draw(GuiWidget sender, DrawEventArgs e, Matrix4X4 itemMaxtrix, WorldView world)
|
||||
{
|
||||
if (!sceneContext.RendererOptions.RenderBed)
|
||||
{
|
||||
|
|
@ -101,13 +102,24 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
{
|
||||
this.EnsureBedTexture(sceneContext.Scene.SelectedItem);
|
||||
|
||||
var alpha = 255;
|
||||
if (SelectedObjectUnderBed)
|
||||
{
|
||||
alpha = 200;
|
||||
}
|
||||
if (!LookingDownOnBed)
|
||||
{
|
||||
alpha = 32;
|
||||
}
|
||||
|
||||
GL.Disable(EnableCap.Lighting);
|
||||
GLHelper.Render(
|
||||
sceneContext.Mesh,
|
||||
theme.UnderBedColor.WithAlpha(32),
|
||||
Color.White.WithAlpha(alpha),
|
||||
RenderTypes.Shaded,
|
||||
world.ModelviewMatrix,
|
||||
blendTexture: !this.LookingDownOnBed,
|
||||
forceCullBackFaces: false);
|
||||
GL.Enable(EnableCap.Lighting);
|
||||
|
||||
if (sceneContext.PrinterShape != null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -214,8 +214,10 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
zHeightDisplayInfo.Visible = true;
|
||||
|
||||
double distanceToHit = Vector3Ex.Dot(mouseEvent3D.info.HitPosition, mouseEvent3D.MouseRay.directionNormal);
|
||||
hitPlane = new PlaneShape(mouseEvent3D.MouseRay.directionNormal, distanceToHit, null);
|
||||
var upNormal = Vector3.UnitZ;
|
||||
var sideNormal = upNormal.Cross(mouseEvent3D.MouseRay.directionNormal).GetNormal();
|
||||
var planeNormal = upNormal.Cross(sideNormal).GetNormal();
|
||||
hitPlane = new PlaneShape(new Plane(planeNormal, mouseEvent3D.info.HitPosition), null);
|
||||
|
||||
initialHitPosition = mouseEvent3D.info.HitPosition;
|
||||
transformOnMouseDown = selectedItem.Matrix;
|
||||
|
|
|
|||
|
|
@ -1126,11 +1126,21 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
var bedNormalInViewSpace = Vector3Ex.TransformNormal(Vector3.UnitZ, World.ModelviewMatrix).GetNormal();
|
||||
var pointOnBedInViewSpace = Vector3Ex.Transform(new Vector3(10, 10, 0), World.ModelviewMatrix);
|
||||
var lookingDownOnBed = Vector3Ex.Dot(bedNormalInViewSpace, pointOnBedInViewSpace) < 0;
|
||||
floorDrawable.LookingDownOnBed = Vector3Ex.Dot(bedNormalInViewSpace, pointOnBedInViewSpace) < 0;
|
||||
|
||||
floorDrawable.LookingDownOnBed = lookingDownOnBed;
|
||||
floorDrawable.SelectedObjectUnderBed = false;
|
||||
if (selectedItem != null)
|
||||
{
|
||||
var aabb = selectedItem.GetAxisAlignedBoundingBox();
|
||||
if (aabb.MinXYZ.Z < 0)
|
||||
{
|
||||
floorDrawable.SelectedObjectUnderBed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (lookingDownOnBed)
|
||||
var renderBedTransparent = !floorDrawable.LookingDownOnBed || floorDrawable.SelectedObjectUnderBed;
|
||||
|
||||
if (renderBedTransparent)
|
||||
{
|
||||
floorDrawable.Draw(this, e, Matrix4X4.Identity, this.World);
|
||||
}
|
||||
|
|
@ -1174,7 +1184,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
forceCullBackFaces: false);
|
||||
}
|
||||
|
||||
if (!lookingDownOnBed)
|
||||
if (!renderBedTransparent)
|
||||
{
|
||||
floorDrawable.Draw(this, e, Matrix4X4.Identity, this.World);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue