├── README.md ├── base-sio2 ├── assets │ ├── Interface │ │ └── .removeme │ ├── MatDefs │ │ └── .removeme │ ├── Materials │ │ └── .removeme │ ├── Models │ │ └── simsilica.j3o │ ├── Scenes │ │ └── .removeme │ ├── Shaders │ │ └── .removeme │ ├── Sounds │ │ └── .removeme │ └── Textures │ │ └── .removeme ├── build.gradle ├── settings.gradle └── src │ └── main │ ├── java │ └── rename │ │ ├── Main.java │ │ └── SiliconDioxideState.java │ └── resources │ ├── license.txt │ └── log4j2.xml ├── fonts ├── anita30.fnt └── anita30_0.png ├── network-basic ├── assets │ ├── Interface │ │ └── .removeme │ ├── MatDefs │ │ └── .removeme │ ├── Materials │ │ └── .removeme │ ├── Models │ │ └── simsilica.j3o │ ├── Scenes │ │ └── .removeme │ ├── Shaders │ │ └── .removeme │ ├── Sounds │ │ └── .removeme │ └── Textures │ │ └── Monkey.png ├── build.gradle ├── settings.gradle └── src │ └── main │ ├── java │ └── example │ │ ├── ConnectionState.java │ │ ├── GameConstants.java │ │ ├── GameSessionEvent.java │ │ ├── GameSessionState.java │ │ ├── HostState.java │ │ ├── InGameMenuState.java │ │ ├── LoginState.java │ │ ├── Main.java │ │ ├── MainGameFunctions.java │ │ ├── MainMenuState.java │ │ ├── MessageState.java │ │ ├── SiliconDioxideState.java │ │ └── net │ │ ├── client │ │ └── GameClient.java │ │ └── server │ │ └── GameServer.java │ └── resources │ ├── license.txt │ └── log4j2.xml ├── random └── fow │ ├── .gitattributes │ ├── .gitignore │ ├── build.gradle │ ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ ├── settings.gradle │ └── src │ └── main │ ├── java │ └── fow │ │ └── App.java │ └── resources │ └── MatDefs │ ├── FowLighting.frag │ ├── FowLighting.j3md │ └── FowLighting.vert ├── sigem ├── assets │ ├── Interface │ │ └── .removeme │ ├── MatDefs │ │ └── .removeme │ ├── Materials │ │ └── .removeme │ ├── Models │ │ ├── Rock1 │ │ │ ├── Rock1.j3o │ │ │ └── textures │ │ │ │ ├── Rock02LV3_1_1024.jpg │ │ │ │ └── Rock02LV3_2_1024.jpg │ │ ├── fighter.j3o │ │ └── simsilica.j3o │ ├── Scenes │ │ └── .removeme │ ├── Shaders │ │ └── .removeme │ ├── Sounds │ │ └── .removeme │ └── Textures │ │ ├── earthmap.jpg │ │ ├── light-burst.png │ │ ├── missile.png │ │ ├── neon-puff256.png │ │ ├── power-up.png │ │ ├── ship1.png │ │ ├── starmap.png │ │ └── white-puff256.png ├── build.gradle ├── settings.gradle └── src │ └── main │ ├── java │ └── sigem │ │ ├── GameConstants.java │ │ ├── GameSessionEvent.java │ │ ├── Main.java │ │ ├── MainGameFunctions.java │ │ ├── MainMenuState.java │ │ ├── SiliconDioxideState.java │ │ ├── es │ │ ├── Impulse.java │ │ ├── MassProperties.java │ │ ├── ObjectType.java │ │ ├── Position.java │ │ ├── ShipInput.java │ │ └── SphereShape.java │ │ ├── sim │ │ ├── ArenaBoundary.java │ │ ├── AsteroidHitListener.java │ │ ├── Body.java │ │ ├── CollisionSystem.java │ │ ├── Contact.java │ │ ├── ContactListener.java │ │ ├── ControlDriver.java │ │ ├── GameEntities.java │ │ ├── MissileHitListener.java │ │ ├── PhysicsListener.java │ │ ├── PlanetGravity.java │ │ ├── PositionPublisher.java │ │ ├── ShipDriver.java │ │ ├── ShipInputSystem.java │ │ └── SimplePhysics.java │ │ └── view │ │ ├── CameraState.java │ │ ├── GameSessionState.java │ │ ├── InGameMenuState.java │ │ ├── ModelViewState.java │ │ ├── PlayerInputState.java │ │ └── PlayerMovementFunctions.java │ └── resources │ ├── license.txt │ └── log4j2.xml ├── sim-eth-basic ├── assets │ ├── Interface │ │ └── .removeme │ ├── MatDefs │ │ └── .removeme │ ├── Materials │ │ └── .removeme │ ├── Models │ │ ├── fighter.j3o │ │ └── simsilica.j3o │ ├── Scenes │ │ └── .removeme │ ├── Shaders │ │ └── .removeme │ ├── Sounds │ │ └── .removeme │ └── Textures │ │ ├── Monkey.png │ │ ├── galaxy+X.jpg │ │ ├── galaxy+Y.jpg │ │ ├── galaxy+Z.jpg │ │ ├── galaxy-X.jpg │ │ ├── galaxy-Y.jpg │ │ ├── galaxy-Z.jpg │ │ └── ship1.png ├── build.gradle ├── release-notes.md ├── settings.gradle └── src │ └── main │ ├── java │ └── example │ │ ├── CommandConsoleState.java │ │ ├── CommandEntry.java │ │ ├── ConnectionState.java │ │ ├── GameConstants.java │ │ ├── GameSessionEvent.java │ │ ├── GameSessionState.java │ │ ├── HelpState.java │ │ ├── HostState.java │ │ ├── InGameMenuState.java │ │ ├── LoginState.java │ │ ├── Main.java │ │ ├── MainGameFunctions.java │ │ ├── MainMenuState.java │ │ ├── MessageState.java │ │ ├── SiliconDioxideState.java │ │ ├── TimeState.java │ │ ├── debug │ │ └── TimeSequenceState.java │ │ ├── net │ │ ├── AccountSession.java │ │ ├── AccountSessionListener.java │ │ ├── GameSession.java │ │ ├── GameSessionListener.java │ │ ├── chat │ │ │ ├── ChatSession.java │ │ │ ├── ChatSessionListener.java │ │ │ ├── client │ │ │ │ └── ChatClientService.java │ │ │ └── server │ │ │ │ └── ChatHostedService.java │ │ ├── client │ │ │ ├── AccountClientService.java │ │ │ ├── GameClient.java │ │ │ └── GameSessionClientService.java │ │ └── server │ │ │ ├── AccountEvent.java │ │ │ ├── AccountHostedService.java │ │ │ ├── GameServer.java │ │ │ ├── GameSessionHostedService.java │ │ │ └── ZoneNetworkSystem.java │ │ ├── sim │ │ ├── Body.java │ │ ├── ControlDriver.java │ │ ├── PhysicsListener.java │ │ ├── ShipDriver.java │ │ └── SimplePhysics.java │ │ └── view │ │ ├── ModelViewState.java │ │ ├── PlayerMovementFunctions.java │ │ ├── PlayerMovementState.java │ │ ├── SkyState.java │ │ └── SpaceGridState.java │ └── resources │ ├── license.txt │ ├── log4j2.xml │ └── sim-eth-basic-splash-512.png ├── sim-eth-es ├── assets │ ├── Interface │ │ └── .removeme │ ├── MatDefs │ │ ├── .removeme │ │ ├── FogUnshaded.frag │ │ ├── FogUnshaded.j3md │ │ └── FogUnshaded.vert │ ├── Materials │ │ └── .removeme │ ├── Models │ │ ├── fighter.j3o │ │ └── simsilica.j3o │ ├── Scenes │ │ └── .removeme │ ├── Shaders │ │ └── .removeme │ ├── Sounds │ │ └── .removeme │ └── Textures │ │ ├── Monkey.png │ │ ├── galaxy+X.jpg │ │ ├── galaxy+Y.jpg │ │ ├── galaxy+Z.jpg │ │ ├── galaxy-X.jpg │ │ ├── galaxy-Y.jpg │ │ ├── galaxy-Z.jpg │ │ ├── gravsphere.png │ │ └── ship1.png ├── build.gradle ├── release-notes.md ├── settings.gradle └── src │ └── main │ ├── java │ └── example │ │ ├── CommandConsoleState.java │ │ ├── CommandEntry.java │ │ ├── ConnectionState.java │ │ ├── GameConstants.java │ │ ├── GameSessionEvent.java │ │ ├── GameSessionState.java │ │ ├── HelpState.java │ │ ├── HostState.java │ │ ├── InGameMenuState.java │ │ ├── LoginState.java │ │ ├── Main.java │ │ ├── MainGameFunctions.java │ │ ├── MainMenuState.java │ │ ├── MessageState.java │ │ ├── SiliconDioxideState.java │ │ ├── TimeState.java │ │ ├── debug │ │ └── TimeSequenceState.java │ │ ├── es │ │ ├── BodyPosition.java │ │ ├── BodyPositionCache.java │ │ ├── MassProperties.java │ │ ├── ObjectType.java │ │ ├── ObjectTypes.java │ │ ├── Position.java │ │ └── SphereShape.java │ │ ├── net │ │ ├── AccountSession.java │ │ ├── AccountSessionListener.java │ │ ├── GameSession.java │ │ ├── GameSessionListener.java │ │ ├── chat │ │ │ ├── ChatSession.java │ │ │ ├── ChatSessionListener.java │ │ │ ├── client │ │ │ │ └── ChatClientService.java │ │ │ └── server │ │ │ │ └── ChatHostedService.java │ │ ├── client │ │ │ ├── AccountClientService.java │ │ │ ├── GameClient.java │ │ │ ├── GameSessionClientService.java │ │ │ └── SharedObjectUpdater.java │ │ └── server │ │ │ ├── AccountEvent.java │ │ │ ├── AccountHostedService.java │ │ │ ├── GameServer.java │ │ │ ├── GameSessionHostedService.java │ │ │ └── ZoneNetworkSystem.java │ │ ├── sim │ │ ├── BasicEnvironment.java │ │ ├── Body.java │ │ ├── BodyPositionPublisher.java │ │ ├── ControlDriver.java │ │ ├── GameEntities.java │ │ ├── PhysicsListener.java │ │ ├── ShipDriver.java │ │ └── SimplePhysics.java │ │ └── view │ │ ├── HudLabelState.java │ │ ├── ModelViewState.java │ │ ├── PlayerListState.java │ │ ├── PlayerMovementFunctions.java │ │ ├── PlayerMovementState.java │ │ ├── SkyState.java │ │ └── SpaceGridState.java │ └── resources │ ├── license.txt │ ├── log4j2.xml │ ├── server-log4j2.xml │ ├── sim-eth-es-splash-512.png │ └── sim-eth-es-splash-512.psd ├── simple-jme ├── assets │ ├── Interface │ │ └── removeme.txt │ ├── MatDefs │ │ └── removeme.txt │ ├── Materials │ │ └── removeme.txt │ ├── Models │ │ └── removeme.txt │ ├── Scenes │ │ └── removeme.txt │ ├── Shaders │ │ └── removeme.txt │ ├── Sounds │ │ └── removeme.txt │ └── Textures │ │ └── Monkey.png ├── build.gradle ├── settings.gradle └── src │ └── main │ ├── java │ └── mygame │ │ └── Main.java │ └── resources │ └── removeme.txt └── zay-es-net-basic ├── README.md ├── build.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── src └── main ├── java └── example │ ├── GameClient.java │ ├── GameConstants.java │ ├── GameServer.java │ ├── LogUtil.java │ ├── Position.java │ └── SimpleGameLogic.java └── resources ├── client-log4j2.xml └── server-log4j2.xml /README.md: -------------------------------------------------------------------------------- 1 | # Examples 2 | Example applications for various Simsilica libraries, singly or in combination. 3 | 4 | ## simple-jme 5 | A simple JME "blue cube" example using a gradle build file and an asset project setup. 6 | 7 | To run: `gradle run` 8 | 9 | ## zay-es-net-basic 10 | A non-UI, non-graphical, example of using the zay-es-net networking layer for zay-es. 11 | 12 | To run the server: `gradle runServer` 13 | 14 | To run the client: `gradle runClient` 15 | 16 | ## network-basic 17 | A base template project for network games. Provides a simple main menu that includes 18 | options for hosting a local game or connecting to a remote game. Sets up the client/server 19 | code but otherwise provides absolutely no game logic. A blank canvas ready for 'game'. 20 | 21 | To run: `gradle run` 22 | 23 | ## sim-eth-basic 24 | A simple space ships 'game' built on JME, Lemur, SpiderMonkey, and the SimEthereal real-time 25 | object synching library. 26 | 27 | To run: `gradle run` 28 | 29 | ## sim-eth-es 30 | A simple space ships 'game' built on JME, Lemur, Zay-ES, Zay-ES-Net, SpiderMonkey, and the SimEthereal real-time 31 | object synching library. This modifies the sim-eth-basic to be ES based using the Zay-ES library. 32 | 33 | To run: `gradle run` 34 | -------------------------------------------------------------------------------- /base-sio2/assets/Interface/.removeme: -------------------------------------------------------------------------------- 1 | Remove me when there are files here. -------------------------------------------------------------------------------- /base-sio2/assets/MatDefs/.removeme: -------------------------------------------------------------------------------- 1 | Remove me when there are files here. -------------------------------------------------------------------------------- /base-sio2/assets/Materials/.removeme: -------------------------------------------------------------------------------- 1 | Remove me when there are files here. -------------------------------------------------------------------------------- /base-sio2/assets/Models/simsilica.j3o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Simsilica/Examples/589bdb897e7c88494c6587651dfba95ba5a1ecc3/base-sio2/assets/Models/simsilica.j3o -------------------------------------------------------------------------------- /base-sio2/assets/Scenes/.removeme: -------------------------------------------------------------------------------- 1 | Remove me when there are files here. -------------------------------------------------------------------------------- /base-sio2/assets/Shaders/.removeme: -------------------------------------------------------------------------------- 1 | Remove me when there are files here. -------------------------------------------------------------------------------- /base-sio2/assets/Sounds/.removeme: -------------------------------------------------------------------------------- 1 | Remove me when there are files here. -------------------------------------------------------------------------------- /base-sio2/assets/Textures/.removeme: -------------------------------------------------------------------------------- 1 | Remove me when there are files here. -------------------------------------------------------------------------------- /base-sio2/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java' 2 | apply plugin: 'application' 3 | apply plugin: 'eclipse' 4 | apply plugin: 'idea' 5 | 6 | mainClassName='rename.Main' 7 | 8 | repositories { 9 | mavenLocal() 10 | 11 | if( JavaVersion.current() == JavaVersion.VERSION_1_7 ) { 12 | // Fallback for JDK 7 that can no longer connect to jcenter with https 13 | maven { url "http://jcenter.bintray.com" } 14 | } else { 15 | jcenter() 16 | } 17 | } 18 | 19 | ext.jmeVersion = "[3.2,)" 20 | 21 | project(":assets") { 22 | apply plugin: "java" 23 | 24 | buildDir = rootProject.file("build/assets") 25 | 26 | sourceSets { 27 | main { 28 | resources { 29 | srcDir '.' 30 | } 31 | } 32 | } 33 | } 34 | 35 | 36 | dependencies { 37 | 38 | compile "org.jmonkeyengine:jme3-core:$jmeVersion" 39 | compile "org.jmonkeyengine:jme3-desktop:$jmeVersion" 40 | compile "org.jmonkeyengine:jme3-lwjgl:$jmeVersion" 41 | 42 | // For a UI and input mapping 43 | compile "com.simsilica:lemur:1.12.0" 44 | compile "com.simsilica:lemur-proto:1.10.0" 45 | 46 | // General utilities 47 | compile "com.simsilica:sio2:1.3.0" 48 | compile "com.simsilica:sim-math:1.3.0" 49 | 50 | // Standard utility stuff 51 | compile 'com.google.guava:guava:19.0' 52 | compile 'org.slf4j:slf4j-api:1.7.13' 53 | runtime 'org.apache.logging.log4j:log4j-slf4j-impl:2.5' 54 | 55 | 56 | runtime project(':assets') 57 | } 58 | 59 | task wrapper(type: Wrapper) { 60 | } 61 | 62 | 63 | -------------------------------------------------------------------------------- /base-sio2/settings.gradle: -------------------------------------------------------------------------------- 1 | include 'assets' 2 | -------------------------------------------------------------------------------- /base-sio2/src/main/java/rename/SiliconDioxideState.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | * 4 | * Copyright (c) 2016, Simsilica, LLC 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 34 | * OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | package rename; 38 | 39 | import com.jme3.app.Application; 40 | import com.jme3.app.state.BaseAppState; 41 | import com.jme3.math.*; 42 | import com.jme3.scene.*; 43 | 44 | /** 45 | * Just a spinning silicon dioxide molecule. 46 | * 47 | * @author Paul Speed 48 | */ 49 | public class SiliconDioxideState extends BaseAppState { 50 | 51 | private Node logo; 52 | 53 | public SiliconDioxideState() { 54 | } 55 | 56 | @Override 57 | protected void initialize( Application app ) { 58 | logo = new Node("LogoHolder"); 59 | Spatial molecule = app.getAssetManager().loadModel("Models/simsilica.j3o"); 60 | molecule.center(); 61 | logo.attachChild(molecule); 62 | logo.setLocalScale(0.5f); 63 | } 64 | 65 | @Override 66 | protected void cleanup( Application app ) { 67 | } 68 | 69 | @Override 70 | protected void onEnable() { 71 | Node root = ((Main)getApplication()).getRootNode(); 72 | root.attachChild(logo); 73 | 74 | getApplication().getCamera().setLocation(new Vector3f(0, 0, 10)); 75 | getApplication().getCamera().lookAtDirection(new Vector3f(0, 0, -1), Vector3f.UNIT_Y); 76 | } 77 | 78 | @Override 79 | public void update( float tpf ) { 80 | logo.rotate(0, tpf, 0); 81 | } 82 | 83 | @Override 84 | protected void onDisable() { 85 | logo.removeFromParent(); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /base-sio2/src/main/resources/license.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, Simsilica, LLC 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the 14 | distribution. 15 | 16 | 3. Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived 18 | from this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 25 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 29 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 31 | OF THE POSSIBILITY OF SUCH DAMAGE. 32 | 33 | 34 | -------------------------------------------------------------------------------- /base-sio2/src/main/resources/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | %d{ABSOLUTE} %-5p (%t) [%c{1}] %m%n 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /fonts/anita30_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Simsilica/Examples/589bdb897e7c88494c6587651dfba95ba5a1ecc3/fonts/anita30_0.png -------------------------------------------------------------------------------- /network-basic/assets/Interface/.removeme: -------------------------------------------------------------------------------- 1 | Remove me when there are files here. -------------------------------------------------------------------------------- /network-basic/assets/MatDefs/.removeme: -------------------------------------------------------------------------------- 1 | Remove me when there are files here. -------------------------------------------------------------------------------- /network-basic/assets/Materials/.removeme: -------------------------------------------------------------------------------- 1 | Remove me when there are files here. -------------------------------------------------------------------------------- /network-basic/assets/Models/simsilica.j3o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Simsilica/Examples/589bdb897e7c88494c6587651dfba95ba5a1ecc3/network-basic/assets/Models/simsilica.j3o -------------------------------------------------------------------------------- /network-basic/assets/Scenes/.removeme: -------------------------------------------------------------------------------- 1 | Remove me when there are files here. -------------------------------------------------------------------------------- /network-basic/assets/Shaders/.removeme: -------------------------------------------------------------------------------- 1 | Remove me when there are files here. -------------------------------------------------------------------------------- /network-basic/assets/Sounds/.removeme: -------------------------------------------------------------------------------- 1 | Remove me when there are files here. -------------------------------------------------------------------------------- /network-basic/assets/Textures/Monkey.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Simsilica/Examples/589bdb897e7c88494c6587651dfba95ba5a1ecc3/network-basic/assets/Textures/Monkey.png -------------------------------------------------------------------------------- /network-basic/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java' 2 | apply plugin: 'application' 3 | apply plugin: 'eclipse' 4 | apply plugin: 'idea' 5 | 6 | mainClassName='example.Main' 7 | 8 | repositories { 9 | mavenLocal() 10 | jcenter() 11 | } 12 | 13 | ext.jmeVersion = "[3.3,)" 14 | 15 | project(":assets") { 16 | apply plugin: "java" 17 | 18 | buildDir = rootProject.file("build/assets") 19 | 20 | sourceSets { 21 | main { 22 | resources { 23 | srcDir '.' 24 | } 25 | } 26 | } 27 | } 28 | 29 | 30 | dependencies { 31 | 32 | // Need at least basic JME 33 | compile "org.jmonkeyengine:jme3-core:$jmeVersion" 34 | compile "org.jmonkeyengine:jme3-desktop:$jmeVersion" 35 | compile "org.jmonkeyengine:jme3-lwjgl:$jmeVersion" 36 | //Had to add this to get networking to update. Might be gradle bug from this version. 37 | compile("org.jmonkeyengine:jme3-networking:$jmeVersion") { 38 | force = true; 39 | } 40 | 41 | // We definitely want a UI 42 | compile "com.simsilica:lemur:1.13.0" 43 | compile "com.simsilica:lemur-proto:1.11.0" 44 | 45 | // And our base code for sim-etheral, SiO2, etc. 46 | // (many of these need to be built locally and 'gradle install'ed as of this writing) 47 | compile "com.simsilica:sio2:[1.0,)" 48 | compile "com.simsilica:sim-math:[1.0,)" 49 | compile "com.simsilica:sim-ethereal:[1.0,)" 50 | 51 | // Standard utility stuff 52 | compile 'com.google.guava:guava:19.0' 53 | compile 'org.slf4j:slf4j-api:1.7.13' 54 | runtime 'org.apache.logging.log4j:log4j-slf4j-impl:2.5' 55 | 56 | runtime project(':assets') 57 | } 58 | 59 | task wrapper(type: Wrapper) { 60 | } 61 | 62 | tasks.withType(JavaCompile) { 63 | options.compilerArgs = ["-Xlint:deprecation"] 64 | } 65 | -------------------------------------------------------------------------------- /network-basic/settings.gradle: -------------------------------------------------------------------------------- 1 | include 'assets' 2 | -------------------------------------------------------------------------------- /network-basic/src/main/java/example/GameConstants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | * 4 | * Copyright (c) 2016, Simsilica, LLC 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 34 | * OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | package example; 38 | 39 | 40 | /** 41 | * 42 | * 43 | * @author Paul Speed 44 | */ 45 | public class GameConstants { 46 | 47 | public static final String GAME_NAME = "SimEtheral Example"; 48 | public static final int PROTOCOL_VERSION = 42; 49 | 50 | public static final int DEFAULT_PORT = 4269; 51 | } 52 | -------------------------------------------------------------------------------- /network-basic/src/main/java/example/GameSessionEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | * 4 | * Copyright (c) 2016, Simsilica, LLC 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 34 | * OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | package example; 38 | 39 | import com.simsilica.event.*; 40 | 41 | /** 42 | * Events that are sent to the event bus for different client side player-related 43 | * events. 44 | * 45 | * @author Paul Speed 46 | */ 47 | public class GameSessionEvent { 48 | 49 | /** 50 | * Singals that the local player has joined the game. 51 | */ 52 | public static EventType sessionStarted = EventType.create("SessionStarted", GameSessionEvent.class); 53 | 54 | /** 55 | * Singals that the local player has left the game. 56 | */ 57 | public static EventType sessionEnded = EventType.create("SessionEnded", GameSessionEvent.class); 58 | 59 | /** 60 | * Creates a game session event. 61 | */ 62 | public GameSessionEvent() { 63 | } 64 | 65 | @Override 66 | public String toString() { 67 | return getClass().getSimpleName() + "[]"; 68 | } 69 | } 70 | 71 | 72 | -------------------------------------------------------------------------------- /network-basic/src/main/java/example/MainGameFunctions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | * 4 | * Copyright (c) 2016, Simsilica, LLC 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 34 | * OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | package example; 38 | 39 | import com.jme3.input.KeyInput; 40 | import com.simsilica.lemur.input.FunctionId; 41 | import com.simsilica.lemur.input.InputMapper; 42 | 43 | 44 | /** 45 | * Defines a set of global game functions and some default key/control 46 | * mappings. 47 | * 48 | * @author Paul Speed 49 | */ 50 | public class MainGameFunctions { 51 | 52 | public static final String IN_GAME = "In Game"; 53 | public static final FunctionId F_IN_GAME_MENU = new FunctionId(IN_GAME, "Menu"); 54 | 55 | public static void initializeDefaultMappings( InputMapper inputMapper ) { 56 | 57 | inputMapper.map(F_IN_GAME_MENU, KeyInput.KEY_ESCAPE); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /network-basic/src/main/java/example/SiliconDioxideState.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | * 4 | * Copyright (c) 2016, Simsilica, LLC 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 34 | * OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | package example; 38 | 39 | import com.jme3.app.Application; 40 | import com.jme3.app.state.BaseAppState; 41 | import com.jme3.math.*; 42 | import com.jme3.scene.*; 43 | 44 | /** 45 | * Just a spinning silicon dioxide molecule. 46 | * 47 | * @author Paul Speed 48 | */ 49 | public class SiliconDioxideState extends BaseAppState { 50 | 51 | private Node logo; 52 | 53 | public SiliconDioxideState() { 54 | } 55 | 56 | @Override 57 | protected void initialize( Application app ) { 58 | logo = new Node("LogoHolder"); 59 | Spatial molecule = app.getAssetManager().loadModel("Models/simsilica.j3o"); 60 | molecule.center(); 61 | logo.attachChild(molecule); 62 | logo.setLocalScale(0.5f); 63 | } 64 | 65 | @Override 66 | protected void cleanup( Application app ) { 67 | } 68 | 69 | @Override 70 | protected void onEnable() { 71 | Node root = ((Main)getApplication()).getRootNode(); 72 | root.attachChild(logo); 73 | } 74 | 75 | @Override 76 | public void update( float tpf ) { 77 | logo.rotate(0, tpf, 0); 78 | } 79 | 80 | @Override 81 | protected void onDisable() { 82 | logo.removeFromParent(); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /network-basic/src/main/resources/license.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, Simsilica, LLC 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the 14 | distribution. 15 | 16 | 3. Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived 18 | from this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 25 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 29 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 31 | OF THE POSSIBILITY OF SUCH DAMAGE. 32 | 33 | 34 | -------------------------------------------------------------------------------- /network-basic/src/main/resources/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | %d{ABSOLUTE} %-5p [%c{1}] %m%n 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /random/fow/.gitattributes: -------------------------------------------------------------------------------- 1 | # 2 | # https://help.github.com/articles/dealing-with-line-endings/ 3 | # 4 | # These are explicitly windows files and should use crlf 5 | *.bat text eol=crlf 6 | 7 | -------------------------------------------------------------------------------- /random/fow/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore Gradle project-specific cache directory 2 | .gradle 3 | 4 | # Ignore Gradle build output directory 5 | build 6 | -------------------------------------------------------------------------------- /random/fow/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by the Gradle 'init' task. 3 | * 4 | * This generated file contains a sample Java application project to get you started. 5 | * For more details take a look at the 'Building Java & JVM projects' chapter in the Gradle 6 | * User Manual available at https://docs.gradle.org/7.4.2/userguide/building_java_projects.html 7 | * This project uses @Incubating APIs which are subject to change. 8 | */ 9 | 10 | plugins { 11 | // Apply the application plugin to add support for building a CLI application in Java. 12 | id 'application' 13 | } 14 | 15 | repositories { 16 | // Use Maven Central for resolving dependencies. 17 | mavenCentral() 18 | } 19 | 20 | ext.jmeVersion = '3.6.1-stable' 21 | 22 | dependencies { 23 | 24 | implementation "org.jmonkeyengine:jme3-core:$jmeVersion" 25 | implementation "org.jmonkeyengine:jme3-desktop:$jmeVersion" 26 | implementation "org.jmonkeyengine:jme3-effects:$jmeVersion" 27 | implementation "org.jmonkeyengine:jme3-plugins:$jmeVersion" 28 | implementation "org.jmonkeyengine:jme3-lwjgl:$jmeVersion" 29 | implementation "org.jmonkeyengine:jme3-awt-dialogs:$jmeVersion" 30 | 31 | implementation 'com.google.guava:guava:30.1.1-jre' 32 | } 33 | 34 | testing { 35 | suites { 36 | // Configure the built-in test suite 37 | test { 38 | // Use JUnit4 test framework 39 | useJUnit('4.13.2') 40 | } 41 | } 42 | } 43 | 44 | application { 45 | // Define the main class for the application. 46 | mainClass = 'fow.App' 47 | } 48 | -------------------------------------------------------------------------------- /random/fow/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Simsilica/Examples/589bdb897e7c88494c6587651dfba95ba5a1ecc3/random/fow/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /random/fow/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /random/fow/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /random/fow/settings.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by the Gradle 'init' task. 3 | * 4 | * The settings file is used to specify which projects to include in your build. 5 | * 6 | * Detailed information about configuring a multi-project build in Gradle can be found 7 | * in the user manual at https://docs.gradle.org/7.4.2/userguide/multi_project_builds.html 8 | * This project uses @Incubating APIs which are subject to change. 9 | */ 10 | 11 | rootProject.name = 'fow' 12 | include('app') 13 | -------------------------------------------------------------------------------- /sigem/assets/Interface/.removeme: -------------------------------------------------------------------------------- 1 | Remove me when there are files here. -------------------------------------------------------------------------------- /sigem/assets/MatDefs/.removeme: -------------------------------------------------------------------------------- 1 | Remove me when there are files here. -------------------------------------------------------------------------------- /sigem/assets/Materials/.removeme: -------------------------------------------------------------------------------- 1 | Remove me when there are files here. -------------------------------------------------------------------------------- /sigem/assets/Models/Rock1/Rock1.j3o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Simsilica/Examples/589bdb897e7c88494c6587651dfba95ba5a1ecc3/sigem/assets/Models/Rock1/Rock1.j3o -------------------------------------------------------------------------------- /sigem/assets/Models/Rock1/textures/Rock02LV3_1_1024.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Simsilica/Examples/589bdb897e7c88494c6587651dfba95ba5a1ecc3/sigem/assets/Models/Rock1/textures/Rock02LV3_1_1024.jpg -------------------------------------------------------------------------------- /sigem/assets/Models/Rock1/textures/Rock02LV3_2_1024.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Simsilica/Examples/589bdb897e7c88494c6587651dfba95ba5a1ecc3/sigem/assets/Models/Rock1/textures/Rock02LV3_2_1024.jpg -------------------------------------------------------------------------------- /sigem/assets/Models/fighter.j3o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Simsilica/Examples/589bdb897e7c88494c6587651dfba95ba5a1ecc3/sigem/assets/Models/fighter.j3o -------------------------------------------------------------------------------- /sigem/assets/Models/simsilica.j3o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Simsilica/Examples/589bdb897e7c88494c6587651dfba95ba5a1ecc3/sigem/assets/Models/simsilica.j3o -------------------------------------------------------------------------------- /sigem/assets/Scenes/.removeme: -------------------------------------------------------------------------------- 1 | Remove me when there are files here. -------------------------------------------------------------------------------- /sigem/assets/Shaders/.removeme: -------------------------------------------------------------------------------- 1 | Remove me when there are files here. -------------------------------------------------------------------------------- /sigem/assets/Sounds/.removeme: -------------------------------------------------------------------------------- 1 | Remove me when there are files here. -------------------------------------------------------------------------------- /sigem/assets/Textures/earthmap.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Simsilica/Examples/589bdb897e7c88494c6587651dfba95ba5a1ecc3/sigem/assets/Textures/earthmap.jpg -------------------------------------------------------------------------------- /sigem/assets/Textures/light-burst.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Simsilica/Examples/589bdb897e7c88494c6587651dfba95ba5a1ecc3/sigem/assets/Textures/light-burst.png -------------------------------------------------------------------------------- /sigem/assets/Textures/missile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Simsilica/Examples/589bdb897e7c88494c6587651dfba95ba5a1ecc3/sigem/assets/Textures/missile.png -------------------------------------------------------------------------------- /sigem/assets/Textures/neon-puff256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Simsilica/Examples/589bdb897e7c88494c6587651dfba95ba5a1ecc3/sigem/assets/Textures/neon-puff256.png -------------------------------------------------------------------------------- /sigem/assets/Textures/power-up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Simsilica/Examples/589bdb897e7c88494c6587651dfba95ba5a1ecc3/sigem/assets/Textures/power-up.png -------------------------------------------------------------------------------- /sigem/assets/Textures/ship1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Simsilica/Examples/589bdb897e7c88494c6587651dfba95ba5a1ecc3/sigem/assets/Textures/ship1.png -------------------------------------------------------------------------------- /sigem/assets/Textures/starmap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Simsilica/Examples/589bdb897e7c88494c6587651dfba95ba5a1ecc3/sigem/assets/Textures/starmap.png -------------------------------------------------------------------------------- /sigem/assets/Textures/white-puff256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Simsilica/Examples/589bdb897e7c88494c6587651dfba95ba5a1ecc3/sigem/assets/Textures/white-puff256.png -------------------------------------------------------------------------------- /sigem/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java' 2 | apply plugin: 'application' 3 | apply plugin: 'eclipse' 4 | apply plugin: 'idea' 5 | 6 | mainClassName='sigem.Main' 7 | 8 | repositories { 9 | mavenLocal() 10 | 11 | if( JavaVersion.current() == JavaVersion.VERSION_1_7 ) { 12 | // Fallback for JDK 7 that can no longer connect to jcenter with https 13 | maven { url "http://jcenter.bintray.com" } 14 | } else { 15 | jcenter() 16 | } 17 | } 18 | 19 | //ext.jmeVersion = "[3.2,)" 20 | ext.jmeVersion = "3.3.0-SNAPSHOT" 21 | 22 | project(":assets") { 23 | apply plugin: "java" 24 | 25 | buildDir = rootProject.file("build/assets") 26 | 27 | sourceSets { 28 | main { 29 | resources { 30 | srcDir '.' 31 | } 32 | } 33 | } 34 | } 35 | 36 | 37 | dependencies { 38 | 39 | compile "org.jmonkeyengine:jme3-core:$jmeVersion" 40 | compile "org.jmonkeyengine:jme3-desktop:$jmeVersion" 41 | compile "org.jmonkeyengine:jme3-lwjgl:$jmeVersion" 42 | 43 | // For a UI and input mapping 44 | compile "com.simsilica:lemur:1.13.0" 45 | compile "com.simsilica:lemur-proto:1.11.0" 46 | 47 | // General utilities 48 | compile "com.simsilica:sio2:1.3.0" 49 | compile "com.simsilica:sim-math:1.3.0" 50 | 51 | // Standard utility stuff 52 | compile 'com.google.guava:guava:19.0' 53 | compile 'org.slf4j:slf4j-api:1.7.13' 54 | runtime 'org.apache.logging.log4j:log4j-slf4j-impl:2.5' 55 | 56 | 57 | runtime project(':assets') 58 | } 59 | 60 | task wrapper(type: Wrapper) { 61 | } 62 | 63 | -------------------------------------------------------------------------------- /sigem/settings.gradle: -------------------------------------------------------------------------------- 1 | include 'assets' 2 | -------------------------------------------------------------------------------- /sigem/src/main/java/sigem/GameConstants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | * 4 | * Copyright (c) 2019, Simsilica, LLC 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 34 | * OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | package sigem; 38 | 39 | import com.simsilica.mathd.*; 40 | 41 | /** 42 | * 43 | * 44 | * @author Paul Speed 45 | */ 46 | public class GameConstants { 47 | public static final String TITLE = "Silicon Gemini"; 48 | public static final String VERSION = "v0.1"; 49 | public static final String GAME_NAME = "Sigem"; 50 | 51 | public static final Vec3d ARENA_EXTENTS = new Vec3d(295, 0, 165); 52 | } 53 | -------------------------------------------------------------------------------- /sigem/src/main/java/sigem/GameSessionEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | * 4 | * Copyright (c) 2016, Simsilica, LLC 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 34 | * OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | package sigem; 38 | 39 | import com.simsilica.event.*; 40 | 41 | /** 42 | * Events that are sent to the event bus for different client side player-related 43 | * events. 44 | * 45 | * @author Paul Speed 46 | */ 47 | public class GameSessionEvent { 48 | 49 | /** 50 | * Signals that the game has started. 51 | */ 52 | public static EventType sessionStarted = EventType.create("SessionStarted", GameSessionEvent.class); 53 | 54 | /** 55 | * Signals that the game has been paused. 56 | */ 57 | public static EventType sessionPaused = EventType.create("SessionPaused", GameSessionEvent.class); 58 | 59 | /** 60 | * Signals that the game has been resumed. 61 | */ 62 | public static EventType sessionResumed = EventType.create("SessionResumed", GameSessionEvent.class); 63 | 64 | /** 65 | * Signals that the game has ended. 66 | */ 67 | public static EventType sessionEnded = EventType.create("SessionEnded", GameSessionEvent.class); 68 | 69 | /** 70 | * Creates a game session event. 71 | */ 72 | public GameSessionEvent() { 73 | } 74 | 75 | @Override 76 | public String toString() { 77 | return getClass().getSimpleName() + "[]"; 78 | } 79 | } 80 | 81 | 82 | -------------------------------------------------------------------------------- /sigem/src/main/java/sigem/SiliconDioxideState.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | * 4 | * Copyright (c) 2016, Simsilica, LLC 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 34 | * OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | package sigem; 38 | 39 | import com.jme3.app.Application; 40 | import com.jme3.app.state.BaseAppState; 41 | import com.jme3.math.*; 42 | import com.jme3.scene.*; 43 | 44 | /** 45 | * Just a spinning silicon dioxide molecule. 46 | * 47 | * @author Paul Speed 48 | */ 49 | public class SiliconDioxideState extends BaseAppState { 50 | 51 | private Node logo; 52 | 53 | public SiliconDioxideState() { 54 | } 55 | 56 | @Override 57 | protected void initialize( Application app ) { 58 | logo = new Node("LogoHolder"); 59 | Spatial molecule = app.getAssetManager().loadModel("Models/simsilica.j3o"); 60 | molecule.center(); 61 | logo.attachChild(molecule); 62 | logo.setLocalScale(0.5f); 63 | } 64 | 65 | @Override 66 | protected void cleanup( Application app ) { 67 | } 68 | 69 | @Override 70 | protected void onEnable() { 71 | Node root = ((Main)getApplication()).getRootNode(); 72 | root.attachChild(logo); 73 | 74 | getApplication().getCamera().setLocation(new Vector3f(0, 0, 10)); 75 | getApplication().getCamera().lookAtDirection(new Vector3f(0, 0, -1), Vector3f.UNIT_Y); 76 | } 77 | 78 | @Override 79 | public void update( float tpf ) { 80 | logo.rotate(0, tpf, 0); 81 | } 82 | 83 | @Override 84 | protected void onDisable() { 85 | logo.removeFromParent(); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /sigem/src/main/java/sigem/es/Impulse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | * 4 | * Copyright (c) 2019, Simsilica, LLC 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 34 | * OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | package sigem.es; 38 | 39 | import com.simsilica.es.EntityComponent; 40 | import com.simsilica.mathd.Vec3d; 41 | 42 | 43 | /** 44 | * An instantaneous velocity change, usually set during object 45 | * creation. 46 | * 47 | * @author Paul Speed 48 | */ 49 | public class Impulse implements EntityComponent { 50 | private Vec3d linear; 51 | private Vec3d angular; 52 | 53 | public Impulse() { 54 | this(0, 0, 0); 55 | } 56 | 57 | public Impulse( double x, double y, double z ) { 58 | this(new Vec3d(x, y, z), new Vec3d()); 59 | } 60 | 61 | public Impulse( Vec3d loc, Vec3d ang ) { 62 | this.linear = loc; 63 | this.angular = ang; 64 | } 65 | 66 | public Vec3d getLinear() { 67 | return linear; 68 | } 69 | 70 | public Vec3d getAngular() { 71 | return angular; 72 | } 73 | 74 | @Override 75 | public String toString() { 76 | return "Impulse[linear=" + linear + ", angular=" + angular + "]"; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /sigem/src/main/java/sigem/es/MassProperties.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | * 4 | * Copyright (c) 2016, Simsilica, LLC 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 34 | * OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | package sigem.es; 38 | 39 | import com.simsilica.es.EntityComponent; 40 | 41 | 42 | /** 43 | * 44 | * 45 | * @author Paul Speed 46 | */ 47 | public class MassProperties implements EntityComponent { 48 | private double invMass; 49 | 50 | public MassProperties( double invMass ) { 51 | this.invMass = invMass; 52 | } 53 | 54 | public double getInverseMass() { 55 | return invMass; 56 | } 57 | 58 | public double getMass() { 59 | if( invMass == 0 ) { 60 | return Double.POSITIVE_INFINITY; 61 | } 62 | return 1/invMass; 63 | } 64 | 65 | @Override 66 | public String toString() { 67 | return "MassProperties[inverseMass=" + invMass + "]"; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /sigem/src/main/java/sigem/es/ObjectType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | * 4 | * Copyright (c) 2016, Simsilica, LLC 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 34 | * OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | package sigem.es; 38 | 39 | import com.simsilica.es.EntityComponent; 40 | import com.simsilica.es.EntityData; 41 | 42 | 43 | /** 44 | * For visible game objects, this is the type of object. 45 | * 46 | * @author Paul Speed 47 | */ 48 | public class ObjectType implements EntityComponent { 49 | 50 | public static final String TYPE_SHIP = "ship"; 51 | public static final String TYPE_PLANET = "planet"; 52 | public static final String TYPE_ASTEROID = "asteroid"; 53 | public static final String TYPE_ASTEROID_CHUNK = "asteroidChunk"; 54 | public static final String TYPE_THRUST = "thrust"; 55 | public static final String TYPE_MISSILE = "missile"; 56 | public static final String TYPE_PLASMA_EXPLOSION = "plasmaExplosion"; 57 | public static final String TYPE_FUEL_DROP = "fuelDrop"; 58 | public static final String TYPE_SHIELD_DROP = "shieldDrop"; 59 | 60 | private int type; 61 | 62 | protected ObjectType() { 63 | } 64 | 65 | public ObjectType( int type ) { 66 | this.type = type; 67 | } 68 | 69 | public static ObjectType create( String typeName, EntityData ed ) { 70 | return new ObjectType(ed.getStrings().getStringId(typeName, true)); 71 | } 72 | 73 | public int getType() { 74 | return type; 75 | } 76 | 77 | public String getTypeName( EntityData ed ) { 78 | return ed.getStrings().getString(type); 79 | } 80 | 81 | @Override 82 | public String toString() { 83 | return getClass().getSimpleName() + "[type=" + type + "]"; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /sigem/src/main/java/sigem/es/ShipInput.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | * 4 | * Copyright (c) 2019, Simsilica, LLC 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 34 | * OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | package sigem.es; 38 | 39 | import com.simsilica.es.EntityComponent; 40 | import com.simsilica.mathd.*; 41 | 42 | /** 43 | * The current control input for a ship. Consists of 44 | * a Vec3d "thrust" value which indicates the forward 45 | * thrust as well as turning thrust. The third element is ignored. 46 | * 47 | * @author Paul Speed 48 | */ 49 | public class ShipInput implements EntityComponent { 50 | private Vec3d thrust; 51 | 52 | public ShipInput( Vec3d thrust ) { 53 | this.thrust = thrust; 54 | } 55 | 56 | public Vec3d getThrust() { 57 | return thrust; 58 | } 59 | 60 | @Override 61 | public String toString() { 62 | return "ShipInput[" + thrust + "]"; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /sigem/src/main/java/sigem/es/SphereShape.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | * 4 | * Copyright (c) 2016, Simsilica, LLC 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 34 | * OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | package sigem.es; 38 | 39 | import com.simsilica.es.EntityComponent; 40 | import com.simsilica.mathd.Vec3d; 41 | 42 | 43 | /** 44 | * 45 | * 46 | * @author Paul Speed 47 | */ 48 | public class SphereShape implements EntityComponent { 49 | 50 | private double radius; 51 | private Vec3d offset; 52 | 53 | /** 54 | * For SpiderMonkey serialization purposes. 55 | */ 56 | protected SphereShape() { 57 | } 58 | 59 | /** 60 | * Creates a new sphere collision shape with the specified 61 | * radius and 'center' relative to the natural origin of 62 | * the object to which it applies. -CoG in most cases. 63 | */ 64 | public SphereShape( double radius, Vec3d centerOffset ) { 65 | this.radius = radius; 66 | this.offset = centerOffset; 67 | } 68 | 69 | public double getRadius() { 70 | return radius; 71 | } 72 | 73 | public Vec3d getCenterOffset() { 74 | return offset; 75 | } 76 | 77 | @Override 78 | public String toString() { 79 | return "SphereShape[radius=" + radius + ", centerOffset=" + offset + "]"; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /sigem/src/main/java/sigem/sim/Contact.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | * 4 | * Copyright (c) 2019, Simsilica, LLC 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 34 | * OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | package sigem.sim; 38 | 39 | import com.google.common.base.MoreObjects; 40 | 41 | import com.simsilica.mathd.*; 42 | 43 | /** 44 | * 45 | * 46 | * @author Paul Speed 47 | */ 48 | public class Contact { 49 | public Body b1; 50 | public Body b2; 51 | public double pen; 52 | public Vec3d cp; 53 | public Vec3d cn; 54 | public double energy; 55 | 56 | public Contact( Body b1, Body b2 ) { 57 | this.b1 = b1; 58 | this.b2 = b2; 59 | } 60 | 61 | @Override 62 | public String toString() { 63 | return MoreObjects.toStringHelper(getClass().getSimpleName()) 64 | .add("b1", b1) 65 | .add("b2", b2) 66 | .add("pen", pen) 67 | .add("cp", cp) 68 | .add("cn", cn) 69 | .add("energy", energy) 70 | .toString(); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /sigem/src/main/java/sigem/sim/ContactListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | * 4 | * Copyright (c) 2019, Simsilica, LLC 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 34 | * OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | package sigem.sim; 38 | 39 | 40 | /** 41 | * Notified about contacts produced by the collision system. 42 | * 43 | * @author Paul Speed 44 | */ 45 | public interface ContactListener { 46 | public void newContact( Contact c ); 47 | } 48 | -------------------------------------------------------------------------------- /sigem/src/main/java/sigem/sim/ControlDriver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | * 4 | * Copyright (c) 2016, Simsilica, LLC 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 34 | * OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | package sigem.sim; 38 | 39 | 40 | /** 41 | * 42 | * 43 | * @author Paul Speed 44 | */ 45 | public interface ControlDriver { 46 | 47 | public void initialize( Body body ); 48 | 49 | public void update( double stepTime, Body body ); 50 | } 51 | -------------------------------------------------------------------------------- /sigem/src/main/java/sigem/sim/PhysicsListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | * 4 | * Copyright (c) 2016, Simsilica, LLC 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 34 | * OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | package sigem.sim; 38 | 39 | import com.simsilica.sim.SimTime; 40 | 41 | /** 42 | * 43 | * 44 | * @author Paul Speed 45 | */ 46 | public interface PhysicsListener { 47 | 48 | public void beginFrame( SimTime time ); 49 | 50 | public void addBody( Body body ); 51 | 52 | public void updateBody( Body body ); 53 | 54 | public void removeBody( Body body ); 55 | 56 | public void endFrame( SimTime time ); 57 | 58 | } 59 | -------------------------------------------------------------------------------- /sigem/src/main/java/sigem/sim/PositionPublisher.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | * 4 | * Copyright (c) 2019, Simsilica, LLC 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 34 | * OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | package sigem.sim; 38 | 39 | import com.simsilica.es.*; 40 | import com.simsilica.mathd.*; 41 | import com.simsilica.sim.*; 42 | 43 | import sigem.es.Position; 44 | 45 | 46 | /** 47 | * Publishes physics body positions to a Position component. 48 | * 49 | * @author Paul Speed 50 | */ 51 | public class PositionPublisher extends AbstractGameSystem 52 | implements PhysicsListener { 53 | 54 | private EntityData ed; 55 | private SimTime time; 56 | 57 | public PositionPublisher() { 58 | } 59 | 60 | @Override 61 | protected void initialize() { 62 | this.ed = getSystem(EntityData.class); 63 | 64 | getSystem(SimplePhysics.class).addPhysicsListener(this); 65 | } 66 | 67 | @Override 68 | protected void terminate() { 69 | getSystem(SimplePhysics.class).removePhysicsListener(this); 70 | } 71 | 72 | @Override 73 | public void beginFrame( SimTime time ) { 74 | this.time = time; 75 | } 76 | 77 | @Override 78 | public void addBody( Body body ) { 79 | } 80 | 81 | @Override 82 | public void updateBody( Body body ) { 83 | Position pos = new Position(body.pos, body.orientation); 84 | ed.setComponent(body.bodyId, pos); 85 | } 86 | 87 | @Override 88 | public void removeBody( Body body ) { 89 | ed.removeComponent(body.bodyId, Position.class); 90 | } 91 | 92 | @Override 93 | public void endFrame( SimTime time ) { 94 | } 95 | } 96 | 97 | 98 | -------------------------------------------------------------------------------- /sigem/src/main/resources/license.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, Simsilica, LLC 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the 14 | distribution. 15 | 16 | 3. Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived 18 | from this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 25 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 29 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 31 | OF THE POSSIBILITY OF SUCH DAMAGE. 32 | 33 | 34 | -------------------------------------------------------------------------------- /sigem/src/main/resources/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | %d{ABSOLUTE} %-5p (%t) [%c{1}] %m%n 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /sim-eth-basic/assets/Interface/.removeme: -------------------------------------------------------------------------------- 1 | Remove me when there are files here. -------------------------------------------------------------------------------- /sim-eth-basic/assets/MatDefs/.removeme: -------------------------------------------------------------------------------- 1 | Remove me when there are files here. -------------------------------------------------------------------------------- /sim-eth-basic/assets/Materials/.removeme: -------------------------------------------------------------------------------- 1 | Remove me when there are files here. -------------------------------------------------------------------------------- /sim-eth-basic/assets/Models/fighter.j3o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Simsilica/Examples/589bdb897e7c88494c6587651dfba95ba5a1ecc3/sim-eth-basic/assets/Models/fighter.j3o -------------------------------------------------------------------------------- /sim-eth-basic/assets/Models/simsilica.j3o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Simsilica/Examples/589bdb897e7c88494c6587651dfba95ba5a1ecc3/sim-eth-basic/assets/Models/simsilica.j3o -------------------------------------------------------------------------------- /sim-eth-basic/assets/Scenes/.removeme: -------------------------------------------------------------------------------- 1 | Remove me when there are files here. -------------------------------------------------------------------------------- /sim-eth-basic/assets/Shaders/.removeme: -------------------------------------------------------------------------------- 1 | Remove me when there are files here. -------------------------------------------------------------------------------- /sim-eth-basic/assets/Sounds/.removeme: -------------------------------------------------------------------------------- 1 | Remove me when there are files here. -------------------------------------------------------------------------------- /sim-eth-basic/assets/Textures/Monkey.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Simsilica/Examples/589bdb897e7c88494c6587651dfba95ba5a1ecc3/sim-eth-basic/assets/Textures/Monkey.png -------------------------------------------------------------------------------- /sim-eth-basic/assets/Textures/galaxy+X.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Simsilica/Examples/589bdb897e7c88494c6587651dfba95ba5a1ecc3/sim-eth-basic/assets/Textures/galaxy+X.jpg -------------------------------------------------------------------------------- /sim-eth-basic/assets/Textures/galaxy+Y.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Simsilica/Examples/589bdb897e7c88494c6587651dfba95ba5a1ecc3/sim-eth-basic/assets/Textures/galaxy+Y.jpg -------------------------------------------------------------------------------- /sim-eth-basic/assets/Textures/galaxy+Z.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Simsilica/Examples/589bdb897e7c88494c6587651dfba95ba5a1ecc3/sim-eth-basic/assets/Textures/galaxy+Z.jpg -------------------------------------------------------------------------------- /sim-eth-basic/assets/Textures/galaxy-X.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Simsilica/Examples/589bdb897e7c88494c6587651dfba95ba5a1ecc3/sim-eth-basic/assets/Textures/galaxy-X.jpg -------------------------------------------------------------------------------- /sim-eth-basic/assets/Textures/galaxy-Y.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Simsilica/Examples/589bdb897e7c88494c6587651dfba95ba5a1ecc3/sim-eth-basic/assets/Textures/galaxy-Y.jpg -------------------------------------------------------------------------------- /sim-eth-basic/assets/Textures/galaxy-Z.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Simsilica/Examples/589bdb897e7c88494c6587651dfba95ba5a1ecc3/sim-eth-basic/assets/Textures/galaxy-Z.jpg -------------------------------------------------------------------------------- /sim-eth-basic/assets/Textures/ship1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Simsilica/Examples/589bdb897e7c88494c6587651dfba95ba5a1ecc3/sim-eth-basic/assets/Textures/ship1.png -------------------------------------------------------------------------------- /sim-eth-basic/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java' 2 | apply plugin: 'application' 3 | apply plugin: 'eclipse' 4 | apply plugin: 'idea' 5 | 6 | mainClassName='example.Main' 7 | 8 | repositories { 9 | mavenLocal() 10 | jcenter() 11 | } 12 | 13 | ext.jmeVersion = "[3.3,)" 14 | 15 | project(":assets") { 16 | apply plugin: "java" 17 | 18 | buildDir = rootProject.file("build/assets") 19 | 20 | sourceSets { 21 | main { 22 | resources { 23 | srcDir '.' 24 | } 25 | } 26 | } 27 | } 28 | 29 | 30 | dependencies { 31 | 32 | // Need at least basic JME 33 | compile "org.jmonkeyengine:jme3-core:$jmeVersion" 34 | compile "org.jmonkeyengine:jme3-desktop:$jmeVersion" 35 | compile "org.jmonkeyengine:jme3-lwjgl:$jmeVersion" 36 | //Had to add this to get networking to update. Might be gradle bug from this version. 37 | compile("org.jmonkeyengine:jme3-networking:$jmeVersion") { 38 | force = true; 39 | } 40 | 41 | // We definitely want a UI 42 | compile "com.simsilica:lemur:1.13.0" 43 | compile "com.simsilica:lemur-proto:1.11.0" 44 | 45 | // And our base code for sim-etheral, SiO2, etc. 46 | // (many of these need to be built locally and 'gradle install'ed as of this writing) 47 | compile "com.simsilica:sio2:[1.0,)" 48 | compile "com.simsilica:sim-math:[1.0,)" 49 | compile "com.simsilica:sim-ethereal:[1.0,)" 50 | 51 | // Standard utility stuff 52 | compile 'com.google.guava:guava:19.0' 53 | compile 'org.slf4j:slf4j-api:1.7.13' 54 | runtime 'org.apache.logging.log4j:log4j-slf4j-impl:2.5' 55 | 56 | runtime project(':assets') 57 | } 58 | 59 | task wrapper(type: Wrapper) { 60 | } 61 | 62 | task runServer(type: JavaExec) { 63 | classpath sourceSets.main.runtimeClasspath 64 | main = "example.net.server.GameServer" 65 | jvmArgs '-Dlog4j.configurationFile=server-log4j2.xml' 66 | standardInput = System.in 67 | } 68 | 69 | // Create a custom server start script in the distribution 70 | task serverStartScript(type: CreateStartScripts) { 71 | mainClassName = "example.net.server.GameServer" 72 | applicationName = "server" 73 | outputDir = new File(project.buildDir, 'scripts') 74 | classpath = jar.outputs.files + project.configurations.runtime 75 | defaultJvmOpts = ['-Dlog4j.configurationFile=server-log4j2.xml'] 76 | } 77 | 78 | /*applicationDistribution.into("bin") { 79 | from(serverStartScript) 80 | fileMode = 0755 81 | }*/ 82 | 83 | // I think this is ultimately clearer than the above 84 | distributions { 85 | main { 86 | contents { 87 | from(serverStartScript) { 88 | into "bin" 89 | } 90 | } 91 | } 92 | } 93 | 94 | // Either way we end up with dupes if we don't do this 95 | distZip { 96 | duplicatesStrategy = 'exclude' 97 | } 98 | 99 | tasks.withType(JavaCompile) { 100 | options.compilerArgs = ["-Xlint:deprecation"] 101 | } -------------------------------------------------------------------------------- /sim-eth-basic/release-notes.md: -------------------------------------------------------------------------------- 1 | Version 4 (unreleased) 2 | ---------- 3 | * Converted ModelViewState to use TimeState instead of calling the TimeSource 4 | directly. 5 | * Fixed some ship model creation bugs that caused ghost ships to appear when 6 | connecting after another ship was already connected but out of range. 7 | 8 | 9 | Version 3 10 | ---------- 11 | * Added ability to configure a server message on the stand-alone 12 | server but also include a decent default. 13 | * Added a build target that will add a server script tn the distribution 14 | for running a stand-alone server. 15 | * Added a "stats" command to the command console of the headless server 16 | that dumps the connection stats for all currently connected players. 17 | * Added a TimeState for other states that want to get a consistent frame time. 18 | * Added a debug TimeSequenceState that can pop-up a time sync debug display. 19 | * Added "Resume" menu item to the In-Game menu. 20 | * Added an in-game "Help" pop-up mapping to the F1 key. 21 | * Added Gamepad mapping so "select" button will now open the in-game menu. 22 | * Added Gamepad mapping so the HAT will strafe/elevate. 23 | 24 | 25 | Version 2 26 | ---------- 27 | * Added a simple chat service. 28 | * Added ship labels that show the player name. 29 | * Updated the network protocol version to 43. 30 | 31 | 32 | Version 1 33 | ----------- 34 | * Initial public release included basic client and server using 35 | SimEthereal. 36 | -------------------------------------------------------------------------------- /sim-eth-basic/settings.gradle: -------------------------------------------------------------------------------- 1 | include 'assets' 2 | -------------------------------------------------------------------------------- /sim-eth-basic/src/main/java/example/CommandEntry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | * 4 | * Copyright (c) 2016, Simsilica, LLC 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 34 | * OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | package example; 38 | 39 | 40 | /** 41 | * Added to the CommandConsoleState to perform entered commands on behalf 42 | * of the user. 43 | * 44 | * @author Paul Speed 45 | */ 46 | public interface CommandEntry { 47 | 48 | public void runCommand( String cmd ); 49 | } 50 | -------------------------------------------------------------------------------- /sim-eth-basic/src/main/java/example/GameSessionEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | * 4 | * Copyright (c) 2016, Simsilica, LLC 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 34 | * OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | package example; 38 | 39 | import com.simsilica.event.*; 40 | 41 | /** 42 | * Events that are sent to the event bus for different client side player-related 43 | * events. 44 | * 45 | * @author Paul Speed 46 | */ 47 | public class GameSessionEvent { 48 | 49 | /** 50 | * Signals that the local player has joined the game. 51 | */ 52 | public static EventType sessionStarted = EventType.create("SessionStarted", GameSessionEvent.class); 53 | 54 | /** 55 | * Signals that the local player has left the game. 56 | */ 57 | public static EventType sessionEnded = EventType.create("SessionEnded", GameSessionEvent.class); 58 | 59 | /** 60 | * Creates a game session event. 61 | */ 62 | public GameSessionEvent() { 63 | } 64 | 65 | @Override 66 | public String toString() { 67 | return getClass().getSimpleName() + "[]"; 68 | } 69 | } 70 | 71 | 72 | -------------------------------------------------------------------------------- /sim-eth-basic/src/main/java/example/MainGameFunctions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | * 4 | * Copyright (c) 2016, Simsilica, LLC 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 34 | * OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | package example; 38 | 39 | import com.jme3.input.KeyInput; 40 | import com.simsilica.lemur.input.Button; 41 | import com.simsilica.lemur.input.FunctionId; 42 | import com.simsilica.lemur.input.InputMapper; 43 | 44 | 45 | /** 46 | * Defines a set of global game functions and some default key/control 47 | * mappings. 48 | * 49 | * @author Paul Speed 50 | */ 51 | public class MainGameFunctions { 52 | 53 | public static final String IN_GAME = "In Game"; 54 | public static final FunctionId F_IN_GAME_MENU = new FunctionId(IN_GAME, "Menu"); 55 | 56 | public static final FunctionId F_IN_GAME_HELP = new FunctionId(IN_GAME, "In-Game Help"); 57 | 58 | public static final FunctionId F_COMMAND_CONSOLE = new FunctionId(IN_GAME, "Command Console"); 59 | 60 | public static final FunctionId F_TIME_DEBUG = new FunctionId(IN_GAME, "Time Debug"); 61 | 62 | public static void initializeDefaultMappings( InputMapper inputMapper ) { 63 | 64 | inputMapper.map(F_IN_GAME_MENU, KeyInput.KEY_ESCAPE); 65 | inputMapper.map(F_IN_GAME_MENU, Button.JOYSTICK_SELECT); // the normal one 66 | inputMapper.map(F_IN_GAME_MENU, Button.JOYSTICK_BUTTON8); // just in case it's not a gamepad 67 | inputMapper.map(F_IN_GAME_HELP, KeyInput.KEY_F1); 68 | 69 | inputMapper.map(F_TIME_DEBUG, KeyInput.KEY_F7); 70 | 71 | inputMapper.map(F_COMMAND_CONSOLE, KeyInput.KEY_RETURN); 72 | inputMapper.map(F_COMMAND_CONSOLE, KeyInput.KEY_NUMPADENTER); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /sim-eth-basic/src/main/java/example/SiliconDioxideState.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | * 4 | * Copyright (c) 2016, Simsilica, LLC 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 34 | * OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | package example; 38 | 39 | import com.jme3.app.Application; 40 | import com.jme3.app.state.BaseAppState; 41 | import com.jme3.math.*; 42 | import com.jme3.scene.*; 43 | 44 | /** 45 | * Just a spinning silicon dioxide molecule. 46 | * 47 | * @author Paul Speed 48 | */ 49 | public class SiliconDioxideState extends BaseAppState { 50 | 51 | private Node logo; 52 | 53 | public SiliconDioxideState() { 54 | } 55 | 56 | @Override 57 | protected void initialize( Application app ) { 58 | logo = new Node("LogoHolder"); 59 | Spatial molecule = app.getAssetManager().loadModel("Models/simsilica.j3o"); 60 | molecule.center(); 61 | logo.attachChild(molecule); 62 | logo.setLocalScale(0.5f); 63 | } 64 | 65 | @Override 66 | protected void cleanup( Application app ) { 67 | } 68 | 69 | @Override 70 | protected void onEnable() { 71 | Node root = ((Main)getApplication()).getRootNode(); 72 | root.attachChild(logo); 73 | 74 | getApplication().getCamera().setLocation(new Vector3f(0, 0, 10)); 75 | getApplication().getCamera().lookAtDirection(new Vector3f(0, 0, -1), Vector3f.UNIT_Y); 76 | } 77 | 78 | @Override 79 | public void update( float tpf ) { 80 | logo.rotate(0, tpf, 0); 81 | } 82 | 83 | @Override 84 | protected void onDisable() { 85 | logo.removeFromParent(); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /sim-eth-basic/src/main/java/example/net/AccountSession.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | * 4 | * Copyright (c) 2016, Simsilica, LLC 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 34 | * OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | package example.net; 38 | 39 | import com.jme3.network.service.rmi.Asynchronous; 40 | 41 | /** 42 | * A client's view of the account related services on the server. 43 | * 44 | * @author Paul Speed 45 | */ 46 | public interface AccountSession { 47 | 48 | /** 49 | * Returns information about the server. Currently this is just 50 | * a description. It would be better to split this into an asynchronous 51 | * request but this is way simpler. This could be expanded to 52 | * include capabilities, accepted password hashes, and so on. 53 | */ 54 | public String getServerInfo(); 55 | 56 | /** 57 | * Called by the client to provide the player name for this connection 58 | * and "login" to the game. The server will respond asynchronously with 59 | * a notifyLoginStatus() to the client's AccountSessionListener. 60 | * Note: this could have been done synchronously but synchronous calls 61 | * should generally be avoided when they can. a) it prevents odd logic 62 | * deadlocks if one isn't careful, and b) it makes user interfaces automatically 63 | * more responsive without having to write special background worker code. 64 | * When possible, go asynchronous. 65 | */ 66 | @Asynchronous 67 | public void login( String playerName ); 68 | } 69 | -------------------------------------------------------------------------------- /sim-eth-basic/src/main/java/example/net/AccountSessionListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | * 4 | * Copyright (c) 2016, Simsilica, LLC 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 34 | * OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | package example.net; 38 | 39 | import com.jme3.network.service.rmi.Asynchronous; 40 | 41 | /** 42 | * The asynchronous callbacks the server-side account service uses 43 | * to send information back to the client. A client will register 44 | * an AccountSessionListener to handle these callbacks. 45 | * 46 | * These are especially important to do asynchronously as they 47 | * might otherwise block other callbacks other services might be 48 | * waiting to make. Also, synchronous callbacks often contribute to 49 | * logical deadlocks. 50 | * 51 | * @author Paul Speed 52 | */ 53 | public interface AccountSessionListener { 54 | 55 | /** 56 | * Called by the server to provide login status to the client after 57 | * a login attempt. 58 | */ 59 | @Asynchronous 60 | public void notifyLoginStatus( boolean loggedIn ); 61 | } 62 | -------------------------------------------------------------------------------- /sim-eth-basic/src/main/java/example/net/GameSession.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | * 4 | * Copyright (c) 2016, Simsilica, LLC 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 34 | * OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | package example.net; 38 | 39 | import com.jme3.math.Quaternion; 40 | import com.jme3.math.Vector3f; 41 | import com.jme3.network.service.rmi.Asynchronous; 42 | 43 | 44 | /** 45 | * The client's view of the 'game'. Provides necessary access to the 46 | * general game interaction and possibly game or player state. 47 | * 48 | * @author Paul Speed 49 | */ 50 | public interface GameSession { 51 | 52 | /** 53 | * Returns the ID of the player object. 54 | */ 55 | public int getPlayerObject(); 56 | 57 | /** 58 | * Sends information to the game back end about the current 59 | * movement state of the player from user input. Because this 60 | * state is continuous, it doesn't need to be reliable. 61 | */ 62 | @Asynchronous(reliable=false) 63 | public void move( Quaternion rotation, Vector3f thrust ); 64 | } 65 | -------------------------------------------------------------------------------- /sim-eth-basic/src/main/java/example/net/GameSessionListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | * 4 | * Copyright (c) 2016, Simsilica, LLC 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 34 | * OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | package example.net; 38 | 39 | import com.jme3.math.*; 40 | import com.jme3.network.service.rmi.Asynchronous; 41 | 42 | /** 43 | * The asynchronous callbacks that the game back-end uses to 44 | * send game-session information to the player. 45 | * 46 | * @author Paul Speed 47 | */ 48 | public interface GameSessionListener { 49 | 50 | /** 51 | * Called when a new player has joined the game. 52 | */ 53 | @Asynchronous 54 | public void playerJoined( int clientId, String playerName, int shipId ); 55 | 56 | /** 57 | * Called when an existing player has left the game. 58 | */ 59 | @Asynchronous 60 | public void playerLeft( int clientId, String playerName, int shipId ); 61 | } 62 | -------------------------------------------------------------------------------- /sim-eth-basic/src/main/java/example/net/chat/ChatSession.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | * 4 | * Copyright (c) 2016, Simsilica, LLC 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 34 | * OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | package example.net.chat; 38 | 39 | import java.util.List; 40 | 41 | import com.jme3.network.service.rmi.Asynchronous; 42 | 43 | /** 44 | * A client's view of the chat services. 45 | * 46 | * @author Paul Speed 47 | */ 48 | public interface ChatSession { 49 | 50 | /** 51 | * Sends a new message to the chat. 52 | */ 53 | @Asynchronous 54 | public void sendMessage( String message ); 55 | 56 | /** 57 | * Returns the list of players currently in the chat. 58 | */ 59 | public List getPlayerNames(); 60 | } 61 | -------------------------------------------------------------------------------- /sim-eth-basic/src/main/java/example/net/chat/ChatSessionListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | * 4 | * Copyright (c) 2016, Simsilica, LLC 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 34 | * OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | package example.net.chat; 38 | 39 | import com.jme3.network.service.rmi.Asynchronous; 40 | 41 | /** 42 | * The asynchronous callbacks the server-side chat service 43 | * uses to send information to the client. 44 | * 45 | * @author Paul Speed 46 | */ 47 | public interface ChatSessionListener { 48 | 49 | /** 50 | * Called when a new player has joined the chat. 51 | */ 52 | @Asynchronous 53 | public void playerJoined( int clientId, String playerName ); 54 | 55 | /** 56 | * Called when a player has sent a message to the chat. 57 | */ 58 | @Asynchronous 59 | public void newMessage( int clientId, String playerName, String message ); 60 | 61 | /** 62 | * Called when an existing player has left the chat. 63 | */ 64 | @Asynchronous 65 | public void playerLeft( int clientId, String playerName ); 66 | 67 | } 68 | -------------------------------------------------------------------------------- /sim-eth-basic/src/main/java/example/net/server/AccountEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | * 4 | * Copyright (c) 2016, Simsilica, LLC 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 34 | * OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | package example.net.server; 38 | 39 | import com.google.common.base.MoreObjects; 40 | 41 | import com.jme3.network.HostedConnection; 42 | 43 | import com.simsilica.event.EventType; 44 | 45 | /** 46 | * Events that are send to the event bus for different account state 47 | * related events. These are server-side only events and are available 48 | * to the other hosted services and possible the game systems in some 49 | * rarer cases. 50 | * 51 | * @author Paul Speed 52 | */ 53 | public class AccountEvent { 54 | 55 | /** 56 | * Singals that a player has successfully logged in. 57 | */ 58 | public static EventType playerLoggedOn = EventType.create("PlayerLoggedOn", AccountEvent.class); 59 | 60 | /** 61 | * Singals that a player has logged out. 62 | */ 63 | public static EventType playerLoggedOff = EventType.create("PlayerLoggedOff", AccountEvent.class); 64 | 65 | private HostedConnection conn; 66 | private String playerName; 67 | 68 | public AccountEvent( HostedConnection conn, String playerName ) { 69 | this.conn = conn; 70 | this.playerName = playerName; 71 | } 72 | 73 | public HostedConnection getConnection() { 74 | return conn; 75 | } 76 | 77 | public String getPlayerName() { 78 | return playerName; 79 | } 80 | 81 | @Override 82 | public String toString() { 83 | return MoreObjects.toStringHelper(getClass().getSimpleName()) 84 | .add("conn", conn) 85 | .add("playerName", playerName) 86 | .toString(); 87 | } 88 | } 89 | 90 | 91 | -------------------------------------------------------------------------------- /sim-eth-basic/src/main/java/example/sim/ControlDriver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | * 4 | * Copyright (c) 2016, Simsilica, LLC 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 34 | * OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | package example.sim; 38 | 39 | 40 | /** 41 | * 42 | * 43 | * @author Paul Speed 44 | */ 45 | public interface ControlDriver { 46 | 47 | public void update( double stepTime, Body body ); 48 | } 49 | -------------------------------------------------------------------------------- /sim-eth-basic/src/main/java/example/sim/PhysicsListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | * 4 | * Copyright (c) 2016, Simsilica, LLC 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 34 | * OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | package example.sim; 38 | 39 | import com.simsilica.sim.SimTime; 40 | 41 | /** 42 | * 43 | * 44 | * @author Paul Speed 45 | */ 46 | public interface PhysicsListener { 47 | 48 | public void beginFrame( SimTime time ); 49 | 50 | public void addBody( Body body ); 51 | 52 | public void updateBody( Body body ); 53 | 54 | public void removeBody( Body body ); 55 | 56 | public void endFrame( SimTime time ); 57 | 58 | } 59 | -------------------------------------------------------------------------------- /sim-eth-basic/src/main/resources/license.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, Simsilica, LLC 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the 14 | distribution. 15 | 16 | 3. Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived 18 | from this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 25 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 29 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 31 | OF THE POSSIBILITY OF SUCH DAMAGE. 32 | 33 | 34 | -------------------------------------------------------------------------------- /sim-eth-basic/src/main/resources/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | %d{ABSOLUTE} %-5p [%c{1}] %m%n 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /sim-eth-basic/src/main/resources/sim-eth-basic-splash-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Simsilica/Examples/589bdb897e7c88494c6587651dfba95ba5a1ecc3/sim-eth-basic/src/main/resources/sim-eth-basic-splash-512.png -------------------------------------------------------------------------------- /sim-eth-es/assets/Interface/.removeme: -------------------------------------------------------------------------------- 1 | Remove me when there are files here. -------------------------------------------------------------------------------- /sim-eth-es/assets/MatDefs/.removeme: -------------------------------------------------------------------------------- 1 | Remove me when there are files here. -------------------------------------------------------------------------------- /sim-eth-es/assets/MatDefs/FogUnshaded.frag: -------------------------------------------------------------------------------- 1 | #import "Common/ShaderLib/GLSLCompat.glsllib" 2 | 3 | #if defined(HAS_GLOWMAP) || defined(HAS_COLORMAP) || (defined(HAS_LIGHTMAP) && !defined(SEPARATE_TEXCOORD)) 4 | #define NEED_TEXCOORD1 5 | #endif 6 | 7 | #if defined(DISCARD_ALPHA) 8 | uniform float m_AlphaDiscardThreshold; 9 | #endif 10 | 11 | uniform vec4 m_Color; 12 | uniform sampler2D m_ColorMap; 13 | uniform sampler2D m_LightMap; 14 | 15 | uniform vec4 m_FogColor; 16 | uniform float m_FogDepth; 17 | 18 | varying vec2 texCoord1; 19 | varying vec2 texCoord2; 20 | 21 | varying vec4 vertColor; 22 | 23 | varying float cameraDistance; 24 | 25 | void main(){ 26 | vec4 color = vec4(1.0); 27 | 28 | #ifdef HAS_COLORMAP 29 | color *= texture2D(m_ColorMap, texCoord1); 30 | #endif 31 | 32 | #ifdef HAS_VERTEXCOLOR 33 | color *= vertColor; 34 | #endif 35 | 36 | #ifdef HAS_COLOR 37 | color *= m_Color; 38 | #endif 39 | 40 | #ifdef HAS_LIGHTMAP 41 | #ifdef SEPARATE_TEXCOORD 42 | color.rgb *= texture2D(m_LightMap, texCoord2).rgb; 43 | #else 44 | color.rgb *= texture2D(m_LightMap, texCoord1).rgb; 45 | #endif 46 | #endif 47 | 48 | #if defined(DISCARD_ALPHA) 49 | if(color.a < m_AlphaDiscardThreshold){ 50 | discard; 51 | } 52 | #endif 53 | 54 | #ifdef HAS_FOG 55 | // The problem with using the drag depth is that fog will change 56 | // as you turn the camera. 57 | //float originalZ = gl_FragCoord.z / gl_FragCoord.w; 58 | //float fogFactor = min(1.0, originalZ / m_FogDepth); 59 | 60 | // Might really want exp or exp2 fog here... linear seems ok for 61 | // space lighting versus real fog. 62 | float fogFactor = min(1.0, cameraDistance / m_FogDepth); 63 | color = mix(color, m_FogColor, fogFactor); 64 | #endif 65 | 66 | gl_FragColor = color; 67 | } 68 | -------------------------------------------------------------------------------- /sim-eth-es/assets/MatDefs/FogUnshaded.vert: -------------------------------------------------------------------------------- 1 | #import "Common/ShaderLib/GLSLCompat.glsllib" 2 | #import "Common/ShaderLib/Skinning.glsllib" 3 | #import "Common/ShaderLib/Instancing.glsllib" 4 | 5 | attribute vec3 inPosition; 6 | 7 | #if defined(HAS_COLORMAP) || (defined(HAS_LIGHTMAP) && !defined(SEPARATE_TEXCOORD)) 8 | #define NEED_TEXCOORD1 9 | #endif 10 | 11 | attribute vec2 inTexCoord; 12 | attribute vec2 inTexCoord2; 13 | attribute vec4 inColor; 14 | 15 | varying vec2 texCoord1; 16 | varying vec2 texCoord2; 17 | 18 | varying vec4 vertColor; 19 | 20 | uniform vec3 g_CameraPosition; 21 | varying float cameraDistance; 22 | 23 | void main(){ 24 | #ifdef NEED_TEXCOORD1 25 | texCoord1 = inTexCoord; 26 | #endif 27 | 28 | #ifdef SEPARATE_TEXCOORD 29 | texCoord2 = inTexCoord2; 30 | #endif 31 | 32 | #ifdef HAS_VERTEXCOLOR 33 | vertColor = inColor; 34 | #endif 35 | 36 | vec4 modelSpacePos = vec4(inPosition, 1.0); 37 | #ifdef NUM_BONES 38 | Skinning_Compute(modelSpacePos); 39 | #endif 40 | 41 | vec4 worldPos = vec4(inPosition, 1.0); 42 | worldPos = TransformWorld(worldPos); 43 | cameraDistance = distance(worldPos.xyz, g_CameraPosition); 44 | 45 | gl_Position = TransformWorldViewProjection(modelSpacePos); 46 | } 47 | -------------------------------------------------------------------------------- /sim-eth-es/assets/Materials/.removeme: -------------------------------------------------------------------------------- 1 | Remove me when there are files here. -------------------------------------------------------------------------------- /sim-eth-es/assets/Models/fighter.j3o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Simsilica/Examples/589bdb897e7c88494c6587651dfba95ba5a1ecc3/sim-eth-es/assets/Models/fighter.j3o -------------------------------------------------------------------------------- /sim-eth-es/assets/Models/simsilica.j3o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Simsilica/Examples/589bdb897e7c88494c6587651dfba95ba5a1ecc3/sim-eth-es/assets/Models/simsilica.j3o -------------------------------------------------------------------------------- /sim-eth-es/assets/Scenes/.removeme: -------------------------------------------------------------------------------- 1 | Remove me when there are files here. -------------------------------------------------------------------------------- /sim-eth-es/assets/Shaders/.removeme: -------------------------------------------------------------------------------- 1 | Remove me when there are files here. -------------------------------------------------------------------------------- /sim-eth-es/assets/Sounds/.removeme: -------------------------------------------------------------------------------- 1 | Remove me when there are files here. -------------------------------------------------------------------------------- /sim-eth-es/assets/Textures/Monkey.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Simsilica/Examples/589bdb897e7c88494c6587651dfba95ba5a1ecc3/sim-eth-es/assets/Textures/Monkey.png -------------------------------------------------------------------------------- /sim-eth-es/assets/Textures/galaxy+X.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Simsilica/Examples/589bdb897e7c88494c6587651dfba95ba5a1ecc3/sim-eth-es/assets/Textures/galaxy+X.jpg -------------------------------------------------------------------------------- /sim-eth-es/assets/Textures/galaxy+Y.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Simsilica/Examples/589bdb897e7c88494c6587651dfba95ba5a1ecc3/sim-eth-es/assets/Textures/galaxy+Y.jpg -------------------------------------------------------------------------------- /sim-eth-es/assets/Textures/galaxy+Z.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Simsilica/Examples/589bdb897e7c88494c6587651dfba95ba5a1ecc3/sim-eth-es/assets/Textures/galaxy+Z.jpg -------------------------------------------------------------------------------- /sim-eth-es/assets/Textures/galaxy-X.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Simsilica/Examples/589bdb897e7c88494c6587651dfba95ba5a1ecc3/sim-eth-es/assets/Textures/galaxy-X.jpg -------------------------------------------------------------------------------- /sim-eth-es/assets/Textures/galaxy-Y.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Simsilica/Examples/589bdb897e7c88494c6587651dfba95ba5a1ecc3/sim-eth-es/assets/Textures/galaxy-Y.jpg -------------------------------------------------------------------------------- /sim-eth-es/assets/Textures/galaxy-Z.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Simsilica/Examples/589bdb897e7c88494c6587651dfba95ba5a1ecc3/sim-eth-es/assets/Textures/galaxy-Z.jpg -------------------------------------------------------------------------------- /sim-eth-es/assets/Textures/gravsphere.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Simsilica/Examples/589bdb897e7c88494c6587651dfba95ba5a1ecc3/sim-eth-es/assets/Textures/gravsphere.png -------------------------------------------------------------------------------- /sim-eth-es/assets/Textures/ship1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Simsilica/Examples/589bdb897e7c88494c6587651dfba95ba5a1ecc3/sim-eth-es/assets/Textures/ship1.png -------------------------------------------------------------------------------- /sim-eth-es/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java' 2 | apply plugin: 'application' 3 | apply plugin: 'eclipse' 4 | apply plugin: 'idea' 5 | 6 | mainClassName='example.Main' 7 | 8 | repositories { 9 | mavenLocal() 10 | jcenter() 11 | } 12 | 13 | ext.jmeVersion = "[3.3,)" 14 | 15 | project(":assets") { 16 | apply plugin: "java" 17 | 18 | buildDir = rootProject.file("build/assets") 19 | 20 | sourceSets { 21 | main { 22 | resources { 23 | srcDir '.' 24 | } 25 | } 26 | } 27 | } 28 | 29 | dependencies { 30 | 31 | // Need at least basic JME 32 | compile("org.jmonkeyengine:jme3-core:$jmeVersion") { 33 | // For some reason if I don't do this then it picks up alpha4 instead 34 | // of beta2-SNAPSHOT. 35 | force = true 36 | } 37 | compile "org.jmonkeyengine:jme3-desktop:$jmeVersion" 38 | compile "org.jmonkeyengine:jme3-lwjgl:$jmeVersion" 39 | compile("org.jmonkeyengine:jme3-networking:$jmeVersion") { 40 | force = true; 41 | } 42 | 43 | // We definitely want a UI 44 | compile "com.simsilica:lemur:1.13.0" 45 | compile "com.simsilica:lemur-proto:1.11.0" 46 | 47 | // And our base code for sim-etheral, SiO2, etc. 48 | // (many of these need to be built locally and 'gradle install'ed as of this writing) 49 | compile "com.simsilica:sio2:[1.0,)" 50 | // compile "com.simsilica:sim-math:1.1.1" // break sim-ethereal 1.2.1 51 | compile "com.simsilica:sim-math:[1.0,)" 52 | compile "com.simsilica:sim-ethereal:[1.0,)" 53 | 54 | // Standard utility stuff 55 | compile 'com.google.guava:guava:19.0' 56 | compile 'org.slf4j:slf4j-api:1.7.13' 57 | runtime 'org.apache.logging.log4j:log4j-slf4j-impl:2.5' 58 | 59 | runtime project(':assets') 60 | } 61 | 62 | task wrapper(type: Wrapper) { 63 | } 64 | 65 | task runServer(type: JavaExec) { 66 | classpath sourceSets.main.runtimeClasspath 67 | main = "example.net.server.GameServer" 68 | jvmArgs '-Dlog4j.configurationFile=server-log4j2.xml' 69 | standardInput = System.in 70 | } 71 | 72 | // Create a custom server start script in the distribution 73 | task serverStartScript(type: CreateStartScripts) { 74 | mainClassName = "example.net.server.GameServer" 75 | applicationName = "server" 76 | outputDir = new File(project.buildDir, 'scripts') 77 | classpath = jar.outputs.files + project.configurations.runtime 78 | defaultJvmOpts = ['-Dlog4j.configurationFile=server-log4j2.xml'] 79 | } 80 | 81 | /*applicationDistribution.into("bin") { 82 | from(serverStartScript) 83 | fileMode = 0755 84 | }*/ 85 | 86 | // I think this is ultimately clearer than the above 87 | distributions { 88 | main { 89 | contents { 90 | from(serverStartScript) { 91 | into "bin" 92 | } 93 | } 94 | } 95 | } 96 | 97 | // Either way we end up with dupes if we don't do this 98 | distZip { 99 | duplicatesStrategy = 'exclude' 100 | } 101 | 102 | tasks.withType(JavaCompile) { 103 | options.compilerArgs = ["-Xlint:deprecation"] 104 | } -------------------------------------------------------------------------------- /sim-eth-es/release-notes.md: -------------------------------------------------------------------------------- 1 | Version 1 (unreleased) 2 | ---------- 3 | * Initial fork of the sim-eth-basic project 4 | 5 | -------------------------------------------------------------------------------- /sim-eth-es/settings.gradle: -------------------------------------------------------------------------------- 1 | include 'assets' 2 | -------------------------------------------------------------------------------- /sim-eth-es/src/main/java/example/CommandEntry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | * 4 | * Copyright (c) 2016, Simsilica, LLC 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 34 | * OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | package example; 38 | 39 | 40 | /** 41 | * Added to the CommandConsoleState to perform entered commands on behalf 42 | * of the user. 43 | * 44 | * @author Paul Speed 45 | */ 46 | public interface CommandEntry { 47 | 48 | public void runCommand( String cmd ); 49 | } 50 | -------------------------------------------------------------------------------- /sim-eth-es/src/main/java/example/GameSessionEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | * 4 | * Copyright (c) 2016, Simsilica, LLC 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 34 | * OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | package example; 38 | 39 | import com.simsilica.event.*; 40 | 41 | /** 42 | * Events that are sent to the event bus for different client side player-related 43 | * events. 44 | * 45 | * @author Paul Speed 46 | */ 47 | public class GameSessionEvent { 48 | 49 | /** 50 | * Singals that the local player has joined the game. 51 | */ 52 | public static EventType sessionStarted = EventType.create("SessionStarted", GameSessionEvent.class); 53 | 54 | /** 55 | * Singals that the local player has left the game. 56 | */ 57 | public static EventType sessionEnded = EventType.create("SessionEnded", GameSessionEvent.class); 58 | 59 | /** 60 | * Creates a game session event. 61 | */ 62 | public GameSessionEvent() { 63 | } 64 | 65 | @Override 66 | public String toString() { 67 | return getClass().getSimpleName() + "[]"; 68 | } 69 | } 70 | 71 | 72 | -------------------------------------------------------------------------------- /sim-eth-es/src/main/java/example/MainGameFunctions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | * 4 | * Copyright (c) 2016, Simsilica, LLC 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 34 | * OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | package example; 38 | 39 | import com.jme3.input.KeyInput; 40 | import com.simsilica.lemur.input.Button; 41 | import com.simsilica.lemur.input.FunctionId; 42 | import com.simsilica.lemur.input.InputMapper; 43 | 44 | 45 | /** 46 | * Defines a set of global game functions and some default key/control 47 | * mappings. 48 | * 49 | * @author Paul Speed 50 | */ 51 | public class MainGameFunctions { 52 | 53 | public static final String IN_GAME = "In Game"; 54 | public static final FunctionId F_IN_GAME_MENU = new FunctionId(IN_GAME, "Menu"); 55 | 56 | public static final FunctionId F_IN_GAME_HELP = new FunctionId(IN_GAME, "In-Game Help"); 57 | 58 | public static final FunctionId F_PLAYER_LIST = new FunctionId(IN_GAME, "Player List"); 59 | 60 | public static final FunctionId F_COMMAND_CONSOLE = new FunctionId(IN_GAME, "Command Console"); 61 | 62 | public static final FunctionId F_TIME_DEBUG = new FunctionId(IN_GAME, "Time Debug"); 63 | 64 | public static void initializeDefaultMappings( InputMapper inputMapper ) { 65 | 66 | inputMapper.map(F_IN_GAME_MENU, KeyInput.KEY_ESCAPE); 67 | inputMapper.map(F_IN_GAME_MENU, Button.JOYSTICK_SELECT); // the normal one 68 | inputMapper.map(F_IN_GAME_MENU, Button.JOYSTICK_BUTTON8); // just in case it's not a gamepad 69 | inputMapper.map(F_IN_GAME_HELP, KeyInput.KEY_F1); 70 | 71 | inputMapper.map(F_PLAYER_LIST, KeyInput.KEY_F2); 72 | 73 | inputMapper.map(F_TIME_DEBUG, KeyInput.KEY_F7); 74 | 75 | inputMapper.map(F_COMMAND_CONSOLE, KeyInput.KEY_RETURN); 76 | inputMapper.map(F_COMMAND_CONSOLE, KeyInput.KEY_NUMPADENTER); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /sim-eth-es/src/main/java/example/SiliconDioxideState.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | * 4 | * Copyright (c) 2016, Simsilica, LLC 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 34 | * OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | package example; 38 | 39 | import com.jme3.app.Application; 40 | import com.jme3.app.state.BaseAppState; 41 | import com.jme3.math.*; 42 | import com.jme3.scene.*; 43 | 44 | /** 45 | * Just a spinning silicon dioxide molecule. 46 | * 47 | * @author Paul Speed 48 | */ 49 | public class SiliconDioxideState extends BaseAppState { 50 | 51 | private Node logo; 52 | 53 | public SiliconDioxideState() { 54 | } 55 | 56 | @Override 57 | protected void initialize( Application app ) { 58 | logo = new Node("LogoHolder"); 59 | Spatial molecule = app.getAssetManager().loadModel("Models/simsilica.j3o"); 60 | molecule.center(); 61 | logo.attachChild(molecule); 62 | logo.setLocalScale(0.5f); 63 | } 64 | 65 | @Override 66 | protected void cleanup( Application app ) { 67 | } 68 | 69 | @Override 70 | protected void onEnable() { 71 | Node root = ((Main)getApplication()).getRootNode(); 72 | root.attachChild(logo); 73 | 74 | getApplication().getCamera().setLocation(new Vector3f(0, 0, 10)); 75 | getApplication().getCamera().lookAtDirection(new Vector3f(0, 0, -1), Vector3f.UNIT_Y); 76 | } 77 | 78 | @Override 79 | public void update( float tpf ) { 80 | logo.rotate(0, tpf, 0); 81 | } 82 | 83 | @Override 84 | protected void onDisable() { 85 | logo.removeFromParent(); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /sim-eth-es/src/main/java/example/es/MassProperties.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | * 4 | * Copyright (c) 2016, Simsilica, LLC 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 34 | * OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | package example.es; 38 | 39 | import com.simsilica.es.EntityComponent; 40 | 41 | 42 | /** 43 | * 44 | * 45 | * @author Paul Speed 46 | */ 47 | public class MassProperties implements EntityComponent { 48 | private double invMass; 49 | 50 | public MassProperties( double invMass ) { 51 | this.invMass = invMass; 52 | } 53 | 54 | public double getInverseMass() { 55 | return invMass; 56 | } 57 | 58 | public double getMass() { 59 | if( invMass == 0 ) { 60 | return Double.POSITIVE_INFINITY; 61 | } 62 | return 1/invMass; 63 | } 64 | 65 | @Override 66 | public String toString() { 67 | return "MassProperties[inverseMass=" + invMass + "]"; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /sim-eth-es/src/main/java/example/es/ObjectType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | * 4 | * Copyright (c) 2016, Simsilica, LLC 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 34 | * OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | package example.es; 38 | 39 | import com.simsilica.es.EntityComponent; 40 | import com.simsilica.es.EntityData; 41 | 42 | 43 | /** 44 | * For visible game objects, this is the type of object. 45 | * 46 | * @author Paul Speed 47 | */ 48 | public class ObjectType implements EntityComponent { 49 | 50 | private int type; 51 | 52 | protected ObjectType() { 53 | } 54 | 55 | public ObjectType( int type ) { 56 | this.type = type; 57 | } 58 | 59 | public static ObjectType create( String typeName, EntityData ed ) { 60 | return new ObjectType(ed.getStrings().getStringId(typeName, true)); 61 | } 62 | 63 | public int getType() { 64 | return type; 65 | } 66 | 67 | public String getTypeName( EntityData ed ) { 68 | return ed.getStrings().getString(type); 69 | } 70 | 71 | @Override 72 | public String toString() { 73 | return getClass().getSimpleName() + "[type=" + type + "]"; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /sim-eth-es/src/main/java/example/es/ObjectTypes.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | * 4 | * Copyright (c) 2016, Simsilica, LLC 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 34 | * OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | package example.es; 38 | 39 | import com.simsilica.es.EntityData; 40 | 41 | /** 42 | * Factory methods for the common object types. Because we run the 43 | * string names through the EntityData's string index we can't just 44 | * have normal constants. 45 | * 46 | * @author Paul Speed 47 | */ 48 | public class ObjectTypes { 49 | public static final String SHIP = "ship"; 50 | public static final String GRAV_SPHERE = "gravSphere"; 51 | 52 | public static ObjectType shipType( EntityData ed ) { 53 | return ObjectType.create(SHIP, ed); 54 | } 55 | 56 | public static ObjectType gravSphereType( EntityData ed ) { 57 | return ObjectType.create(GRAV_SPHERE, ed); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /sim-eth-es/src/main/java/example/es/SphereShape.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | * 4 | * Copyright (c) 2016, Simsilica, LLC 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 34 | * OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | package example.es; 38 | 39 | import com.simsilica.es.EntityComponent; 40 | import com.simsilica.mathd.Vec3d; 41 | 42 | 43 | /** 44 | * 45 | * 46 | * @author Paul Speed 47 | */ 48 | public class SphereShape implements EntityComponent { 49 | 50 | private double radius; 51 | private Vec3d offset; 52 | 53 | /** 54 | * For SpiderMonkey serialization purposes. 55 | */ 56 | protected SphereShape() { 57 | } 58 | 59 | /** 60 | * Creates a new sphere collision shape with the specified 61 | * radius and 'center' relative to the natural origin of 62 | * the object to which it applies. -CoG in most cases. 63 | */ 64 | public SphereShape( double radius, Vec3d centerOffset ) { 65 | this.radius = radius; 66 | this.offset = centerOffset; 67 | } 68 | 69 | public double getRadius() { 70 | return radius; 71 | } 72 | 73 | public Vec3d getCenterOffset() { 74 | return offset; 75 | } 76 | 77 | @Override 78 | public String toString() { 79 | return "SphereShape[radius=" + radius + ", centerOffset=" + offset + "]"; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /sim-eth-es/src/main/java/example/net/AccountSession.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | * 4 | * Copyright (c) 2016, Simsilica, LLC 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 34 | * OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | package example.net; 38 | 39 | import com.jme3.network.service.rmi.Asynchronous; 40 | 41 | /** 42 | * A client's view of the account related services on the server. 43 | * 44 | * @author Paul Speed 45 | */ 46 | public interface AccountSession { 47 | 48 | /** 49 | * Returns information about the server. Currently this is just 50 | * a description. It would be better to split this into an asynchronous 51 | * request but this is way simpler. This could be expanded to 52 | * include capabilities, accepted password hashes, and so on. 53 | */ 54 | public String getServerInfo(); 55 | 56 | /** 57 | * Called by the client to provide the player name for this connection 58 | * and "login" to the game. The server will respond asynchronously with 59 | * a notifyLoginStatus() to the client's AccountSessionListener. 60 | * Note: this could have been done synchronously but synchronous calls 61 | * should generally be avoided when they can. a) it prevents odd logic 62 | * deadlocks if one isn't careful, and b) it makes user interfaces automatically 63 | * more responsive without having to write special background worker code. 64 | * When possible, go asynchronous. 65 | */ 66 | @Asynchronous 67 | public void login( String playerName ); 68 | } 69 | -------------------------------------------------------------------------------- /sim-eth-es/src/main/java/example/net/AccountSessionListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | * 4 | * Copyright (c) 2016, Simsilica, LLC 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 34 | * OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | package example.net; 38 | 39 | import com.jme3.network.service.rmi.Asynchronous; 40 | 41 | /** 42 | * The asynchronous callbacks the server-side account service uses 43 | * to send information back to the client. A client will register 44 | * an AccountSessionListener to handle these callbacks. 45 | * 46 | * These are especially important to do asynchronously as they 47 | * might otherwise block other callbacks other services might be 48 | * waiting to make. Also, synchronous callbacks often contribute to 49 | * logical deadlocks. 50 | * 51 | * @author Paul Speed 52 | */ 53 | public interface AccountSessionListener { 54 | 55 | /** 56 | * Called by the server to provide login status to the client after 57 | * a login attempt. 58 | */ 59 | @Asynchronous 60 | public void notifyLoginStatus( boolean loggedIn ); 61 | } 62 | -------------------------------------------------------------------------------- /sim-eth-es/src/main/java/example/net/GameSession.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | * 4 | * Copyright (c) 2016, Simsilica, LLC 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 34 | * OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | package example.net; 38 | 39 | import com.jme3.math.Quaternion; 40 | import com.jme3.math.Vector3f; 41 | import com.jme3.network.service.rmi.Asynchronous; 42 | 43 | import com.simsilica.es.EntityId; 44 | 45 | /** 46 | * The client's view of the 'game'. Provides necessary access to the 47 | * general game interaction and possibly game or player state. 48 | * 49 | * @author Paul Speed 50 | */ 51 | public interface GameSession { 52 | 53 | /** 54 | * Returns the ID of the ship entity. 55 | */ 56 | public EntityId getShip(); 57 | 58 | /** 59 | * Returns the ID of the player entity. 60 | */ 61 | public EntityId getPlayer(); 62 | 63 | /** 64 | * Sends information to the game back end about the current 65 | * movement state of the player from user input. Because this 66 | * state is continuous, it doesn't need to be reliable. 67 | */ 68 | @Asynchronous(reliable=false) 69 | public void move( Quaternion rotation, Vector3f thrust ); 70 | } 71 | -------------------------------------------------------------------------------- /sim-eth-es/src/main/java/example/net/GameSessionListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | * 4 | * Copyright (c) 2016, Simsilica, LLC 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 34 | * OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | package example.net; 38 | 39 | import com.jme3.math.*; 40 | import com.jme3.network.service.rmi.Asynchronous; 41 | 42 | /** 43 | * The asynchronous callbacks that the game back-end uses to 44 | * send game-session information to the player. 45 | * 46 | * @author Paul Speed 47 | */ 48 | public interface GameSessionListener { 49 | 50 | } 51 | -------------------------------------------------------------------------------- /sim-eth-es/src/main/java/example/net/chat/ChatSession.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | * 4 | * Copyright (c) 2016, Simsilica, LLC 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 34 | * OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | package example.net.chat; 38 | 39 | import java.util.List; 40 | 41 | import com.jme3.network.service.rmi.Asynchronous; 42 | 43 | /** 44 | * A client's view of the chat services. 45 | * 46 | * @author Paul Speed 47 | */ 48 | public interface ChatSession { 49 | 50 | /** 51 | * Sends a new message to the chat. 52 | */ 53 | @Asynchronous 54 | public void sendMessage( String message ); 55 | 56 | /** 57 | * Returns the list of players currently in the chat. 58 | */ 59 | public List getPlayerNames(); 60 | } 61 | -------------------------------------------------------------------------------- /sim-eth-es/src/main/java/example/net/chat/ChatSessionListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | * 4 | * Copyright (c) 2016, Simsilica, LLC 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 34 | * OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | package example.net.chat; 38 | 39 | import com.jme3.network.service.rmi.Asynchronous; 40 | 41 | /** 42 | * The asynchronous callbacks the server-side chat service 43 | * uses to send information to the client. 44 | * 45 | * @author Paul Speed 46 | */ 47 | public interface ChatSessionListener { 48 | 49 | /** 50 | * Called when a new player has joined the chat. 51 | */ 52 | @Asynchronous 53 | public void playerJoined( int clientId, String playerName ); 54 | 55 | /** 56 | * Called when a player has sent a message to the chat. 57 | */ 58 | @Asynchronous 59 | public void newMessage( int clientId, String playerName, String message ); 60 | 61 | /** 62 | * Called when an existing player has left the chat. 63 | */ 64 | @Asynchronous 65 | public void playerLeft( int clientId, String playerName ); 66 | 67 | } 68 | -------------------------------------------------------------------------------- /sim-eth-es/src/main/java/example/sim/BasicEnvironment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | * 4 | * Copyright (c) 2016, Simsilica, LLC 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 34 | * OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | package example.sim; 38 | 39 | import com.simsilica.es.*; 40 | import com.simsilica.mathd.*; 41 | import com.simsilica.sim.*; 42 | 43 | import example.es.*; 44 | 45 | /** 46 | * Creates a bunch of base entities in the environment. 47 | * 48 | * @author Paul Speed 49 | */ 50 | public class BasicEnvironment extends AbstractGameSystem { 51 | 52 | private EntityData ed; 53 | 54 | @Override 55 | protected void initialize() { 56 | this.ed = getSystem(EntityData.class); 57 | if( ed == null ) { 58 | throw new RuntimeException("SimplePhysics system requires an EntityData object."); 59 | } 60 | } 61 | 62 | @Override 63 | protected void terminate() { 64 | } 65 | 66 | @Override 67 | public void start() { 68 | 69 | // Create some built in objects 70 | double spacing = 256; 71 | double offset = -2 * spacing + spacing * 0.5; 72 | for( int x = 0; x < 4; x++ ) { 73 | for( int y = 0; y < 4; y++ ) { 74 | for( int z = 0; z < 4; z++ ) { 75 | Vec3d pos = new Vec3d(offset + x * spacing, offset + y * spacing, offset + z * spacing); 76 | GameEntities.createGravSphere(pos, 10, ed); 77 | } 78 | } 79 | } 80 | } 81 | 82 | @Override 83 | public void stop() { 84 | // For now at least, we won't be reciprocal, ie: we won't remove 85 | // all of the stuff we added. 86 | } 87 | 88 | } 89 | -------------------------------------------------------------------------------- /sim-eth-es/src/main/java/example/sim/ControlDriver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | * 4 | * Copyright (c) 2016, Simsilica, LLC 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 34 | * OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | package example.sim; 38 | 39 | 40 | /** 41 | * 42 | * 43 | * @author Paul Speed 44 | */ 45 | public interface ControlDriver { 46 | 47 | public void update( double stepTime, Body body ); 48 | } 49 | -------------------------------------------------------------------------------- /sim-eth-es/src/main/java/example/sim/GameEntities.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | * 4 | * Copyright (c) 2016, Simsilica, LLC 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 34 | * OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | package example.sim; 38 | 39 | import com.simsilica.mathd.*; 40 | import com.simsilica.es.*; 41 | 42 | import example.es.*; 43 | 44 | /** 45 | * Utility methods for creating the common game entities used by 46 | * the simulation. In cases where a game entity may have multiple 47 | * specific componnets or dependencies used to create it, it can be 48 | * more convenient to have a centralized factory method. Especially 49 | * if those objects are widely used. For entities with only a few 50 | * components or that are created by one system and only consumed by 51 | * one other, then this is not necessarily true. 52 | * 53 | * @author Paul Speed 54 | */ 55 | public class GameEntities { 56 | 57 | public static EntityId createShip( EntityId parent, EntityData ed ) { 58 | EntityId result = ed.createEntity(); 59 | Name name = ed.getComponent(parent, Name.class); 60 | ed.setComponent(result, name); 61 | ed.setComponents(result, ObjectTypes.shipType(ed), 62 | new MassProperties(1/50.0), new SphereShape(3, new Vec3d())); 63 | 64 | return result; 65 | } 66 | 67 | public static EntityId createGravSphere( Vec3d pos, double radius, EntityData ed ) { 68 | EntityId result = ed.createEntity(); 69 | ed.setComponents(result, ObjectTypes.gravSphereType(ed), 70 | new Position(pos, new Quatd().fromAngles(-Math.PI * 0.5, 0, 0)), 71 | new SphereShape(radius, new Vec3d())); 72 | return result; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /sim-eth-es/src/main/java/example/sim/PhysicsListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | * 4 | * Copyright (c) 2016, Simsilica, LLC 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 34 | * OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | package example.sim; 38 | 39 | import com.simsilica.sim.SimTime; 40 | 41 | /** 42 | * 43 | * 44 | * @author Paul Speed 45 | */ 46 | public interface PhysicsListener { 47 | 48 | public void beginFrame( SimTime time ); 49 | 50 | public void addBody( Body body ); 51 | 52 | public void updateBody( Body body ); 53 | 54 | public void removeBody( Body body ); 55 | 56 | public void endFrame( SimTime time ); 57 | 58 | } 59 | -------------------------------------------------------------------------------- /sim-eth-es/src/main/java/example/view/SkyState.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | * 4 | * Copyright (c) 2016, Simsilica, LLC 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 34 | * OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | package example.view; 38 | 39 | import com.jme3.app.Application; 40 | import com.jme3.app.state.BaseAppState; 41 | import com.jme3.scene.Spatial; 42 | import com.jme3.texture.Texture; 43 | import com.jme3.util.SkyFactory; 44 | 45 | import example.Main; 46 | 47 | /** 48 | * 49 | * 50 | * @author Paul Speed 51 | */ 52 | public class SkyState extends BaseAppState { 53 | 54 | private Spatial sky; 55 | 56 | public SkyState() { 57 | } 58 | 59 | @Override 60 | protected void initialize( Application app ) { 61 | 62 | Texture texture1 = app.getAssetManager().loadTexture("Textures/galaxy+Z.jpg"); 63 | Texture texture2 = app.getAssetManager().loadTexture("Textures/galaxy-Z.jpg"); 64 | Texture texture3 = app.getAssetManager().loadTexture("Textures/galaxy+X.jpg"); 65 | Texture texture4 = app.getAssetManager().loadTexture("Textures/galaxy-X.jpg"); 66 | Texture texture5 = app.getAssetManager().loadTexture("Textures/galaxy+Y.jpg"); 67 | Texture texture6 = app.getAssetManager().loadTexture("Textures/galaxy-Y.jpg"); 68 | 69 | sky = SkyFactory.createSky(app.getAssetManager(), 70 | texture1, texture2, 71 | texture3, texture4, 72 | texture5, texture6); 73 | } 74 | 75 | @Override 76 | protected void cleanup( Application app ) { 77 | } 78 | 79 | @Override 80 | protected void onEnable() { 81 | ((Main)getApplication()).getRootNode().attachChild(sky); 82 | } 83 | 84 | @Override 85 | protected void onDisable() { 86 | sky.removeFromParent(); 87 | } 88 | } 89 | 90 | 91 | -------------------------------------------------------------------------------- /sim-eth-es/src/main/resources/license.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, Simsilica, LLC 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the 14 | distribution. 15 | 16 | 3. Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived 18 | from this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 25 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 29 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 31 | OF THE POSSIBILITY OF SUCH DAMAGE. 32 | 33 | 34 | -------------------------------------------------------------------------------- /sim-eth-es/src/main/resources/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | %d{ABSOLUTE} %-5p [%c{1}] %m%n 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /sim-eth-es/src/main/resources/server-log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | %d{ABSOLUTE} %-5p [%c{1}] %m%n 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /sim-eth-es/src/main/resources/sim-eth-es-splash-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Simsilica/Examples/589bdb897e7c88494c6587651dfba95ba5a1ecc3/sim-eth-es/src/main/resources/sim-eth-es-splash-512.png -------------------------------------------------------------------------------- /sim-eth-es/src/main/resources/sim-eth-es-splash-512.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Simsilica/Examples/589bdb897e7c88494c6587651dfba95ba5a1ecc3/sim-eth-es/src/main/resources/sim-eth-es-splash-512.psd -------------------------------------------------------------------------------- /simple-jme/assets/Interface/removeme.txt: -------------------------------------------------------------------------------- 1 | Remove me when there are files here. -------------------------------------------------------------------------------- /simple-jme/assets/MatDefs/removeme.txt: -------------------------------------------------------------------------------- 1 | Remove me when there are files here. -------------------------------------------------------------------------------- /simple-jme/assets/Materials/removeme.txt: -------------------------------------------------------------------------------- 1 | Remove me when there are files here. -------------------------------------------------------------------------------- /simple-jme/assets/Models/removeme.txt: -------------------------------------------------------------------------------- 1 | Remove me when there are files here. -------------------------------------------------------------------------------- /simple-jme/assets/Scenes/removeme.txt: -------------------------------------------------------------------------------- 1 | Remove me when there are files here. -------------------------------------------------------------------------------- /simple-jme/assets/Shaders/removeme.txt: -------------------------------------------------------------------------------- 1 | Remove me when there are files here. -------------------------------------------------------------------------------- /simple-jme/assets/Sounds/removeme.txt: -------------------------------------------------------------------------------- 1 | Remove me when there are files here. -------------------------------------------------------------------------------- /simple-jme/assets/Textures/Monkey.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Simsilica/Examples/589bdb897e7c88494c6587651dfba95ba5a1ecc3/simple-jme/assets/Textures/Monkey.png -------------------------------------------------------------------------------- /simple-jme/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java' 2 | apply plugin: 'application' 3 | apply plugin: 'eclipse' 4 | apply plugin: 'idea' 5 | 6 | mainClassName='mygame.Main' 7 | 8 | repositories { 9 | jcenter() 10 | } 11 | 12 | ext.jmeVersion = "[3.1,)" 13 | 14 | project(":assets") { 15 | apply plugin: "java" 16 | 17 | buildDir = rootProject.file("build/assets") 18 | 19 | sourceSets { 20 | main { 21 | resources { 22 | srcDir '.' 23 | } 24 | } 25 | } 26 | } 27 | 28 | 29 | dependencies { 30 | 31 | compile "org.jmonkeyengine:jme3-core:$jmeVersion" 32 | compile "org.jmonkeyengine:jme3-desktop:$jmeVersion" 33 | compile "org.jmonkeyengine:jme3-lwjgl:$jmeVersion" 34 | 35 | runtime project(':assets') 36 | } 37 | 38 | task wrapper(type: Wrapper) { 39 | } 40 | 41 | task createDirs << { 42 | 43 | def pkg = 'mygame' 44 | def dirs = [ 45 | file("./src/main/java/$pkg"), 46 | file("./src/main/resources"), 47 | file("./assets/Interface"), 48 | file("./assets/MatDefs"), 49 | file("./assets/Materials"), 50 | file("./assets/Models"), 51 | file("./assets/Scenes"), 52 | file("./assets/Shaders"), 53 | file("./assets/Sounds"), 54 | file("./assets/Textures"), 55 | ] 56 | 57 | dirs.each { 58 | if( !it.exists() ) { 59 | println "Creating " + it 60 | it.mkdirs() 61 | } 62 | if( it.listFiles().length == 0 ) { 63 | def stub = new File(it, 'removeme.txt') 64 | println "Creating stub file to allow git checkin, file:$stub" 65 | stub.text = "Remove me when there are files here." 66 | } 67 | } 68 | } 69 | 70 | 71 | -------------------------------------------------------------------------------- /simple-jme/settings.gradle: -------------------------------------------------------------------------------- 1 | include 'assets' 2 | -------------------------------------------------------------------------------- /simple-jme/src/main/java/mygame/Main.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | * 4 | * Copyright (c) 2015, Simsilica, LLC 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 34 | * OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | package mygame; 38 | 39 | import com.jme3.app.SimpleApplication; 40 | import com.jme3.math.ColorRGBA; 41 | import com.jme3.material.Material; 42 | import com.jme3.scene.Geometry; 43 | import com.jme3.scene.shape.Box; 44 | import com.jme3.texture.Texture; 45 | 46 | /** 47 | * 48 | * 49 | * @author Paul Speed 50 | */ 51 | public class Main extends SimpleApplication { 52 | 53 | public static void main( String... args ) { 54 | Main main = new Main(); 55 | main.start(); 56 | } 57 | 58 | public void simpleInitApp() { 59 | 60 | Box box = new Box(1, 1, 1); 61 | Geometry geom = new Geometry("box", box); 62 | Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); 63 | mat.setColor("Color", ColorRGBA.Blue); 64 | 65 | Texture texture = assetManager.loadTexture("Textures/Monkey.png"); 66 | mat.setTexture("ColorMap", texture); 67 | 68 | geom.setMaterial(mat); 69 | rootNode.attachChild(geom); 70 | } 71 | } 72 | 73 | 74 | -------------------------------------------------------------------------------- /simple-jme/src/main/resources/removeme.txt: -------------------------------------------------------------------------------- 1 | Remove me when there are files here. -------------------------------------------------------------------------------- /zay-es-net-basic/README.md: -------------------------------------------------------------------------------- 1 | 2 | Introduction 3 | ============= 4 | This is a simple example of using Zay-ES-Net and SpiderMonkey 5 | to create a client-server entity-enabled application. 6 | 7 | The test illustrates only the most basic functionality by 8 | creating a simple command line server that moves some entities 9 | around on an imaginary 10x10 board. If they bump into the sides 10 | then they turn a random direction. Every 5 seconds, a random entity 11 | is removed and another random entity is created. 12 | 13 | It is only setup to run from one machine as there is no way to 14 | pass a host address to the client. You can run as many clients as 15 | you like, though. 16 | 17 | 18 | Running 19 | ============= 20 | 21 | To run the server: 22 | * Open a command line 23 | * cd into the zay-es-net-basic directory 24 | * type: 25 | gradlew runServer 26 | 27 | To run the client: 28 | * Open a command line 29 | * cd into the zay-es-net-basic directory 30 | * type: 31 | gradlew runClient 32 | 33 | The client will terminate on its own after 60 seconds. 34 | 35 | 36 | Design Caveats 37 | =============== 38 | I tried to keep at as absolutely basic as possible so some corners 39 | were cut in terms of proper design. These are especially apparent 40 | on the client where everything is included in one class. A normal 41 | client will have several app states with the actual 'game client' 42 | app state not even getting attached until the connection is fully 43 | started (as a result of the client state listener). 44 | 45 | In this example, I've simplified things by blocking the thread with 46 | a CountDownLatch. I do not recommend this in normal practice. 47 | 48 | 49 | Class Anatomy 50 | ============== 51 | 52 | **GameServer**: all of the game server code except for the game logic. 53 | 54 | **SimpleGameLogic**: the actual 'game' logic that moves the pieces around 55 | on the imaginary board and turns them when they bump into the sides. This 56 | is also where entities are randomly added and removed every 5 seconds. 57 | 58 | **GameClient**: all of the game client code. 59 | 60 | **GameConstants**: constants like game name, game port, etc. that are shared 61 | between client and server. 62 | 63 | **Position**: a custom component that holds the location and rotation of an 64 | entity. 65 | 66 | **LogUtil**: a utility class to initialize the JUL to sl4fj bridge because I 67 | can't stand JUL and all of the simsilica tools log to slf4j already. 68 | 69 | 70 | Logging 71 | ======== 72 | Logging for the client and server can be configured in: 73 | * src/main/resources/client-log4j2.xml for the client. 74 | * src/main/resources/server-log4j2.xml for the server. 75 | 76 | For example, the networking logging level can be lowered to 77 | provide more detail. (For example, setting it to DEBUG, TRACE, 78 | or ALL.) 79 | -------------------------------------------------------------------------------- /zay-es-net-basic/build.gradle: -------------------------------------------------------------------------------- 1 | 2 | apply plugin: 'java' 3 | 4 | repositories { 5 | jcenter() 6 | } 7 | 8 | dependencies { 9 | 10 | // Just for the jme.math 11 | compile 'org.jmonkeyengine:jme3-core:[3.1,)' 12 | 13 | compile 'com.simsilica:zay-es:[1.2,)' 14 | compile 'com.simsilica:zay-es-net:[1.2,)' 15 | 16 | // Not recommended for production but good for a demo 17 | compile 'org.slf4j:jul-to-slf4j:1.7.5' 18 | 19 | runtime 'org.apache.logging.log4j:log4j-slf4j-impl:2.5' 20 | runtime 'org.apache.logging.log4j:log4j-core:2.5' 21 | } 22 | 23 | 24 | task runServer(type: JavaExec) { 25 | classpath sourceSets.main.runtimeClasspath 26 | main = "example.GameServer" 27 | jvmArgs '-Dlog4j.configurationFile=server-log4j2.xml' 28 | } 29 | 30 | 31 | task runClient(type: JavaExec) { 32 | classpath sourceSets.main.runtimeClasspath 33 | main = "example.GameClient" 34 | jvmArgs '-Dlog4j.configurationFile=client-log4j2.xml' 35 | } 36 | 37 | task wrapper(type: Wrapper) { 38 | } 39 | -------------------------------------------------------------------------------- /zay-es-net-basic/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Simsilica/Examples/589bdb897e7c88494c6587651dfba95ba5a1ecc3/zay-es-net-basic/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /zay-es-net-basic/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Mar 01 12:35:48 EST 2016 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-bin.zip 7 | -------------------------------------------------------------------------------- /zay-es-net-basic/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /zay-es-net-basic/src/main/java/example/GameConstants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | * 4 | * Copyright (c) 2015, Simsilica, LLC 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 34 | * OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | package example; 38 | 39 | 40 | /** 41 | * 42 | * 43 | * @author Paul Speed 44 | */ 45 | public class GameConstants { 46 | public static final String NAME = "Zay-ES Example"; 47 | public static final int PROTOCOL_VERSION = 1; 48 | public static final int PORT = 9942; 49 | } 50 | -------------------------------------------------------------------------------- /zay-es-net-basic/src/main/java/example/LogUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | * 4 | * Copyright (c) 2015, Simsilica, LLC 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 34 | * OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | package example; 38 | 39 | import java.util.logging.Level; 40 | import java.util.logging.Logger; 41 | import java.util.logging.LogManager; 42 | import org.slf4j.bridge.SLF4JBridgeHandler; 43 | 44 | /** 45 | * 46 | * 47 | * @author Paul Speed 48 | */ 49 | public class LogUtil { 50 | 51 | static Logger global = Logger.getGlobal(); 52 | static Logger network = Logger.getLogger("com.jme3.network"); 53 | 54 | public static void initialize() { 55 | 56 | // Note: this is not a very efficient way to map JUL to 57 | // slf4j but it is simple 58 | //LogManager.getLogManager().reset(); 59 | SLF4JBridgeHandler.removeHandlersForRootLogger(); 60 | SLF4JBridgeHandler.install(); 61 | global.setLevel(Level.FINEST); 62 | 63 | // Really not sure why this isn't working without this as 64 | // it should inherit from global. I really hate JUL. 65 | network.setLevel(Level.FINEST); 66 | 67 | global.info("JUL to slf4j bridge initialized."); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /zay-es-net-basic/src/main/java/example/Position.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | * 4 | * Copyright (c) 2015, Simsilica, LLC 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in 16 | * the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * 3. Neither the name of the copyright holder nor the names of its 20 | * contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 34 | * OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | package example; 38 | 39 | import com.jme3.math.Quaternion; 40 | import com.jme3.math.Vector3f; 41 | import com.simsilica.es.EntityComponent; 42 | 43 | /** 44 | * 45 | * 46 | * @author Paul Speed 47 | */ 48 | public class Position implements EntityComponent { 49 | private Quaternion facing; 50 | private Vector3f location; 51 | 52 | protected Position() { 53 | // Just for serialization 54 | } 55 | 56 | public Position( Vector3f location ) { 57 | this(location, new Quaternion()); 58 | } 59 | 60 | public Position( Vector3f location, Quaternion facing ) { 61 | this.location = location.clone(); 62 | this.facing = facing.clone(); 63 | } 64 | 65 | public Position changeLocation( Vector3f location ) { 66 | return new Position(location, facing); 67 | } 68 | 69 | public Position changeFacing( Quaternion facing ) { 70 | return new Position(location, facing); 71 | } 72 | 73 | public Quaternion getFacing() { 74 | return facing; 75 | } 76 | 77 | public Vector3f getLocation() { 78 | return location; 79 | } 80 | 81 | @Override 82 | public String toString() { 83 | return "Position[" + location + ", " + facing + "]"; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /zay-es-net-basic/src/main/resources/client-log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | %d{ABSOLUTE} %-5p [%c{1}] %m%n 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /zay-es-net-basic/src/main/resources/server-log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | %d{ABSOLUTE} %-5p [%c{1}] %m%n 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | --------------------------------------------------------------------------------