Skip to content

Instantly share code, notes, and snippets.

@Martin-Pitt
Last active November 4, 2024 01:20
Show Gist options
  • Save Martin-Pitt/12a58cd498fd382fb7068e2fe29b1a83 to your computer and use it in GitHub Desktop.
Save Martin-Pitt/12a58cd498fd382fb7068e2fe29b1a83 to your computer and use it in GitHub Desktop.

Number Display Revised

Done a bunch of maths and scripting to revise this mesh design to optimise it.

It'll feature a rectangular panel to display 3 digits at once using a texture that has numbers from 0-999. There will be three of these digit panels each with a separate material.

Between the digit panels will be locations for separators such as commas or points.

I also want to be able to support negative numbers. After a lot of thought, the best way to approach this would be to slide a minus character left/right depending on how many digits the number has visible. So there would have to be a long thin rectangle going through all digit panels as well as extending out so that I can place the minus when the display has all 9 digits occupied.

In terms of relative sizes to reference for the geometry (via pixels in the font texture):

  • digit panels are 75x48 each (so a digit is 25x48),
  • the minus character is 25 wide.
  • Commas/periods are 11 wide, so the separators/gaps between the digit panels should be 11 wide as well
    • Note that unlike the sketch below we'll have the separators and panels bunched up rather than overlapping
  • Adding it all up (3 panels, 2 gaps), the long thin rectangle for minus should be (75*3 + 11*2 =) 247 wide.
    • Note that the minus rectangle is shifted left by one digit (25).

Sketch

Here is how it might look like with all the numbers, commas and minus: Numbers Render You can use this as a reference for figuring out the relative vertical heights/placement of things.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment