adjust materials
This commit is contained in:
@ -8,6 +8,7 @@ import com.badlogic.gdx.graphics.g2d.BitmapFont
|
|||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||||
import com.badlogic.gdx.graphics.g3d.*
|
import com.badlogic.gdx.graphics.g3d.*
|
||||||
import com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute
|
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.IntAttribute
|
||||||
import com.badlogic.gdx.graphics.g3d.attributes.TextureAttribute
|
import com.badlogic.gdx.graphics.g3d.attributes.TextureAttribute
|
||||||
import com.badlogic.gdx.graphics.g3d.environment.DirectionalLight
|
import com.badlogic.gdx.graphics.g3d.environment.DirectionalLight
|
||||||
@ -42,13 +43,16 @@ class Game: ApplicationAdapter()
|
|||||||
{
|
{
|
||||||
val modelBuilder = ModelBuilder()
|
val modelBuilder = ModelBuilder()
|
||||||
val size = 2.0f
|
val size = 2.0f
|
||||||
//val material = Material(ColorAttribute.createDiffuse(Color.WHITE))
|
val material = Material(
|
||||||
val material = Material(TextureAttribute(TextureAttribute.Diffuse,
|
ColorAttribute.createDiffuse(XnaColor.White),
|
||||||
TextureDescriptor(texture,
|
TextureAttribute(TextureAttribute.Diffuse,
|
||||||
Texture.TextureFilter.Linear,
|
TextureDescriptor(texture,
|
||||||
Texture.TextureFilter.Linear,
|
Texture.TextureFilter.Linear,
|
||||||
Texture.TextureWrap.ClampToEdge,
|
Texture.TextureFilter.Linear,
|
||||||
Texture.TextureWrap.ClampToEdge)))
|
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
|
val attribs = VertexAttributes.Usage.Position or VertexAttributes.Usage.TextureCoordinates or VertexAttributes.Usage.Normal
|
||||||
return modelBuilder.createBox(size, size, size, material, attribs.toLong())
|
return modelBuilder.createBox(size, size, size, material, attribs.toLong())
|
||||||
}
|
}
|
||||||
@ -56,8 +60,11 @@ class Game: ApplicationAdapter()
|
|||||||
private fun makeFloor(texture: Texture): Model
|
private fun makeFloor(texture: Texture): Model
|
||||||
{
|
{
|
||||||
val modelBuilder = ModelBuilder()
|
val modelBuilder = ModelBuilder()
|
||||||
//val material = Material(ColorAttribute.createDiffuse(XnaColor.BlanchedAlmond))
|
val material = Material(
|
||||||
val material = Material(TextureAttribute.createDiffuse(texture))
|
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 attribs = VertexAttributes.Usage.Position or VertexAttributes.Usage.TextureCoordinates or VertexAttributes.Usage.Normal
|
||||||
val size = 10.0f
|
val size = 10.0f
|
||||||
return modelBuilder.createRect(
|
return modelBuilder.createRect(
|
||||||
@ -76,7 +83,11 @@ class Game: ApplicationAdapter()
|
|||||||
|
|
||||||
texJolk = assetManager.get("jolkmeup.jpg")
|
texJolk = assetManager.get("jolkmeup.jpg")
|
||||||
fntComic = assetManager.get("Comic Sans MS.ttf")
|
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)
|
cube = makeCube(texJolk)
|
||||||
floor = makeFloor(assetManager.get("cobblestone.png"))
|
floor = makeFloor(assetManager.get("cobblestone.png"))
|
||||||
@ -101,7 +112,7 @@ class Game: ApplicationAdapter()
|
|||||||
|
|
||||||
cubeInstance = ModelInstance(cube)
|
cubeInstance = ModelInstance(cube)
|
||||||
floorInstance = ModelInstance(floor)
|
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)
|
suzanneInstance.transform = Matrix4().translate(3.0f, 1.0f, -3.5f)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package gay.pizza.CavesOfJolk
|
package gay.pizza.CavesOfJolk
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color
|
import com.badlogic.gdx.graphics.Color
|
||||||
|
import com.badlogic.gdx.math.MathUtils
|
||||||
import com.badlogic.gdx.math.Vector2
|
import com.badlogic.gdx.math.Vector2
|
||||||
import ktx.math.div
|
import ktx.math.div
|
||||||
import ktx.math.times
|
import ktx.math.times
|
||||||
@ -51,3 +52,9 @@ fun Color.lighten(ld: Double): Color
|
|||||||
val rgb = HUSLColorConverter.hsluvToRgb(hsl)
|
val rgb = HUSLColorConverter.hsluvToRgb(hsl)
|
||||||
return Color(rgb[0].toFloat(), rgb[1].toFloat(), rgb[2].toFloat(), a)
|
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))
|
||||||
|
Reference in New Issue
Block a user