-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
mihaita
authored and
mihaita
committed
Jul 21, 2016
0 parents
commit a83f260
Showing
16 changed files
with
1,999 additions
and
0 deletions.
There are no files selected for viewing
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 @@ | ||
/build/ |
Binary file not shown.
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<jnlp spec="1.0+" codebase="${jnlp.codebase}" href="launch.jnlp"> | ||
<information> | ||
<title>${APPLICATION.TITLE}</title> | ||
<vendor>${APPLICATION.VENDOR}</vendor> | ||
<homepage href="${APPLICATION.HOMEPAGE}"/> | ||
<description>${APPLICATION.DESC}</description> | ||
<description kind="short">${APPLICATION.DESC.SHORT}</description> | ||
<!--${JNLP.ICONS}--> | ||
<!--${JNLP.OFFLINE.ALLOWED}--> | ||
</information> | ||
<!--${JNLP.SECURITY}--> | ||
<resources> | ||
<!--${JNLP.RESOURCES.RUNTIME}--> | ||
<!--${JNLP.RESOURCES.MAIN.JAR}--> | ||
<!--${JNLP.RESOURCES.JARS}--> | ||
<jar href='lib/assets.jar'/> | ||
<!--${JNLP.RESOURCES.EXTENSIONS}--> | ||
</resources> | ||
<application-desc main-class="${jnlp.main.class}"> | ||
<!--${JNLP.APPLICATION.ARGS}--> | ||
</application-desc> | ||
</jnlp> |
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,15 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!--assets-impl.xml v1.0--> | ||
<project name="assets-impl" basedir=".."> | ||
<target name="-init-assets"> | ||
<jar jarfile="${build.dir}/${assets.jar.name}" excludes="${assets.excludes}" basedir="${assets.folder.name}" compress="${assets.compress}"/> | ||
<property location="${assets.folder.name}" name="assets.dir.resolved"/> | ||
<property location="${build.dir}/${assets.jar.name}" name="assets.jar.resolved"/> | ||
<property location="${build.classes.dir}" name="build.classes.dir.resolved"/> | ||
<pathconvert property="run.classpath.without.build.classes.dir"> | ||
<path path="${run.classpath}"/> | ||
<map from="${build.classes.dir.resolved}" to=""/> | ||
<map from="${assets.dir.resolved}" to="${assets.jar.resolved}"/> | ||
</pathconvert> | ||
</target> | ||
</project> |
Large diffs are not rendered by default.
Oops, something went wrong.
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,8 @@ | ||
build.xml.data.CRC32=94bf7c61 | ||
build.xml.script.CRC32=79a29eb7 | ||
build.xml.stylesheet.CRC32=[email protected] | ||
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. | ||
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. | ||
nbproject/build-impl.xml.data.CRC32=03b85f22 | ||
nbproject/build-impl.xml.script.CRC32=d778f35b | ||
nbproject/build-impl.xml.stylesheet.CRC32=[email protected] |
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,92 @@ | ||
annotation.processing.enabled=true | ||
annotation.processing.enabled.in.editor=false | ||
annotation.processing.processors.list= | ||
annotation.processing.run.all.processors=true | ||
application.title=MyGame | ||
application.vendor=MyCompany | ||
assets.jar.name=assets.jar | ||
assets.excludes=**/*.j3odata,**/*.mesh,**/*.skeleton,**/*.mesh\.xml,**/*.skeleton\.xml,**/*.scene,**/*.material,**/*.obj,**/*.mtl,**/*.3ds,**/*.dae,**/*.blend,**/*.blend*[0-9] | ||
assets.folder.name=assets | ||
assets.compress=true | ||
build.classes.dir=${build.dir}/classes | ||
build.classes.excludes=**/*.java,**/*.form | ||
# This directory is removed when the project is cleaned: | ||
build.dir=build | ||
build.generated.dir=${build.dir}/generated | ||
build.generated.sources.dir=${build.dir}/generated-sources | ||
# Only compile against the classpath explicitly listed here: | ||
build.sysclasspath=ignore | ||
build.test.classes.dir=${build.dir}/test/classes | ||
build.test.results.dir=${build.dir}/test/results | ||
compile.on.save=true | ||
# Uncomment to specify the preferred debugger connection transport: | ||
#debug.transport=dt_socket | ||
debug.classpath=\ | ||
${run.classpath} | ||
debug.test.classpath=\ | ||
${run.test.classpath} | ||
# This directory is removed when the project is cleaned: | ||
dist.dir=dist | ||
dist.jar=${dist.dir}/${application.title}.jar | ||
dist.javadoc.dir=${dist.dir}/javadoc | ||
endorsed.classpath= | ||
excludes= | ||
includes=** | ||
jar.compress=false | ||
javac.classpath=\ | ||
${libs.jme3-jogg.classpath}:\ | ||
${libs.jme3-networking.classpath}:\ | ||
${libs.jme3-plugins.classpath}:\ | ||
${libs.jme3-core.classpath}:\ | ||
${libs.jme3-desktop.classpath}:\ | ||
${libs.jme3-lwjgl.classpath}:\ | ||
${libs.jme3-effects.classpath}:\ | ||
${libs.jme3-terrain.classpath}:\ | ||
${libs.jme3-bullet.classpath}:\ | ||
${libs.jme3-bullet-native.classpath} | ||
# Space-separated list of extra javac options | ||
javac.compilerargs= | ||
javac.deprecation=false | ||
javac.processorpath=\ | ||
${javac.classpath} | ||
javac.source=1.6 | ||
javac.target=1.6 | ||
javac.test.classpath=\ | ||
${javac.classpath}:\ | ||
${build.classes.dir} | ||
javadoc.additionalparam= | ||
javadoc.author=false | ||
javadoc.encoding=${source.encoding} | ||
javadoc.noindex=false | ||
javadoc.nonavbar=false | ||
javadoc.notree=false | ||
javadoc.private=false | ||
javadoc.splitindex=true | ||
javadoc.use=true | ||
javadoc.version=false | ||
javadoc.windowtitle= | ||
jaxbwiz.endorsed.dirs="${netbeans.home}/../ide12/modules/ext/jaxb/api" | ||
jme.project.version=3.1 | ||
jnlp.codebase.type=local | ||
jnlp.descriptor=application | ||
jnlp.enabled=false | ||
jnlp.offline-allowed=false | ||
jnlp.signed=false | ||
main.class=mygame.Main | ||
meta.inf.dir=${src.dir}/META-INF | ||
manifest.file=MANIFEST.MF | ||
mkdist.disabled=false | ||
platform.active=default_platform | ||
run.classpath=\ | ||
${javac.classpath}:\ | ||
${build.classes.dir}:\ | ||
${assets.folder.name} | ||
# Space-separated list of JVM arguments used when running the project | ||
# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value | ||
# or test-sys-prop.name=value to set system properties for unit tests): | ||
run.jvmargs= | ||
run.test.classpath=\ | ||
${javac.test.classpath}:\ | ||
${build.test.classes.dir} | ||
source.encoding=UTF-8 | ||
src.dir=src |
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,18 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://www.netbeans.org/ns/project/1"> | ||
<type>org.netbeans.modules.java.j2seproject</type> | ||
<configuration> | ||
<buildExtensions xmlns="http://www.netbeans.org/ns/ant-build-extender/1"> | ||
<extension file="assets-impl.xml" id="assets"> | ||
<dependency dependsOn="-init-assets" target="-do-init"/> | ||
</extension> | ||
</buildExtensions> | ||
<data xmlns="http://www.netbeans.org/ns/j2se-project/3"> | ||
<name>OpenHex</name> | ||
<source-roots> | ||
<root id="src.dir"/> | ||
</source-roots> | ||
<test-roots/> | ||
</data> | ||
</configuration> | ||
</project> |
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,66 @@ | ||
/* | ||
* To change this license header, choose License Headers in Project Properties. | ||
* To change this template file, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
package mygame; | ||
|
||
import com.jme3.app.SimpleApplication; | ||
import com.jme3.collision.CollisionResults; | ||
import com.jme3.input.controls.ActionListener; | ||
import com.jme3.math.Ray; | ||
import com.jme3.math.Vector2f; | ||
import com.jme3.math.Vector3f; | ||
|
||
/** | ||
* | ||
* @author mihaita | ||
*/ | ||
public class Clicker implements ActionListener { | ||
|
||
private final SimpleApplication app; | ||
|
||
public Clicker(SimpleApplication app) { | ||
this.app = app; | ||
} | ||
|
||
public void onAction(String name, boolean isPressed, float tpf) { | ||
|
||
System.out.println("Click!"); | ||
|
||
if(name.equals("Pick") && !isPressed) { | ||
//Shoot the ray! | ||
|
||
// Reset results list. | ||
CollisionResults results = new CollisionResults(); | ||
|
||
// Convert screen click to 3d position | ||
Vector2f click2d = app.getInputManager().getCursorPosition(); | ||
Vector3f click3d = app.getCamera().getWorldCoordinates(new Vector2f(click2d.x, click2d.y), 0f).clone(); | ||
Vector3f dir = app.getCamera().getWorldCoordinates(new Vector2f(click2d.x, click2d.y), 1f).subtractLocal(click3d).normalizeLocal(); | ||
|
||
// Aim the ray from the clicked spot forwards. | ||
Ray ray = new Ray(click3d, dir); | ||
|
||
// Collect intersections between ray and all nodes in results list. | ||
app.getRootNode().collideWith(ray, results); | ||
|
||
// Print the results so we see what is going on | ||
for (int i = 0; i < results.size(); i++) { | ||
|
||
//Say what is found | ||
System.out.println(results.getCollision(i).toString()); | ||
|
||
} | ||
|
||
if (results.size() > 0) { | ||
//There is a thing, so do something | ||
|
||
System.out.println("you clicked on something"); | ||
|
||
results.getClosestCollision().getGeometry().setMaterial(Main.getRandomMat()); | ||
|
||
} | ||
} | ||
} | ||
} |
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,104 @@ | ||
package mygame; | ||
|
||
import com.jme3.app.SimpleApplication; | ||
import com.jme3.asset.AssetManager; | ||
import com.jme3.input.MouseInput; | ||
import com.jme3.input.controls.MouseButtonTrigger; | ||
import com.jme3.material.Material; | ||
import com.jme3.math.ColorRGBA; | ||
import com.jme3.renderer.RenderManager; | ||
import com.jme3.scene.Geometry; | ||
import com.jme3.scene.shape.Torus; | ||
import com.jme3.system.AppSettings; | ||
import nl.ibe.hex.HexGrid; | ||
import nl.ibe.hex.HexagonMesh; | ||
|
||
/** | ||
* test | ||
* @author normenhansen | ||
*/ | ||
public class Main extends SimpleApplication { | ||
|
||
private static AssetManager shortcut; | ||
|
||
public static void main(String[] args) { | ||
AppSettings settings = new AppSettings(true); | ||
settings.setTitle("OpenHex v0.0.1"); | ||
|
||
Main app = new Main(); | ||
app.setSettings(settings); | ||
app.start(); | ||
|
||
} | ||
private Clicker click; | ||
|
||
@Override | ||
public void simpleInitApp() { | ||
shortcut = getAssetManager(); | ||
|
||
flyCam.setMoveSpeed(50); | ||
flyCam.setDragToRotate(true); | ||
|
||
HexagonMesh h = new HexagonMesh(1); | ||
Geometry geom = new Geometry("Box", h); | ||
|
||
HexagonMesh h2 = new HexagonMesh(1); | ||
Geometry geom2 = new Geometry("Hexagon 2", h2); | ||
|
||
Torus t = new Torus(6, 6, 0.05f, 1f); | ||
Geometry cyl = new Geometry("Tor", t); | ||
|
||
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); | ||
mat.setColor("Color", ColorRGBA.Blue); | ||
cyl.setMaterial(mat); | ||
|
||
Material red = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); | ||
red.setColor("Color", ColorRGBA.Red); | ||
//red.getAdditionalRenderState().setFaceCullMode(FaceCullMode.Off); | ||
geom.setMaterial(red); | ||
|
||
Material green = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); | ||
green.setColor("Color", ColorRGBA.Green); | ||
//green.getAdditionalRenderState().setFaceCullMode(FaceCullMode.Off); | ||
geom2.setMaterial(green); | ||
|
||
// rootNode.attachChild(cyl); | ||
// rootNode.attachChild(geom); | ||
// rootNode.attachChild(geom2); | ||
geom.setLocalTranslation(0, 0, 0); | ||
|
||
float height = 2; | ||
float width = (float) (Math.sqrt(3)/2 * height); | ||
geom2.move(width/2, 0, height * 0.75f); | ||
|
||
cyl.move(-(width/2), 0, height * 0.75f); | ||
|
||
//Create the grid | ||
HexGrid grid = new HexGrid(4, rootNode); | ||
|
||
//Create a clicker | ||
click = new Clicker(this); | ||
initMappings(); | ||
} | ||
|
||
public void initMappings() { | ||
inputManager.addMapping("Pick", new MouseButtonTrigger(MouseInput.BUTTON_LEFT)); | ||
inputManager.addListener(click, "Pick"); | ||
} | ||
|
||
@Override | ||
public void simpleUpdate(float tpf) { | ||
//TODO: add update code | ||
} | ||
|
||
@Override | ||
public void simpleRender(RenderManager rm) { | ||
//TODO: add render code | ||
} | ||
|
||
public static Material getRandomMat() { | ||
Material mat = new Material(shortcut, "Common/MatDefs/Misc/Unshaded.j3md"); | ||
mat.setColor("Color", ColorRGBA.randomColor()); | ||
return mat; | ||
} | ||
} |
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,29 @@ | ||
/* | ||
* To change this template, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
package nl.ibe.hex; | ||
|
||
/** | ||
* A coordinate with 3 values. | ||
* | ||
* @author mihaita | ||
*/ | ||
public class HexCoordinate { | ||
|
||
public int x; | ||
public int y; | ||
public int z; | ||
|
||
public HexCoordinate(int x, int y, int z) { | ||
this.x = x; | ||
this.y = y; | ||
this.z = z; | ||
} | ||
|
||
@Override | ||
public String toString() | ||
{ | ||
return "HexCoordinate: [ "+x+", "+y+", "+z+" ]"; | ||
} | ||
} |
Oops, something went wrong.