Hi everyone.
I read a lot of wiki, read a lot of forum, and spent some tests in sdk. But still I need help.
EDIT 1:
I don’t need to create a network game. It has already been created and is working. I need to do the right physics, simulate the movement of the object on area and transfer the coordinates of the object to the client. The client is already working and only waiting for network packets. It’s simple task.
So, I have a java game-server. It produces all game calculations. The client and server communicate in network packets with the data.
Now I need to add physics to it. The client and server will be communicate with the x, y, z coordinates.
I don’t need a scene renderer, sounds, control. Only physics and character control to move mobs on area.
Now about the game. I have several locations. Earth 1, Earth 2… Earth 500. Each Earth is a separate independent physical space consisting of .fbx objects and HeightMap terrain.
The game has only two types of creatures: a player and a mob. There will be no modeling. These are just spheres. Each sphere has its own GhostObjects for agrs.
How do I make the structure of the server part? I really don’t understand yet:
-
Do I need SimpleAplication?
1.1) If a SimpleAplication is needed, then each Earth is better made extends from SimpleAplication or there are other better options. -
For each Earth I want a separate StateManager where I will attach the nps and player, for better performance calculations update() states. How to create a separate StateManager for each Earth? Expand from AbstractAppState?
-
I will need CharacterControl, walkDirection and getPhysicsLocation to send coord to the client. From which class is it better to expand the player and mob?
-
In the future I want to use NavMesh, how to be with it?)
Last but not least. I need to design a server part and a copy of this in the sdk to debag, to see what the earth looks like.
Help create the skeleton of the server part, please.
What should I use? Libbulletjme, Minie, or native libs from maven.
My test looks working, but I don’t know how to expand further. Is it right way?
<dependency>
<groupId>org.jmonkeyengine</groupId>
<artifactId>jme3-desktop</artifactId>
<version>3.3.2-stable</version>
</dependency>
<dependency>
<groupId>org.jmonkeyengine</groupId>
<artifactId>jme3-bullet-native</artifactId>
<version>3.3.2-stable</version>
</dependency>
<dependency>
<groupId>org.jmonkeyengine</groupId>
<artifactId>jme3-terrain</artifactId>
<version>3.3.2-stable</version>
</dependency>
package com.test;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.ByteOrder;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.jme3.app.SimpleApplication;
import com.jme3.bullet.BulletAppState;
import com.jme3.bullet.collision.shapes.CapsuleCollisionShape;
import com.jme3.bullet.control.CharacterControl;
import com.jme3.bullet.control.RigidBodyControl;
import com.jme3.material.Material;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.Node;
import com.jme3.scene.shape.Box;
import com.jme3.system.JmeContext.Type;
import com.jme3.terrain.geomipmap.TerrainQuad;
public class TestApp extends SimpleApplication {
private TerrainQuad terrain;
Material mat_terrain;
float[] heightmap;
private BulletAppState bulletAppState;
private CharacterControl character;
Node model;
private Vector3f walkDirection = new Vector3f(0, 0, 0);
Vector3f destination;
public static void main(String[] args) {
TestApp app = new TestApp();
app.start(Type.Headless);
}
@Override
public void simpleInitApp() {
bulletAppState = new BulletAppState();
stateManager.attach(bulletAppState);
// cutted code
// heightmap create from stream byte array heightmapfile
heightmap = HeightMapBuild.build();
terrain = new TerrainQuad("my terrain", 65, 2049, heightmap);
terrain.setLocalTranslation(2049, 0, 2049);
terrain.setLocalScale(2f, 1f, 2f);
rootNode.attachChild(terrain);
terrain.addControl(new RigidBodyControl(0));
bulletAppState.getPhysicsSpace().add(terrain);
CapsuleCollisionShape capsuleShape = new CapsuleCollisionShape(1.5f, 6f, 1);
character = new CharacterControl(capsuleShape, 0.01f);
Geometry testcub = new Geometry(null, new Box(3f, 3f, 3f));
testcub.addControl(character);
rootNode.attachChild(testcub);
character.setPhysicsLocation(new Vector3f(1200, 200, 836));
character.setGravity(new Vector3f(0, -30f, 0));
bulletAppState.getPhysicsSpace().add(character);
destination = new Vector3f(1000, 0, 600).subtractLocal(character.getPhysicsLocation());
walkDirection.addLocal(destination).normalizeLocal().multLocal(1f);
character.setWalkDirection(walkDirection);
}
@Override
public void simpleUpdate(float tpf) {
float xdistance = character.getPhysicsLocation().x - 1000;
System.out.println(character.getPhysicsLocation().y);
if (xdistance < 10) {
walkDirection.set(0, 0, 0);
character.setWalkDirection(walkDirection);
}
}
}