use of gaiasky.scenegraph.particle.IParticleRecord in project gaiasky by langurmonkey.
the class StarGroup method renderCloseupStar.
private void renderCloseupStar(int idx, float fovFactor, Vector3d cPosD, ExtShaderProgram shader, IntMesh mesh, double thPointTimesFovFactor, double thUpOverFovFactor, double thDownOverFovFactor, float alpha) {
if (filter(idx) && isVisible(idx)) {
IParticleRecord star = pointData.get(idx);
double varScl = getVariableSizeScaling(idx);
double sizeOriginal = getSize(idx);
double size = sizeOriginal * varScl;
double radius = size * Constants.STAR_SIZE_FACTOR;
Vector3d starPos = fetchPosition(star, cPosD, D31.get(), currDeltaYears);
double distToCamera = starPos.len();
double viewAngle = (sizeOriginal * Constants.STAR_SIZE_FACTOR / distToCamera) / fovFactor;
Color.abgr8888ToColor(c, getColor(idx));
if (viewAngle >= thPointTimesFovFactor) {
double fuzzySize = getFuzzyRenderSize(sizeOriginal, radius, distToCamera, viewAngle, thDownOverFovFactor, thUpOverFovFactor);
Vector3 pos = starPos.put(F33.get());
shader.setUniformf("u_pos", pos);
shader.setUniformf("u_size", (float) fuzzySize);
shader.setUniformf("u_color", c.r, c.g, c.b, alpha);
shader.setUniformf("u_distance", (float) distToCamera);
shader.setUniformf("u_apparent_angle", (float) (viewAngle * Settings.settings.scene.star.pointSize));
shader.setUniformf("u_radius", (float) radius);
// Sprite.render
mesh.render(shader, GL20.GL_TRIANGLES, 0, 6);
}
}
}
use of gaiasky.scenegraph.particle.IParticleRecord in project gaiasky by langurmonkey.
the class MilkyWay method transformData.
private void transformData() {
// Set static coordinates to position
coordinates.getEquatorialCartesianCoordinates(null, pos);
// Initialise transform
if (transformName != null) {
Class<Coordinates> c = Coordinates.class;
try {
Method m = ClassReflection.getMethod(c, transformName);
Matrix4d trf = (Matrix4d) m.invoke(null);
coordinateSystem = trf.putIn(new Matrix4());
} catch (ReflectionException e) {
Logger.getLogger(this.getClass()).error("Error getting/invoking method Coordinates." + transformName + "()");
}
} else {
// Equatorial, nothing
}
// Model
Vector3 aux = new Vector3();
Vector3 pos3 = pos.toVector3();
// Transform all
for (BillboardDataset bd : datasets) {
List<IParticleRecord> a = bd.data;
if (a != null) {
for (int i = 0; i < a.size(); i++) {
IParticleRecord pr = a.get(i);
aux.set((float) pr.x(), (float) pr.z(), (float) pr.y());
aux.scl(size).rotate(-90, 0, 1, 0).mul(coordinateSystem).add(pos3);
pr.setPos(aux.x, aux.y, aux.z);
}
}
}
}
use of gaiasky.scenegraph.particle.IParticleRecord in project gaiasky by langurmonkey.
the class DatasetPreferencesWindow method generateFilterTable.
private void generateFilterTable(Filter filter) {
float minSelectWidth = 160f;
filterTable.clearChildren();
if (filter != null && filter.hasRules()) {
// Operation
OwnSelectBox<String> operation = new OwnSelectBox<>(skin);
operation.setWidth(minSelectWidth);
operation.setItems("and", "or", "xor");
operation.setSelected(filter.getOperationString().toLowerCase());
operation.addListener(event -> {
if (event instanceof ChangeEvent) {
String newOp = operation.getSelected();
filter.setOperation(newOp);
filterEdited = true;
return true;
}
return false;
});
filterTable.add(new OwnLabel(I18n.txt("gui.dataset.filter.operation"), skin)).left().padRight(pad10 * 2f).padBottom(pad10);
filterTable.add(operation).left().expandX().padBottom(pad10).row();
// Rules
Array<FilterRule> rules = filter.getRules();
Table rulesTable = new Table(skin);
filterTable.add(rulesTable).colspan(2);
for (FilterRule rule : rules) {
// UNIT
OwnLabel unit = new OwnLabel(rule.getAttribute().getUnit(), skin);
// ATTRIBUTE
boolean stars = ci.object instanceof StarGroup || ci.object instanceof OctreeWrapper;
Array<AttributeComboBoxBean> attrs = new Array<>(false, stars ? 12 : 7);
// Add particle attributes (dist, alpha, delta)
attrs.add(new AttributeComboBoxBean(new AttributeDistance()));
attrs.add(new AttributeComboBoxBean(new AttributeRA()));
attrs.add(new AttributeComboBoxBean(new AttributeDEC()));
attrs.add(new AttributeComboBoxBean(new AttributeEclLatitude()));
attrs.add(new AttributeComboBoxBean(new AttributeEclLongitude()));
attrs.add(new AttributeComboBoxBean(new AttributeGalLatitude()));
attrs.add(new AttributeComboBoxBean(new AttributeGalLongitude()));
if (stars) {
// Star-only attributes (appmag, absmag, mualpha, mudelta, radvel)
attrs.add(new AttributeComboBoxBean(new AttributeAppmag()));
attrs.add(new AttributeComboBoxBean(new AttributeAbsmag()));
attrs.add(new AttributeComboBoxBean(new AttributeMualpha()));
attrs.add(new AttributeComboBoxBean(new AttributeMudelta()));
attrs.add(new AttributeComboBoxBean(new AttributeRadvel()));
}
// Colors
attrs.add(new AttributeComboBoxBean(new AttributeColorRed()));
attrs.add(new AttributeComboBoxBean(new AttributeColorGreen()));
attrs.add(new AttributeComboBoxBean(new AttributeColorBlue()));
// Extra attributes
if (ci.object instanceof ParticleGroup) {
ParticleGroup pg = (ParticleGroup) ci.object;
if (pg.size() > 0) {
IParticleRecord first = pg.get(0);
if (first.hasExtra()) {
ObjectDoubleMap.Keys<UCD> ucds = first.extraKeys();
for (UCD ucd : ucds) attrs.add(new AttributeComboBoxBean(new AttributeUCD(ucd)));
}
}
}
OwnSelectBox<AttributeComboBoxBean> attribute = new OwnSelectBox<>(skin);
attribute.setItems(attrs);
attribute.setSelected(getAttributeBean(rule.getAttribute(), attrs));
attribute.addListener(event -> {
if (event instanceof ChangeEvent) {
IAttribute newAttr = attribute.getSelected().attr;
rule.setAttribute(newAttr);
// Update unit
unit.setText(newAttr.getUnit());
filterEdited = true;
return true;
}
return false;
});
rulesTable.add(attribute).left().padRight(pad10).padBottom(pad5);
// COMPARATOR
String[] cmps = new String[] { "<", "<=", ">", ">=", "==", "!=" };
OwnSelectBox<String> comparator = new OwnSelectBox<>(skin);
comparator.setWidth(minSelectWidth);
comparator.setItems(cmps);
comparator.setSelected(rule.getComparator().toString());
comparator.addListener(event -> {
if (event instanceof ChangeEvent) {
IComparator newComp = rule.getComparatorFromString(comparator.getSelected());
rule.setComparator(newComp);
filterEdited = true;
return true;
}
return false;
});
rulesTable.add(comparator).left().padRight(pad10).padBottom(pad5);
// VALUE
FloatValidator fval = new FloatValidator(-Float.MAX_VALUE, Float.MAX_VALUE);
OwnTextField value = new OwnTextField(Double.toString(rule.getValue()), skin, fval);
value.addListener(event -> {
if (event instanceof ChangeEvent) {
if (value.isValid()) {
try {
rule.setValue(Float.parseFloat(value.getText()));
filterEdited = true;
return true;
} catch (Exception e) {
logger.error(e);
return false;
}
}
return false;
}
return false;
});
rulesTable.add(value).left().padRight(pad10).padBottom(pad5);
// UNIT
rulesTable.add(unit).left().padRight(pad10 * 3f).padBottom(pad5);
// RUBBISH
OwnTextIconButton rubbish = new OwnTextIconButton("", skin, "rubbish");
rubbish.addListener(new OwnTextTooltip(I18n.txt("gui.tooltip.dataset.filter.rule.remove"), skin));
rubbish.addListener(event -> {
if (event instanceof ChangeEvent) {
deleteRule(filter, rule);
filterEdited = true;
return true;
}
return false;
});
rulesTable.add(rubbish).left().padBottom(pad5).row();
}
// New rule button
OwnTextIconButton addRule = new OwnTextIconButton(I18n.txt("gui.dataset.filter.rule.add"), skin, "add");
addRule.addListener(new OwnTextTooltip(I18n.txt("gui.tooltip.dataset.filter.rule.add"), skin));
addRule.pad(pad10);
rulesTable.add(addRule).left().padTop(pad10).row();
addRule.addListener(event -> {
if (event instanceof ChangeEvent) {
dpw.addRule(filter);
filterEdited = true;
return true;
}
return false;
});
} else {
// Add
filterTable.add(new OwnLabel(I18n.txt("gui.dataset.filter.nofilters"), skin)).left().padBottom(pad10).row();
OwnTextIconButton addFilter = new OwnTextIconButton(I18n.txt("gui.dataset.filter.add"), skin, "add");
addFilter.addListener(new OwnTextTooltip(I18n.txt("gui.tooltip.dataset.filter.add"), skin));
addFilter.pad(pad10);
filterTable.add(addFilter).left().padBottom(pad5).row();
addFilter.addListener(event -> {
if (event instanceof ChangeEvent) {
dpw.addFilter();
filterEdited = true;
return true;
}
return false;
});
}
pack();
}
Aggregations