Interrupt / delverengine

Delver game engine and editor
zlib License
803 stars 81 forks source link

Add support for rendering BitmapFonts in 3D #95

Closed evrimoztamur closed 4 years ago

evrimoztamur commented 4 years ago

This branch is a crude (but nearly feature-complete) implementation to replace the Text entity.

The replacement of the sprite-indexed font rendering allows the engine to render 3D text with accented characters and other features of the BitmapFont class. It also sets precedent for rendering SpriteBatches in the 3D world.

The outstanding issue with this implementation is the lighting, which is currently bottlenecked at https://github.com/evrimoztamur/delverengine/blob/e86c4934f934daa15d073d86d6c1baf743796beb/Dungeoneer/src/com/interrupt/dungeoneer/gfx/GlRenderer.java#L812. I can't figure out how to correctly set the colour based on the 3D world light.

@Interrupt @joshuaskelly could you do a brief test of the existing featureset, and comment on lighting issues later?

Interrupt commented 4 years ago

The GlRenderer.java:GetLightmapAt function call will return the level's static lighting at a given point in space. Static sprites in the game will only look that up once at level load (unless the lighting in that part of the level gets refreshed) and dynamic sprites end up looking up that color every frame.

See: https://github.com/Interrupt/delverengine/blob/2b52a21cb41b6a162d58e0113d4aa58edf7d6833/Dungeoneer/src/com/interrupt/dungeoneer/gfx/GlRenderer.java#L2670

And also when drawing a sprite: https://github.com/Interrupt/delverengine/blob/2b52a21cb41b6a162d58e0113d4aa58edf7d6833/Dungeoneer/src/com/interrupt/dungeoneer/gfx/GlRenderer.java#L2239

evrimoztamur commented 4 years ago

output

Added newline support, please review @Interrupt.

evrimoztamur commented 4 years ago

output2

evrimoztamur commented 4 years ago

Replaced Text with NeoText and it looks like it has smoothly transitioned. There's a small issue with the entity ? being displayed, @Interrupt @joshuaskelly any help with getting rid of that?

image

Interrupt commented 4 years ago

This could be a way to upgrade older text entities to the new way of rendering: https://gist.github.com/Interrupt/c9ea5272c196563c7410cc6d36d6f1c9

evrimoztamur commented 4 years ago

image

Looks good to me, the conversion code from @Interrupt wasn't entirely correct in the sense that it was a catch-all for the new Text entities too.

I replaced this check with an instanceof against DrawableSprite which is a guaranteed determinant of legacy Text entities.

This commit also fixed two comments from @joshuaskelly, and also adjusts the above gist to correctly position entities based on their past rotation (the new text alignment only persists in the block, and Text entities are always centered on entity origin; this means that the old left-origin text must be moved to the new center-origin-aligned position).