EosEngine is Java Game Engine based on LWJGL. EosEngine was created by Kutaisi International University students as a part of the university course "Basic Game Engine Development".
Before continuing, you will need the following:
- git installed on the computer
- Java IDE (Example: IntelliJ IDEA, Eclipse IDE)
- *Dependencies that are needed, will be installed automaticlly when you will build the project
Install EosEngine with git:
-
Click "CODE" in the top right corner of the github page, then click "HTTPS". Go ahead and copy the link which should look something like this:
https://github.com/KIU-GEDGADA/EosEngine.git
-
Next open terminal in the file you want to clone the project to and type this:
git clone [INSERT LINK HERE]
-
And You are DONE! You have successfully added the project to you computer.
- Clone the repository
- Open the project
- Locate
src/main/java/finalDemo/Preview.java
- run the project
Our main goal was to make non-euclidean easily accessible game engine in Java
. With our game engine you can easily
interact with projections and views of an item, which makes it ideal for non-euclidean worlds.
Every project's step one is to get to know the documentation. So before continuing we highly recommend you to read documentation, which is located below.
Of course the first step when creating a game is to create Game.java
. Make sure that
the class implements Entity like this:
public class Game implements Entity {
// Rest of the code here
}
this way all the methods you will need be added automatically. That's it! You have successfully created your own game class!
There are some things we need to add to make sure that the game engine can run the game smoothly without issues. Items, When adding new item to the game like in the demo:
Item item = new Item("Cube", new Model(new Mesh("res/models/goodCube.obj")), shaders, texture1);
Renderer.addItem(item);
We need to make sure to add it to the Renderer
so the item can be rendered. Light initialization can be
seen !here
Second thing we need to make sure is that after adding the item we need to destroy it in the overridden
method called Destroy()
Like this:
@Override
public void destroy() {
item.destroy();
}
To add Camera
to the game and actually start manipulating it you should do the following:
camera = Camera.getInstance();
Because we used design pattern called Singleton, we are able to do this. If you want to modify the camera settings, you can do the following:
camera.setFOV(30).setPosition(3,4,5); // So on.. so on...
If you want to move the Camera
during the game, you should use this method:
camera.movePosition(xVelocity, yVelocity, zVelocity);
as this method ensures that camera directions do not get messed up.
A Model
holds a Texture
and a Mesh
. It makes sure to attach those objects together.
Creation of Model
is pretty straight forward:
Model model = new Model(new Mesh(PATH or PARAMETERS), texture);
Texture
is again optional.
As we talked about in the last chapter, Item
needs few more functions to be called, so it can be rendered
correctly.
Item
needs following parameters in the constructor:
- Name
- Model (check the last chapter)
- Shaders (check the last chapter)
- Texture (Optional)
Generators
is a static
class, which generates models for certain scenarios. For example:
- Terrains
- Simple Objects
- Triangles
- Cubes
For now Generators only consist of Terrain Generation. So let's recap: Here is how you create item:
Model model = new Model(Generators.generateTerrain()).setTexture(texture2, 0.1f);
terrain1 = new Item(POSITION, NAME, model, GIVENSHADERS);
So as you can see, we just changed constructor of model from new Mesh(PATH)
to Generators.generateTerrain()
.
With this you have successfully generated a terrain!
Material
class make sure to attach correct textures to correct meshes and adds few parameters including:
- ambientColor
- diffuseColor
- specularColor
Now these parameters can be changed real-time or before execution. User does not need to create material or pass it to
somewhere, as engine automatically creates it and stores it in model, so to retrieve material you just call:
modelName.getMaterial()
. Material is also the one which is responsible for attaching texture to mesh therefore, if you
want to set texture, do it like this: modelName.getMaterial().setTexture(PASS_TEXTURE)
For now our game engine supports two types of lights: DirectionalLight
and PointLight
. To use these correctly choose
the correct
shader when creating an item and create list with it:
Shader vs = new Shader("res/shaders/tv2vs.glsl");
Shader fs = new Shader("res/shaders/tv2fs.glsl");
List<Shader> shaders = List.of(new Shader[]{vs, fs});
then add it to item as list:
Model model = new Model(new Mesh("res/models/goodCube.obj")).setTexture(new Texture("res/textures/goodTexture.png"))
complexObject = new Item(pos6, "Complex Figure with Ligthing and texture", model, shaders);
Then you can create lighting of your type
PointLight pointLight = new PointLight(lightColor, new Vector3f(0,-5,0), 100f, 0, 0, 1);
And Finally add it to the Renderer
Renderer.addLight(pointLight);
Make sure to add lights before items as doing it reverse may cause problems!