mrlem / siage3d

SImple Android Game Engine - 3D, the easy way
GNU General Public License v3.0
10 stars 0 forks source link
3d-engine android game-engine kotlin opengl-es scenegraph

Siage3D

build License: GPL v3 maven-central

Siage3D stands for SImple Android Game Engine.

Screenshot

So it's a game engine that is:

Please note that this engine is a work in progress. Though feedback is always welcome, it is neither feature-complete nor production ready yet (and it might never be).

Getting started

Setup

In your build.gradle, add the following repository (if not already present):

repositories {
    mavenCentral()
}

And add the following dependency:

implementation "org.mrlem.siage3d:siage3d-core:0.2.0"

Usage

Create an activity for your game:

class Game : SceneActivity() {

    override fun createSceneAdapter() = SceneAdapter(initialScene)

}

Declare it in your manifest:

        <activity android:name=".Game">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

Create the scene:

val initialScene = scene {
    camera {
        position(0f, 1.75f, 5f)
    }

    sky {
        color(.6f, .8f, 1f)
    }

    directionLight("sun") {
        diffuse(1f, 1f, 1f)
        rotation(0f, 60f, 0f)
    }

    objectNode("my-cube", BoxShape()) {
        material { texture(R.drawable.crate1_diffuse) }
        position(0f, 1f, -2f)
    }
}

Create the behaviour for our cube:

class RotatingBehaviour : Behaviour() {

    private val spatialNode get() = node as? SpatialNode
    private var time = 0f

    override fun update(delta: Float) {
        time += delta
        spatialNode?.setRotation(0f, time * 50f, 0f)
    }

}

And finally: create the scene adapter, that's where you bind the scene to the view, and where we will assign the cube its behaviour in this simple example:

class SceneAdapter(scene: Scene) : SceneAdapter(scene) {

    private val cube = scene.get<ObjectNode>("my-cube")!!

    init {
        cube.add(RotatingBehaviour())
    }

}

And voilà!

Want to know more? checkout the slightly more advanced sample!

Features

About

Author

License

GPLv3 see LICENSE.md

Acknowlegments

Built with:

Special thanks to: