Commit 1cab3496 authored by Bartosz Borucki's avatar Bartosz Borucki

Merge branch 'InterpolateToRegularMesh' into 'develop'

interpolate to regular mesh new version

See merge request !71
parents 1b9dc54f 97f85783
Pipeline #30938132 passed with stage
in 0 seconds
This diff is collapsed.
......@@ -40,6 +40,7 @@
<core package="pl.edu.icm.visnow.lib.basic.testdata.TestIrregularFieldFlow"/>
<core package="pl.edu.icm.visnow.lib.basic.testdata.ColorCube"/>
<core package="pl.edu.icm.visnow.lib.basic.testdata.VNLogo"/>
<core package="pl.edu.icm.visnow.geometries.interactiveGlyphs.TestInteractiveGlyph"/>
</folder>
<folder name="utilities" autohelpfile="pl.edu.icm.visnow.lib.basic.utilities.help_folder.html" autosort="yes">
<core package="pl.edu.icm.visnow.lib.basic.filters.FieldCombiner"/>
......@@ -66,6 +67,7 @@
<core package="pl.edu.icm.visnow.lib.basic.filters.RegularToIrregularField"/>
<core package="pl.edu.icm.visnow.lib.basic.filters.Triangulation"/>
<core package="pl.edu.icm.visnow.lib.basic.filters.Boundaries"/>
<core package="pl.edu.icm.visnow.lib.basic.filters.ConvexHull"/>
<core package="pl.edu.icm.visnow.lib.basic.filters.ClearMaskedOutNodes"/>
<core package="pl.edu.icm.visnow.lib.basic.filters.GeometricCrop"/>
</folder>
......
......@@ -62,9 +62,6 @@ import pl.edu.icm.visnow.gui.widgets.SectionHeader;
*/
public class DataMappingGUI extends javax.swing.JPanel
{
private static final Logger LOGGER = Logger.getLogger(DataMappingGUI.class);
private boolean debug = VisNow.isDebug();
protected Field inField = null;
protected CellSet inCellSet = null;
protected DataMappingParams params = null;
......
......@@ -113,7 +113,7 @@
</Property>
<Property name="max" type="float" value="5.0"/>
<Property name="showingFields" type="boolean" value="false"/>
<Property name="val" type="float" value="1.5"/>
<Property name="val" type="float" value="1.2"/>
</Properties>
<Events>
<EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="sizeSliderStateChanged"/>
......
......@@ -76,13 +76,12 @@ public class FontGUI extends javax.swing.JPanel
{
this.params = params;
text2DGUI.setParams(params);
text2DGUI.setVisible(!params.isThreeDimensional());
qualitySlider.setVisible(params.isThreeDimensional());
}
public void setInitBrightness(float v)
{
// map.setMapIndex(ColorMapManager.COLORMAP1D_RGB);
// brightnessEditor.setRGBMap();
brightnessEditor.setValue(0);
brightnessEditor.setVisible(true);
colorEditor.setVisible(false);
......@@ -352,12 +351,14 @@ public class FontGUI extends javax.swing.JPanel
{//GEN-HEADEREND:event_glyph2DButtonActionPerformed
params.setThreeDimensional(glyph3DButton.isSelected());
text2DGUI.setVisible(!glyph3DButton.isSelected());
qualitySlider.setVisible(glyph3DButton.isSelected());
}//GEN-LAST:event_glyph2DButtonActionPerformed
private void glyph3DButtonActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_glyph3DButtonActionPerformed
{//GEN-HEADEREND:event_glyph3DButtonActionPerformed
params.setThreeDimensional(glyph3DButton.isSelected());
text2DGUI.setVisible(glyph2DButton.isSelected());
qualitySlider.setVisible(glyph3DButton.isSelected());
}//GEN-LAST:event_glyph3DButtonActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
......
......@@ -59,28 +59,30 @@ public class BoxGlyph extends Glyph
super(params);
setName("box glyph");
type = BOX;
glyphVerts = new float[]{-1, -1, -1, -1, -1, 1,
1, -1, -1, 1, -1, 1,
1, 1, -1, 1, 1, 1,
-1, 1, -1, -1, 1, 1,
-1, -1, -1, 1, -1, -1,
-1, 1, -1, 1, 1, -1,
-1, 1, 1, 1, 1, 1,
-1, -1, 1, 1, -1, 1,
-1, -1, -1, -1, 1, -1,
1, -1, -1, 1, 1, -1,
1, -1, 1, 1, 1, 1,
-1, -1, 1, -1, 1, 1};
glyphVerts = new float[]{-1, -1, -1, -1, -1, 1,
1, -1, -1, 1, -1, 1,
1, 1, -1, 1, 1, 1,
-1, 1, -1, -1, 1, 1,
-1, -1, -1, 1, -1, -1,
-1, 1, -1, 1, 1, -1,
-1, 1, 1, 1, 1, 1,
-1, -1, 1, 1, -1, 1,
-1, -1, -1, -1, 1, -1,
1, -1, -1, 1, 1, -1,
1, -1, 1, 1, 1, 1,
-1, -1, 1, -1, 1, 1};
visibleWidgets = U_ROT_VIS | V_ROT_VIS | W_ROT_VIS |
U_RANGE_VIS | V_RANGE_VIS | W_RANGE_VIS;
U_TRANS_VIS | V_TRANS_VIS | W_TRANS_VIS |
U_RANGE_VIS | V_RANGE_VIS | W_RANGE_VIS |
SCALE_VIS | VOLUME_VIS;
params.setVisibleWidgets(visibleWidgets);
lines = new IndexedLineArray(24, GeometryArray.COORDINATES | GeometryArray.COLOR_3, 24);
lines.setCoordinateIndices(0, new int[] { 0, 1, 2, 3, 4, 5, 6, 7,
8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23 });
16, 17, 18, 19, 20, 21, 22, 23,});
lines.setColorIndices(0, new int[] { 0, 0, 0, 0, 0, 0, 0, 0,
1, 1, 1, 1, 1, 1, 1, 1,
2, 2, 2, 2, 2, 2, 2, 2 });
2, 2, 2, 2, 2, 2, 2, 2});
lines.setCapability(GeometryArray.ALLOW_COORDINATE_READ);
lines.setCapability(GeometryArray.ALLOW_COORDINATE_WRITE);
lines.setCapability(GeometryArray.ALLOW_COLOR_READ);
......@@ -89,6 +91,8 @@ public class BoxGlyph extends Glyph
lines.setColors(0, lineColors);
lineShape.addGeometry(lines);
glyphGroup.addChild(lineShape);
reper = new Reper3D(params);
addChild(reper);
}
@Override
......@@ -96,23 +100,34 @@ public class BoxGlyph extends Glyph
{
for (int i = 0; i < 3; i++) {
float c = params.center[i];
float u = params.uScale * params.u[i];
float v = params.vScale * params.v[i];
float w = params.wScale * params.w[i];
float u0 = params.uRange[0] * params.u[i];
float u1 = params.uRange[1] * params.u[i];
float v0 = params.vRange[0] * params.v[i];
float v1 = params.vRange[1] * params.v[i];
float w0 = params.wRange[0] * params.w[i];
float w1 = params.wRange[1] * params.w[i];
glyphVerts[ i] = glyphVerts[24 + i] = glyphVerts[48 + i] = c - u - v - w;
glyphVerts[ 3 + i] = glyphVerts[42 + i] = glyphVerts[66 + i] = c - u - v + w;
glyphVerts[ i] = glyphVerts[24 + i] = glyphVerts[48 + i] = c + u0 + v0 + w0;
glyphVerts[ 3 + i] = glyphVerts[42 + i] = glyphVerts[66 + i] = c + u0 + v0 + w1;
glyphVerts[ 6 + i] = glyphVerts[27 + i] = glyphVerts[54 + i] = c + u - v - w;
glyphVerts[ 9 + i] = glyphVerts[45 + i] = glyphVerts[60 + i] = c + u - v + w;
glyphVerts[ 6 + i] = glyphVerts[27 + i] = glyphVerts[54 + i] = c + u1 + v0 + w0;
glyphVerts[ 9 + i] = glyphVerts[45 + i] = glyphVerts[60 + i] = c + u1 + v0 + w1;
glyphVerts[12 + i] = glyphVerts[33 + i] = glyphVerts[57 + i] = c + u + v - w;
glyphVerts[15 + i] = glyphVerts[39 + i] = glyphVerts[63 + i] = c + u + v + w;
glyphVerts[12 + i] = glyphVerts[33 + i] = glyphVerts[57 + i] = c + u1 + v1 + w0;
glyphVerts[15 + i] = glyphVerts[39 + i] = glyphVerts[63 + i] = c + u1 + v1 + w1;
glyphVerts[18 + i] = glyphVerts[30 + i] = glyphVerts[51 + i] = c - u + v - w;
glyphVerts[21 + i] = glyphVerts[36 + i] = glyphVerts[69 + i] = c - u + v + w;
}
glyphVerts[18 + i] = glyphVerts[30 + i] = glyphVerts[51 + i] = c + u0 + v1 + w0;
glyphVerts[21 + i] = glyphVerts[36 + i] = glyphVerts[69 + i] = c + u0 + v1 + w1;
}
lines.setCoordinates(0, glyphVerts);
lines.setColors(0, lineColors);
float s = params.getScale();
if (showReper && reper.getParent() == null)
addChild(reper);
if (!showReper && reper.getParent() != null)
removeChild(reper);
if (reper.getParent() != null)
reper.update(new float[] {s, s, s});
}
}
......@@ -115,8 +115,8 @@ public class CircleGlyph extends Glyph
for (int i = 0; i < 3; i++) {
float c = params.center[i];
float u = params.scale * params.u[i];
float v = params.scale * params.v[i];
float u = params.glyphDim * params.u[i];
float v = params.glyphDim * params.v[i];
glyphVerts[12 * LOD + 3 + i] = c - u;
glyphVerts[12 * LOD + 6 + i] = c + u;
......
......@@ -80,6 +80,7 @@ abstract public class Glyph extends OpenBranchGroup
protected float[] lineColors = {0, .6f, .6f, .6f, .6f, 0, .6f, 0, .6f};
protected int visibleWidgets = W_ROT_VIS;
protected boolean useRadius = false;
protected boolean showReper = true;
abstract public void update();
......@@ -99,7 +100,7 @@ abstract public class Glyph extends OpenBranchGroup
lineApp.setColoringAttributes(colorAttr);
lineShape.setAppearance(lineApp);
transpAttr.setTransparencyMode(TransparencyAttributes.NICEST);
transpAttr.setTransparency(.8f);
transpAttr.setTransparency(.6f);
surfApp.setTransparencyAttributes(transpAttr);
addChild(glyphGroup);
}
......@@ -127,6 +128,11 @@ abstract public class Glyph extends OpenBranchGroup
{
return type;
}
public void setShowReper(boolean showReper) {
this.showReper = showReper;
update();
}
public void setParams(InteractiveGlyphParams params)
{
......
......@@ -118,7 +118,7 @@ public class InteractiveGlyph extends OpenBranchGroup
{
switch (type) {
case PLANE:
glyph = new PlaneGlyph(params, forceUseRadius);
glyph = new PlaneGlyph(params);
break;
case SPHERE:
glyph = new SphereGlyph(params);
......@@ -275,26 +275,29 @@ public class InteractiveGlyph extends OpenBranchGroup
{
float[] boxVerts;
float[] center = params.getCenter();
float[][] v = new float[3][3];
float[][][] v = new float[2][3][3];
for (int i = 0; i < 3; i++) {
v[0][i] = params.getuScale() * params.getU()[i];
v[1][i] = params.getvScale() * params.getV()[i];
v[2][i] = params.getwScale() * params.getW()[i];
v[0][0][i] = params.getuRange()[0] * params.getU()[i];
v[0][1][i] = params.getvRange()[0] * params.getV()[i];
v[0][2][i] = params.getwRange()[0] * params.getW()[i];
v[1][0][i] = params.getuRange()[1] * params.getU()[i];
v[1][1][i] = params.getvRange()[1] * params.getV()[i];
v[1][2][i] = params.getwRange()[1] * params.getW()[i];
}
if (trueDim == 3) {
boxVerts = new float[24];
for (int i = -1, m = 0; i < 2; i += 2)
for (int j = -1; j < 2; j+= 2)
for (int k = -1; k < 2; k += 2)
for (int i = 0, m = 0; i < 2; i++)
for (int j = 0; j < 2; j++)
for (int k = 0; k < 2; k++)
for (int l = 0; l < 3; l++, m++)
boxVerts[m] = center[l] + i * v[2][l] + j * v[1][l] + k * v[0][l];
boxVerts[m] = center[l] + v[i][0][l] + v[j][1][l] + v[k][2][l];
}
else {
boxVerts = new float[12];
for (int i = -1, m = 0; i < 2; i += 2)
for (int j = -1; j < 2; j+= 2)
for (int l = 0; l < 3; l++, m++)
boxVerts[m] = center[l] + i * v[1][l] + j * v[0][l];
for (int i = 0, m = 0; i < 2; i++)
for (int j = 0; j < 2; j++)
for (int l = 0; l < 3; l++, m++)
boxVerts[m] = center[l] + v[i][0][l] + v[j][1][l];
}
return boxVerts;
}
......
......@@ -61,7 +61,7 @@ public class LineGlyph extends Glyph
U_TRANS_VIS | V_TRANS_VIS | W_TRANS_VIS |
SCALE_VIS | AXES_VIS;
params.setVisibleWidgets(visibleWidgets);
reper = new Reper(params);
reper = new Reper3D(params);
addChild(reper);
}
......@@ -72,12 +72,12 @@ public class LineGlyph extends Glyph
setName("line glyph");
visibleWidgets = useRadius ? U_ROT_VIS | V_ROT_VIS | W_ROT_VIS |
U_TRANS_VIS | V_TRANS_VIS | W_TRANS_VIS |
SCALE_VIS | AXES_VIS | RADIUS_VIS
SCALE_VIS | AXES_VIS | RADIUS_VIS
: U_ROT_VIS | V_ROT_VIS | W_ROT_VIS |
U_TRANS_VIS | V_TRANS_VIS | W_TRANS_VIS |
SCALE_VIS | AXES_VIS;
params.setVisibleWidgets(visibleWidgets);
reper = new Reper(params);
reper = new Reper3D(params);
addChild(reper);
}
......@@ -90,9 +90,8 @@ public class LineGlyph extends Glyph
@Override
public void update()
{
float s = params.scale;
reper.update(params.center, .3f * s, .3f * s, s,
params.u, params.v, params.w);
float s = params.getScale();
reper.update(new float[]{.3f * s, .3f * s, s});
}
}
......@@ -121,8 +121,8 @@ public class PlanarLineGlyph extends Glyph
lineColors[3 * i + j] = currentColors[i + 1][j];
for (int i = 0; i < 3; i++) {
float c = params.center[i];
float u = params.scale * params.u[i];
float v = params.scale * params.v[i];
float u = params.glyphDim * params.u[i];
float v = params.glyphDim * params.v[i];
glyphVerts[i] = c - u;
glyphVerts[3 + i] = c + u;
......
......@@ -41,6 +41,7 @@
package pl.edu.icm.visnow.geometries.interactiveGlyphs;
import javax.media.j3d.GeometryArray;
import javax.media.j3d.IndexedLineArray;
import javax.media.j3d.IndexedQuadArray;
import static pl.edu.icm.visnow.geometries.interactiveGlyphs.InteractiveGlyph.GlyphType.PLANE;
import static pl.edu.icm.visnow.geometries.interactiveGlyphs.InteractiveGlyphParams.*;
......@@ -61,51 +62,19 @@ public class PlaneGlyph extends Glyph
public PlaneGlyph(InteractiveGlyphParams params)
{
super(params);
reper = new Reper(params);
reper = new Reper3D(params);
type = PLANE;
setName("plane glyph");
params.setRadiusSliderTitle("planar area dimension (in % of field size)");
visibleWidgets = U_ROT_VIS | V_ROT_VIS | W_ROT_VIS |
U_TRANS_VIS | V_TRANS_VIS | W_TRANS_VIS |
U_RANGE_VIS | V_RANGE_VIS |
SCALE_VIS | AXES_VIS;
params.setVisibleWidgets(visibleWidgets);
glyphVerts = new float[] {-1, -1, 0,
1, -1, 0,
1, 1, 0,
-1, 1, 0,
0, 0, 0,
0, 0, 1.5f};
glyphRects = new IndexedQuadArray(4, GeometryArray.COORDINATES, 4);
glyphRects.setCoordinateIndices(0, new int[] {0, 1, 2, 3});
glyphRects.setCapability(GeometryArray.ALLOW_COORDINATE_READ);
glyphRects.setCapability(GeometryArray.ALLOW_COORDINATE_WRITE);
glyphRects.setCoordinates(0, planeVerts);
surfShape.setAppearance(surfApp);
surfShape.addGeometry(glyphRects);
glyphGroup.addChild(surfShape);
currentColors = params.getCurrentColors();
addChild(reper);
}
public PlaneGlyph(InteractiveGlyphParams params, boolean useRadius)
{
super(params, useRadius);
reper = new Reper(params);
type = PLANE;
setName("plane glyph");
visibleWidgets = useRadius ? U_ROT_VIS | V_ROT_VIS | W_ROT_VIS |
U_TRANS_VIS | V_TRANS_VIS | W_TRANS_VIS |
SCALE_VIS | AXES_VIS | RADIUS_VIS
: U_ROT_VIS | V_ROT_VIS | W_ROT_VIS |
U_TRANS_VIS | V_TRANS_VIS | W_TRANS_VIS |
SCALE_VIS | AXES_VIS;
params.setVisibleWidgets(visibleWidgets);
glyphVerts = new float[] {-1, -1, 0,
1, -1, 0,
1, 1, 0,
-1, 1, 0,
0, 0, 0,
0, 0, 1.5f};
glyphVerts = new float[] {-1, -1, 0, -1, 1, 0,
1, -1, 0, 1, 1, 0,
-1, -1, 0, 1, -1, 0,
-1, 1, 0, 1, 1, 0};
glyphRects = new IndexedQuadArray(4, GeometryArray.COORDINATES, 4);
glyphRects.setCoordinateIndices(0, new int[] {0, 1, 2, 3});
glyphRects.setCapability(GeometryArray.ALLOW_COORDINATE_READ);
......@@ -114,6 +83,17 @@ public class PlaneGlyph extends Glyph
surfShape.setAppearance(surfApp);
surfShape.addGeometry(glyphRects);
glyphGroup.addChild(surfShape);
lines = new IndexedLineArray(8, GeometryArray.COORDINATES | GeometryArray.COLOR_3, 8);
lines.setCoordinateIndices(0, new int[] { 0, 1, 2, 3, 4, 5, 6, 7});
lines.setColorIndices(0, new int[] { 2, 2, 2, 2, 1, 1, 1, 1});
lines.setCapability(GeometryArray.ALLOW_COORDINATE_READ);
lines.setCapability(GeometryArray.ALLOW_COORDINATE_WRITE);
lines.setCapability(GeometryArray.ALLOW_COLOR_READ);
lines.setCapability(GeometryArray.ALLOW_COLOR_WRITE);
lines.setCoordinates(0, glyphVerts);
lines.setColors(0, lineColors);
lineShape.addGeometry(lines);
glyphGroup.addChild(lineShape);
currentColors = params.getCurrentColors();
addChild(reper);
}
......@@ -129,20 +109,23 @@ public class PlaneGlyph extends Glyph
{
for (int i = 0; i < 3; i++) {
float c = params.center[i];
float u = params.scale * params.u[i];
float v = params.scale * params.v[i];
if (useRadius) {
u = params.radius * params.u[i];
v = params.radius * params.v[i];
}
planeVerts[i] = c - u - v;
planeVerts[3 + i] = c + u - v;
planeVerts[6 + i] = c + u + v;
planeVerts[9 + i] = c - u + v;
float u0 = params.uRange[0] * params.u[i];
float u1 = params.uRange[1] * params.u[i];
float v0 = params.vRange[0] * params.v[i];
float v1 = params.vRange[1] * params.v[i];
planeVerts[i] = c + u0 + v0;
planeVerts[3 + i] = c + u1 + v0;
planeVerts[6 + i] = c + u1 + v1;
planeVerts[9 + i] = c + u0 + v1;
glyphVerts[ i] = glyphVerts[12 + i] = c + u0 + v0;
glyphVerts[ 3 + i] = glyphVerts[18 + i] = c + u0 + v1;
glyphVerts[ 6 + i] = glyphVerts[15 + i] = c + u1 + v0;
glyphVerts[ 9 + i] = glyphVerts[21 + i] = c + u1 + v1;
}
glyphRects.setCoordinates(0, planeVerts);
float s = params.scale;
reper.update(params.center, .3f * s, .3f * s, .6f * s,
params.u, params.v, params.w);
lines.setCoordinates(0, glyphVerts);
float s = params.getScale();
reper.update(new float[]{.3f * s, .3f * s, s});
}
}
......@@ -40,8 +40,6 @@
package pl.edu.icm.visnow.geometries.interactiveGlyphs;
import javax.media.j3d.GeometryArray;
import javax.media.j3d.IndexedLineArray;
import static pl.edu.icm.visnow.geometries.interactiveGlyphs.InteractiveGlyph.GlyphType.POINT;
import static pl.edu.icm.visnow.geometries.interactiveGlyphs.InteractiveGlyphParams.*;
......@@ -62,7 +60,7 @@ public class PointGlyph extends Glyph
visibleWidgets = U_ROT_VIS | V_ROT_VIS | W_ROT_VIS |
U_TRANS_VIS | V_TRANS_VIS | W_TRANS_VIS |
SCALE_VIS;
reper = new Reper(params);
reper = new Reper3D(params);
addChild(reper);
params.setVisibleWidgets(visibleWidgets);
}
......@@ -70,8 +68,6 @@ public class PointGlyph extends Glyph
@Override
public final void update()
{
float s = .3f * params.scale;
reper.update(params.center, s, s, s,
params.u, params.v, params.w);
reper.update();
}
}
......@@ -60,7 +60,10 @@ public class RectangleGlyph extends Glyph
super(params);
type = RECTANGLE;
setName("rectangle glyph");
visibleWidgets = W_ROT_VIS | U_RANGE_VIS | V_RANGE_VIS;
visibleWidgets = W_ROT_VIS |
U_TRANS_VIS | V_TRANS_VIS |
U_RANGE_VIS | V_RANGE_VIS |
SCALE_VIS | VOLUME_VIS;
params.setVisibleWidgets(visibleWidgets);
glyphVerts = new float[] {-1, -1, 0, -1, 1, 0,
1, -1, 0, 1, 1, 0,
......@@ -77,6 +80,8 @@ public class RectangleGlyph extends Glyph
lines.setColors(0, lineColors);
lineShape.addGeometry(lines);
glyphGroup.addChild(lineShape);
reper = new Reper2D(params);
addChild(reper);
}
@Override
......@@ -84,15 +89,26 @@ public class RectangleGlyph extends Glyph
{
for (int i = 0; i < 2; i++) {
float c = params.center[i];
float u = params.uScale * params.u[i];
float v = params.vScale * params.v[i];
glyphVerts[ i] = glyphVerts[12 + i] = c - u - v;
glyphVerts[ 3 + i] = glyphVerts[18 + i] = c - u + v;
glyphVerts[ 6 + i] = glyphVerts[15 + i] = c + u - v;
glyphVerts[ 9 + i] = glyphVerts[21 + i] = c + u + v;
float u0 = params.uRange[0] * params.u[i];
float u1 = params.uRange[1] * params.u[i];
float v0 = params.vRange[0] * params.v[i];
float v1 = params.vRange[1] * params.v[i];
glyphVerts[ i] = glyphVerts[12 + i] = c + u0 + v0;
glyphVerts[ 3 + i] = glyphVerts[18 + i] = c + u0 + v1;
glyphVerts[ 6 + i] = glyphVerts[15 + i] = c + u1 + v0;
glyphVerts[ 9 + i] = glyphVerts[21 + i] = c + u1 + v1;
System.arraycopy(currentColors[2 - i], 0, lineColors, 3 * i, 3);
}
lines.setCoordinates(0, glyphVerts);
lines.setColors(0, lineColors);
float s = params.getScale();
if (showReper && reper.getParent() == null)
addChild(reper);
if (!showReper && reper.getParent() != null)
removeChild(reper);
if (reper.getParent() != null)
reper.update(new float[] {s, s, s});
}
}
......@@ -40,7 +40,6 @@
package pl.edu.icm.visnow.geometries.interactiveGlyphs;
import javax.media.j3d.GeometryArray;
import javax.media.j3d.IndexedLineStripArray;
import pl.edu.icm.visnow.geometries.objects.generics.OpenBranchGroup;
import pl.edu.icm.visnow.geometries.objects.generics.OpenShape3D;
......@@ -51,40 +50,28 @@ import pl.edu.icm.visnow.geometries.objects.generics.OpenShape3D;
* Warsaw University, Interdisciplinary Centre
* for Mathematical and Computational Modelling)
*/
public class Reper extends OpenBranchGroup
abstract public class Reper extends OpenBranchGroup
{
protected IndexedLineStripArray glyphLines =
new IndexedLineStripArray(15,
GeometryArray.COORDINATES | GeometryArray.COLOR_3,
18, new int[] {3, 3, 3, 3, 3, 3});
protected OpenShape3D lineShape = new OpenShape3D("lines");
protected float[] glyphVerts = new float[45];
protected InteractiveGlyphParams params;
protected IndexedLineStripArray glyphLines;
protected OpenShape3D lineShape = new OpenShape3D("lines");
protected float[] scale;
protected float[] glyphVerts;
protected float[][] currentColors = InteractiveGlyphParams.LIGHT_COLORS;
protected float[] lineColors = {0, .6f, .6f, .6f, .6f, 0, .6f, 0, .6f};
public Reper(InteractiveGlyphParams params)
{
super();
glyphVerts = new float[45];
update(new float[]{0, 0, 0}, 1, 1, 1,
new float[]{1, 0, 0}, new float[]{0, 1, 0}, new float[]{0, 0, 1});
glyphLines.setCoordinateIndices(0, new int[] {0, 1, 2, 3, 1, 4,
5, 6, 7, 8, 6, 9,
10, 11, 12, 13, 11, 14});
glyphLines.setColorIndices(0, new int[] {0, 0, 0, 0, 0, 0,
1, 1, 1, 1, 1, 1,
2, 2, 2, 2, 2, 2});
glyphLines.setCapability(GeometryArray.ALLOW_COORDINATE_READ);
glyphLines.setCapability(GeometryArray.ALLOW_COORDINATE_WRITE);
glyphLines.setCapability(GeometryArray.ALLOW_COLOR_READ);
glyphLines.setCapability(GeometryArray.ALLOW_COLOR_WRITE);
glyphLines.setCoordinates(0, glyphVerts);
glyphLines.setColors(0, lineColors);
lineShape.addGeometry(glyphLines);
addChild(lineShape);
currentColors = params.getCurrentColors();
for (int i = 0; i < 3; i++)
System.arraycopy(currentColors[(i + 1) % 3], 0, lineColors, 3 * i, 3);
this.params = params;
scale = new float[] {1, 1, 1};
}
public Reper(InteractiveGlyphParams params, float[] scale)
{
super();
this.params = params;
this.scale = scale;
}
public void updateColors(float[][] currentColors)
......@@ -93,32 +80,10 @@ public class Reper extends OpenBranchGroup
System.arraycopy(currentColors[(i + 1) % 3], 0, lineColors, 3 * i, 3);
}
private void addArrow(float[] center, float scale,
float[] uu, float[] vv, float[] ww, int s)
{
float t = (float)Math.sqrt(3) * .05f;
for (int i = 0; i < 3; i++) {
float c = center[i];
float u = scale * uu[i];
float v = scale * vv[i];
float w = scale * ww[i];
glyphVerts[s + i] = c - u;
glyphVerts[s + 3 + i] = c + u;
glyphVerts[s + 6 + i] = c + .85f * u + .07f * v;
glyphVerts[s + 9 + i] = c + .85f * u - .035f * v - t * w;
glyphVerts[s + 12 + i] = c + .85f * u - .035f * v + t * w;