use of gaiasky.util.CatalogInfo in project gaiasky by langurmonkey.
the class GenericCatalog method initialize.
public void initialize(boolean dataLoad, boolean createCatalogInfo) {
super.initialize();
// Load data
try {
String dsName = this.getName();
// Load data and add
if (dataLoad) {
Class<?> clazz = Class.forName(provider);
ISceneGraphLoader provider = (ISceneGraphLoader) clazz.getConstructor().newInstance();
if (datafile != null)
provider.initialize(new String[] { datafile });
else if (ds != null)
provider.initialize(ds);
provider.setName(dsName);
objects = provider.loadData();
objects.forEach(object -> {
object.setParent(dsName);
object.setColor(this.cc);
object.setLabelcolor(this.labelcolor != null ? this.labelcolor.clone() : this.cc.clone());
object.initialize();
});
}
// Create catalog info
if (createCatalogInfo) {
if (catalogInfo == null) {
catalogInfo = new CatalogInfo(dsName, description, null, CatalogInfoSource.INTERNAL, 1f, this);
}
EventManager.publish(Event.CATALOG_ADD, this, catalogInfo, false);
}
} catch (Exception e) {
Logger.getLogger(this.getClass()).error(e);
}
}
use of gaiasky.util.CatalogInfo in project gaiasky by langurmonkey.
the class SearchDialog method checkString.
private boolean checkString(String text, ISceneGraph sg) {
try {
if (sg.containsNode(text)) {
SceneGraphNode node = sg.getNode(text);
if (node instanceof IFocus) {
IFocus focus = ((IFocus) node).getFocus(text);
boolean timeOverflow = focus.isCoordinatesTimeOverflow();
boolean canSelect = !(focus instanceof ParticleGroup) || ((ParticleGroup) focus).canSelect();
boolean ctOn = GaiaSky.instance.isOn(focus.getCt());
Optional<CatalogInfo> ci = GaiaSky.instance.getCatalogInfoFromObject(node);
boolean datasetVisible = ci.isEmpty() || ci.get().isVisible(true);
if (!timeOverflow && canSelect && ctOn && datasetVisible) {
GaiaSky.postRunnable(() -> {
EventManager.publish(Event.CAMERA_MODE_CMD, this, CameraMode.FOCUS_MODE, true);
EventManager.publish(Event.FOCUS_CHANGE_CMD, this, focus, true);
});
info(null);
} else if (timeOverflow) {
info(I18n.txt("gui.objects.search.timerange", text));
} else if (!canSelect) {
info(I18n.txt("gui.objects.search.filter", text));
} else if (!datasetVisible) {
info(I18n.txt("gui.objects.search.dataset.invisible", text, ci.get().name));
} else {
info(I18n.txt("gui.objects.search.invisible", text, focus.getCt().toString()));
}
return true;
}
} else {
info(null);
}
} catch (Exception e) {
logger.error(e);
}
return false;
}
use of gaiasky.util.CatalogInfo in project gaiasky by langurmonkey.
the class OrbitalElementsGroupRenderSystem method renderStud.
@Override
public void renderStud(Array<IRenderable> renderables, ICamera camera, double t) {
for (IRenderable renderable : renderables) {
OrbitalElementsGroup oeg = (OrbitalElementsGroup) renderable;
if (!inGpu(oeg)) {
int n = oeg.children.size;
int offset = addMeshData(n * 4, n * 6);
setOffset(oeg, offset);
curr = meshes.get(offset);
ensureTempVertsSize(n * 4 * curr.vertexSize);
ensureTempIndicesSize(n * 6);
AtomicInteger numVerticesAdded = new AtomicInteger(0);
AtomicInteger numParticlesAdded = new AtomicInteger(0);
CatalogInfo ci = oeg.getCatalogInfo();
Array<SceneGraphNode> children = oeg.children;
children.forEach(child -> {
Orbit orbit = (Orbit) child;
OrbitComponent oc = orbit.oc;
// 4 vertices per particle
for (int vert = 0; vert < 4; vert++) {
// Vertex POSITION
tempVerts[curr.vertexIdx + posOffset] = vertPos[vert].getFirst();
tempVerts[curr.vertexIdx + posOffset + 1] = vertPos[vert].getSecond();
// UV coordinates
tempVerts[curr.vertexIdx + uvOffset] = vertUV[vert].getFirst();
tempVerts[curr.vertexIdx + uvOffset + 1] = vertUV[vert].getSecond();
// COLOR
float[] c = oeg.isHighlighted() && ci != null ? ci.getHlColor() : orbit.pointColor;
tempVerts[curr.vertexIdx + curr.colorOffset] = Color.toFloatBits(c[0], c[1], c[2], c[3]);
// ORBIT ELEMENTS 01
tempVerts[curr.vertexIdx + elems01Offset] = (float) Math.sqrt(oc.mu / Math.pow(oc.semimajoraxis * 1000d, 3d));
tempVerts[curr.vertexIdx + elems01Offset + 1] = (float) oc.epoch;
// In metres
tempVerts[curr.vertexIdx + elems01Offset + 2] = (float) (oc.semimajoraxis * 1000d);
tempVerts[curr.vertexIdx + elems01Offset + 3] = (float) oc.e;
// ORBIT ELEMENTS 02
tempVerts[curr.vertexIdx + elems02Offset] = (float) (oc.i * MathUtilsd.degRad);
tempVerts[curr.vertexIdx + elems02Offset + 1] = (float) (oc.ascendingnode * MathUtilsd.degRad);
tempVerts[curr.vertexIdx + elems02Offset + 2] = (float) (oc.argofpericenter * MathUtilsd.degRad);
tempVerts[curr.vertexIdx + elems02Offset + 3] = (float) (oc.meananomaly * MathUtilsd.degRad);
// SIZE
tempVerts[curr.vertexIdx + sizeOffset] = orbit.pointSize * (oeg.isHighlighted() && ci != null ? ci.hlSizeFactor : 1);
curr.vertexIdx += curr.vertexSize;
curr.numVertices++;
numVerticesAdded.incrementAndGet();
}
// Indices
quadIndices(curr);
numParticlesAdded.incrementAndGet();
setInGpu(orbit, true);
});
int count = numVerticesAdded.get() * curr.vertexSize;
setCount(oeg, count);
curr.mesh.setVertices(tempVerts, 0, count);
curr.mesh.setIndices(tempIndices, 0, numParticlesAdded.get() * 6);
setInGpu(oeg, true);
}
curr = meshes.get(getOffset(renderable));
if (curr != null) {
ExtShaderProgram shaderProgram = getShaderProgram();
shaderProgram.begin();
shaderProgram.setUniformMatrix("u_projView", camera.getCamera().combined);
shaderProgram.setUniformf("u_camPos", camera.getPos().put(aux1));
shaderProgram.setUniformf("u_alpha", alphas[renderable.getComponentType().getFirstOrdinal()] * renderable.getOpacity());
shaderProgram.setUniformf("u_falloff", 2.5f);
shaderProgram.setUniformf("u_sizeFactor", Settings.settings.scene.star.pointSize * 0.08f * oeg.getPointscaling());
shaderProgram.setUniformf("u_sizeLimits", (float) (particleSizeLimits[0]), (float) (particleSizeLimits[1]));
// VR scale
shaderProgram.setUniformf("u_vrScale", (float) Constants.DISTANCE_SCALE_FACTOR);
// Emulate double, for compatibility
double curRt = AstroUtils.getJulianDate(GaiaSky.instance.time.getTime());
float curRt1 = (float) curRt;
float curRt2 = (float) (curRt - (double) curRt1);
shaderProgram.setUniformf("u_t", curRt1, curRt2);
shaderProgram.setUniformMatrix("u_eclToEq", maux.setToRotation(0, 1, 0, -90).mul(Coordinates.equatorialToEclipticF()));
// Relativistic effects
addEffectsUniforms(shaderProgram, camera);
try {
curr.mesh.render(shaderProgram, GL20.GL_TRIANGLES);
} catch (IllegalArgumentException e) {
logger.error(e, "Render exception");
}
shaderProgram.end();
}
}
}
use of gaiasky.util.CatalogInfo in project gaiasky by langurmonkey.
the class OctreeGroupLoader method loadOctreeData.
@Override
protected AbstractOctreeWrapper loadOctreeData() {
/*
* LOAD METADATA
*/
logger.info(I18n.txt("notif.loading", metadata));
MetadataBinaryIO metadataReader = new MetadataBinaryIO();
OctreeNode root = metadataReader.readMetadataMapped(metadata);
if (root != null) {
logger.info(I18n.txt("notif.nodeloader", root.numNodesRec(), metadata));
logger.info(I18n.txt("notif.loading", particles));
/*
* CREATE OCTREE WRAPPER WITH ROOT NODE - particle group is by default
* parallel, so we never use OctreeWrapperConcurrent
*/
AbstractOctreeWrapper octreeWrapper = new OctreeWrapper("Universe", root);
octreeWrapper.setFadeout(new double[] { 8e3, 5e5 });
// Catalog info
String name = this.name != null ? this.name : "LOD data";
String description = this.description != null ? this.description : "Octree-based LOD dataset";
CatalogInfo ci = new CatalogInfo(name, description, null, CatalogInfoSource.LOD, 1.5f, octreeWrapper);
ci.nParticles = params.containsKey("nobjects") ? (Long) params.get("nobjects") : -1;
ci.sizeBytes = params.containsKey("size") ? (Long) params.get("size") : -1;
EventManager.publish(Event.CATALOG_ADD, this, ci, false);
dataVersionHint = name.contains("DR2") || name.contains("dr2") || description.contains("DR2") || description.contains("dr2") ? 0 : 1;
/*
* LOAD LOD LEVELS - LOAD PARTICLE DATA
*/
try {
int depthLevel = Math.min(OctreeNode.maxDepth, PRELOAD_DEPTH);
loadLod(depthLevel, octreeWrapper);
flushLoadedIds();
} catch (IOException e) {
logger.error(e);
}
return octreeWrapper;
} else {
logger.info("Dataset not found: " + metadata + " - " + particles);
return null;
}
}
use of gaiasky.util.CatalogInfo in project gaiasky by langurmonkey.
the class OrbitalElementsGroup method initializeCatalogInfo.
private void initializeCatalogInfo() {
if (this.catalogInfo == null) {
// Create catalog info and broadcast
CatalogInfo ci = new CatalogInfo(names[0], names[0], null, CatalogInfoSource.INTERNAL, 1f, this);
ci.nParticles = this.children != null ? this.children.size : -1;
// Insert
EventManager.publish(Event.CATALOG_ADD, this, ci, false);
}
}
Aggregations