diching RGB10; colors are now fully vec3

This commit is contained in:
minjaesong
2017-07-09 02:21:24 +09:00
parent 43fee8aa9d
commit 28d7b44821
23 changed files with 299 additions and 282 deletions

View File

@@ -39,7 +39,9 @@ object AVKey {
* 0000 0010000000 0010000000 0010000000
* ^ Red ^ Green ^ Blue
*/
const val LUMINOSITY = "luminosity"
const val LUMR = "luminosityred"
const val LUMG = "luminositygreen"
const val LUMB = "luminosityblue"
const val DRAGCOEFF = "dragcoeff"
const val FALLDAMPENMULT = "falldampenmult"

View File

@@ -1,6 +1,7 @@
package net.torvald.terrarum.gameactors
import com.badlogic.gdx.Gdx
import com.badlogic.gdx.graphics.Color
import com.jme3.math.FastMath
import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.gameactors.faction.Faction
@@ -8,6 +9,7 @@ import net.torvald.terrarum.itemproperties.GameItem
import net.torvald.terrarum.itemproperties.Material
import net.torvald.terrarum.realestate.LandUtil
import net.torvald.terrarum.ui.UIInventory
import net.torvald.terrarum.worlddrawer.LightmapRenderer
import java.util.*
/**
@@ -47,19 +49,17 @@ open class ActorHumanoid(birth: GameDate, death: GameDate? = null)
if (houseDesignation != null) houseDesignation!!.clear()
}
/**
* Recommended implementation:
*
override var luminosity: Int
get() = actorValue.getAsInt(AVKey.LUMINOSITY) ?: 0
set(value) {
actorValue[AVKey.LUMINOSITY] = value
}
*/
override var luminosity: Int
get() = actorValue.getAsInt(AVKey.LUMINOSITY) ?: 0
override var luminosity: Color
get() = Color(
(actorValue.getAsFloat(AVKey.LUMR) ?: 0f) / LightmapRenderer.MUL_FLOAT,
(actorValue.getAsFloat(AVKey.LUMG) ?: 0f) / LightmapRenderer.MUL_FLOAT,
(actorValue.getAsFloat(AVKey.LUMB) ?: 0f) / LightmapRenderer.MUL_FLOAT,
1f
)
set(value) {
actorValue[AVKey.LUMINOSITY] = value
actorValue[AVKey.LUMR] = value.r * LightmapRenderer.MUL_FLOAT
actorValue[AVKey.LUMG] = value.g * LightmapRenderer.MUL_FLOAT
actorValue[AVKey.LUMB] = value.b * LightmapRenderer.MUL_FLOAT
}
/**

View File

@@ -31,7 +31,8 @@ typealias Second = Float
*
* Created by minjaesong on 16-01-13.
*/
open class ActorWithPhysics(renderOrder: RenderOrder, val immobileBody: Boolean = false, physics: Boolean = true) : ActorWithBody(renderOrder) {
open class ActorWithPhysics(renderOrder: RenderOrder, val immobileBody: Boolean = false, physics: Boolean = true) :
ActorWithBody(renderOrder) {
val COLLISION_TEST_MODE = false

View File

@@ -1,5 +1,6 @@
package net.torvald.terrarum.gameactors
import com.badlogic.gdx.graphics.Color
import net.torvald.terrarum.ModMgr
import net.torvald.terrarum.blockproperties.Block
import net.torvald.terrarum.blockproperties.BlockCodex
@@ -11,11 +12,12 @@ import java.util.*
*/
internal class FixtureTikiTorch : FixtureBase(), Luminous {
override var luminosity: Int
override var luminosity: Color
get() = BlockCodex[Block.TORCH].luminosity
set(value) {
throw UnsupportedOperationException()
}
override val lightBoxList: ArrayList<Hitbox>
init {

View File

@@ -1,5 +1,7 @@
package net.torvald.terrarum.gameactors
import com.badlogic.gdx.graphics.Color
/**
* Created by minjaesong on 16-02-19.
*/
@@ -8,13 +10,20 @@ interface Luminous {
/**
* Recommended implementation:
*
override var luminosity: Int
get() = actorValue.getAsInt(AVKey.LUMINOSITY) ?: 0
override var luminosity: Color
get() = Color(
(actorValue.getAsFloat(AVKey.LUMR) ?: 0f) / LightmapRenderer.MUL_FLOAT,
(actorValue.getAsFloat(AVKey.LUMG) ?: 0f) / LightmapRenderer.MUL_FLOAT,
(actorValue.getAsFloat(AVKey.LUMB) ?: 0f) / LightmapRenderer.MUL_FLOAT,
1f
)
set(value) {
actorValue[AVKey.LUMINOSITY] = value
actorValue[AVKey.LUMR] = value.r * LightmapRenderer.MUL_FLOAT
actorValue[AVKey.LUMG] = value.g * LightmapRenderer.MUL_FLOAT
actorValue[AVKey.LUMB] = value.b * LightmapRenderer.MUL_FLOAT
}
*/
var luminosity: Int
var luminosity: Color
/**
* Arguments:

View File

@@ -49,8 +49,9 @@ object PlayerBuilderSigrid {
p.actorValue[AVKey.INTELLIGENT] = true
//p.actorValue[AVKey.LUMINOSITY] = Color(0x434aff).to10bit()
//p.actorValue[AVKey.LUMINOSITY] = 214127943 // bright purple
//p.actorValue[AVKey.LUMR] = 0.84f
//p.actorValue[AVKey.LUMR] = 0.93f
//p.actorValue[AVKey.LUMR] = 1.37f
p.actorValue[AVKey.BASEDEFENCE] = 141

View File

@@ -28,8 +28,8 @@ open class ProjectileSimple(
val speed: Int
override var luminosity: Int
get() = bulletDatabase[type][OFFSET_LUMINOSITY] as Int
override var luminosity: Color
get() = (bulletDatabase[type][OFFSET_LUMINOSITY] as Color).cpy()
set(value) {
}
/**
@@ -115,8 +115,8 @@ open class ProjectileSimple(
val OFFSET_LUMINOSITY = 4
val bulletDatabase = arrayOf(
// damage, display colour, no gravity, speed
arrayOf(7, Color(0xFF5429), true, 40, 32),
arrayOf(8, Color(0xFF5429), true, 20, 0)
arrayOf(7, Color(0xFF5429_FF.toInt()), true, 40, 32),
arrayOf(8, Color(0xFF5429_FF.toInt()), true, 20, 0)
// ...
)
}

View File

@@ -1,5 +1,7 @@
package net.torvald.terrarum.gameactors
import com.badlogic.gdx.graphics.Color
/**
* Created by minjaesong on 16-04-26.
*/
@@ -15,7 +17,7 @@ class WeaponSwung(val itemID: Int) : ActorWithPhysics(Actor.RenderOrder.MIDTOP),
actorValue[AVKey.LUMINOSITY] = value
}
*/
override var luminosity: Int
override var luminosity: Color
get() = throw UnsupportedOperationException()
set(value) {
}

View File

@@ -73,14 +73,6 @@ internal class AILuaAPI(g: Globals, actor: ActorWithPhysics) {
t["strength"] = actor.avStrength.toLua()
val lumrgb: Int = actor.actorValue.getAsInt(AVKey.LUMINOSITY) ?: 0
val MUL_2 = LightmapRenderer.MUL_2
val MUL = LightmapRenderer.MUL
val CHMAX = LightmapRenderer.CHANNEL_MAX
t["luminosityRGB"] = lumrgb.toLua()
t["luminosity"] = (lumrgb.div(MUL_2).and(CHMAX).times(3) +
lumrgb.div(MUL).and(CHMAX).times(4) +
lumrgb.and(1023)).div(8.0).toLua() // quick luminosity calculation
return t
}