7 digit alphanumeric display

About Truespace Archives

These pages are a copy of the official truespace forums prior to their removal somewhere around 2011.

They are retained here for archive purposes only.

7 digit alphanumeric display // Scriptorium

1  2  |  

Post by ProfessorKhaos // Dec 30, 2006, 10:59pm

ProfessorKhaos
Total Posts: 622
pic
Hi all,


Just thought I'd share a project I've been working on. Might have some interesting uses for live data display within your projects.


http://img527.imageshack.us/img527/406/leddisplay001sk8.jpg

http://img527.imageshack.us/img527/7298/leddisplay002cp0.jpg


This example is a 7 digit display composed of 16 segment LEDs (plus decimal point).


Digits can be chained together to achive the desired length. Would be relatively easy to create a 20 digit display though I haven't tested it's performance at that level.


Includes scripting necessary for alphanumeric displays and some limited punctuation and symbols (all letters are uppercase)


Allows user to set the on/off color of the elements as well so you could simulate LED or flourescent displays.


Hope to share it with folks here soon.


P.K.

Post by ProfessorKhaos // Dec 30, 2006, 11:03pm

ProfessorKhaos
Total Posts: 622
pic
By the way, the "scripting a clock" course was of some help when working on this project. Gave me a good model to dissect when looking at color control.

Post by ProfessorKhaos // Dec 31, 2006, 7:27am

ProfessorKhaos
Total Posts: 622
pic
Moved this project over to the interactive artwork section since it's not so much a "how to script" issue as it is a "product of scripting" soon to be shared.

Post by ProfessorKhaos // Jan 7, 2007, 8:46pm

ProfessorKhaos
Total Posts: 622
pic
Going to see just how much I can push the envelope here...


Decided to take on a more ambitious display. It's going to be a balancing act between cutting out unnecessary scripts and links and having more controllable polygons.


As it turns out the latest version of the segmented display uses Material index modification in the mesh. This is done against 60 triangles in the mesh for each digit. It's a reasonable speed improvement over the original which had a material for each segment (x how ever many segments per digit x how ever many digits)


As it turns out, a 6 x 6 dot matrix display has 36 * 2 = 62 triangles that would have to be turned on or off. I can represent far more digits with 6 x 6 matrix than a 16 segmet LED display. The reason this is practical is because the LED segments require a few extra triangles to get the shape right. The decimal point especially, although reduced to a octagon is still fairly costly from a material index modification point of view.


Dot matrix is easy. They're just a grid of squares. Creating them with a script object also gives them a predictable assignment order in terms of the triangles.


Bottom line? I think I can squeeze more characters and equivalent performance out of a dot matrix display. Also, the regular sized mesh spacing makes it very easy for me to regenerate any number of columns and have smoother scrolling text.


Already created a script to create the mesh itself. A second script will be used for matrix material index modification (so as to not perform unnecessary steps to recreate vertices over and over).


We'll see where this goes...

http://img411.imageshack.us/img411/2036/dotmatrix001gx6.jpg

http://img444.imageshack.us/img444/7020/dotmatrix002oi1.jpg


Anchor points (default axis position) can be defined as well. upper left, lower left, upper right, lower right, top center, bottom center, left center, right center, and object center.


P.K.

Post by Norm // Jan 8, 2007, 7:16am

Norm
Total Posts: 862
pic
Interesting so far. Looking forward to results :)

Post by ProfessorKhaos // Jan 9, 2007, 4:56am

ProfessorKhaos
Total Posts: 622
pic
Worked on material mapping script and tested ability to set/clear dots. So far so good. Not really a good speed test yet though as each dot is a new script execution with the test app. Proves a graphic display capability though.


http://img81.imageshack.us/img81/5063/dotmatrix003zk4.jpg

http://img174.imageshack.us/img174/2064/dotmatrix004jm3.jpg

Post by roman // Jan 10, 2007, 12:46pm

roman
Total Posts: 320
ProfessorKhaos, I do not see your e-mail address, would you contact me at roman@caligari.com? I have a proposition in mind for you:)

Post by ProfessorKhaos // Jan 10, 2007, 4:36pm

ProfessorKhaos
Total Posts: 622
pic
Got your message Roman :)


Sent you an email from my home account so that you'd have my address. Am very curious what you may have in mind!


Cheers!


Glen

Post by ProfessorKhaos // Jan 20, 2007, 9:53pm

ProfessorKhaos
Total Posts: 622
pic
Now have the ability to write a character at a time to my new display. Method uses bitmap pixels to define fonts so they can be redefined by scene maker if desired.


Will extend it to write strings soon. Starting x,y position for upper left corner of character is arbitrary. Character can even be partially or totally outside of character display and it's handled properly.


So far it appears reasonably fast. Should be able to get a gradually scrolling character display capability.


P.K.

Post by trueBlue // Jan 21, 2007, 6:11am

trueBlue
Total Posts: 1761
pic
Looking good P.K. Just a thought but wouldn't transparency be a good option for the background?

Post by ProfessorKhaos // Jan 21, 2007, 10:16am

ProfessorKhaos
Total Posts: 622
pic
hmmm. :)


I like the way you think trueBlue! We're going to end up with a bunch of see-thru minority report style screens at this rate! The screens aren't double sided of course so that may be something to contend with if looking from behind them. Haven't checked to see if mesh-specific double sided rendering is an option yet or not.


I'd imagine that transparency could easily be incorporated when defined as a material type. The project exists pretty much in 2 sections right now. There's the display mesh generator (creates the initial mesh) and then there's the display driver (modifies the mesh's material indices). I've piggybacked a color selector in the mesh generator but once set the materials "are what they are" and the display driver is just changing between 3 selections (background, off, and on).


Could always increase the number of valid colors too (for instance a multicolor display) but that would take a bit more complexity and I wanted to make sure I could do the basics first.


I believe transparency would be a "no cost" item to incorporate ('cept for that back side issue) so I'll definitely keep it on the "must do" list.


P.K.

Post by trueBlue // Jan 21, 2007, 10:37am

trueBlue
Total Posts: 1761
pic
Cool! Not sure I would want or need to look at the back side of the display. If you wanted to read text backwards I guess you could enter it that way. :p
I see your LED all over the place in the Lake House Place. What a great script!

Post by ProfessorKhaos // Jan 21, 2007, 6:20pm

ProfessorKhaos
Total Posts: 622
pic
A few little updates.


Can write an entire string at a time now. Going to code in some extra capabilities to allow inverse characters, etc using escape-like sequences. Also may allow user to specify font cell size (currently 8x8 fixed) in case they want to use a more basic or elaborate font of their own design.

Post by ProfessorKhaos // Jan 21, 2007, 6:26pm

ProfessorKhaos
Total Posts: 622
pic
By the way, the font itself wasn't my creation. It came from the following web site:


http://overcode.yak.net/12


As indicated, it's freely distributable. The reason for the large white gap up front is due to the non-printability of ASCII characters up to 32. The bitmap is used 'as is' to provide the font definition for my display. Saved me lots of time since I no longer had to worry about hardcoding a font and I'm sure you'll agree it's a better, more flexible solution.

Post by Norm // Jan 22, 2007, 6:09am

Norm
Total Posts: 862
pic
I bet this could be used for realtime debugging and working with scripts. All kinds of possibilities. Tres cool :cool:

Post by trueBlue // Jan 22, 2007, 8:50am

trueBlue
Total Posts: 1761
pic
hmmm. :)

I like the way you think trueBlue! We're going to end up with a bunch of see-thru minority report style screens at this rate! The screens aren't double sided of course so that may be something to contend with if looking from behind them. Haven't checked to see if mesh-specific double sided rendering is an option yet or not.

I'd imagine that transparency could easily be incorporated when defined as a material type. The project exists pretty much in 2 sections right now. There's the display mesh generator (creates the initial mesh) and then there's the display driver (modifies the mesh's material indices). I've piggybacked a color selector in the mesh generator but once set the materials "are what they are" and the display driver is just changing between 3 selections (background, off, and on).

Could always increase the number of valid colors too (for instance a multicolor display) but that would take a bit more complexity and I wanted to make sure I could do the basics first.

I believe transparency would be a "no cost" item to incorporate ('cept for that back side issue) so I'll definitely keep it on the "must do" list.

P.K.
I am experimenting with adding Transparency to your 1 Digit Display. Turns out it is really easy. I went inside each material and replaced the Solid node with a SolidTransparency node and exported to the top.
At first not knowing what the hell I was doing I painted each Background triangle with transparency in Model. Which brings me to my point here. I wanted to share something that happened at some point in time while in Model doing the above. At some point there was another Shape created and so there was two of them. Then everything went south. Not sure why this happened just wanted you to beware.

So are you going to dedicate your 7 digit alphanumeric display in memory of John Hall?

Post by ProfessorKhaos // Jan 22, 2007, 3:59pm

ProfessorKhaos
Total Posts: 622
pic
Could always place a comment in the script itself and perhaps give it a default message to that effect. People would clear it out at design time of course but it might be a nice touch.


I've noticed things do get a bit whacky when you manipulate script generated objects such as these. I guess that's pretty much because these objects function in ways that are already "off the beaten path". That's why it's a good idea to become a proficient LE user, especially when you want to tweak an existing item's functionality.

Post by ProfessorKhaos // Jan 23, 2007, 2:06pm

ProfessorKhaos
Total Posts: 622
pic
Just bouncing a few ideas for display control around...


I figure the script could be fed a series of escape codes (i.e. backslash followed by a character or character grouping) as part of the text string to indicate just how the text would be drawn on screen.


Here's kinda what I had in mind (subject to suggestions/change of course):



***ESCAPING THE ESCAPE CHARACTER***


\\ = \ (allows you to include a backslash in the actual text)



***CURSOR POSITIONING***


\n = return to far left and down one line

\r = return to far left but stay on the same line.


\N = move cursor up (north) one line

\S = move cursor down (south) one line

\E = move cursor right (east) one space

\W = move cursor left (west) one space


\H = clear display and return cursor to home (upper left) position

\h = leave display as is and return cursor to home position


***TEXT FORMATTING***


\I = turn inverse text on for characters that follow

\i = turn inverse text off for characters that follow


\T = turn transparent background on for characters that follow

\t = turn transparent background off for characters that follow


\U = turn underline on for characters that follow

\u = turn underline off for characters that follow


\C = display cursor position (not sure about this...)

\c = hide cursor position (ditto)


***MORE ADVANCED FEATURES (VERY TENATIVE)***


\L[x1,y1,x2,y2,mode] = draw line from x1,y1 to x2,y2 using a given draw mode (on/off/invert)


\F[x1,y1,x2,y2,mode] = fill an area (makes a solid box) with x1,y1 as one corner and x2,y2 as the other corner. Same draw mode conventions as line.


\O[x,y] = offset the home position by -x pixels horizontally and -y pixels vertically. Just one idea I had to manage smooth scrolling.


***NOTES***


X pixels increase from left to right

y pixels increase from top down.


upper corner is 0,0 in x,y coordinates


I don't think that lines will be wrapped, thus if you try to display more characters on a line than you can, it doesn't wrap around to the next line. There's a reason for this. First, I'm lazy. Second, it would be relatively easy for your own app to insert a '\n' at the appropriate spot. Third, it may interfere with plans down the road for smooth scrolling text features.


Anyway, that's my thoughts so far. Comments?

Post by Norm // Jan 23, 2007, 5:31pm

Norm
Total Posts: 862
pic
I wonder if vbscript would be more robust in such a case.

With jscript is difficult to access keycode and such. With vbscript, msdn gives some good examples. I read where the can be done at form level, which to me means script level. So you can capture keyboard activity or restrict it as desired when the script is run. Might be easier than passing slashes and building whole new language. I never really tried myself so just passing along my thoughts.

Post by ProfessorKhaos // Jan 23, 2007, 7:26pm

ProfessorKhaos
Total Posts: 622
pic
It's still early enough in the project that VBScript would be an easy rewrite. Might be interesting to see if there's a performance difference as well.


I've actually got a pretty good handle on the parser necessary to detect escaped sequences. Not quite sure how the other way would work.


For the planned method, the display driver basically becomes a type of state machine where each character in the string is fed into it to set the mode and subsequent characters are interpreted depending on the state machine's mode at that time.


In semi-JScript psuedocode it would be something like the following



thisCharIndex = 0;

numChars = thisString.length();


parseMode = "normal"

cmdMode = "";

paramNum = 0;


while (thisCharIndex < numChars)

{

thisChar = thisString[thisCharIndex];


if (parseMode == "normal")

{

\\ normal character mode

if (thisChar == "\")

{

\\ we're being placed in escape mode

parseMode = "escaped"

}

else

{

\\ treat the character literally

<insert code here to draw character at current location on screen>

}

}

else if (parseMode = "escaped")

{

\\ current character determines which escape command we're using


if (thisChar == "N")

{

\\ we just got the code to move up a line


yline = yline - 1;

if (yline < 0) {yline = 0}

parseMode = "normal";

cmdMode = "";

paramNum = 0;

}

else if (thisChar == "S")

{

\\ we just got the code to move down a line


yline = yline + 1;

parseMode = "normal";

cmdMode = "";

paramNum = 0;

}


.

. other parameter-less commands here

.



}

else if (thisChar == "L")

{

\\ we just got the code to draw a line so preserve command type,

\\ clear param list and then change to param parsing mode


cmdMode = "L"

parseMode = "read_params"

paramNum = 0;

}


.

. other parameter based commands here

.


}

else

{

\\ Command code wasn't recognized so ignore it and go back to normal

\\ parsing mode.


parseMode = "normal";

cmdMode = "";

paramNum = 0;

}

}

else if (parseMode == "read_params")

{

\\ this mode reads in parameters from a list


if (paramNum == 0)

{

\\ this should be the start of the parameter list

if (thisChar != "[")

{

\\ Illegal opening character for start of param list, ignore it and go

\\ back to normal parsing mode.


parseMode = "normal";

cmdMode = "";

paramNum == 0;

}

else

{

\\ valid opening character found, start parsing parameters


paramNum = 1;

param[1] = "";

}

}

else

{

\\ add to parameter until "," or "]" found


if (thisChar == ",")

{

\\ comma found, move on to next parameter


if (paramNum >= 5)

{

\\ we've exceeded the max number of params we want to use

\\ so ignore the command and return to normal mode


parseMode = "normal";

cmdMode = "";

paramNum = 0;

}

else

{

paramNum++;

param[paramNum] = "";

}

else if (thisChar == "]")

{

\\ we've reached the end of the parameter list so process the

\\ command


if (cmdMode = "L" && paramNum == 5)

{

\\ execute line command using param list then return to normal

\\ parsing mode for subsequent text


draw_line(param[1], param[2], param[3], param[4], param[5])

parseMode = "normal"

cmdMode = "";

paramNum = 0;

}


.

. other parameter based command tests/executions here

.


}

else if (cmdMode = "F" && paramNum == 5)

{

\\ execute fill area command using param list then return to

\\ normal parsing mode for subsequent text


fill_area(param[1], param[2], param[3], param[4], param[5])

parseMode = "normal"

cmdMode = "";

paramNum = 0;

}

else

{

\\ wrong number of params accompanied command type so

\\ ignore command and return to normal parsing mode


parseMode = "normal"

cmdMode = "";

paramNum = 0;

}

}

else

{

\\ this character is part of the current parameter so just append it


param[paramNum] = param[paramNum] + thisChar;

}

}

}

else

{

\\ weird parse mode... shouldn't be here so reset to "normal"


parseMode = "normal"

cmdMode = "";

paramNum = 0;

}


// move on to next character in string


thisCharIndex++

}



I'm thinking that any keyboard interception/processing would come from an outside script and be fed to this one just for display purposes. My understanding of some of the more advanced methods is a bit limited so what you see may be somewhat of a brute force attempt. lol. Maybe I'll learn something new with this one.

Post by ProfessorKhaos // Jan 31, 2007, 3:47pm

ProfessorKhaos
Total Posts: 622
pic
Ok folks, finally got a version ready to post... a little optimization work left to go but this has the basic functionality.... yes that also includes ability to draw lines :)


There are a few special character codes to manipulate the display (passed as part of the input string). Note that they are case sensitive.


\\ = substitute single '\' character (allows you to still use backslashes on display)


\n = carriage return


\U = turn on undercase mode

\u = turn off undercase mode


\I = turn on inverted pixels mode

\i = turn off inverted pixels mode


\N = north (move cursor up by one pixel)

\S = south (move cursor down by one pixel)

\E = east (move cursor right by one pixel)

\W = west (move cursor left by one pixel)


\l[x1,y1,x2,y2,drawmode] <- lower case L, draws a line given by the parameters contained in brackets


drawmode can be 3 values,


0 = off

1 = on

2 = toggle


Mesh and font parameters appear on their own tabs within the matrix control panel.


The message shown below is part of the default display setup. You will only see the top two lines of them unless you update the mesh to have 112 rows. I did this to help keep the .rcd file size small.


Not the cleanest scripts I've ever written but it works. May go back and clean it up at some point but most of the features are set.


P.K.


Old image and file removed, see new ones below

Post by ProfessorKhaos // Jan 31, 2007, 3:57pm

ProfessorKhaos
Total Posts: 622
pic
Example showing single pixel positioning of letters and line drawing capabilities

Post by ProfessorKhaos // Feb 1, 2007, 12:28pm

ProfessorKhaos
Total Posts: 622
pic
Updated files... please use this one instead. Better materials handling for rendering in Vray. Also, added transparency controls for materials per trueBlue's suggestion above (see projector clock project in this thread for potential uses: http://forums1.caligari.com/truespace/showthread.php?t=2147 ).


Make sure you check out the other aspect tabs (default/mesh/font, selected by dropdown in upper right corner).

Post by trueBlue // Feb 3, 2007, 2:26pm

trueBlue
Total Posts: 1761
pic
Wow... P.K. you really out did yourself with this one. This is great!
Where is the spell checker? ;)
I am enjoying reading your script. First script that I have read that makes since to me, I like your style. Well thought out and executed.
Also nice touch with dedication to John Hall. This will most likely enter my mind every time when using this. A few years ago I had a twenty five year old relationship end to that ughly C word.

Thanks P.K.

Post by ProfessorKhaos // Feb 3, 2007, 5:40pm

ProfessorKhaos
Total Posts: 622
pic
Thanks trueBlue. Actually you don't realize just how badly I needed that spell checker very recently. Alas, it doesn't help when I have name confusions or use valid words in the wrong manner.


I'm happy to see it's already working away in new and interesting places. :)


Sorry for your loss there. I've known others in similar circumstances. The older I get the more and more it seems to happen too :(


Anyway I'm glad you made that suggestion. Obviously I don't know him by any measure other than the comments left on his memorial page. At the time I hadn't gone beyond the font page itself until you had noticed it. When I did read the page, it made perfect sense to add that statement. He certainly did make my project far easier, which is to say that his efforts are still helping us today.

Post by ProfessorKhaos // Feb 4, 2007, 2:36am

ProfessorKhaos
Total Posts: 622
pic
There may be some DNS issue. I was able to get to the page via this link


http://overcode.yak.net/1


Here's an image of the main page (at least the start as there were miles of supportive comments and condolences that followed on the same page).


P.K.


I think you may have typed overcode.jak.net/1 instead of overcode.yak.net/1. Maybe that was the reason but I'm basing it on your post, not your browsing. I did indeed get ads when I used the mistyped address. Hope the link above helps!

Post by ProfessorKhaos // Feb 6, 2007, 10:53pm

ProfessorKhaos
Total Posts: 622
pic
Newer version about ready to send out... this one actually is just a bitmap generator so it's up to you how you map it on your object.


It can use either an existing bitmap for the background or a solid color, which is quite the enhancement over the polygon version. Could probably even be used for alpha maps or bump maps. Haven't tried it in that yet but I'm sure the creative folks here will have a few ideas.


This script only generates one text. If you want more than one line on a bitmap you can chain the scripts together and use the margin settings to shift the text up or down a bit.


The outputs are "stackable" such that you can put multiple lines on a bitmap of multiple colors.


Panel comments have been enhanced so hopefully the display will be a bit more friendly to figure out. Only caution has to do with the "sharpness" control. Don't let it get too large as it behaves much the same way antialiasing does when rendering (sharpness of 2 yield 4 pixels per matrix "cell".


I've eliminated some of the expensive niceities of the original such as gaps between display cells. It also has the effect of reducing aliasing effects which would potentially require supersampling to suppress.


Obviously the bigger the display and the longer the string of text, the slower the update will be.


Best of all, the .rcd file is only 74k... smaller than 2 of the 3 .jpg images you currently see below.


P.K.

Post by trueBlue // Feb 7, 2007, 8:39am

trueBlue
Total Posts: 1761
pic
Very cool there P.K. I have not messed around with this very much. Changing the Char Size X and Y creates an error.

Post by ProfessorKhaos // Feb 7, 2007, 10:56am

ProfessorKhaos
Total Posts: 622
pic
Hi TrueBlue!


I believe what you're seeing is an error associated with trying to access a pixel outside of the font map's dimensions.


Perhaps I should clarify a bit more on the purpose of the Char Size X and Y terms. They're used to tell the script the dimensions of the font map's pixels, not necessarily control the size of the output bitmap. Since the output is intended to be used on a UV mapped object, I figured that the user could stretch/squish the object dimensions or UV settings to achieve the desired look with a bitmap of small dimensions.


If the background bitmap or characters become a bit fuzzy due to pixel blending or downsampling then the sharpness setting can correct for this at the cost of performance. A sharpness of 2 basically doubles the width and height of the output bitmap but requires 4 pixels for every 1 pixel to be set when drawing the characters. 3 results in 9, 4 in 16, etc... I've tested all the way to 25 but the wait can become pretty painful.


The default font map is 1024 x 8 pixels. This breaks out to be 128 8x8 pixel characters representing ascii values of 0-127.


When changing the Char Size X and Char Size Y terms you're actually telling the script how many pixels are used in the font map to define each character. This way you can make and use your own fonts of any practical dimension so long as each character consists of the same pixel dimensions.


A 12x12 font could be created in a font bitmap of 1536 x 12 pixels. A 5x5 font could be created in a font bitmap of 640 x 5 pixels.


I could have assumed the height would always be the font map height and the width would always be the font map width divided by 128. Maybe that would be a better way to approach it. What you're seeing is the residual part of my script where I considered supporting multiple fonts of various character lengths simultaneously by creating rows in the font map. This would require more information in the script to interpret character sizes. Probably an obsolete notion at this point anyway.


Stay tuned. MkVc may be coming out very soon.


v/r,


Glen

Post by ProfessorKhaos // Feb 7, 2007, 12:36pm

ProfessorKhaos
Total Posts: 622
pic
New update. MkVc


-derives character dimensions from font bitmap size

-protects user from illegal margin, column, and sharpness entries

-improved script readability & flow

-reworked panel text to better explain font bitmap format


Glen
Awportals.com is a privately held community resource website dedicated to Active Worlds.
Copyright (c) Mark Randall 2006 - 2024. All Rights Reserved.
Awportals.com   ·   ProLibraries Live   ·   Twitter   ·   LinkedIn