All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.de.fabmax.kool.physics.geometry.SphereGeometry.kt Maven / Gradle / Ivy

There is a newer version: 0.15.1
Show newest version
package de.fabmax.kool.physics.geometry

import de.fabmax.kool.math.MutableVec3f
import de.fabmax.kool.math.spatial.BoundingBoxF
import de.fabmax.kool.scene.geometry.MeshBuilder

expect fun SphereGeometry(radius: Float): SphereGeometry

interface SphereGeometry : CollisionGeometry {
    val radius: Float

    override fun generateMesh(target: MeshBuilder) {
        target.icoSphere {
            radius = [email protected]
            steps = 2
        }
    }

    override fun getBounds(result: BoundingBoxF) = result.set(-radius, -radius, -radius, radius, radius, radius)

    override fun estimateInertiaForMass(mass: Float, result: MutableVec3f): MutableVec3f {
        val i = 2f / 5f * mass * radius * radius
        return result.set(i, i, i)
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy