Suppose that you have two overlapped regions and you want to avoid Z-fighting.
If you want to prevent Z-fighting, you can follow the approach reported below.
First of all, you should decide which entity you prefer to display on top (in this case I choose Region).
Next, you should create a new class MyRegion that derives from Region, and override Draw() and Render() methods.
class MyRegion : Region
{
public MyRegion(double x, double y, double radius)
: base(new List<ICurve>(){new Circle(x, y, 0, radius)}, Plane.XY)
{
}
protected override void Draw(DrawParams data)
{
data.RenderContext.PushRasterizerState();
data.RenderContext.SetState(rasterizerStateType.CCW_PolygonFill_NoCullFace_PolygonOffset_Minus3Minus2);
base.Draw(data);
data.RenderContext.PopRasterizerState();
}
protected override void Render(RenderParams data)
{
data.RenderContext.PushRasterizerState();
data.RenderContext.SetState(rasterizerStateType.CCW_PolygonFill_NoCullFace_PolygonOffset_Minus3Minus2);
base.Render(data);
data.RenderContext.PopRasterizerState();
}
}
Finally, when you draw the two entities:
Region mr = new MyRegion(80, 80, 30);
mr.ColorMethod = colorMethodType.byEntity;
mr.Color = Color.Red;
design1.Entities.Add(mr);
Region rect = devDept.Eyeshot.Entities.Region.CreateRectangle(200, 200);
rect.Color = Color.Gray;
rect.ColorMethod = colorMethodType.byEntity;
design1.Entities.Add(rect);
you will obtain the following result:
Comments
If a "Surface" is only single-sided, and the drawing it done on the underside (i.e. derived class from `LinearPath`) facing outwards, Then this method will force the appearance to be flipped to the inside.
This is the solution I am currently using:
Please sign in to leave a comment.