From 344080e14d3da278f779dcf87755b34edf3fd48b Mon Sep 17 00:00:00 2001 From: a dinosaur Date: Sat, 19 Aug 2023 01:38:20 +1000 Subject: [PATCH] krazy lites --- src/main/kotlin/Game.kt | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/Game.kt b/src/main/kotlin/Game.kt index 84ba94d..eecbb81 100644 --- a/src/main/kotlin/Game.kt +++ b/src/main/kotlin/Game.kt @@ -6,10 +6,7 @@ import com.badlogic.gdx.graphics.* import com.badlogic.gdx.graphics.g2d.BitmapFont import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.badlogic.gdx.graphics.g3d.* -import com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute -import com.badlogic.gdx.graphics.g3d.attributes.FloatAttribute -import com.badlogic.gdx.graphics.g3d.attributes.IntAttribute -import com.badlogic.gdx.graphics.g3d.attributes.TextureAttribute +import com.badlogic.gdx.graphics.g3d.attributes.* import com.badlogic.gdx.graphics.g3d.environment.DirectionalLight import com.badlogic.gdx.graphics.g3d.environment.PointLight import com.badlogic.gdx.graphics.g3d.model.data.* @@ -35,6 +32,7 @@ class Game: ApplicationAdapter() private lateinit var colin: Colin private var jolkRot = 0.0f + private var lightTheta = 0.0f private lateinit var cubeInstance: ModelInstance private lateinit var floorInstance: ModelInstance @@ -205,6 +203,7 @@ class Game: ApplicationAdapter() { colin.update(deltaTime) + lightTheta += deltaTime jolkRot += 15.0f * deltaTime } @@ -215,6 +214,28 @@ class Game: ApplicationAdapter() ScreenUtils.clear(XnaColor.CornflowerBlue, true) + env.get(PointLightsAttribute.Type)?.let { it as PointLightsAttribute + var thetaa = lightTheta * 6.0f * 0.12f + var thetab = lightTheta * 6.0f * 0.011f + var thetac = lightTheta * 6.0f * 0.056f + + for (light in it.lights) + { + val x = 4.0f + 6.0f * MathUtils.cos(thetaa) + val z = -6.0f + 3.0f * MathUtils.sin(thetaa * 2.0f) + val y = 0.33f + 0.33f * MathUtils.sin(thetab) + val i = 3.1f + 1.53f * MathUtils.cos(thetac) + + val spacing = 0.5f * MathUtils.PI * (2.0f / 3.0f) + thetaa += spacing + thetab += spacing * 0.98f + thetac += spacing * 0.5566f + + light.setPosition(x, y, z) + light.setIntensity(i) + } + } + val jolkPos = Vector3(0.0f, 1.0f + MathUtils.sin(jolkRot * 0.25f) * 0.25f, -4.0f) val world = Matrix4() .setTranslation(jolkPos)