mirror of https://github.com/rusefi/jzy3d-api.git
Let depth peeling renderer configure background color with view setting.
This commit is contained in:
parent
42e8d0f218
commit
14c30edf64
|
@ -104,19 +104,21 @@ public class Chart {
|
|||
/* HELPERS TO PRETTIFY CHARTS */
|
||||
|
||||
public Chart black() {
|
||||
getView().setBackgroundColor(Color.BLACK);
|
||||
getAxisLayout().setGridColor(Color.WHITE);
|
||||
getAxisLayout().setMainColor(Color.WHITE);
|
||||
return this;
|
||||
return color(Color.BLACK, Color.WHITE);
|
||||
}
|
||||
|
||||
|
||||
public Chart white() {
|
||||
getView().setBackgroundColor(Color.WHITE);
|
||||
getAxisLayout().setGridColor(Color.BLACK);
|
||||
getAxisLayout().setMainColor(Color.BLACK);
|
||||
return color(Color.WHITE, Color.BLACK);
|
||||
}
|
||||
|
||||
public Chart color(Color background, Color axis) {
|
||||
getView().setBackgroundColor(background);
|
||||
getAxisLayout().setGridColor(axis);
|
||||
getAxisLayout().setMainColor(axis);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public Chart view2d() {
|
||||
IAxisLayout axe = getAxisLayout();
|
||||
axe.setZAxeLabelDisplayed(false);
|
||||
|
|
|
@ -20,14 +20,14 @@ import org.jzy3d.plot3d.transform.Transform;
|
|||
*
|
||||
*/
|
||||
public class CoplanarityManager extends Drawable implements IGLBindedResource {
|
||||
protected List<Drawable> outlines;
|
||||
protected List<? extends Drawable> outlines;
|
||||
protected Drawable plane;
|
||||
|
||||
public CoplanarityManager(Drawable outline, Drawable plane) {
|
||||
this(Lists.of(outline), plane);
|
||||
}
|
||||
|
||||
public CoplanarityManager(List<Drawable> outlines, Drawable plane) {
|
||||
public CoplanarityManager(List<? extends Drawable> outlines, Drawable plane) {
|
||||
this.outlines = outlines;
|
||||
this.plane = plane;
|
||||
|
||||
|
@ -45,7 +45,7 @@ public class CoplanarityManager extends Drawable implements IGLBindedResource {
|
|||
* @param outlines
|
||||
* @param plane
|
||||
*/
|
||||
protected void computeBounds(List<Drawable> outlines, Drawable plane) {
|
||||
protected void computeBounds(List<? extends Drawable> outlines, Drawable plane) {
|
||||
this.bbox = new BoundingBox3d();
|
||||
|
||||
if (plane.getBounds() != null && !plane.getBounds().isReset()) {
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.jzy3d.events.IViewPointChangedListener;
|
|||
import org.jzy3d.events.ViewIsVerticalEvent;
|
||||
import org.jzy3d.events.ViewLifecycleEvent;
|
||||
import org.jzy3d.events.ViewPointChangedEvent;
|
||||
import org.jzy3d.io.Console;
|
||||
import org.jzy3d.maths.BoundingBox3d;
|
||||
import org.jzy3d.maths.Coord2d;
|
||||
import org.jzy3d.maths.Coord3d;
|
||||
|
@ -926,6 +927,8 @@ public class View {
|
|||
painter.clearColor(backgroundColor);
|
||||
painter.glClearDepth(1);
|
||||
|
||||
//Console.println("View.clear with color", backgroundColor);
|
||||
|
||||
if (!slave) {
|
||||
painter.glClearColorAndDepthBuffers();
|
||||
}
|
||||
|
|
|
@ -75,7 +75,17 @@ public class DepthPeelingRenderer3d extends AWTRenderer3d {
|
|||
|
||||
if(view!=null) {
|
||||
view.clear();
|
||||
|
||||
float[] background = new float[3];
|
||||
|
||||
background[0] = view.getBackgroundColor().r;
|
||||
background[1] = view.getBackgroundColor().g;
|
||||
background[2] = view.getBackgroundColor().b;
|
||||
|
||||
dualPeelingAlgorithm.setBackground(background);
|
||||
|
||||
//dualPeelingAlgorithm.setOpacity(0.95f);
|
||||
|
||||
// Following line will call taskToRender, which will trigger :
|
||||
// algo.resetNumPass()
|
||||
// algo.doRender()
|
||||
|
|
|
@ -33,6 +33,27 @@ public abstract class AbstractDepthPeelingAlgorithm implements IDepthPeelingAlgo
|
|||
|
||||
|
||||
public AbstractDepthPeelingAlgorithm() {}
|
||||
|
||||
|
||||
public void setBackground(float[] color) {
|
||||
if(color.length!=3) {
|
||||
throw new IllegalArgumentException("Expect an array with three components");
|
||||
}
|
||||
g_backgroundColor = color;
|
||||
}
|
||||
|
||||
public float[] getBackground(){
|
||||
return g_backgroundColor;
|
||||
}
|
||||
|
||||
public void setOpacity(float opacity){
|
||||
g_opacity[0] = opacity;
|
||||
}
|
||||
|
||||
public float getOpacity(){
|
||||
return g_opacity[0];
|
||||
}
|
||||
|
||||
|
||||
protected abstract void buildShaders(GL2 gl);
|
||||
|
||||
|
|
|
@ -21,4 +21,13 @@ public interface IDepthPeelingAlgorithm {
|
|||
public IGLRenderer getTasksToRender();
|
||||
|
||||
public void setTasksToRender(IGLRenderer tasksToRender);
|
||||
|
||||
public void setBackground(float[] color);
|
||||
|
||||
public float[] getBackground();
|
||||
|
||||
public void setOpacity(float opacity);
|
||||
|
||||
public float getOpacity();
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue