diff --git a/src/main/kotlin/Game.kt b/src/main/kotlin/Game.kt index c90bef2..1d6de77 100644 --- a/src/main/kotlin/Game.kt +++ b/src/main/kotlin/Game.kt @@ -8,6 +8,7 @@ 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.environment.DirectionalLight @@ -42,13 +43,16 @@ class Game: ApplicationAdapter() { val modelBuilder = ModelBuilder() val size = 2.0f - //val material = Material(ColorAttribute.createDiffuse(Color.WHITE)) - val material = Material(TextureAttribute(TextureAttribute.Diffuse, - TextureDescriptor(texture, - Texture.TextureFilter.Linear, - Texture.TextureFilter.Linear, - Texture.TextureWrap.ClampToEdge, - Texture.TextureWrap.ClampToEdge))) + val material = Material( + ColorAttribute.createDiffuse(XnaColor.White), + TextureAttribute(TextureAttribute.Diffuse, + TextureDescriptor(texture, + Texture.TextureFilter.Linear, + Texture.TextureFilter.Linear, + Texture.TextureWrap.ClampToEdge, + Texture.TextureWrap.ClampToEdge)), + ColorAttribute.createSpecular(XnaColor.Gray), + FloatAttribute.createShininess(20.0f)) val attribs = VertexAttributes.Usage.Position or VertexAttributes.Usage.TextureCoordinates or VertexAttributes.Usage.Normal return modelBuilder.createBox(size, size, size, material, attribs.toLong()) } @@ -56,8 +60,11 @@ class Game: ApplicationAdapter() private fun makeFloor(texture: Texture): Model { val modelBuilder = ModelBuilder() - //val material = Material(ColorAttribute.createDiffuse(XnaColor.BlanchedAlmond)) - val material = Material(TextureAttribute.createDiffuse(texture)) + val material = Material( + ColorAttribute.createDiffuse(XnaColor.BlanchedAlmond.lighten(0.01)), + ColorAttribute.createSpecular(XnaColor.BlanchedAlmond.mix(XnaColor.Black, 0.4f)), + FloatAttribute.createShininess(65.0f), + TextureAttribute.createDiffuse(texture)) val attribs = VertexAttributes.Usage.Position or VertexAttributes.Usage.TextureCoordinates or VertexAttributes.Usage.Normal val size = 10.0f return modelBuilder.createRect( @@ -76,7 +83,11 @@ class Game: ApplicationAdapter() texJolk = assetManager.get("jolkmeup.jpg") fntComic = assetManager.get("Comic Sans MS.ttf") + val suzanne = assetManager.get("suzanne.g3db", Model::class.java) + // Override ridiculous shininess because i cbf to fix the model + for (i in suzanne.materials) + i.set(FloatAttribute.createShininess(30.0f)) cube = makeCube(texJolk) floor = makeFloor(assetManager.get("cobblestone.png")) @@ -101,7 +112,7 @@ class Game: ApplicationAdapter() cubeInstance = ModelInstance(cube) floorInstance = ModelInstance(floor) - suzanneInstance = ModelInstance(assetManager.get("suzanne.g3db", Model::class.java)) + suzanneInstance = ModelInstance(suzanne) suzanneInstance.transform = Matrix4().translate(3.0f, 1.0f, -3.5f) } diff --git a/src/main/kotlin/Util.kt b/src/main/kotlin/Util.kt index 43776d0..431b399 100644 --- a/src/main/kotlin/Util.kt +++ b/src/main/kotlin/Util.kt @@ -1,6 +1,7 @@ package gay.pizza.CavesOfJolk import com.badlogic.gdx.graphics.Color +import com.badlogic.gdx.math.MathUtils import com.badlogic.gdx.math.Vector2 import ktx.math.div import ktx.math.times @@ -51,3 +52,9 @@ fun Color.lighten(ld: Double): Color val rgb = HUSLColorConverter.hsluvToRgb(hsl) return Color(rgb[0].toFloat(), rgb[1].toFloat(), rgb[2].toFloat(), a) } + +fun Color.mix(rhs: Color, x: Float) = Color( + MathUtils.lerp(this.r, rhs.r, x), + MathUtils.lerp(this.g, rhs.g, x), + MathUtils.lerp(this.b, rhs.b, x), + MathUtils.lerp(this.a, rhs.a, x))