Compare commits
21 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0ccb7189ee | |||
| 54f129c925 | |||
| 3722b479ee | |||
| 0bf5d7414c | |||
| e6a3dcc50e | |||
| 1219096138 | |||
| df45c5e086 | |||
| 92d82e26ce | |||
| 53c8740e13 | |||
| 11f3160846 | |||
| 68720e1d1f | |||
| 3192682853 | |||
| 8d8a90f29a | |||
| be4a13c1d0 | |||
| 4b51802309 | |||
| 9a6b5ec048 | |||
| 5ae985ced9 | |||
| 47887a4abb | |||
| 1285842b55 | |||
| 7288a7ee99 | |||
| fca84badb8 |
Generated
+2
-1
@@ -4,10 +4,11 @@
|
|||||||
<exclude-output />
|
<exclude-output />
|
||||||
<content url="file://$MODULE_DIR$">
|
<content url="file://$MODULE_DIR$">
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/resources" isTestSource="false" />
|
||||||
</content>
|
</content>
|
||||||
<orderEntry type="inheritedJdk" />
|
<orderEntry type="inheritedJdk" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
<orderEntry type="library" name="lwjgl-release-3.2" level="project" />
|
<orderEntry type="library" name="lwjgl-release-3.2" level="project" />
|
||||||
<orderEntry type="library" name="commons-io-2" level="project" />
|
<orderEntry type="library" name="snakeyaml-1.9" level="project" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
||||||
Generated
+152
@@ -0,0 +1,152 @@
|
|||||||
|
<component name="ArtifactManager">
|
||||||
|
<artifact type="jar" name="Helium-Engine:jar">
|
||||||
|
<output-path>$PROJECT_DIR$/out/artifacts/Helium_Engine_jar</output-path>
|
||||||
|
<root id="archive" name="Helium-Engine.jar">
|
||||||
|
<element id="module-output" name="Helium-Engine" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/joml-1.9.24.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-egl.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-lz4.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-nfd.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-par.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-sse.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-stb.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-vma.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-bgfx.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-cuda.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-glfw.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-jawt.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-llvm.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-lmdb.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-meow.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-odbc.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-opus.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-yoga.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-zstd.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-assimp.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-nanovg.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-openal.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-opencl.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-opengl.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-openvr.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-tinyfd.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-tootle.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-vulkan.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-xxhash.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-javadoc.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-nuklear.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-shaderc.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-sources.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-tinyexr.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-jemalloc.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-opengles.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-remotery.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-rpmalloc.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-libdivide.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-egl-javadoc.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-egl-sources.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-lz4-javadoc.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-lz4-sources.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-nfd-javadoc.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-nfd-sources.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-par-javadoc.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-par-sources.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-sse-javadoc.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-sse-sources.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-stb-javadoc.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-stb-sources.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-vma-javadoc.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-vma-sources.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-bgfx-javadoc.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-bgfx-sources.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-cuda-javadoc.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-cuda-sources.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-glfw-javadoc.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-glfw-sources.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-jawt-javadoc.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-jawt-sources.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-llvm-javadoc.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-llvm-sources.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-lmdb-javadoc.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-lmdb-sources.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-meow-javadoc.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-meow-sources.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-odbc-javadoc.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-odbc-sources.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-opus-javadoc.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-opus-sources.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-yoga-javadoc.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-yoga-sources.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-zstd-javadoc.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-zstd-sources.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-natives-macos.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-assimp-javadoc.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-assimp-sources.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-nanovg-javadoc.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-nanovg-sources.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-openal-javadoc.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-openal-sources.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-opencl-javadoc.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-opencl-sources.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-opengl-javadoc.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-opengl-sources.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-openvr-javadoc.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-openvr-sources.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-tinyfd-javadoc.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-tinyfd-sources.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-tootle-javadoc.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-tootle-sources.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-vulkan-javadoc.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-vulkan-sources.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-xxhash-javadoc.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-xxhash-sources.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-nuklear-javadoc.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-nuklear-sources.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-shaderc-javadoc.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-shaderc-sources.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-tinyexr-javadoc.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-tinyexr-sources.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-jemalloc-javadoc.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-jemalloc-sources.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-opengles-javadoc.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-opengles-sources.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-remotery-javadoc.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-remotery-sources.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-rpmalloc-javadoc.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-rpmalloc-sources.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-libdivide-javadoc.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-libdivide-sources.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-lz4-natives-macos.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-nfd-natives-macos.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-par-natives-macos.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-sse-natives-macos.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-stb-natives-macos.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-vma-natives-macos.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-bgfx-natives-macos.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-glfw-natives-macos.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-llvm-natives-macos.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-lmdb-natives-macos.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-meow-natives-macos.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-opus-natives-macos.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-yoga-natives-macos.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-zstd-natives-macos.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-assimp-natives-macos.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-nanovg-natives-macos.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-openal-natives-macos.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-opengl-natives-macos.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-openvr-natives-macos.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-tinyfd-natives-macos.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-tootle-natives-macos.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-vulkan-natives-macos.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-xxhash-natives-macos.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-nuklear-natives-macos.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-shaderc-natives-macos.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-tinyexr-natives-macos.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-jemalloc-natives-macos.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-opengles-natives-macos.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-remotery-natives-macos.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-rpmalloc-natives-macos.jar" path-in-jar="/" />
|
||||||
|
<element id="extracted-dir" path="$USER_HOME$/Downloads/lwjgl-release-3.2.3-custom/lwjgl-libdivide-natives-macos.jar" path-in-jar="/" />
|
||||||
|
</root>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
Generated
-15
@@ -1,15 +0,0 @@
|
|||||||
<component name="libraryTable">
|
|
||||||
<library name="commons-io-2">
|
|
||||||
<CLASSES>
|
|
||||||
<root url="file://$USER_HOME$/Downloads/commons-io-2.6" />
|
|
||||||
</CLASSES>
|
|
||||||
<JAVADOC>
|
|
||||||
<root url="file://$USER_HOME$/Downloads/commons-io-2.6/docs" />
|
|
||||||
</JAVADOC>
|
|
||||||
<SOURCES>
|
|
||||||
<root url="file://$USER_HOME$/Downloads/commons-io-2.6" />
|
|
||||||
</SOURCES>
|
|
||||||
<jarDirectory url="file://$USER_HOME$/Downloads/commons-io-2.6" recursive="false" />
|
|
||||||
<jarDirectory url="file://$USER_HOME$/Downloads/commons-io-2.6" recursive="false" type="SOURCES" />
|
|
||||||
</library>
|
|
||||||
</component>
|
|
||||||
Generated
+9
@@ -0,0 +1,9 @@
|
|||||||
|
<component name="libraryTable">
|
||||||
|
<library name="snakeyaml-1.9">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$USER_HOME$/Downloads/snakeyaml-1.9.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES />
|
||||||
|
</library>
|
||||||
|
</component>
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 9.0 KiB |
@@ -0,0 +1,7 @@
|
|||||||
|
public interface Game {
|
||||||
|
void setup() throws Exception;
|
||||||
|
void loop() throws Exception;
|
||||||
|
void close() throws Exception;
|
||||||
|
void run() throws Exception;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,83 +0,0 @@
|
|||||||
import org.hl.engine.graphics.*;
|
|
||||||
import org.hl.engine.io.Display;
|
|
||||||
import org.hl.engine.io.Input;
|
|
||||||
import org.hl.engine.math.lalg.Vector3f;
|
|
||||||
import org.hl.engine.math.lalg.Vector2f;
|
|
||||||
import org.lwjgl.glfw.GLFW;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public class Test {
|
|
||||||
public final static int WIDTH = 640, HEIGHT = 480;
|
|
||||||
public final String windowName = "Game!";
|
|
||||||
public Display display;
|
|
||||||
public Input i;
|
|
||||||
public Renderer renderer;
|
|
||||||
public Shader shader;
|
|
||||||
|
|
||||||
public Mesh mesh = new Mesh(new Vertex[] {
|
|
||||||
new Vertex(new Vector3f(-0.5F, 0.5F, 0.0F), new Vector3f(0, 0, 1.0F), new Vector2f(0, 0)),
|
|
||||||
new Vertex(new Vector3f(-0.5F, -0.5F, 0.0F), new Vector3f(0, 0, 1.0F), new Vector2f(0, 1)),
|
|
||||||
new Vertex(new Vector3f(0.5F, -0.5F, 0.0F), new Vector3f(1.0F, 0, 1.0F), new Vector2f(1, 1)),
|
|
||||||
new Vertex(new Vector3f(0.5F, 0.5F, 0.0F), new Vector3f(1.0F, 0, 1.0F), new Vector2f(1, 0)),
|
|
||||||
|
|
||||||
}, new int[] {
|
|
||||||
0, 1, 2,
|
|
||||||
0, 2, 3
|
|
||||||
|
|
||||||
}, new Material(new Texture("resources/textures/thonk.png")));
|
|
||||||
|
|
||||||
public void run() throws Exception {
|
|
||||||
setup();
|
|
||||||
i = new Input(display);
|
|
||||||
while (!(display.shouldClose()) && !i.isKeyDown(GLFW.GLFW_KEY_ESCAPE)) {
|
|
||||||
loop();
|
|
||||||
}
|
|
||||||
|
|
||||||
close();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void loop() {
|
|
||||||
update();
|
|
||||||
render();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void setup() throws Exception {
|
|
||||||
// System.out.println("Initializing Game ");
|
|
||||||
display = new Display(WIDTH, HEIGHT, windowName);
|
|
||||||
display.create();
|
|
||||||
shader = new Shader("/resources/shaders/mainVertex.glsl", "/resources/shaders/mainFragment.glsl");
|
|
||||||
renderer = new Renderer(shader);
|
|
||||||
display.setBackgroundColor(1F, 1F, 1F);
|
|
||||||
mesh.create();
|
|
||||||
shader.create();
|
|
||||||
|
|
||||||
}
|
|
||||||
private void update() {
|
|
||||||
// System.out.println("Updating ");
|
|
||||||
int frames = display.update();
|
|
||||||
display.setWindowName(display.getWindowName().substring(0, 4) + " (Frames : " + frames + ")");
|
|
||||||
|
|
||||||
i.reset();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void render() {
|
|
||||||
// System.out.println("Rendering ");
|
|
||||||
renderer.renderMesh(mesh);
|
|
||||||
display.swapBuffers();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void close() {
|
|
||||||
display.destroy();
|
|
||||||
mesh.destroy();
|
|
||||||
shader.destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
|
||||||
new Test().run();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -15,12 +15,19 @@ public class Mesh {
|
|||||||
private int[] indices;
|
private int[] indices;
|
||||||
private int vertexArrayObject, positionBufferObject, indicesBufferObject, colorBufferObject, textureBufferObject;
|
private int vertexArrayObject, positionBufferObject, indicesBufferObject, colorBufferObject, textureBufferObject;
|
||||||
private Material material;
|
private Material material;
|
||||||
|
private boolean type;
|
||||||
|
|
||||||
// A group of vertices combined based on the indexes
|
// A group of vertices combined based on the indexes
|
||||||
public Mesh(Vertex[] vertices, int[] indices, Material material) {
|
public Mesh(Vertex[] vertices, int[] indices, Material material, String type) throws Exception {
|
||||||
this.vertices = vertices;
|
this.vertices = vertices;
|
||||||
this.indices = indices;
|
this.indices = indices;
|
||||||
this.material = material;
|
this.material = material;
|
||||||
|
if (!type.equals("texture") && !type.equals("color")) {
|
||||||
|
throw new Exception("Type must be either texture or color. ");
|
||||||
|
}
|
||||||
|
this.type = type.equals("texture");
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -140,4 +147,12 @@ public class Mesh {
|
|||||||
|
|
||||||
return bufferID;
|
return bufferID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMaterial(Material material) {
|
||||||
|
this.material = material;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,61 @@
|
|||||||
|
package org.hl.engine.graphics;
|
||||||
|
|
||||||
|
import org.hl.engine.math.lalg.Vector2f;
|
||||||
|
import org.hl.engine.math.lalg.Vector3f;
|
||||||
|
import org.lwjgl.assimp.*;
|
||||||
|
|
||||||
|
public class ModelLoader {
|
||||||
|
public static Mesh loadModel(String path, String texture) throws Exception {
|
||||||
|
AIScene scene = Assimp.aiImportFile(path, Assimp.aiProcess_JoinIdenticalVertices | Assimp.aiProcess_Triangulate);
|
||||||
|
|
||||||
|
if (scene == null) {
|
||||||
|
throw new Exception("Couldn't load model at " + path);
|
||||||
|
}
|
||||||
|
|
||||||
|
AIMesh mesh = AIMesh.create(scene.mMeshes().get(0));
|
||||||
|
int vertexCount = mesh.mNumVertices();
|
||||||
|
|
||||||
|
AIVector3D.Buffer vertices = mesh.mVertices();
|
||||||
|
AIVector3D.Buffer normals = mesh.mNormals();
|
||||||
|
|
||||||
|
Vertex[] vertexList = new Vertex[vertexCount];
|
||||||
|
|
||||||
|
for (int i = 0; i < vertexCount; i ++) {
|
||||||
|
AIVector3D vertex = vertices.get(i);
|
||||||
|
Vector3f engineVertex = new Vector3f(vertex.x(), vertex.y(), vertex.z());
|
||||||
|
|
||||||
|
AIVector3D normal = normals.get(i);
|
||||||
|
Vector3f engineNormal = new Vector3f(normal.x(), normal.y(), normal.z());
|
||||||
|
|
||||||
|
Vector2f meshTextureCoord = new Vector2f(0, 0);
|
||||||
|
|
||||||
|
if (mesh.mNumUVComponents().get(0) != 0) {
|
||||||
|
AIVector3D tex = mesh.mTextureCoords(0).get(i);
|
||||||
|
meshTextureCoord.setX(tex.x());
|
||||||
|
meshTextureCoord.setY(tex.y());
|
||||||
|
}
|
||||||
|
|
||||||
|
vertexList[i] = new Vertex(engineVertex, meshTextureCoord, engineNormal);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int faceCount = mesh.mNumFaces();
|
||||||
|
AIFace.Buffer indices = mesh.mFaces();
|
||||||
|
int[] indicesList = new int[faceCount*3];
|
||||||
|
|
||||||
|
for (int i = 0; i < faceCount; i ++) {
|
||||||
|
AIFace face = indices.get(i);
|
||||||
|
indicesList[i * 3 + 0] = face.mIndices().get(0);
|
||||||
|
indicesList[i * 3 + 1] = face.mIndices().get(1);
|
||||||
|
indicesList[i * 3 + 2] = face.mIndices().get(2);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Mesh(vertexList, indicesList, new Material(new Texture(texture)), "texture");
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,5 +1,9 @@
|
|||||||
package org.hl.engine.graphics;
|
package org.hl.engine.graphics;
|
||||||
|
|
||||||
|
import org.hl.engine.io.Display;
|
||||||
|
import org.hl.engine.math.lalg.Matrix4f;
|
||||||
|
import org.hl.engine.objects.Camera;
|
||||||
|
import org.hl.engine.objects.GameObject;
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
import org.lwjgl.opengl.GL13;
|
import org.lwjgl.opengl.GL13;
|
||||||
import org.lwjgl.opengl.GL15;
|
import org.lwjgl.opengl.GL15;
|
||||||
@@ -8,28 +12,34 @@ import org.lwjgl.opengl.GL30;
|
|||||||
public class Renderer {
|
public class Renderer {
|
||||||
|
|
||||||
private Shader shader;
|
private Shader shader;
|
||||||
|
private Display display;
|
||||||
|
|
||||||
public Renderer(Shader shader) {
|
public Renderer(Display display, Shader shader) {
|
||||||
this.shader = shader;
|
this.shader = shader;
|
||||||
|
this.display = display;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void renderMesh(GameObject object, Camera camera) {
|
||||||
public void renderMesh(Mesh mesh) {
|
|
||||||
|
|
||||||
// Renders the mesh by drawing it using triangles (least complicated)
|
// Renders the mesh by drawing it using triangles (least complicated)
|
||||||
GL30.glBindVertexArray(mesh.getVertexArrayObject());
|
GL30.glBindVertexArray(object.getMesh().getVertexArrayObject());
|
||||||
GL30.glEnableVertexAttribArray(0);
|
GL30.glEnableVertexAttribArray(0);
|
||||||
GL30.glEnableVertexAttribArray(1);
|
GL30.glEnableVertexAttribArray(1);
|
||||||
GL30.glEnableVertexAttribArray(2);
|
GL30.glEnableVertexAttribArray(2);
|
||||||
GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, mesh.getIndicesBufferObject());
|
GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, object.getMesh().getIndicesBufferObject());
|
||||||
|
|
||||||
GL13.glActiveTexture(GL13.GL_TEXTURE0);
|
GL13.glActiveTexture(GL13.GL_TEXTURE0);
|
||||||
|
|
||||||
GL13.glBindTexture(GL11.GL_TEXTURE_2D, mesh.getMaterial().getTexture().getId());
|
GL13.glBindTexture(GL11.GL_TEXTURE_2D, object.getMesh().getMaterial().getTexture().getId());
|
||||||
|
|
||||||
shader.bind();
|
shader.bind();
|
||||||
|
|
||||||
GL11.glDrawElements(GL11.GL_TRIANGLES, mesh.getIndices().length, GL11.GL_UNSIGNED_INT, 0);
|
shader.setUniform("type", object.getMesh().isType());
|
||||||
|
shader.setUniform("projection", display.getProjectionMatrix());
|
||||||
|
shader.setUniform("view", Matrix4f.view(camera.getPosition(), camera.getRotation()));
|
||||||
|
shader.setUniform("model", Matrix4f.transform(object.getPosition(), object.getRotation(), object.getScale()));
|
||||||
|
|
||||||
|
GL11.glDrawElements(GL11.GL_TRIANGLES, object.getMesh().getIndices().length, GL11.GL_UNSIGNED_INT, 0);
|
||||||
|
|
||||||
shader.unbind();
|
shader.unbind();
|
||||||
GL30.glDisableVertexAttribArray(0);
|
GL30.glDisableVertexAttribArray(0);
|
||||||
|
|||||||
@@ -1,8 +1,15 @@
|
|||||||
package org.hl.engine.graphics;
|
package org.hl.engine.graphics;
|
||||||
|
|
||||||
|
import org.hl.engine.math.lalg.Matrix4f;
|
||||||
|
import org.hl.engine.math.lalg.Vector2f;
|
||||||
|
import org.hl.engine.math.lalg.Vector3f;
|
||||||
|
import org.hl.engine.math.lalg.Vector4f;
|
||||||
import org.hl.engine.utils.FileUtils;
|
import org.hl.engine.utils.FileUtils;
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
import org.lwjgl.opengl.GL20;
|
import org.lwjgl.opengl.GL20;
|
||||||
|
import org.lwjgl.system.MemoryUtil;
|
||||||
|
|
||||||
|
import java.nio.FloatBuffer;
|
||||||
|
|
||||||
public class Shader {
|
public class Shader {
|
||||||
private String vertexFile;
|
private String vertexFile;
|
||||||
@@ -10,6 +17,9 @@ public class Shader {
|
|||||||
|
|
||||||
private int vertexID, fragmentID, programID;
|
private int vertexID, fragmentID, programID;
|
||||||
|
|
||||||
|
public static final String VERTEXSHADER = "/resources/shaders/mainVertex.glsl";
|
||||||
|
public static final String FRAGSHADER = "/resources/shaders/mainFragment.glsl";
|
||||||
|
|
||||||
public Shader(String vertexPath, String fragmentPath) {
|
public Shader(String vertexPath, String fragmentPath) {
|
||||||
vertexFile = FileUtils.loadAsString(vertexPath);
|
vertexFile = FileUtils.loadAsString(vertexPath);
|
||||||
fragmentFile = FileUtils.loadAsString(fragmentPath);
|
fragmentFile = FileUtils.loadAsString(fragmentPath);
|
||||||
@@ -66,9 +76,40 @@ public class Shader {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GL20.glDeleteShader(vertexID);
|
}
|
||||||
GL20.glDeleteShader(fragmentID);
|
|
||||||
|
|
||||||
|
public int getUniformLocation(String name) {
|
||||||
|
return GL20.glGetUniformLocation(programID, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUniform(String name, float value) {
|
||||||
|
GL20.glUniform1f(getUniformLocation(name), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUniform(String name, int value) {
|
||||||
|
GL20.glUniform1i(getUniformLocation(name), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUniform(String name, boolean value) {
|
||||||
|
GL20.glUniform1i(getUniformLocation(name), value ? 1 : 0);
|
||||||
|
}
|
||||||
|
public void setUniform(String name, Vector2f value) {
|
||||||
|
GL20.glUniform2f(getUniformLocation(name), value.getX(), value.getY());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUniform(String name, Vector3f value) {
|
||||||
|
GL20.glUniform3f(getUniformLocation(name), value.getX(), value.getY(), value.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUniform(String name, Vector4f value) {
|
||||||
|
GL20.glUniform4f(getUniformLocation(name), value.getX(), value.getY(), value.getZ(), value.getA());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUniform(String name, Matrix4f value) {
|
||||||
|
FloatBuffer matrix = MemoryUtil.memAllocFloat(Matrix4f.SIZE * Matrix4f.SIZE);
|
||||||
|
matrix.put(value.convertTo1D()).flip();
|
||||||
|
GL20.glUniformMatrix4fv(getUniformLocation(name), true, matrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bind so we can use the shader
|
// Bind so we can use the shader
|
||||||
@@ -83,6 +124,12 @@ public class Shader {
|
|||||||
|
|
||||||
// Destroy the program
|
// Destroy the program
|
||||||
public void destroy() {
|
public void destroy() {
|
||||||
|
GL20.glDetachShader(programID, vertexID);
|
||||||
|
GL20.glDetachShader(programID, fragmentID);
|
||||||
|
|
||||||
|
GL20.glDeleteShader(vertexID);
|
||||||
|
GL20.glDeleteShader(fragmentID);
|
||||||
|
|
||||||
GL20.glDeleteProgram(programID);
|
GL20.glDeleteProgram(programID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,12 +8,31 @@ public class Vertex {
|
|||||||
|
|
||||||
// Just a vertex
|
// Just a vertex
|
||||||
|
|
||||||
private Vector3f position;
|
private Vector3f position, normal;
|
||||||
private Vector3f color;
|
private Vector3f color;
|
||||||
private Vector2f textureCoords;
|
private Vector2f textureCoords;
|
||||||
|
private boolean type;
|
||||||
|
|
||||||
|
public Vertex(Vector3f position, Vector2f textureCoords) {
|
||||||
|
this.position = position;
|
||||||
|
this.textureCoords = textureCoords;
|
||||||
|
this.color = new Vector3f(1, 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
public Vertex (Vector3f position, Vector3f color, Vector2f textureCoords) {
|
public Vertex(Vector3f position, Vector2f textureCoords, Vector3f normal) {
|
||||||
|
this.position = position;
|
||||||
|
this.textureCoords = textureCoords;
|
||||||
|
this.normal = normal;
|
||||||
|
this.color = new Vector3f(1, 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vertex(Vector3f position, Vector3f color) {
|
||||||
|
this.position = position;
|
||||||
|
this.color = color;
|
||||||
|
this.textureCoords = new Vector2f(0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vertex(Vector3f position, Vector3f color, Vector2f textureCoords) {
|
||||||
this.position = position;
|
this.position = position;
|
||||||
this.color = color;
|
this.color = color;
|
||||||
this.textureCoords = textureCoords;
|
this.textureCoords = textureCoords;
|
||||||
@@ -32,4 +51,11 @@ public class Vertex {
|
|||||||
return textureCoords;
|
return textureCoords;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector3f getNormal() {
|
||||||
|
return normal;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package org.hl.engine.io;
|
package org.hl.engine.io;
|
||||||
|
|
||||||
|
import org.hl.engine.math.lalg.Matrix4f;
|
||||||
import org.hl.engine.math.lalg.Vector3f;
|
import org.hl.engine.math.lalg.Vector3f;
|
||||||
import org.lwjgl.glfw.GLFWErrorCallback;
|
import org.lwjgl.glfw.GLFWErrorCallback;
|
||||||
import org.lwjgl.glfw.GLFWVidMode;
|
import org.lwjgl.glfw.GLFWVidMode;
|
||||||
@@ -29,15 +30,21 @@ public class Display {
|
|||||||
private int savedPosY;
|
private int savedPosY;
|
||||||
private int savedWidth;
|
private int savedWidth;
|
||||||
private int savedHeight;
|
private int savedHeight;
|
||||||
|
private Matrix4f projection;
|
||||||
|
private boolean isLocked;
|
||||||
|
private double[] cursorX = new double[1];
|
||||||
|
private double[] cursorY = new double[1];
|
||||||
|
private double[] enabledCursorX = new double[1];
|
||||||
|
private double[] enabledCursorY = new double[1];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Constructor to create the display
|
// Constructor to create the display
|
||||||
public Display (int width, int height, String windowName) {
|
public Display (int width, int height, String windowName, float fov, float near, float far) {
|
||||||
this.width = width;
|
this.width = width;
|
||||||
this.height = height;
|
this.height = height;
|
||||||
this.windowName = windowName;
|
this.windowName = windowName;
|
||||||
|
projection = Matrix4f.projection(fov, (float)this.width / (float) this.height, near, far);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Change the window name
|
// Change the window name
|
||||||
@@ -67,6 +74,10 @@ public class Display {
|
|||||||
return isFullscreen;
|
return isFullscreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Matrix4f getProjectionMatrix() {
|
||||||
|
return projection;
|
||||||
|
}
|
||||||
|
|
||||||
// Makes the screen fullscreen or not based on the argument
|
// Makes the screen fullscreen or not based on the argument
|
||||||
public void setFullscreen(boolean fullscreen) {
|
public void setFullscreen(boolean fullscreen) {
|
||||||
isFullscreen = fullscreen;
|
isFullscreen = fullscreen;
|
||||||
@@ -89,6 +100,26 @@ public class Display {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void mouseState(boolean lock) {
|
||||||
|
if (lock != isLocked) {
|
||||||
|
if (lock) {
|
||||||
|
glfwGetCursorPos(window, enabledCursorX, enabledCursorY);
|
||||||
|
glfwSetCursorPos(window, cursorX[0], cursorY[0]);
|
||||||
|
isLocked = lock;
|
||||||
|
glfwSetInputMode(window, GLFW_CURSOR, lock ? GLFW_CURSOR_DISABLED : GLFW_CURSOR_NORMAL);
|
||||||
|
} else {
|
||||||
|
glfwGetCursorPos(window, cursorX, cursorY);
|
||||||
|
isLocked = lock;
|
||||||
|
glfwSetInputMode(window, GLFW_CURSOR, lock ? GLFW_CURSOR_DISABLED : GLFW_CURSOR_NORMAL);
|
||||||
|
glfwSetCursorPos(window, enabledCursorX[0], enabledCursorY[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isLocked() {
|
||||||
|
return isLocked;
|
||||||
|
}
|
||||||
|
|
||||||
// resized getter
|
// resized getter
|
||||||
|
|
||||||
public boolean isResized() {
|
public boolean isResized() {
|
||||||
@@ -107,9 +138,13 @@ public class Display {
|
|||||||
//System.exit(1);
|
//System.exit(1);
|
||||||
throw new Exception("Failed to initialize GLFW! ");
|
throw new Exception("Failed to initialize GLFW! ");
|
||||||
}
|
}
|
||||||
|
if(System.getProperty("os.name").contains("Mac")) {
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
|
||||||
|
} else {
|
||||||
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
|
||||||
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);
|
||||||
|
}
|
||||||
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL11.GL_TRUE);
|
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL11.GL_TRUE);
|
||||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||||
|
|
||||||
@@ -129,6 +164,8 @@ public class Display {
|
|||||||
windowYPos[0] = (videoMode.height() - this.height ) / 2;
|
windowYPos[0] = (videoMode.height() - this.height ) / 2;
|
||||||
glfwSetWindowPos(window, windowXPos[0], windowYPos[0]);
|
glfwSetWindowPos(window, windowXPos[0], windowYPos[0]);
|
||||||
|
|
||||||
|
glfwSetCursorPos(window, 0, 0);
|
||||||
|
|
||||||
|
|
||||||
// Graphics
|
// Graphics
|
||||||
glfwMakeContextCurrent(window);
|
glfwMakeContextCurrent(window);
|
||||||
@@ -217,4 +254,8 @@ public class Display {
|
|||||||
public void setBackgroundColor(float r, float g, float b) {
|
public void setBackgroundColor(float r, float g, float b) {
|
||||||
background.setVector(r, g, b);
|
background.setVector(r, g, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void reset() {
|
||||||
|
swapBuffers();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,196 @@
|
|||||||
|
package org.hl.engine.math.lalg;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public class Matrix4f {
|
||||||
|
public static final int SIZE = 4;
|
||||||
|
private float[][] elements = new float[SIZE][SIZE];
|
||||||
|
|
||||||
|
|
||||||
|
public Matrix4f() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Matrix4f(float[][] values) {
|
||||||
|
this.elements = values;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static Matrix4f identity() {
|
||||||
|
float[][] identityArray = {
|
||||||
|
{1 , 0 , 0 , 0},
|
||||||
|
{0 , 1 , 0 , 0},
|
||||||
|
{0 , 0 , 1 , 0},
|
||||||
|
{0 , 0 , 0 , 1}
|
||||||
|
};
|
||||||
|
return new Matrix4f(identityArray);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Matrix4f zeroes() {
|
||||||
|
float[][] zeroMatrix = {
|
||||||
|
{0 , 0 , 0 , 0},
|
||||||
|
{0 , 0 , 0 , 0},
|
||||||
|
{0 , 0 , 0 , 0},
|
||||||
|
{0 , 0 , 0 , 0}
|
||||||
|
};
|
||||||
|
return new Matrix4f(zeroMatrix);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Matrix4f translate(Vector3f translate) {
|
||||||
|
Matrix4f result = Matrix4f.identity();
|
||||||
|
|
||||||
|
result.set(3, 0, translate.getX());
|
||||||
|
result.set(3, 1, translate.getY());
|
||||||
|
result.set(3, 2, translate.getZ());
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static Matrix4f flip(Matrix4f matrix) {
|
||||||
|
Matrix4f flippedMatrix = matrix;
|
||||||
|
for (int i = 0; i < SIZE; i ++) {
|
||||||
|
for (int j = 0; j < SIZE; j ++ ) {
|
||||||
|
flippedMatrix.set(i, j, matrix.get(j, i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return flippedMatrix;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This one doesn't work
|
||||||
|
|
||||||
|
/* public static Matrix4f rotate(float angle, Vector3f axis) {
|
||||||
|
|
||||||
|
float cos = (float)Math.cos(Math.toDegrees(angle));
|
||||||
|
float sin = (float)Math.sin(Math.toDegrees(angle));
|
||||||
|
float C = 1 - cos;
|
||||||
|
float x = axis.getX();
|
||||||
|
float y = axis.getY();
|
||||||
|
float z = axis.getZ();
|
||||||
|
float[][] rotArray = {
|
||||||
|
{cos + x*x*C , x*y*C - z*sin , x*z*C + y*sin , 0},
|
||||||
|
{y*z*C + z*sin , cos + y*y*C , y*z*C - x*sin , 0},
|
||||||
|
{z*x*C-y*sin , z*y*C + x*sin , cos + z*z*C , 0},
|
||||||
|
{0 , 0 , 0 , 1}
|
||||||
|
};
|
||||||
|
|
||||||
|
return new Matrix4f(rotArray);
|
||||||
|
} */
|
||||||
|
public static Matrix4f rotate(float angle, Vector3f axis) {
|
||||||
|
Matrix4f result = Matrix4f.identity();
|
||||||
|
|
||||||
|
float cos = (float) Math.cos(Math.toRadians(angle));
|
||||||
|
float sin = (float) Math.sin(Math.toRadians(angle));
|
||||||
|
float C = 1 - cos;
|
||||||
|
|
||||||
|
result.set(0, 0, cos + axis.getX() * axis.getX() * C);
|
||||||
|
result.set(0, 1, axis.getX() * axis.getY() * C - axis.getZ() * sin);
|
||||||
|
result.set(0, 2, axis.getX() * axis.getZ() * C + axis.getY() * sin);
|
||||||
|
result.set(1, 0, axis.getY() * axis.getX() * C + axis.getZ() * sin);
|
||||||
|
result.set(1, 1, cos + axis.getY() * axis.getY() * C);
|
||||||
|
result.set(1, 2, axis.getY() * axis.getZ() * C - axis.getX() * sin);
|
||||||
|
result.set(2, 0, axis.getZ() * axis.getX() * C - axis.getY() * sin);
|
||||||
|
result.set(2, 1, axis.getZ() * axis.getY() * C + axis.getX() * sin);
|
||||||
|
result.set(2, 2, cos + axis.getZ() * axis.getZ() * C);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Matrix4f scale(Vector3f scaleVec) {
|
||||||
|
|
||||||
|
Matrix4f result = Matrix4f.identity();
|
||||||
|
|
||||||
|
result.set(0, 0, scaleVec.getX());
|
||||||
|
result.set(1, 1, scaleVec.getY());
|
||||||
|
result.set(2, 2, scaleVec.getZ());
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Matrix4f projection( float fov, float aspectRatio, float near, float far) {
|
||||||
|
Matrix4f result = Matrix4f.identity();
|
||||||
|
|
||||||
|
float tan = (float)Math.tan(Math.toRadians(fov / 2));
|
||||||
|
float range = far - near;
|
||||||
|
|
||||||
|
result.set(0, 0, 1.0f / (aspectRatio * tan));
|
||||||
|
result.set(1, 1, 1.0f / tan);
|
||||||
|
result.set(2, 2, -((far + near) / range));
|
||||||
|
result.set(3, 2, -1.0f);
|
||||||
|
result.set(2, 3, -(2.0f*far*near/range));
|
||||||
|
result.set(3, 3, 0f);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Matrix4f view(Vector3f position, Vector3f rotation) {
|
||||||
|
|
||||||
|
Vector3f negative = new Vector3f(-position.getX(), -position.getY(), -position.getZ());
|
||||||
|
Matrix4f translationMatrix = Matrix4f.translate(negative);
|
||||||
|
Matrix4f rotationXMatrix = Matrix4f.rotate(-rotation.getX(), new Vector3f(1, 0, 0));
|
||||||
|
Matrix4f rotationYMatrix = Matrix4f.rotate(-rotation.getY(), new Vector3f(0, 1, 0));
|
||||||
|
Matrix4f rotationZMatrix = Matrix4f.rotate(-rotation.getZ(), new Vector3f(0, 0, 1));
|
||||||
|
|
||||||
|
Matrix4f rotMat = Matrix4f.multiply(rotationZMatrix, Matrix4f.multiply(rotationXMatrix, rotationYMatrix));
|
||||||
|
|
||||||
|
return Matrix4f.multiply(rotMat, translationMatrix);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Matrix4f multiply(Matrix4f first, Matrix4f second) {
|
||||||
|
|
||||||
|
Matrix4f result = Matrix4f.zeroes();
|
||||||
|
|
||||||
|
for (int i = 0; i < SIZE; i ++ ) {
|
||||||
|
for (int j = 0; j < SIZE; j ++) {
|
||||||
|
result.set(i, j,
|
||||||
|
first.get(0, i) * second.get(j, 0) +
|
||||||
|
first.get(1, i) * second.get(j, 1) +
|
||||||
|
first.get(2, i) * second.get(j, 2) +
|
||||||
|
first.get(3, i) * second.get(j, 3)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public float get(int x, int y) {
|
||||||
|
return elements[x][y];
|
||||||
|
}
|
||||||
|
|
||||||
|
public void set(int x, int y, float value) {
|
||||||
|
elements[x][y] = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float[][] getAll() {
|
||||||
|
return elements;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Matrix4f transform(Vector3f position, Vector3f rotation, Vector3f scale) {
|
||||||
|
Matrix4f translationMatrix = Matrix4f.translate(position);
|
||||||
|
Matrix4f rotationXMatrix = Matrix4f.rotate(rotation.getX(), new Vector3f(1, 0, 0));
|
||||||
|
Matrix4f rotationYMatrix = Matrix4f.rotate(rotation.getY(), new Vector3f(0, 1, 0));
|
||||||
|
Matrix4f rotationZMatrix = Matrix4f.rotate(rotation.getZ(), new Vector3f(0, 0, 1));
|
||||||
|
Matrix4f scaleMatrix = Matrix4f.scale(scale);
|
||||||
|
|
||||||
|
Matrix4f rotMat = Matrix4f.multiply(rotationXMatrix, Matrix4f.multiply(rotationYMatrix, rotationZMatrix));
|
||||||
|
|
||||||
|
return Matrix4f.multiply(translationMatrix, Matrix4f.multiply(rotMat, scaleMatrix));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public float[] convertTo1D() {
|
||||||
|
float[] returnedArray = new float[SIZE*SIZE];
|
||||||
|
int sizeOfRow = elements[0].length;
|
||||||
|
for (int i = 0; i < elements.length; i ++) {
|
||||||
|
for (int j = 0; j < sizeOfRow; j ++) {
|
||||||
|
returnedArray[i*SIZE + j] = elements[i][j];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return returnedArray;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
package org.hl.engine.math.lalg;
|
package org.hl.engine.math.lalg;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class Vector2f {
|
public class Vector2f {
|
||||||
private float x;
|
private float x;
|
||||||
private float y;
|
private float y;
|
||||||
@@ -15,6 +17,66 @@ public class Vector2f {
|
|||||||
this.y = y;
|
this.y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static Vector2f add(Vector2f first, Vector2f second) {
|
||||||
|
return new Vector2f(first.getX() + second.getX(), first.getY() + second.getY());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Vector2f sub(Vector2f first, Vector2f second) {
|
||||||
|
return new Vector2f(first.getX() - second.getX(), first.getY() - second.getY());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Vector2f mul(Vector2f first, Vector2f second) {
|
||||||
|
return new Vector2f(first.getX() * second.getX(), first.getY() * second.getY());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Vector2f div(Vector2f first, Vector2f second) {
|
||||||
|
return new Vector2f(first.getX() / second.getX(), first.getY() / second.getY());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float dot(Vector2f first, Vector2f second) {
|
||||||
|
return first.getX()*second.getX() + first.getY()*second.getY();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float magnitude(Vector2f vector) {
|
||||||
|
return (float)Math.sqrt(vector.getX()*vector.getX() + vector.getY()*vector.getY());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Vector2f normalize(Vector2f vector) {
|
||||||
|
float len = Vector2f.magnitude(vector);
|
||||||
|
return Vector2f.div(vector, new Vector2f(len, len));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Vector2f scale(Vector2f vector, float scalar) {
|
||||||
|
return new Vector2f(vector.getX()*scalar, vector.getY()*scalar);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Vector2f projection(Vector2f projecting, Vector2f projectedOnto) {
|
||||||
|
return Vector2f.scale(projectedOnto, ( Vector2f.dot(projecting, projectedOnto) / Vector2f.dot(projectedOnto, projectedOnto) ));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
Vector2f vector2f = (Vector2f) o;
|
||||||
|
return Float.compare(vector2f.getX(), getX()) == 0 &&
|
||||||
|
Float.compare(vector2f.getY(), getY()) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(getX(), getY());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Vector2f{" +
|
||||||
|
"x=" + x +
|
||||||
|
", y=" + y +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
|
||||||
public float getX() {
|
public float getX() {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package org.hl.engine.math.lalg;
|
package org.hl.engine.math.lalg;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class Vector3f {
|
public class Vector3f {
|
||||||
private float x;
|
private float x;
|
||||||
private float y;
|
private float y;
|
||||||
@@ -19,6 +21,67 @@ public class Vector3f {
|
|||||||
this.z = z;
|
this.z = z;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Vector3f add(Vector3f first, Vector3f second) {
|
||||||
|
return new Vector3f(first.getX() + second.getX(), first.getY() + second.getY(), first.getZ() + second.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Vector3f sub(Vector3f first, Vector3f second) {
|
||||||
|
return new Vector3f(first.getX() - second.getX(), first.getY() - second.getY(), first.getZ() - second.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Vector3f mul(Vector3f first, Vector3f second) {
|
||||||
|
return new Vector3f(first.getX() * second.getX(), first.getY() * second.getY(), first.getZ() * second.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Vector3f div(Vector3f first, Vector3f second) {
|
||||||
|
return new Vector3f(first.getX() / second.getX(), first.getY() / second.getY(), first.getZ() / second.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float dot(Vector3f first, Vector3f second) {
|
||||||
|
return first.getX()*second.getX() + first.getY()*second.getY() + first.getZ()*second.getZ();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float magnitude(Vector3f vector) {
|
||||||
|
return (float)Math.sqrt(vector.getX()*vector.getX() + vector.getY()*vector.getY() + vector.getZ()*vector.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Vector3f normalize(Vector3f vector) {
|
||||||
|
float len = Vector3f.magnitude(vector);
|
||||||
|
return Vector3f.div(vector, new Vector3f(len, len, len));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Vector3f scale(Vector3f vector, float scalar) {
|
||||||
|
return new Vector3f(vector.getX()*scalar, vector.getY()*scalar, vector.getZ()*scalar);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Vector3f projection(Vector3f projecting, Vector3f projectedOnto) {
|
||||||
|
return Vector3f.scale(projectedOnto, ( Vector3f.dot(projecting, projectedOnto) / Vector3f.dot(projectedOnto, projectedOnto) ));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
Vector3f vector3f = (Vector3f) o;
|
||||||
|
return Float.compare(vector3f.getX(), getX()) == 0 &&
|
||||||
|
Float.compare(vector3f.getY(), getY()) == 0 &&
|
||||||
|
Float.compare(vector3f.getZ(), getZ()) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(getX(), getY(), getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Vector3f{" +
|
||||||
|
"x=" + x +
|
||||||
|
", y=" + y +
|
||||||
|
", z=" + z +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
|
||||||
public float getX() {
|
public float getX() {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package org.hl.engine.math.lalg;
|
package org.hl.engine.math.lalg;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class Vector4f {
|
public class Vector4f {
|
||||||
private float x;
|
private float x;
|
||||||
private float y;
|
private float y;
|
||||||
@@ -21,6 +23,75 @@ public class Vector4f {
|
|||||||
this.a = a;
|
this.a = a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void add(float x, float y, float z, float a) {
|
||||||
|
this.x += x;
|
||||||
|
this.y += y;
|
||||||
|
this.z += z;
|
||||||
|
this.a += a;
|
||||||
|
}
|
||||||
|
public static Vector4f add(Vector4f first, Vector4f second) {
|
||||||
|
return new Vector4f(first.getX() + second.getX(), first.getY() + second.getY(), first.getZ() + second.getZ(), first.getA() + second.getA());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Vector4f sub(Vector4f first, Vector4f second) {
|
||||||
|
return new Vector4f(first.getX() - second.getX(), first.getY() - second.getY(), first.getZ() - second.getZ(), first.getA() - second.getA());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Vector4f mul(Vector4f first, Vector4f second) {
|
||||||
|
return new Vector4f(first.getX() * second.getX(), first.getY() * second.getY(), first.getZ() * second.getZ(), first.getA() * second.getA());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Vector4f div(Vector4f first, Vector4f second) {
|
||||||
|
return new Vector4f(first.getX() / second.getX(), first.getY() / second.getY(), first.getZ() / second.getZ(), first.getA() / second.getA());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float dot(Vector4f first, Vector4f second) {
|
||||||
|
return first.getX()*second.getX() + first.getY()*second.getY() + first.getZ()*second.getZ() + first.getA()*second.getA();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float magnitude(Vector4f vector) {
|
||||||
|
return (float)Math.sqrt(vector.getX()*vector.getX() + vector.getY()*vector.getY() + vector.getZ()*vector.getZ() + vector.getA()*vector.getA());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Vector4f normalize(Vector4f vector) {
|
||||||
|
float len = Vector4f.magnitude(vector);
|
||||||
|
return Vector4f.div(vector, new Vector4f(len, len, len, len));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Vector4f scale(Vector4f vector, float scalar) {
|
||||||
|
return new Vector4f(vector.getX()*scalar, vector.getY()*scalar, vector.getZ()*scalar, vector.getA()*scalar);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Vector4f projection(Vector4f projecting, Vector4f projectedOnto) {
|
||||||
|
return Vector4f.scale(projectedOnto, ( Vector4f.dot(projecting, projectedOnto) / Vector4f.dot(projectedOnto, projectedOnto) ));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
Vector4f vector4f = (Vector4f) o;
|
||||||
|
return Float.compare(vector4f.getX(), getX()) == 0 &&
|
||||||
|
Float.compare(vector4f.getY(), getY()) == 0 &&
|
||||||
|
Float.compare(vector4f.getZ(), getZ()) == 0 &&
|
||||||
|
Float.compare(vector4f.getA(), getA()) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(getX(), getY(), getZ(), getA());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Vector4f{" +
|
||||||
|
"x=" + x +
|
||||||
|
", y=" + y +
|
||||||
|
", z=" + z +
|
||||||
|
", a=" + a +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
|
||||||
public float getX() {
|
public float getX() {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package org.hl.engine.objects;
|
||||||
|
import org.hl.engine.math.lalg.Vector3f;
|
||||||
|
|
||||||
|
public class Camera {
|
||||||
|
private Vector3f position;
|
||||||
|
private Vector3f rotation;
|
||||||
|
|
||||||
|
public Camera(Vector3f position, Vector3f rotation) {
|
||||||
|
this.position = position;
|
||||||
|
this.rotation = rotation;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public Vector3f getPosition() {
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPosition(Vector3f position) throws Exception {
|
||||||
|
this.position = position;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector3f getRotation() {
|
||||||
|
return rotation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRotation(Vector3f rotation) throws Exception {
|
||||||
|
this.rotation = rotation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void movePosition(float offsetX, float offsetY, float offsetZ) {
|
||||||
|
if(offsetZ != 0) {
|
||||||
|
position.setZ(position.getZ() + (float) Math.cos(Math.toRadians(rotation.getY())) * offsetZ);
|
||||||
|
position.setX(position.getX() + (float) Math.sin(Math.toRadians(rotation.getY())) * -offsetZ);
|
||||||
|
}
|
||||||
|
if(offsetX != 0) {
|
||||||
|
position.setX(position.getX() + (float) Math.cos(Math.toRadians(rotation.getY())) * offsetX) ;
|
||||||
|
position.setZ(position.getZ() + (float) Math.sin(Math.toRadians(rotation.getY())) * offsetX);
|
||||||
|
}
|
||||||
|
|
||||||
|
position.setY(position.getY() + offsetY);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,96 @@
|
|||||||
|
package org.hl.engine.objects;
|
||||||
|
|
||||||
|
import org.hl.engine.io.Display;
|
||||||
|
import org.hl.engine.io.Input;
|
||||||
|
import org.hl.engine.math.lalg.Vector3f;
|
||||||
|
import org.lwjgl.glfw.GLFW;
|
||||||
|
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
|
public class FirstPersonCamera extends Camera {
|
||||||
|
private Input i;
|
||||||
|
private float moveSpeed;
|
||||||
|
private float sensitivity;
|
||||||
|
|
||||||
|
private double oldMouseX, oldMouseY = 0;
|
||||||
|
private double newMouseX, newMouseY;
|
||||||
|
|
||||||
|
public FirstPersonCamera(Vector3f position, Vector3f rotation, float moveSpeed, float sensitivity) {
|
||||||
|
super(position, rotation);
|
||||||
|
this.moveSpeed = moveSpeed;
|
||||||
|
this.sensitivity = sensitivity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void create(Input i) {
|
||||||
|
this.i = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void standardKeybindUpdate () throws Exception {
|
||||||
|
|
||||||
|
newMouseX = i.getMouseX();
|
||||||
|
newMouseY = i.getMouseY();
|
||||||
|
|
||||||
|
|
||||||
|
Vector3f cameraPos = getPosition();
|
||||||
|
Vector3f cameraRot = getRotation();
|
||||||
|
|
||||||
|
|
||||||
|
float dx = (float) ((float)newMouseX - oldMouseX);
|
||||||
|
float dy = (float) ((float)newMouseY - oldMouseY);
|
||||||
|
oldMouseX = newMouseX;
|
||||||
|
oldMouseY = newMouseY;
|
||||||
|
|
||||||
|
cameraRot = Vector3f.add(cameraRot, new Vector3f(dy*sensitivity, dx*sensitivity, 0));
|
||||||
|
|
||||||
|
if (i.isKeyDown(GLFW.GLFW_KEY_A)) movePosition(-moveSpeed, 0, 0);
|
||||||
|
if (i.isKeyDown(GLFW.GLFW_KEY_D)) movePosition(moveSpeed, 0, 0);
|
||||||
|
if (i.isKeyDown(GLFW.GLFW_KEY_W)) movePosition(0, 0, -moveSpeed);
|
||||||
|
if (i.isKeyDown(GLFW.GLFW_KEY_S)) movePosition(0, 0, moveSpeed);
|
||||||
|
if (i.isKeyDown(GLFW.GLFW_KEY_SPACE)) movePosition(0, moveSpeed, 0);
|
||||||
|
if (i.isKeyDown(GLFW.GLFW_KEY_LEFT_SHIFT)) movePosition(0, -moveSpeed, 0);
|
||||||
|
if (i.keyPress(GLFW.GLFW_KEY_R)) moveSpeed = 3*moveSpeed;
|
||||||
|
if (i.keyReleased(GLFW.GLFW_KEY_R)) moveSpeed = moveSpeed / 3;
|
||||||
|
|
||||||
|
setRotation(cameraRot);
|
||||||
|
setPosition(cameraPos);
|
||||||
|
|
||||||
|
i.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void moveForward() {
|
||||||
|
movePosition(0, 0, -moveSpeed);
|
||||||
|
}
|
||||||
|
public void moveBackward() {
|
||||||
|
movePosition(0, 0, moveSpeed);
|
||||||
|
}
|
||||||
|
public void moveLeft() {
|
||||||
|
movePosition(-moveSpeed, 0, 0);
|
||||||
|
}
|
||||||
|
public void moveRight() {
|
||||||
|
movePosition(moveSpeed, 0, 0);
|
||||||
|
}
|
||||||
|
public void moveUp() {
|
||||||
|
movePosition(0, moveSpeed, 0);
|
||||||
|
}
|
||||||
|
public void moveDown() {
|
||||||
|
movePosition(0, -moveSpeed, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getMoveSpeed() {
|
||||||
|
return moveSpeed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMoveSpeed(float moveSpeed) {
|
||||||
|
this.moveSpeed = moveSpeed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void rotateCamera(float dx, float dy) throws Exception {
|
||||||
|
|
||||||
|
Vector3f cameraRot = getRotation();
|
||||||
|
cameraRot = Vector3f.add(cameraRot, new Vector3f(dy*sensitivity, dx*sensitivity, 0));
|
||||||
|
|
||||||
|
|
||||||
|
setRotation(cameraRot);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package org.hl.engine.objects;
|
||||||
|
|
||||||
|
import org.hl.engine.math.lalg.Vector3f;
|
||||||
|
|
||||||
|
public class FixedCamera extends Camera {
|
||||||
|
public FixedCamera(Vector3f position, Vector3f rotation) {
|
||||||
|
super(position, rotation);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setRotation(Vector3f rotation) throws Exception {
|
||||||
|
throw new Exception("You cannot rotate a fixed camera! ");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setPosition(Vector3f rotation) throws Exception {
|
||||||
|
throw new Exception("You cannot move a fixed camera! ");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,128 @@
|
|||||||
|
package org.hl.engine.objects;
|
||||||
|
|
||||||
|
import org.hl.engine.graphics.*;
|
||||||
|
import org.hl.engine.math.lalg.Vector2f;
|
||||||
|
import org.hl.engine.math.lalg.Vector3f;
|
||||||
|
import org.hl.engine.objects.yloaders.YMesh;
|
||||||
|
import org.hl.engine.objects.yloaders.YPoint;
|
||||||
|
import org.yaml.snakeyaml.Yaml;
|
||||||
|
import org.yaml.snakeyaml.constructor.Constructor;
|
||||||
|
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
|
||||||
|
public class GameObject {
|
||||||
|
private Vector3f position, rotation, scale;
|
||||||
|
private Mesh mesh;
|
||||||
|
|
||||||
|
public GameObject(Mesh mesh, Vector3f position, Vector3f rotation, Vector3f scale) {
|
||||||
|
this.position = position;
|
||||||
|
this.rotation = rotation;
|
||||||
|
this.scale = scale;
|
||||||
|
this.mesh = mesh;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GameObject(String meshFileName, Vector3f position, Vector3f rotation, Vector3f scale) throws Exception {
|
||||||
|
if (!meshFileName.endsWith(".mesh")) { throw new Exception("Wrong file type! "); }
|
||||||
|
Yaml yaml = new Yaml();
|
||||||
|
FileInputStream inputStream = new FileInputStream(meshFileName);
|
||||||
|
YMesh yMesh = yaml.loadAs(inputStream, YMesh.class);
|
||||||
|
Integer[] cull = yMesh.getCull().toArray(new Integer[0]);
|
||||||
|
String type = yMesh.getType();
|
||||||
|
String texture = yMesh.getTexture();
|
||||||
|
YPoint[] vertices = yMesh.getVertices().toArray(new YPoint[0]);
|
||||||
|
Vertex[] meshFormat = new Vertex[vertices.length];
|
||||||
|
|
||||||
|
for (YPoint vertex : vertices) {
|
||||||
|
if (vertex.getVertex().size() != 3) {
|
||||||
|
throw new Exception("Incorrect number of coordinates. ");
|
||||||
|
}
|
||||||
|
if (vertex.getColor().size() != 3) {
|
||||||
|
throw new Exception("Incorrect number of color values. ");
|
||||||
|
}
|
||||||
|
if (vertex.getTexture().size() != 2) {
|
||||||
|
throw new Exception("Incorrect number of texture coordinates. ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!type.equals("texture") && !type.equals("color")) {
|
||||||
|
throw new Exception("Incorrect type. Type can only be texture or color. ");
|
||||||
|
}
|
||||||
|
for (int i = 0; i < vertices.length; i ++) {
|
||||||
|
Vertex value = new Vertex(
|
||||||
|
new Vector3f(vertices[i].getVertex().get(0), vertices[i].getVertex().get(1), vertices[i].getVertex().get(2)),
|
||||||
|
new Vector3f(vertices[i].getColor().get(0), vertices[i].getColor().get(1), vertices[i].getColor().get(2)),
|
||||||
|
new Vector2f(vertices[i].getTexture().get(0), vertices[i].getTexture().get(1)));
|
||||||
|
meshFormat[i] = value;
|
||||||
|
}
|
||||||
|
int[] indices = new int[cull.length];
|
||||||
|
for (int j = 0; j < cull.length; j ++) {
|
||||||
|
indices[j] = cull[j];
|
||||||
|
}
|
||||||
|
this.mesh = new Mesh(meshFormat, indices, new Material(new Texture(texture)), type);
|
||||||
|
this.position = position;
|
||||||
|
this.scale = scale;
|
||||||
|
this.rotation = rotation;
|
||||||
|
|
||||||
|
}
|
||||||
|
public GameObject(String meshFileName, String texturePath, Vector3f position, Vector3f rotation, Vector3f scale) throws Exception {
|
||||||
|
this.mesh = ModelLoader.loadModel(meshFileName, texturePath);
|
||||||
|
this.position = position;
|
||||||
|
this.scale = scale;
|
||||||
|
this.rotation = rotation;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void create() {
|
||||||
|
mesh.create();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void destroy() {
|
||||||
|
mesh.destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector3f getPosition() {
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector3f getRotation() {
|
||||||
|
return rotation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector3f getScale() {
|
||||||
|
return scale;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Mesh getMesh() {
|
||||||
|
return mesh;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPosition(Vector3f position) {
|
||||||
|
this.position = position;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRotation(Vector3f rotation) {
|
||||||
|
this.rotation = rotation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setScale(Vector3f scale) {
|
||||||
|
this.scale = scale;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
GameObject that = (GameObject) o;
|
||||||
|
return Objects.equals(getPosition(), that.getPosition()) &&
|
||||||
|
Objects.equals(getRotation(), that.getRotation()) &&
|
||||||
|
Objects.equals(getScale(), that.getScale()) &&
|
||||||
|
Objects.equals(getMesh(), that.getMesh());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(getPosition(), getRotation(), getScale(), getMesh());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,173 @@
|
|||||||
|
package org.hl.engine.objects;
|
||||||
|
|
||||||
|
import org.hl.engine.io.Input;
|
||||||
|
import org.hl.engine.math.lalg.Vector3f;
|
||||||
|
import org.lwjgl.glfw.GLFW;
|
||||||
|
|
||||||
|
public class ThirdPersonCamera extends Camera {
|
||||||
|
|
||||||
|
private GameObject object;
|
||||||
|
private Input i;
|
||||||
|
private float distance;
|
||||||
|
private float angle = 0;
|
||||||
|
private float horizAngle = 0;
|
||||||
|
private float vertAngle = 0;
|
||||||
|
private float moveSpeed;
|
||||||
|
private float sensitivity;
|
||||||
|
private float near;
|
||||||
|
private float far;
|
||||||
|
private boolean clickToMove;
|
||||||
|
private boolean clickToZoom;
|
||||||
|
private boolean zoomEnabled;
|
||||||
|
|
||||||
|
private double oldMouseX, oldMouseY = 0;
|
||||||
|
private double newMouseX, newMouseY;
|
||||||
|
|
||||||
|
public ThirdPersonCamera(Vector3f position, Vector3f rotation, GameObject object, float sensitivity, float distance, float near, float far, boolean clickToMove, boolean clickToZoom, boolean zoomEnabled) {
|
||||||
|
super(position, rotation);
|
||||||
|
this.object = object;
|
||||||
|
this.sensitivity = sensitivity;
|
||||||
|
this.clickToMove = clickToMove;
|
||||||
|
this.clickToZoom = clickToZoom;
|
||||||
|
this.zoomEnabled = zoomEnabled;
|
||||||
|
this.near = near;
|
||||||
|
this.far = far;
|
||||||
|
this.distance = distance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void create(Input i) throws Exception {
|
||||||
|
|
||||||
|
this.i = i;
|
||||||
|
setRotation(getRotation());
|
||||||
|
setPosition(getPosition());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void standardKeybindUpdate() throws Exception {
|
||||||
|
|
||||||
|
newMouseX = i.getMouseX();
|
||||||
|
newMouseY = i.getMouseY();
|
||||||
|
|
||||||
|
|
||||||
|
float dx = (float) ((float)newMouseX - oldMouseX);
|
||||||
|
float dy = (float) ((float)newMouseY - oldMouseY);
|
||||||
|
|
||||||
|
if (clickToMove && clickToZoom) {
|
||||||
|
if (i.isButtonDown(GLFW.GLFW_MOUSE_BUTTON_LEFT)) {
|
||||||
|
vertAngle -= dy * sensitivity;
|
||||||
|
horizAngle += dx * sensitivity;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i.isButtonDown(GLFW.GLFW_MOUSE_BUTTON_RIGHT) && zoomEnabled) {
|
||||||
|
if (distance > 0) {
|
||||||
|
distance += dy * sensitivity;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
distance = near;
|
||||||
|
}
|
||||||
|
if (distance > far) {
|
||||||
|
distance = far;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (clickToMove) {
|
||||||
|
|
||||||
|
if (i.isButtonDown(GLFW.GLFW_MOUSE_BUTTON_LEFT)) {
|
||||||
|
vertAngle -= dy * sensitivity;
|
||||||
|
horizAngle += dx * sensitivity;
|
||||||
|
}
|
||||||
|
if (zoomEnabled) {
|
||||||
|
if (distance > 0) {
|
||||||
|
distance += dy * sensitivity;
|
||||||
|
} else {
|
||||||
|
distance = near;
|
||||||
|
}
|
||||||
|
if (distance > far) {
|
||||||
|
distance = far;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (clickToZoom) {
|
||||||
|
|
||||||
|
vertAngle -= dy * sensitivity;
|
||||||
|
horizAngle += dx * sensitivity;
|
||||||
|
|
||||||
|
if (i.isButtonDown(GLFW.GLFW_MOUSE_BUTTON_RIGHT) && zoomEnabled) {
|
||||||
|
if (distance > 0) {
|
||||||
|
distance += dy * sensitivity;
|
||||||
|
} else {
|
||||||
|
distance = near;
|
||||||
|
}
|
||||||
|
if (distance > far) {
|
||||||
|
distance = far;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
vertAngle -= dy * sensitivity;
|
||||||
|
horizAngle += dx * sensitivity;
|
||||||
|
if (zoomEnabled) {
|
||||||
|
if (distance > 0) {
|
||||||
|
distance += dy * sensitivity;
|
||||||
|
} else {
|
||||||
|
distance = near;
|
||||||
|
}
|
||||||
|
if (distance > far) {
|
||||||
|
distance = far;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
oldMouseX = newMouseX;
|
||||||
|
oldMouseY = newMouseY;
|
||||||
|
|
||||||
|
float horizDistance = (float) (distance * Math.cos(Math.toRadians(vertAngle)));
|
||||||
|
float vertDistance = (float) (distance * Math.sin(Math.toRadians(vertAngle)));
|
||||||
|
|
||||||
|
float xOffset = (float) (horizDistance * Math.sin(Math.toRadians(-horizAngle)));
|
||||||
|
float zOffset = (float) (horizDistance * Math.cos(Math.toRadians(-horizAngle)));
|
||||||
|
|
||||||
|
setPosition(new Vector3f(object.getPosition().getX() + xOffset, object.getPosition().getY() - vertDistance, object.getPosition().getZ() + zOffset));
|
||||||
|
setRotation(new Vector3f(-vertAngle, horizAngle,0));
|
||||||
|
|
||||||
|
i.reset();
|
||||||
|
|
||||||
|
}
|
||||||
|
public void movePosition (float dy, float dx) throws Exception {
|
||||||
|
vertAngle -= dy * sensitivity;
|
||||||
|
horizAngle += dx * sensitivity;
|
||||||
|
|
||||||
|
float horizDistance = (float) (distance * Math.cos(Math.toRadians(vertAngle)));
|
||||||
|
float vertDistance = (float) (distance * Math.sin(Math.toRadians(vertAngle)));
|
||||||
|
|
||||||
|
float xOffset = (float) (horizDistance * Math.sin(Math.toRadians(-horizAngle)));
|
||||||
|
float zOffset = (float) (horizDistance * Math.cos(Math.toRadians(-horizAngle)));
|
||||||
|
|
||||||
|
setPosition(new Vector3f(object.getPosition().getX() + xOffset, object.getPosition().getY() - vertDistance, object.getPosition().getZ() + zOffset));
|
||||||
|
setRotation(new Vector3f(-vertAngle, horizAngle,0));
|
||||||
|
}
|
||||||
|
public void zoom (float dy) throws Exception {
|
||||||
|
if (zoomEnabled) {
|
||||||
|
if (distance > 0) {
|
||||||
|
distance += dy * sensitivity;
|
||||||
|
} else {
|
||||||
|
distance = near;
|
||||||
|
}
|
||||||
|
if (distance > far) {
|
||||||
|
distance = far;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
float horizDistance = (float) (distance * Math.cos(Math.toRadians(vertAngle)));
|
||||||
|
float vertDistance = (float) (distance * Math.sin(Math.toRadians(vertAngle)));
|
||||||
|
|
||||||
|
float xOffset = (float) (horizDistance * Math.sin(Math.toRadians(-horizAngle)));
|
||||||
|
float zOffset = (float) (horizDistance * Math.cos(Math.toRadians(-horizAngle)));
|
||||||
|
|
||||||
|
setPosition(new Vector3f(object.getPosition().getX() + xOffset, object.getPosition().getY() - vertDistance, object.getPosition().getZ() + zOffset));
|
||||||
|
setRotation(new Vector3f(-vertAngle, horizAngle,0));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package org.hl.engine.objects;
|
||||||
|
|
||||||
|
import org.hl.engine.math.lalg.Vector3f;
|
||||||
|
|
||||||
|
public class TopDownCamera extends FixedCamera {
|
||||||
|
public TopDownCamera(Vector3f position) {
|
||||||
|
super(position, new Vector3f(90, 0, 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package org.hl.engine.objects.yloaders ;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class YMesh implements java.io.Serializable {
|
||||||
|
private String type;
|
||||||
|
private ArrayList<YPoint> vertices;
|
||||||
|
private ArrayList<Integer> cull;
|
||||||
|
private String texture;
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<YPoint> getVertices() {
|
||||||
|
return vertices;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVertices(ArrayList<YPoint> vertices) {
|
||||||
|
this.vertices = vertices;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<Integer> getCull() {
|
||||||
|
return cull;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCull(ArrayList<Integer> cull) {
|
||||||
|
this.cull = cull;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTexture() {
|
||||||
|
return texture;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTexture(String texture) {
|
||||||
|
this.texture = texture;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package org.hl.engine.objects.yloaders;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class YPoint implements java.io.Serializable {
|
||||||
|
private ArrayList<Float> vertex;
|
||||||
|
private ArrayList<Float> texture;
|
||||||
|
private ArrayList<Float> color;
|
||||||
|
|
||||||
|
public ArrayList<Float> getVertex() {
|
||||||
|
return vertex;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVertex(ArrayList<Float> vertex) {
|
||||||
|
this.vertex = vertex;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<Float> getTexture() {
|
||||||
|
return texture;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTexture(ArrayList<Float> texture) {
|
||||||
|
this.texture = texture;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<Float> getColor() {
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setColor(ArrayList<Float> color) {
|
||||||
|
this.color = color;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,12 +1,17 @@
|
|||||||
#version 410 core
|
#version 410 core
|
||||||
|
|
||||||
|
in vec3 passColor;
|
||||||
|
in vec2 passTextureCoord;
|
||||||
|
uniform int type;
|
||||||
|
|
||||||
|
out vec4 outColor;
|
||||||
|
|
||||||
layout(location = 0) in vec3 passColor;
|
uniform sampler2D tex;
|
||||||
layout(location = 1) in vec2 passTextureCoord;
|
|
||||||
|
|
||||||
layout(location = 0) out vec4 outColor;
|
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
outColor = vec4(passColor, 1.0);
|
if (type == 1) {
|
||||||
|
outColor = texture(tex, passTextureCoord);
|
||||||
|
} else {
|
||||||
|
outColor = vec4(passColor, 1.0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +1,24 @@
|
|||||||
#version 410 core
|
#version 410 core
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
layout(location = 0) in vec3 position;
|
layout(location = 0) in vec3 position;
|
||||||
layout(location = 1) in vec3 color;
|
layout(location = 1) in vec3 color;
|
||||||
layout(location = 2) in vec2 textureCoord;
|
layout(location = 2) in vec2 textureCoord;
|
||||||
|
|
||||||
|
uniform mat4 model;
|
||||||
|
uniform mat4 view;
|
||||||
|
uniform mat4 projection;
|
||||||
|
uniform int type;
|
||||||
|
|
||||||
layout(location = 0) out vec3 passColor;
|
layout(location = 0) out vec3 passColor;
|
||||||
layout(location = 1) out vec2 passTextureCoord;
|
layout(location = 1) out vec2 passTextureCoord;
|
||||||
|
layout(location = 2) out int passType;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
gl_Position = vec4(position, 1.0);
|
gl_Position = projection * view * model * vec4(position, 1.0);
|
||||||
passColor = color;
|
passColor = color;
|
||||||
|
passType = type;
|
||||||
|
|
||||||
passTextureCoord = textureCoord;
|
passTextureCoord = textureCoord;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user