they call me knuckles unlike sonic i dont chuckle i just flex my knuckles

This commit is contained in:
2023-08-20 06:09:48 +10:00
parent e031523ed1
commit 22be9bbe00
4 changed files with 22 additions and 17 deletions

View File

@ -34,11 +34,13 @@ class Game: ApplicationAdapter()
private lateinit var colin: Colin
private var jolkRot = 0.0f
private var lightTheta = 0.0f
private val rand = RandomXS128(69 + 420 + 1919 + 916 + 42 + 1)
private lateinit var cubeInstance: ModelInstance
private lateinit var floorInstance: ModelInstance
private lateinit var suzanneInstance: ModelInstance
private lateinit var rockBatch: ModelCache
private lateinit var knux: ModelInstance
private fun makeCube(texture: Texture): Model
{
@ -171,26 +173,13 @@ class Game: ApplicationAdapter()
floorInstance = ModelInstance(floor)
suzanneInstance = ModelInstance(assetManager.get("suzanne.g3db", Model::class.java))
val rock = assetManager.get("rock.g3db", Model::class.java)
val rand = RandomXS128(69 + 420 + 1919 + 916 + 42 + 1)
val randQuaternion = { rand: RandomXS128 ->
var x: Float
var y: Float
var z: Float
do { x = rand.nextFloat(-1.0f, 1.0f); y = rand.nextFloat(-1.0f, 1.0f); z = x * x + y * y } while (z > 1.0f)
var u: Float
var v: Float
var w: Float
do { u = rand.nextFloat(-1.0f, 1.0f); v = rand.nextFloat(-1.0f, 1.0f); w = u * u + v * v } while (w > 1.0f)
val s = kotlin.math.sqrt((1.0f - z) / w)
Quaternion(x, y, s * u, s * v)
}
val rocks = Array(75) { i->
ModelInstance(rock, Matrix4(
Vector3(
rand.nextFloat(joeMany),
rand.nextFloat(-0.75f, 10.125f),
-rand.nextFloat(joeMany)),
randQuaternion(rand),
rand.nextQuaternion(),
Util.one * rand.nextFloat(0.6f, 6.2f)))
}
rockBatch = ModelCache().apply {
@ -200,6 +189,7 @@ class Game: ApplicationAdapter()
}
suzanneInstance.transform = Matrix4().translate(3.0f, 1.0f, -3.5f)
knux = ModelInstance(assetManager.get("knux.g3db", Model::class.java))
}
override fun resize(width: Int, height: Int)
@ -254,12 +244,14 @@ class Game: ApplicationAdapter()
.rotate(0.0f, 1.0f, 0.0f, jolkRot)
.scale(0.25f, 0.25f, 0.25f)
cubeInstance.transform = world
knux.transform.rotate(rand.nextQuaternion().slerp(Quaternion(), 0.9f))
modelBatch.begin(colin.camera)
modelBatch.render(floorInstance, env)
modelBatch.render(rockBatch, env)
modelBatch.render(cubeInstance, env)
modelBatch.render(suzanneInstance, env)
modelBatch.render(knux, env)
modelBatch.end()
spriteBatch.begin()

View File

@ -50,6 +50,7 @@ class Resources private constructor()
assetManager.load("cobblestone_normal.png", Texture::class.java, linearMipped)
assetManager.load("cobblestone_specular.png", Texture::class.java, linearMipped)
assetManager.load("rock.g3db", Model::class.java)
assetManager.load("knux.g3db", Model::class.java)
}
}

View File

@ -3,9 +3,7 @@ package gay.pizza.CavesOfJolk
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g3d.Attribute
import com.badlogic.gdx.graphics.g3d.Attributes
import com.badlogic.gdx.math.MathUtils
import com.badlogic.gdx.math.Vector2
import com.badlogic.gdx.math.Vector3
import com.badlogic.gdx.math.*
import ktx.math.div
import ktx.math.times
import ktx.math.unaryMinus
@ -75,3 +73,17 @@ fun Color.mix(rhs: Color, x: Float) = Color(
fun <T: Attribute> Attributes.get(type: Long) = get(type) as? T
fun Random.nextFloat(min: Float, max: Float) = min + nextFloat() * (max - min)
fun RandomXS128.nextQuaternion(): Quaternion
{
var x: Float
var y: Float
var z: Float
do { x = nextFloat(-1.0f, 1.0f); y = nextFloat(-1.0f, 1.0f); z = x * x + y * y } while (z > 1.0f)
var u: Float
var v: Float
var w: Float
do { u = nextFloat(-1.0f, 1.0f); v = nextFloat(-1.0f, 1.0f); w = u * u + v * v } while (w > 1.0f)
val s = kotlin.math.sqrt((1.0f - z) / w)
return Quaternion(x, y, s * u, s * v)
}

Binary file not shown.