This repository has been archived by the owner on May 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #55 from 7map/link-components
Link components
- Loading branch information
Showing
85 changed files
with
3,357 additions
and
1,141 deletions.
There are no files selected for viewing
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
@startuml diagram | ||
|
||
package com.sevenmap { | ||
class App { | ||
+ {static} main(String[] args) : void | ||
} | ||
package core { | ||
package cli { | ||
} | ||
package map { | ||
} | ||
package ui { | ||
} | ||
class Runtime { | ||
} | ||
class Loadable { | ||
} | ||
} | ||
package data { | ||
package objsept { | ||
} | ||
package parsers { | ||
} | ||
package styles { | ||
} | ||
} | ||
package exceptions { | ||
} | ||
|
||
package spinel { | ||
package elements { | ||
} | ||
package gfx { | ||
} | ||
package math { | ||
} | ||
package scheduling { | ||
} | ||
package utils { | ||
} | ||
class Engine implements java.lang.Runnable { | ||
} | ||
class Input { | ||
} | ||
class Window { | ||
} | ||
} | ||
} | ||
|
||
|
||
@enduml |
File renamed without changes.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,161 +1,62 @@ | ||
package com.sevenmap; | ||
|
||
import java.io.File; | ||
import java.io.FileOutputStream; | ||
import java.io.InputStream; | ||
import java.io.OutputStream; | ||
|
||
import com.sevenmap.data.optiObj.LightObj; | ||
import com.sevenmap.data.osm.Elements.Bounds.Bounds; | ||
import com.sevenmap.data.osm.api.OSMAPI; | ||
import com.sevenmap.exceptions.ExitOverrideException; | ||
import com.sevenmap.spinel.Engine; | ||
import com.sevenmap.spinel.elements.GeomNode; | ||
import com.sevenmap.spinel.elements.Item; | ||
import com.sevenmap.spinel.gfx.Material; | ||
import com.sevenmap.spinel.gfx.Mesh; | ||
import com.sevenmap.spinel.gfx.Vertex; | ||
import com.sevenmap.spinel.math.Vector2f; | ||
import com.sevenmap.spinel.math.Vector3f; | ||
import com.sevenmap.spinel.scheduling.events.MoveEvent; | ||
|
||
import org.lwjgl.glfw.GLFW; | ||
import com.sevenmap.core.Props; | ||
import com.sevenmap.core.Runtime; | ||
import com.sevenmap.core.cli.CLI; | ||
|
||
/** | ||
* Main application class. | ||
*/ | ||
public class App { | ||
|
||
private Engine engine = new Engine(); | ||
|
||
// testing only --------------------------------- | ||
private Mesh mesh = new Mesh(new Vertex[] { | ||
new Vertex(new Vector3f(-0.5f, 0.5f, 0.5f), new Vector3f(1.0f, 0.0f, 0.0f), | ||
new Vector2f(0.0f, 0.0f)), // texture | ||
// coordinates | ||
// must | ||
// be | ||
// defined | ||
// counter | ||
// clockwise | ||
new Vertex(new Vector3f(0.5f, 0.5f, 0.5f), new Vector3f(0.0f, 1.0f, 0.0f), | ||
new Vector2f(0.0f, 1.0f)), | ||
new Vertex(new Vector3f(0.5f, -0.5f, 0.5f), new Vector3f(1.0f, 0.0f, 0.0f), | ||
new Vector2f(1.0f, 1.0f)), | ||
new Vertex(new Vector3f(-0.5f, -0.5f, 0.5f), new Vector3f(0.0f, 0.0f, 1.0f), | ||
new Vector2f(1.0f, 0.0f)), | ||
new Vertex(new Vector3f(-0.5f, 0.5f, -0.5f), new Vector3f(1.0f, 0.0f, 0.0f), | ||
new Vector2f(0.0f, 0.0f)), | ||
new Vertex(new Vector3f(0.5f, 0.5f, -0.5f), new Vector3f(0.0f, 1.0f, 0.0f), | ||
new Vector2f(0.0f, 1.0f)), | ||
new Vertex(new Vector3f(0.5f, -0.5f, -0.5f), new Vector3f(1.0f, 0.0f, 0.0f), | ||
new Vector2f(1.0f, 1.0f)), | ||
new Vertex(new Vector3f(-0.5f, -0.5f, -0.5f), new Vector3f(0.0f, 0.0f, 1.0f), | ||
new Vector2f(1.0f, 0.0f)) | ||
|
||
}, | ||
|
||
new int[] { 0, 1, 2, 0, 3, 2, 4, 5, 6, 4, 7, 6 }, new Material("textures/logo.png")); | ||
|
||
private Item testElement = new Item(new Vector3f(0, 0, -1.0f), new Vector3f(0, 0, 0), new Vector3f(1, 1, 1), | ||
mesh); | ||
private Item testElement2 = new Item(new Vector3f(0, 0, -4.0f), new Vector3f(0, 0, 0), new Vector3f(1, 1, 1), | ||
mesh); | ||
|
||
public void start() { | ||
init(); | ||
} | ||
|
||
private GeomNode parentTestNode = new GeomNode(new Vector3f(0, 0, 0), new Vector3f(0, 0, 0)); | ||
private GeomNode parentTestNode2 = new GeomNode(new Vector3f(0, 0, 0), new Vector3f(0, 0, 0)); | ||
public static void main(String[] args) { | ||
|
||
// testing only --------------------------------- | ||
// Create new props | ||
Props props = new Props(); | ||
|
||
/** | ||
* App boot up sequence. | ||
*/ | ||
public void init() { | ||
// Parse args from CLI | ||
CLI.parseArgs(args, props); | ||
|
||
// test out node structure | ||
testElement.setParent(parentTestNode); | ||
testElement2.setParent(parentTestNode); | ||
parentTestNode.setParent(engine.getSceneRoot()); | ||
parentTestNode2.setParent(testElement); | ||
engine.getSceneRoot().tree(); | ||
// Launch app | ||
Runtime rt = new Runtime(); | ||
|
||
// schedule movement macros | ||
engine.getWindow().onKeyDown(GLFW.GLFW_KEY_A, | ||
() -> engine.getCamera().setPos(engine.getCamera().getPos().getX() - 0.05f, | ||
engine.getCamera().getPos().getY(), | ||
engine.getCamera().getPos().getZ())); | ||
engine.getWindow().onKeyDown(GLFW.GLFW_KEY_D, | ||
() -> engine.getCamera().setPos(engine.getCamera().getPos().getX() + 0.05f, | ||
engine.getCamera().getPos().getY(), | ||
engine.getCamera().getPos().getZ())); | ||
engine.getWindow().onKeyDown(GLFW.GLFW_KEY_W, | ||
() -> engine.getCamera().setPos(engine.getCamera().getPos().getX(), | ||
engine.getCamera().getPos().getY(), | ||
engine.getCamera().getPos().getZ() - 0.05f)); | ||
engine.getWindow().onKeyDown(GLFW.GLFW_KEY_S, | ||
() -> engine.getCamera().setPos(engine.getCamera().getPos().getX(), | ||
engine.getCamera().getPos().getY(), | ||
engine.getCamera().getPos().getZ() + 0.05f)); | ||
createStyleJson(props); | ||
|
||
engine.getWindow().onKeyDown(GLFW.GLFW_KEY_E, | ||
() -> engine.getCamera().setRot(engine.getCamera().getRot().getX(), | ||
engine.getCamera().getRot().getY(), | ||
engine.getCamera().getRot().getZ() + 1f)); | ||
engine.getWindow().onKeyDown(GLFW.GLFW_KEY_Q, | ||
() -> engine.getCamera().setRot(engine.getCamera().getRot().getX(), | ||
engine.getCamera().getRot().getY(), | ||
engine.getCamera().getRot().getZ() - 1f)); | ||
engine.getWindow().onKeyDown(GLFW.GLFW_KEY_UP, | ||
() -> engine.getCamera().setRot(engine.getCamera().getRot().getX() + 1f, | ||
engine.getCamera().getRot().getY(), | ||
engine.getCamera().getRot().getZ())); | ||
engine.getWindow().onKeyDown(GLFW.GLFW_KEY_DOWN, | ||
() -> engine.getCamera().setRot(engine.getCamera().getRot().getX() - 1f, | ||
engine.getCamera().getRot().getY(), | ||
engine.getCamera().getRot().getZ())); | ||
engine.getWindow().onKeyDown(GLFW.GLFW_KEY_LEFT, | ||
() -> engine.getCamera().setRot(engine.getCamera().getRot().getX(), | ||
engine.getCamera().getRot().getY() + 1f, | ||
engine.getCamera().getRot().getZ())); | ||
engine.getWindow().onKeyDown(GLFW.GLFW_KEY_RIGHT, | ||
() -> engine.getCamera().setRot(engine.getCamera().getRot().getX(), | ||
engine.getCamera().getRot().getY() - 1f, | ||
engine.getCamera().getRot().getZ())); | ||
rt.load(props); | ||
} | ||
|
||
// schedule engine.getWindow() closing when escape is pressed | ||
engine.getWindow().onKeyDown(GLFW.GLFW_KEY_ESCAPE, () -> { | ||
throw new ExitOverrideException(0); | ||
}); | ||
|
||
// fullscreen | ||
engine.getWindow().onKeyDown(GLFW.GLFW_KEY_F11, | ||
() -> engine.getWindow().setFullscreen(!engine.getWindow().isFullscreen())); | ||
|
||
// event showcase | ||
engine.getWindow().onEvent(new MoveEvent(engine), | ||
() -> parentTestNode.setRot(testElement.getRot().add(new Vector3f(0, 0, 0.3f)))); | ||
|
||
engine.start(); | ||
private static void createStyleJson(Props props) { | ||
File f = new File(props.getAppDataPath() + props.getSettingFile()); | ||
if (!f.exists()) { | ||
InputStream stream = null; | ||
OutputStream resStreamOut = null; | ||
try { | ||
stream = App.class.getClassLoader().getResourceAsStream("maps/settings/styles.json");// note that each / is a | ||
// directory down in the | ||
// "jar tree" been the jar the root of the tree | ||
if (stream == null) { | ||
throw new Exception("Cannot get resource \"" + props.getSettingFile() + "\" from Jar file."); | ||
} | ||
|
||
public static void main(String[] args) { | ||
// Create OSM Map | ||
Bounds N7Bounds = new Bounds(1.45338, 43.60116, 1.45760, 43.60297); | ||
File n7Map = new File("src/main/resources/maps/osm/n7.osm"); | ||
OSMAPI OSMMap = new OSMAPI(N7Bounds, n7Map); | ||
|
||
// Download new map | ||
OSMMap.downloadMap(); | ||
|
||
// Parse data | ||
OSMMap.parse(); | ||
|
||
// Convert into optimized files | ||
LightObj ltObj = new LightObj(OSMMap); | ||
|
||
// | ||
new App().start(); | ||
int readBytes; | ||
byte[] buffer = new byte[4096]; | ||
String path = props.getAppDataPath(); | ||
resStreamOut = new FileOutputStream(path + props.getSettingFile()); | ||
while ((readBytes = stream.read(buffer)) > 0) { | ||
resStreamOut.write(buffer, 0, readBytes); | ||
} | ||
stream.close(); | ||
resStreamOut.close(); | ||
} catch (Exception ex) { | ||
ex.printStackTrace(); | ||
} finally { | ||
} | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.