Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

Commit

Permalink
Merge pull request #55 from 7map/link-components
Browse files Browse the repository at this point in the history
Link components
  • Loading branch information
BSoDium authored May 30, 2021
2 parents f429f46 + d49f74e commit a98f8dc
Show file tree
Hide file tree
Showing 85 changed files with 3,357 additions and 1,141 deletions.
Binary file added doc/meetings/general/Projet_7map_final.pptx
Binary file not shown.
Binary file added doc/meetings/general/diagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 51 additions & 0 deletions doc/meetings/general/diagram_packages.plantuml
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
Binary file added livrables/source3.jar
Binary file not shown.
10 changes: 10 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@
<version>1.9.4</version>
</dependency>

<!-- (DevDeps) Handle args from main
https://mvnrepository.com/artifact/commons-cli/commons-cli -->
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.4</version>
</dependency>

<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
Expand Down Expand Up @@ -413,6 +421,8 @@
<include>**/*.jpg</include>
<include>**/*.png</include>
<include>**/*.ttf</include>
<include>**/*.osm</include>
<include>**/*.json</include>
</includes>
</resource>
</resources>
Expand Down
181 changes: 41 additions & 140 deletions src/main/java/com/sevenmap/App.java
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 {
}
}
}

}
Loading

0 comments on commit a98f8dc

Please sign in to comment.