Color individual faces on click tool
Posted: Sun 24. Jan 2016, 06:05
Hi
I want to implement a custom tool that lets the user click on individual faces of a polygon and when that happens the clicked face changes its color.
I have done some research on the available tools in jReality and one that could help me achieve what I want is the FaceDragEvent. There you can attach a FaceDragListener that handles the event of actual face dragging, which gives you access to the face's vertices and coordinates via the FaceDragEvent object (as seen in the http://www3.math.tu-berlin.de/jreality/ ... gEventTool tutorial).
For example, in the class de.jreality.tutorial.tool.DragEventTool02 you have this code:
My idea is to develop something similar: Create a FaceClickedEvent and a FaceClickedListener that gives you access to the clicked face so you can change it's color. I want a similar method that gets the face color, something like this:
Any idea on what existing classes in jReality I could use to develop this tool? How can I dinamically change a face color after the clicked event?
Thanks so much!
I want to implement a custom tool that lets the user click on individual faces of a polygon and when that happens the clicked face changes its color.
I have done some research on the available tools in jReality and one that could help me achieve what I want is the FaceDragEvent. There you can attach a FaceDragListener that handles the event of actual face dragging, which gives you access to the face's vertices and coordinates via the FaceDragEvent object (as seen in the http://www3.math.tu-berlin.de/jreality/ ... gEventTool tutorial).
For example, in the class de.jreality.tutorial.tool.DragEventTool02 you have this code:
Code: Select all
public void faceDragStart(FaceDragEvent e) {
faceSet = e.getIndexedFaceSet();
points=new double[faceSet.getNumPoints()][];
points = faceSet.getVertexAttributes(Attribute.COORDINATES).toDoubleArrayArray(null);
}
Code: Select all
public void faceClickedStart(FaceClickedEvent e) {
faceSet = e.getIndexedFaceSet();
Color[] colors = faceSet.getFaceAttributes(Attribute.COLORS); // But at runtime this returns null!
}
Thanks so much!