use of gaiasky.scenegraph.SceneGraphNode in project gaiasky by langurmonkey.
the class StarGroupBinaryIO method readParticles.
/**
* Reads a single star group from the given input stream.
*
* @param in The input stream to read the star group from
* @return A list with a single star group object
*/
public List<SceneGraphNode> readParticles(InputStream in) {
List<IParticleRecord> data = provider.loadData(in, 1.0);
StarGroup sg = new StarGroup();
sg.setData(data);
List<SceneGraphNode> l = new ArrayList<>(1);
l.add(sg);
return l;
}
use of gaiasky.scenegraph.SceneGraphNode in project gaiasky by langurmonkey.
the class StarGroupSerializedIO method readParticles.
/**
* Reads a single star group from the given input stream.
*
* @param in
* The input stream to read the star group from
* @return A list with a single star group object
*/
public List<SceneGraphNode> readParticles(InputStream in) {
List<IParticleRecord> data = provider.loadData(in, 1.0);
StarGroup sg = new StarGroup();
sg.setData(data);
List<SceneGraphNode> l = new ArrayList<>(1);
l.add(sg);
return l;
}
use of gaiasky.scenegraph.SceneGraphNode in project gaiasky by langurmonkey.
the class UpdaterTask method call.
@Override
public Void call() throws Exception {
int size = nodes.size;
for (int i = start; i < size; i += step) {
SceneGraphNode node = nodes.get(i);
float opacity = node instanceof Particle && node.octant != null ? node.octant.opacity : (node instanceof FadeNode ? 1f : node.opacity);
node.update(time, node.parent.translation, camera, opacity);
}
return null;
}
use of gaiasky.scenegraph.SceneGraphNode in project gaiasky by langurmonkey.
the class BookmarksComponent method notify.
@Override
public void notify(final Event event, Object source, final Object... data) {
switch(event) {
case FOCUS_CHANGED:
// Update focus selection in focus list
SceneGraphNode sgn;
if (data[0] instanceof String) {
sgn = sg.getNode((String) data[0]);
} else {
sgn = (SceneGraphNode) data[0];
}
// Select only if data[1] is true
if (sgn != null) {
SceneGraphNode node = (SceneGraphNode) data[0];
selectBookmark(node.getName(), false);
}
break;
case BOOKMARKS_ADD:
String name = (String) data[0];
reloadBookmarksTree();
selectBookmark(name, false);
break;
case BOOKMARKS_REMOVE:
case BOOKMARKS_REMOVE_ALL:
reloadBookmarksTree();
break;
default:
break;
}
}
use of gaiasky.scenegraph.SceneGraphNode in project gaiasky by langurmonkey.
the class AtmosphereComponent method updateAtmosphericScatteringParams.
/**
* Updates the atmospheric scattering shader parameters
*
* @param mat The material to update.
* @param alpha The opacity value.
* @param ground Whether it is the ground shader or the atmosphere.
* @param planet The planet itself, holder of this atmosphere
*/
public void updateAtmosphericScatteringParams(Material mat, float alpha, boolean ground, Planet planet, Vector3d vrOffset) {
Vector3b transform = planet.translation;
RotationComponent rc = planet.rc;
SceneGraphNode sol = planet.parent;
transform.put(aux3);
if (vrOffset != null) {
aux1.set(vrOffset).scl(1 / Constants.M_TO_U);
aux3.sub(aux1);
}
// Distance to planet
float camHeight = (float) (aux3.len());
float m_ESun = m_eSun;
float camHeightGr = camHeight - m_fInnerRadius;
float atmFactor = (m_fAtmosphereHeight - camHeightGr) / m_fAtmosphereHeight;
if (!ground && camHeightGr < m_fAtmosphereHeight) {
// Camera inside atmosphere
m_ESun += atmFactor * 100f;
}
// These are here to get the desired effect inside the atmosphere
if (mat.has(AtmosphereAttribute.KrESun))
((AtmosphereAttribute) mat.get(AtmosphereAttribute.KrESun)).value = m_Kr * m_ESun;
else
mat.set(new AtmosphereAttribute(AtmosphereAttribute.KrESun, m_Kr * m_ESun));
if (mat.has(AtmosphereAttribute.KmESun))
((AtmosphereAttribute) mat.get(AtmosphereAttribute.KmESun)).value = m_Km * m_ESun;
else
mat.set(new AtmosphereAttribute(AtmosphereAttribute.KmESun, m_Km * m_ESun));
// Camera height
if (mat.has(AtmosphereAttribute.CameraHeight))
((AtmosphereAttribute) mat.get(AtmosphereAttribute.CameraHeight)).value = camHeight;
else
mat.set(new AtmosphereAttribute(AtmosphereAttribute.CameraHeight, camHeight));
// Planet position
if (ground) {
// Camera position must be corrected using the rotation angle of the planet
aux3.mul(Coordinates.getTransformD(planet.inverseRefPlaneTransform)).rotate(rc.ascendingNode, 0, 1, 0).rotate(-rc.inclination - rc.axialTilt, 0, 0, 1).rotate(-rc.angle, 0, 1, 0);
}
((Vector3Attribute) mat.get(Vector3Attribute.PlanetPos)).value.set(aux3.put(aux));
// CameraPos = -PlanetPos
aux3.scl(-1f);
((Vector3Attribute) mat.get(Vector3Attribute.CameraPos)).value.set(aux3.put(aux));
// Light position respect the earth: LightPos = SunPos - EarthPos
aux3.add(sol.translation).nor();
if (ground) {
// Camera position must be corrected using the rotation angle of the planet
aux3.mul(Coordinates.getTransformD(planet.inverseRefPlaneTransform)).rotate(rc.ascendingNode, 0, 1, 0).rotate(-rc.inclination - rc.axialTilt, 0, 0, 1).rotate(-rc.angle, 0, 1, 0);
}
((Vector3Attribute) mat.get(Vector3Attribute.LightPos)).value.set(aux3.put(aux));
// Alpha value
((AtmosphereAttribute) mat.get(AtmosphereAttribute.Alpha)).value = alpha;
}
Aggregations