Skip to content

Commit

Permalink
Fix shadow issues
Browse files Browse the repository at this point in the history
Some instruments were not having correct shadows applied because they
were .fbx files? Not sure why this is, so I just converted them to .obj
files and fiddled with the code slightly to work correctly. In the
future, I would like to properly convert them to .j3o binary files.
  • Loading branch information
wyskoj committed May 24, 2022
1 parent 433e384 commit 61e31ca
Show file tree
Hide file tree
Showing 198 changed files with 86,962 additions and 74,415 deletions.
5 changes: 5 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import com.jme3.math.ColorRGBA
import com.jme3.math.Quaternion
import com.jme3.math.Ray
import com.jme3.math.Vector3f
import com.jme3.renderer.queue.RenderQueue
import com.jme3.scene.Node
import com.jme3.scene.Spatial
import org.wysko.midis2jam2.Midis2jam2
Expand Down Expand Up @@ -107,7 +108,9 @@ class SpaceLaser(context: Midis2jam2, eventList: List<MidiChannelSpecificEvent>,
private val laserNode = Node()

/** The laser beam. */
internal val laserBeam: Spatial = context.loadModel("SpaceLaserLaser.fbx", "Laser.bmp")
internal val laserBeam: Spatial = context.loadModel("SpaceLaserLaser.obj", "Laser.bmp").apply {
shadowMode = RenderQueue.ShadowMode.Off
}

/** Timer for how long a note has been playing to calculate wobble. */
private var wobbleTime = 0.0
Expand All @@ -119,7 +122,7 @@ class SpaceLaser(context: Midis2jam2, eventList: List<MidiChannelSpecificEvent>,
private val angleCalculator = SIGMOID_CALCULATOR

/** The shooter. */
internal val shooter: Spatial = context.loadModel("SpaceLaser.fbx", "ShinySilver.bmp")
internal val shooter: Spatial = context.loadModel("SpaceLaser.obj", "ShinySilver.bmp")

override fun tick(time: Double, delta: Float) {
super.tick(time, delta)
Expand Down Expand Up @@ -202,9 +205,9 @@ class SpaceLaser(context: Midis2jam2, eventList: List<MidiChannelSpecificEvent>,

init {
/* Load base */
val base = context.loadModel("SpaceLaserBase.fbx", "Wood.bmp")
val base = context.loadModel("SpaceLaserBase.obj", "Wood.bmp")
(base as Node).apply {
getChild(0).setMaterial(context.reflectiveMaterial("Assets/ShinySilver.bmp"))
getChild(1).setMaterial(context.reflectiveMaterial("Assets/ShinySilver.bmp"))
getChild(2).setMaterial(context.unshadedMaterial("Assets/RubberFoot.bmp"))
}

Expand All @@ -231,8 +234,8 @@ class SpaceLaser(context: Midis2jam2, eventList: List<MidiChannelSpecificEvent>,
}
(it.shooter as Node).apply {
getChild(0).setMaterial(context.reflectiveMaterial("Assets/HornSkinGrey.bmp"))
getChild(1).setMaterial(glowMaterial)
getChild(2).setMaterial(context.unshadedMaterial("Assets/RubberFoot.bmp"))
getChild(1).setMaterial(context.unshadedMaterial("Assets/RubberFoot.bmp"))
getChild(2).setMaterial(glowMaterial)
}
it.laserBeam.setMaterial(glowMaterial)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class FrenchHorn(context: Midis2jam2, eventList: List<MidiChannelSpecificEvent>)

init {
/* Load body */
context.loadModel("FrenchHornBody.fbx", "HornSkin.bmp", 0.9f).apply {
context.loadModel("FrenchHornBody.obj", "HornSkin.bmp", 0.9f).apply {
modelNode.attachChild(this)
(this as Node).getChild(1).setMaterial(context.reflectiveMaterial("Assets/HornSkinGrey.bmp"))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class Trombone(context: Midis2jam2, eventList: List<MidiChannelSpecificEvent>) :
init {
/* Attach body, slide, and set rotation of Trombone */
modelNode.run {
attachChild(context.loadModel("Trombone.fbx", "HornSkin.bmp", 0.9f).apply {
attachChild(context.loadModel("Trombone.obj", "HornSkin.bmp", 0.9f).apply {
this as Node
getChild(1).setMaterial(context.reflectiveMaterial("Assets/HornSkinGrey.bmp"))
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class Trumpet(context: Midis2jam2, eventList: List<MidiChannelSpecificEvent>, ty

init {
/* Load trumpet body */
val body = context.loadModel("TrumpetBody.fbx", "HornSkin.bmp", 0.9f)
val body = context.loadModel("TrumpetBody.obj", "HornSkin.bmp", 0.9f)

/* Set horn skin grey material */
(body as Node).getChild(1).setMaterial(context.reflectiveMaterial("Assets/HornSkinGrey.bmp"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class Tuba(context: Midis2jam2, eventList: List<MidiChannelSpecificEvent>) :

init {
/* Load body and bell */
val body = context.loadModel("TubaBody.fbx", "HornSkin.bmp", 0.9f)
val body = context.loadModel("TubaBody.obj", "HornSkin.bmp", 0.9f)
bell.attachChild(context.loadModel("TubaHorn.obj", "HornSkin.bmp", 0.9f))

/* Attach body and bell */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ class StageStrings(
animNode.attachChild(restingString)

// Load bow
bow = context.loadModel("StageStringBow.fbx", type.textureFile).apply {
(this as Node).getChild(1).setMaterial((restingString as Geometry).material)
bow = context.loadModel("StageStringBow.obj", type.textureFile).apply {
(this as Node).getChild(0).setMaterial((restingString as Geometry).material)
}

bowNode.run {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ class Timpani(context: Midis2jam2, eventList: List<MidiChannelSpecificEvent>) :
}

animNode.run {
attachChild(context.loadModel("TimpaniBody.fbx", "HornSkin.bmp", 0.9f).apply {
(this as Node).getChild(1).setMaterial(context.reflectiveMaterial("Assets/HornSkinGrey.bmp"))
attachChild(context.loadModel("TimpaniBody.obj", "HornSkin.bmp", 0.9f).apply {
(this as Node).getChild(0).setMaterial(context.reflectiveMaterial("Assets/HornSkinGrey.bmp"))
})
attachChild(context.loadModel("TimpaniHead.obj", "TimpaniSkin.bmp"))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ class Banjo(context: Midis2jam2, events: List<MidiChannelSpecificEvent>) : Frett
FretHeightByTable.fromJson("Banjo")
),
4,
context.loadModel("Banjo.fbx", "BanjoSkin.png")
context.loadModel("Banjo.obj", "BanjoSkin.png")
) {
override val upperStrings: Array<Spatial> = Array(4) {
context.loadModel("BanjoString.fbx", "BassSkin.bmp").also {
context.loadModel("BanjoString.obj", "BassSkin.bmp").also {
instrumentNode.attachChild(it)
}
}.apply {
Expand All @@ -69,7 +69,7 @@ class Banjo(context: Midis2jam2, events: List<MidiChannelSpecificEvent>) : Frett

override val lowerStrings: Array<Array<Spatial>> = Array(4) {
Array(5) { j: Int ->
context.loadModel("BanjoStringBottom$j.fbx", "BassSkin.bmp").apply {
context.loadModel("BanjoStringBottom$j.obj", "BassSkin.bmp").apply {
instrumentNode.attachChild(this)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class BassGuitar(context: Midis2jam2, events: List<MidiChannelSpecificEvent>, ty
STANDARD("Bass.obj", "BassD.obj", BASS_SKIN_BMP),

/** The fretless Bass Guitar type. */
FRETLESS("BassFretless.fbx", "BassFretlessD.fbx", "BassSkinFretless.png");
FRETLESS("BassFretless.obj", "BassFretlessD.obj", "BassSkinFretless.png");
}

init {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class Guitar(context: Midis2jam2, events: List<MidiChannelSpecificEvent>, type:
val textureFileName: String,
) {
/** Acoustic guitar type. */
ACOUSTIC("GuitarAcoustic.fbx", "GuitarAcousticDropD.fbx", "AcousticGuitar.png"),
ACOUSTIC("GuitarAcoustic.obj", "GuitarAcousticDropD.obj", "AcousticGuitar.png"),

/** Electric guitar type. */
ELECTRIC("Guitar.obj", "GuitarD.obj", "GuitarSkin.bmp");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ class Shamisen(context: Midis2jam2, events: List<MidiChannelSpecificEvent>) : Fr
}
),
3,
context.loadModel("Shamisen.fbx", SHAMISEN_SKIN_TEXTURE)) {
context.loadModel("Shamisen.obj", SHAMISEN_SKIN_TEXTURE)) {

override val upperStrings: Array<Spatial> = Array(3) {
context.loadModel("ShamisenString.fbx", SHAMISEN_SKIN_TEXTURE).apply {
context.loadModel("ShamisenString.obj", SHAMISEN_SKIN_TEXTURE).apply {
instrumentNode.attachChild(this)
setLocalTranslation(positioning.upperX[it], positioning.upperY, FORWARD)
}
Expand All @@ -58,7 +58,7 @@ class Shamisen(context: Midis2jam2, events: List<MidiChannelSpecificEvent>) : Fr

override val lowerStrings: Array<Array<Spatial>> = Array(3) { i: Int ->
Array(5) { j: Int ->
context.loadModel("ShamisenStringBottom$j.fbx", SHAMISEN_SKIN_TEXTURE).apply {
context.loadModel("ShamisenStringBottom$j.obj", SHAMISEN_SKIN_TEXTURE).apply {
instrumentNode.attachChild(this)
setLocalTranslation(positioning.lowerX[i], positioning.lowerY, FORWARD)
cullHint = Always
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ class Accordion(context: Midis2jam2, eventList: MutableList<MidiChannelSpecificE

init {
/* Load left case */
val leftHandCase = context.loadModel("AccordionLeftHand.fbx", type.textureCaseName).also {
val leftHandCase = context.loadModel("AccordionLeftHand.obj", type.textureCaseName).also {
accordionSections[0].attachChild(it)
}

Expand All @@ -236,7 +236,7 @@ class Accordion(context: Midis2jam2, eventList: MutableList<MidiChannelSpecificE
/* Set materials */
(leftHandCase as Node).apply {
getChild(1).setMaterial(leatherStrap)
getChild(0).setMaterial(rubberFoot)
getChild(2).setMaterial(rubberFoot)
}

/* Add the keys */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class JingleBells(context: Midis2jam2, hits: MutableList<MidiNoteOnEvent>) : Non

init {
/* Load stick and materials */
val stick = context.loadModel("JingleBells.fbx", "JingleBells.bmp")
val stick = context.loadModel("JingleBells.obj", "JingleBells.bmp")
(stick as Node).getChild(0).setMaterial(context.unshadedMaterial("Assets/StickSkin.bmp"))

/* Positioning */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ class Slap(context: Midis2jam2, hits: MutableList<MidiNoteOnEvent>) : NonDrumSet

init {
/* Left and right slappers */
leftSlapNode.attachChild(context.loadModel("SlapHalf.fbx", "Wood.bmp"))
rightSlapNode.attachChild(context.loadModel("SlapHalf.fbx", "Wood.bmp").apply {
leftSlapNode.attachChild(context.loadModel("SlapHalf.obj", "Wood.bmp"))
rightSlapNode.attachChild(context.loadModel("SlapHalf.obj", "Wood.bmp").apply {
localRotation = Quaternion().fromAngles(0f, 0f, FastMath.PI)
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class Surdo(context: Midis2jam2, hits: MutableList<MidiNoteOnEvent>) : NonDrumSe
}

init {
recoilNode.attachChild(context.loadModel("DrumSet_Surdo.fbx", "DrumShell_Surdo.png").apply {
recoilNode.attachChild(context.loadModel("DrumSet_Surdo.obj", "DrumShell_Surdo.png").apply {
setLocalScale(1.7f)
})
with(highestLevel) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Tambourine(context: Midis2jam2, hits: MutableList<MidiNoteOnEvent>) : NonD

/** Contains the hand with the tambourine. */
private val tambourineHandNode = Node().apply {
attachChild(context.loadModel("hand_tambourine.fbx", "hands.bmp").apply {
attachChild(context.loadModel("hand_tambourine.obj", "hands.bmp").apply {
(this as Node).getChild(2).setMaterial(context.unshadedMaterial("TambourineWood.bmp"))
getChild(1).setMaterial(context.unshadedMaterial("MetalTexture.bmp"))
setLocalTranslation(0f, 0f, -2f)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class Triangle(context: Midis2jam2, hits: MutableList<MidiNoteOnEvent>, type: Tr
OPEN("Triangle.obj"),

/** Muted triangle type. */
MUTED("MutedTriangle.fbx");
MUTED("MutedTriangle.obj");
}

init {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,21 +105,21 @@ class BassDrum(context: Midis2jam2, hits: MutableList<MidiNoteOnEvent>) : Percus
drumNode.attachChild(drum)

/* Load beater arm */
beaterArm = context.loadModel("DrumSet_BassDrumBeaterArm.fbx", METAL_TEXTURE)
beaterArm = context.loadModel("DrumSet_BassDrumBeaterArm.obj", METAL_TEXTURE)

/* Load beater holder */
val bassDrumBeaterHolder = context.loadModel("DrumSet_BassDrumBeaterHolder.fbx", METAL_TEXTURE)
val bassDrumBeaterHolder = context.loadModel("DrumSet_BassDrumBeaterHolder.obj", METAL_TEXTURE)
val holder = bassDrumBeaterHolder as Node

/* Apply materials */
val arm = beaterArm as Node
val shinySilverMaterial = context.reflectiveMaterial("Assets/ShinySilver.bmp")
val darkMetalMaterial = context.unshadedMaterial("Assets/MetalTextureDark.bmp")
arm.run {
getChild(0).setMaterial(shinySilverMaterial)
getChild(1).setMaterial(darkMetalMaterial)
getChild(0).setMaterial(shinySilverMaterial)
}
holder.getChild(0).setMaterial(darkMetalMaterial)
holder.getChild(1).setMaterial(darkMetalMaterial)

/* Load pedal */
pedal = context.loadModel("DrumSet_BassDrumPedal.obj", METAL_TEXTURE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class TaikoDrum(context: Midis2jam2, eventList: List<MidiChannelSpecificEvent>)
}

init {
val drum = context.loadModel("Taiko.fbx", "TaikoHead.bmp")
val drum = context.loadModel("Taiko.obj", "TaikoHead.bmp")
val woodTexture = context.assetManager.loadTexture("Assets/Wood.bmp")
val material = Material(context.assetManager, "Common/MatDefs/Misc/Unshaded.j3md")
material.setTexture("ColorMap", woodTexture)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class Oboe(context: Midis2jam2, eventList: List<MidiChannelSpecificEvent>) :
inner class OboeClone : HandedClone(this@Oboe, 0.075f) {

/** The bell. */
private val bell = context.loadModel("OboeHorn.fbx", "OboeSkin.png").apply {
private val bell = context.loadModel("OboeHorn.obj", "OboeSkin.png").apply {
modelNode.attachChild(this)
setLocalTranslation(0f, -20.7125f, 0f)
}
Expand All @@ -79,7 +79,7 @@ class Oboe(context: Midis2jam2, eventList: List<MidiChannelSpecificEvent>) :

init {
/* Load body */
modelNode.attachChild(context.loadModel("OboeBody.fbx", "OboeSkin.png"))
modelNode.attachChild(context.loadModel("OboeBody.obj", "OboeSkin.png"))
loadHands()

animNode.setLocalTranslation(0f, 0f, 10f)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ class AltoSax(context: Midis2jam2, events: List<MidiChannelSpecificEvent>) :
setMaterial(shine)
}

context.assetManager.loadModel("Assets/AltoSaxBody.fbx").apply {
context.assetManager.loadModel("Assets/AltoSaxBody.obj").apply {
this as Node
getChild(0).setMaterial(shine)
getChild(1).setMaterial(Material(context.assetManager, "Common/MatDefs/Misc/Unshaded.j3md").apply {
getChild(0).setMaterial(Material(context.assetManager, "Common/MatDefs/Misc/Unshaded.j3md").apply {
setColor("Color", Black)
})
getChild(1).setMaterial(shine)
modelNode.attachChild(this)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ class BaritoneSax(context: Midis2jam2, events: List<MidiChannelSpecificEvent>) :
setMaterial(shine)
}

context.assetManager.loadModel("Assets/BaritoneSaxBody.fbx").apply {
context.assetManager.loadModel("Assets/BaritoneSaxBody.obj").apply {
this as Node
getChild(0).setMaterial(shine)
getChild(1).setMaterial(context.reflectiveMaterial("Assets/HornSkinGrey.bmp"))
getChild(2).setMaterial(Material(context.assetManager, "Common/MatDefs/Misc/Unshaded.j3md").apply {
getChild(0).setMaterial(context.reflectiveMaterial("Assets/HornSkinGrey.bmp"))
getChild(1).setMaterial(Material(context.assetManager, "Common/MatDefs/Misc/Unshaded.j3md").apply {
setColor("Color", ColorRGBA.Black)
})
getChild(2).setMaterial(shine)
modelNode.attachChild(this)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ class SopranoSax(
setMaterial(shine)
}

context.assetManager.loadModel("Assets/SopranoSaxBody.fbx").apply {
context.assetManager.loadModel("Assets/SopranoSaxBody.obj").apply {
this as Node
getChild(0).setMaterial(shine)
getChild(1).setMaterial(Material(context.assetManager, "Common/MatDefs/Misc/Unshaded.j3md").apply {
getChild(0).setMaterial(Material(context.assetManager, "Common/MatDefs/Misc/Unshaded.j3md").apply {
setColor("Color", ColorRGBA.Black)
})
getChild(1).setMaterial(shine)
modelNode.attachChild(this)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class TenorSax(context: Midis2jam2, events: List<MidiChannelSpecificEvent>) :
setMaterial(shine)
}

context.assetManager.loadModel("Assets/TenorSaxBody.fbx").apply {
context.assetManager.loadModel("Assets/TenorSaxBody.obj").apply {
this as Node
getChild(0).setMaterial(shine)
getChild(1).setMaterial(Material(context.assetManager, "Common/MatDefs/Misc/Unshaded.j3md").apply {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,24 +63,24 @@ class BirdTweet(context: Midis2jam2, events: List<MidiChannelSpecificEvent>) :
inner class Bird : BouncyTwelfth() {

/** The open beak. */
private val openBeak = context.loadModel("BirdBeak_Open.fbx", BIRD_TEXTURE).also {
private val openBeak = context.loadModel("BirdBeak_Open.obj", BIRD_TEXTURE).also {
animNode.attachChild(it)
}

/** The closed beak. */
private val closedBeak = context.loadModel("BirdBeak_Closed.fbx", BIRD_TEXTURE).also {
private val closedBeak = context.loadModel("BirdBeak_Closed.obj", BIRD_TEXTURE).also {
animNode.attachChild(it)
}

/** The wings. */
private val wings = context.loadModel("BirdWings.fbx", BIRD_TEXTURE).also {
private val wings = context.loadModel("BirdWings.obj", BIRD_TEXTURE).also {
animNode.attachChild(it)
}

init {
animNode.attachChild(context.loadModel("Bird.fbx", BIRD_TEXTURE).apply {
animNode.attachChild(context.loadModel("Bird.obj", BIRD_TEXTURE).apply {
this as Node
getChild(1).setMaterial(context.reflectiveMaterial("Assets/HornSkin.bmp"))
getChild(0).setMaterial(context.reflectiveMaterial("Assets/HornSkin.bmp"))
})
}

Expand Down

0 comments on commit 61e31ca

Please sign in to comment.