mirror of
https://github.com/13hannes11/LU_opengl_solarsystem_visualization.git
synced 2024-09-04 01:11:01 +02:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dbc7fda722 | ||
|
|
33acc16389 | ||
|
|
1ac7cbcefa | ||
|
|
78fc4f8cd7 |
10
.classpath
Normal file
10
.classpath
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/Apache commons-lan- 3.7"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/JOML"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Hannes/EclipseInstances/oxygen_hobby/lib/jogamp-all-platforms/jar/gluegen-rt.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Hannes/EclipseInstances/oxygen_hobby/lib/jogamp-all-platforms/jar/jogl-all.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
12
.gitignore
vendored
12
.gitignore
vendored
@@ -20,3 +20,15 @@
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
|
||||
.metadata
|
||||
bin/
|
||||
tmp/
|
||||
*.tmp
|
||||
*.bak
|
||||
*.swp
|
||||
*~.nib
|
||||
local.properties
|
||||
.settings/
|
||||
.loadpath
|
||||
.recommenders
|
||||
17
.project
Normal file
17
.project
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>OpenGL-SolarSystem</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -1,7 +1,7 @@
|
||||
# OpenGL: Solar System Visualization
|
||||
|
||||
This project was created for an assignment in the course 3d-graphics at Linnaeus University. The visualization is written using directly OpenGL APIs which are exposed by JOGL.
|
||||
The size of planets and their orbits is not to scale.
|
||||
The size of planets and their orbits is not to scale but the rotation and speed of planets is.
|
||||
|
||||
Controls for using are
|
||||
|
||||
@@ -17,6 +17,7 @@ Controls for using are
|
||||
* ``↓`` rotate camera downwards
|
||||
* ``→`` rotate camera right
|
||||
* ``←`` rotate camera left
|
||||
* ``1`` to ``9`` jump to celestial body (``1`` - Sun, ``2`` - Mercury, ``9`` - Neptun)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -44,6 +44,10 @@ public abstract class GraphicalObject {
|
||||
this.stopWatch.start();
|
||||
}
|
||||
|
||||
public Vector3f getPosition() {
|
||||
return transformation.getTranslation(new Vector3f());
|
||||
}
|
||||
|
||||
public void setPosition(final Vector3f pos) {
|
||||
this.transformation = transformation.setTranslation(pos);
|
||||
}
|
||||
|
||||
@@ -18,104 +18,64 @@ public class SolarSystemScene extends Scene {
|
||||
camera.lookAt(new Vector3f(0.0f, 0.0f, 0.0f));
|
||||
final Universe uv = new Universe();
|
||||
|
||||
this.getCanvas().addKeyListener(new UniverseKeyListener(uv));
|
||||
final UniverseKeyListener universeKeyListener = new UniverseKeyListener(uv, camera);
|
||||
this.getCanvas().addKeyListener(universeKeyListener);
|
||||
// Mercury
|
||||
this.addGraphicalObject(new Planet(
|
||||
new Orbit(new Vector3f(0.0f, 0.0f, 0.0f),
|
||||
0.467f,
|
||||
0.308f),
|
||||
uv,
|
||||
0.38f,
|
||||
"spheres/mercury.jpg", 115.88f, 57.94f));
|
||||
final Planet mercury = new Planet(new Orbit(new Vector3f(0.0f, 0.0f, 0.0f), 0.467f, 0.308f), uv, 0.38f,
|
||||
"spheres/mercury.jpg", 115.88f, 57.94f);
|
||||
this.addGraphicalObject(mercury);
|
||||
universeKeyListener.setKeySphericalSpaceObject(mercury, 2);
|
||||
|
||||
// Venus
|
||||
this.addGraphicalObject(new Planet(
|
||||
new Orbit(new Vector3f(0.0f, 0.0f, 0.0f),
|
||||
0.723f,
|
||||
0.718f),
|
||||
uv,
|
||||
0.38f,
|
||||
"spheres/venus.jpg", 224.701f, 243.0f));
|
||||
final Planet venus = new Planet(new Orbit(new Vector3f(0.0f, 0.0f, 0.0f), 0.723f, 0.718f), uv, 0.38f,
|
||||
"spheres/venus.jpg", 224.701f, 243.0f);
|
||||
this.addGraphicalObject(venus);
|
||||
universeKeyListener.setKeySphericalSpaceObject(venus, 3);
|
||||
|
||||
// Earth
|
||||
final Planet earth = new Planet(
|
||||
new Orbit(new Vector3f(0.0f, 0.0f, 0.0f),
|
||||
0.98f,
|
||||
1.02f),
|
||||
uv,
|
||||
1.0f,
|
||||
final Planet earth = new Planet(new Orbit(new Vector3f(0.0f, 0.0f, 0.0f), 0.98f, 1.02f), uv, 1.0f,
|
||||
"spheres/earth.jpg", 365.256f, 1.0f);
|
||||
this.addGraphicalObject(earth);
|
||||
universeKeyListener.setKeySphericalSpaceObject(earth, 4);
|
||||
// Moon
|
||||
this.addGraphicalObject(new Moon(
|
||||
earth,
|
||||
new Orbit(new Vector3f(0.0f, 0.0f, 0.0f),
|
||||
2 * Universe.EARTH_RADIUS,
|
||||
2 * Universe.EARTH_RADIUS),
|
||||
uv,
|
||||
0.3f,
|
||||
"spheres/moon.jpg",
|
||||
29.530589f,
|
||||
29.530589f));
|
||||
this.addGraphicalObject(new Moon(earth,
|
||||
new Orbit(new Vector3f(0.0f, 0.0f, 0.0f), 2 * Universe.EARTH_RADIUS, 2 * Universe.EARTH_RADIUS), uv,
|
||||
0.3f, "spheres/moon.jpg", 29.530589f, 29.530589f));
|
||||
// Mars
|
||||
this.addGraphicalObject(new Planet(
|
||||
new Orbit(new Vector3f(0.0f, 0.0f, 0.0f),
|
||||
1.5f,
|
||||
1.4f),
|
||||
uv,
|
||||
0.2657f * 2,
|
||||
"spheres/mars.jpg",
|
||||
686.971f,
|
||||
1.0275f));
|
||||
final Planet mars = new Planet(new Orbit(new Vector3f(0.0f, 0.0f, 0.0f), 1.5f, 1.4f), uv, 0.2657f * 2,
|
||||
"spheres/mars.jpg", 686.971f, 1.0275f);
|
||||
this.addGraphicalObject(mars);
|
||||
universeKeyListener.setKeySphericalSpaceObject(mars, 5);
|
||||
|
||||
// Jupiter
|
||||
this.addGraphicalObject(new Planet(
|
||||
new Orbit(new Vector3f(0.0f, 0.0f, 0.0f),
|
||||
5.2f - 3.3f,
|
||||
4.9f - 3.3f),
|
||||
uv,
|
||||
12.0f / 12f,
|
||||
"spheres/jupiter.jpg",
|
||||
4330.0f,
|
||||
0.4132f));
|
||||
final Planet jupiter = new Planet(new Orbit(new Vector3f(0.0f, 0.0f, 0.0f), 5.2f - 3.3f, 4.9f - 3.3f), uv,
|
||||
12.0f / 12f, "spheres/jupiter.jpg", 4330.0f, 0.4132f);
|
||||
this.addGraphicalObject(jupiter);
|
||||
universeKeyListener.setKeySphericalSpaceObject(jupiter, 6);
|
||||
|
||||
// Saturn
|
||||
this.addGraphicalObject(new Planet(
|
||||
new Orbit(new Vector3f(0.0f, 0.0f, 0.0f),
|
||||
9.5f - 7f,
|
||||
9f - 7f),
|
||||
uv,
|
||||
10.0f / 10f,
|
||||
"spheres/saturn.jpg",
|
||||
10751.805f,
|
||||
0.45f));
|
||||
final Planet saturn = new Planet(new Orbit(new Vector3f(0.0f, 0.0f, 0.0f), 9.5f - 7f, 9f - 7f), uv, 10.0f / 10f,
|
||||
"spheres/saturn.jpg", 10751.805f, 0.45f);
|
||||
this.addGraphicalObject(saturn);
|
||||
universeKeyListener.setKeySphericalSpaceObject(saturn, 7);
|
||||
|
||||
// Uranus
|
||||
this.addGraphicalObject(new Planet(
|
||||
new Orbit(new Vector3f(0.0f, 0.0f, 0.0f),
|
||||
19f - 16f,
|
||||
18f - 16f),
|
||||
uv,
|
||||
4.0f / 6,
|
||||
"spheres/uranus.jpg",
|
||||
30660.0f,
|
||||
0.72f));
|
||||
final Planet uranus = new Planet(new Orbit(new Vector3f(0.0f, 0.0f, 0.0f), 19f - 16f, 18f - 16f), uv, 4.0f / 6,
|
||||
"spheres/uranus.jpg", 30660.0f, 0.72f);
|
||||
this.addGraphicalObject(uranus);
|
||||
universeKeyListener.setKeySphericalSpaceObject(uranus, 8);
|
||||
|
||||
// Neptun
|
||||
this.addGraphicalObject(new Planet(
|
||||
new Orbit(new Vector3f(0.0f, 0.0f, 0.0f),
|
||||
30f - 26.0f,
|
||||
29f - 26.0f),
|
||||
uv,
|
||||
3.88f / 6,
|
||||
"spheres/neptune.jpg",
|
||||
30660.0f,
|
||||
0.673f));
|
||||
this.addGraphicalObject(new Sun(new Vector3f(0.0f, 0.0f, 0.0f), 3.0f, "spheres/sun.jpg"));
|
||||
final Planet neptun = new Planet(new Orbit(new Vector3f(0.0f, 0.0f, 0.0f), 30f - 26.0f, 29f - 26.0f), uv,
|
||||
3.88f / 6, "spheres/neptune.jpg", 30660.0f, 0.673f);
|
||||
this.addGraphicalObject(neptun);
|
||||
universeKeyListener.setKeySphericalSpaceObject(neptun, 9);
|
||||
|
||||
this.setSkybox(new String[] {
|
||||
"skybox/space_left_0.png",
|
||||
"skybox/space_right_1.png",
|
||||
"skybox/space_down_2.png",
|
||||
"skybox/space_up_3.png",
|
||||
"skybox/space_front_4.png",
|
||||
"skybox/space_back_5.png"});
|
||||
final Sun sun = new Sun(new Vector3f(0.0f, 0.0f, 0.0f), 3.0f, "spheres/sun.jpg");
|
||||
this.addGraphicalObject(sun);
|
||||
universeKeyListener.setKeySphericalSpaceObject(sun, 1);
|
||||
|
||||
this.setSkybox(new String[] { "skybox/space_left_0.png", "skybox/space_right_1.png", "skybox/space_down_2.png",
|
||||
"skybox/space_up_3.png", "skybox/space_front_4.png", "skybox/space_back_5.png" });
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,13 +3,19 @@ package org.kuchelmeister.solarsystem.input;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.KeyListener;
|
||||
|
||||
import org.kuchelmeister.engine.camera.Camera;
|
||||
import org.kuchelmeister.solarsystem.geometry.SphericalSpaceObject;
|
||||
import org.kuchelmeister.solarsystem.geometry.Universe;
|
||||
|
||||
public class UniverseKeyListener implements KeyListener {
|
||||
Universe universe;
|
||||
Camera camera;
|
||||
SphericalSpaceObject[] spaceObjects;
|
||||
|
||||
public UniverseKeyListener(final Universe universe) {
|
||||
public UniverseKeyListener(final Universe universe, final Camera camera) {
|
||||
this.universe = universe;
|
||||
this.spaceObjects = new SphericalSpaceObject[10];
|
||||
this.camera = camera;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -31,6 +37,21 @@ public class UniverseKeyListener implements KeyListener {
|
||||
System.out.println("Time scale halfed to: " + universe.getTimeScale());
|
||||
}
|
||||
}
|
||||
// Jumping to the position
|
||||
if (KeyEvent.VK_0 <= e.getKeyCode() && e.getKeyCode() <= KeyEvent.VK_9) {
|
||||
final int position = e.getKeyCode() - KeyEvent.VK_0;
|
||||
final SphericalSpaceObject sObject = spaceObjects[position];
|
||||
if (sObject != null) {
|
||||
// TODO: get position and move camera to that position
|
||||
// lookingDirection * radius + sObject.getPosition()
|
||||
this.camera.setPosition(sObject.getPosition());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setKeySphericalSpaceObject(final SphericalSpaceObject object, final int numberKey) {
|
||||
assert 0 <= numberKey && numberKey <= 9;
|
||||
spaceObjects[numberKey] = object;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user