Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

text on box

Demon Lilliehook
Registered User
Join date: 8 May 2007
Posts: 25
07-17-2007 16:04
what is the best way to get letters on a object to form words.

i toke a view at the XY text.

but that way to complicated.
i was thinking of making a texture with 2 row of 13 collums.
is there a way to get the targetted letter to appear on the object.

i tried, with textures from the XY text, but the have more than 1 letter on the textures.
i did an experiment with

llSetTextureAnim (ANIM_ON | PING_PONG | LOOP, 1, 2, 5, 0, 0, 15.0);

but if i turn off ANIM_ON, replace with 0.
i see the whole texture instead of the targetted letter.


kind regards,

marco
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
07-17-2007 16:38
llOffsetTexture() might do the trick, but ultimately a whole lot of the xyText logic will end up relevant, to calculate the right offsets for each letter.
DoteDote Edison
Thinks Too Much
Join date: 6 Jun 2004
Posts: 790
07-17-2007 17:40
Currently, there's no better option than one of the XyText solutions. You could try to reinvent the wheel, but more than likely you'll end up with just another wheel.

XyText can be a little confusing at first, but once you understand how to get it going, you might be surprised how useable it really is.

All you need to do is:
1) Use the XyText prim-maker script to create either the 3 or 5 character prim
2) remove that utility script, add the matchin 3 or 5 character XyText script
3) save a copy of the prim for quick future use

For a single-prim display:
4) send a link message to the prim - llMessageLinked(LINK_SET, DISPLAY_STRING, "test", "";);

For a multi-prim setup, it can get a little complex, but it's a simple concept:
To initialize the prims, you target a link message to each prim via it's link number... that message assigns a row integer to all the prims in a single row along with the starting character index for the column.

I use a two dimensional loop with the outer loop being a row counter, and the inner loop being the column. As well, there is an incremental link number. So, each outer loop increases the row integer... the inner loop increases the column integer and link integer, and the message sent is something like:
llMessageLinked(linkNum, SET_CELL_INFO, llList2CSV([row,col*5]), "";);
(the *5 is for 5-character prims, would be *3 for 3-character XyText)

Of course, the important thing is to link the prims in the correct order... right to left, bottom to top... to make things easier.
Bizcut Vanbrugh
Registered User
Join date: 23 Jul 2006
Posts: 99
07-17-2007 17:54
From: DoteDote Edison
Currently, there's no better option than one of the XyText solutions. You could try to reinvent the wheel, but more than likely you'll end up with just another wheel.

XyText can be a little confusing at first, but once you understand how to get it going, you might be surprised how useable it really is.

All you need to do is:
1) Use the XyText prim-maker script to create either the 3 or 5 character prim
2) remove that utility script, add the matchin 3 or 5 character XyText script
3) save a copy of the prim for quick future use

For a single-prim display:
4) send a link message to the prim - llMessageLinked(LINK_SET, DISPLAY_STRING, "test", "";);

For a multi-prim setup, it can get a little complex, but it's a simple concept:
To initialize the prims, you target a link message to each prim via it's link number... that message assigns a row integer to all the prims in a single row along with the starting character index for the column.

I use a two dimensional loop with the outer loop being a row counter, and the inner loop being the column. As well, there is an incremental link number. So, each outer loop increases the row integer... the inner loop increases the column integer and link integer, and the message sent is something like:
llMessageLinked(linkNum, SET_CELL_INFO, llList2CSV([row,col*5]), "";);
(the *5 is for 5-character prims, would be *3 for 3-character XyText)

Of course, the important thing is to link the prims in the correct order... right to left, bottom to top... to make things easier.



Hey Dotedote you seem to be pretty knowldgeable on this subject would there be any way of getting together in world so you could help me understand this type of script and how to use it better. i have been working on some HUDs and this would be great for diong a few of the things i want to?
Demon Lilliehook
Registered User
Join date: 8 May 2007
Posts: 25
alter version of Xytext
07-18-2007 05:34
i have been playing today with the Xytext from LSLwiki

does anyone have a modified version to display 1 char on 1 prim?

vector GetGridPos(integer index1, integer index2) {
// There are two ways to use the lookup table...
integer Col;
integer Row;
if (index1 >= index2) {
// In this case, the row is the index of the first character:
Row = index1;
// And the col is the index of the second character (x2)
Col = index2 * 2;
}
else { // Index1 < Index2
// In this case, the row is the index of the second character:
Row = index2;
// And the col is the index of the first character, x2, offset by 1.
Col = index1 * 2 + 1;
}
return < Col, Row, 0>;
}

string GetGridTexture(vector grid_pos) {
// Calculate the texture in the grid to use.
integer GridCol = llRound(grid_pos.x) / 20;
integer GridRow = llRound(grid_pos.y) / 10;

// Lookup the texture.
key Texture = llList2Key(CHARACTER_GRID, GridRow * (GridRow + 1) / 2 + GridCol);
return Texture;
}

vector GetGridOffset(vector grid_pos) {
// Zoom in on the texture showing our character pair.
integer Col = llRound(grid_pos.x) % 20;
integer Row = llRound(grid_pos.y) % 10;

// Return the offset in the texture.
return <-0.45 + 0.05 * Col, 0.45 - 0.1 * Row, 0.0>;
}

ShowChars(vector grid_pos1, vector grid_pos2, vector grid_pos3) {
// Set the primitive textures directly.
llSetPrimitiveParams( [
PRIM_TEXTURE, LEFT_FACE, GetGridTexture(grid_pos1), <0.1, 0.1, 0>, GetGridOffset(grid_pos1), PI_BY_TWO,
PRIM_TEXTURE, MIDDLE_FACE, GetGridTexture(grid_pos2), <0.1, 0.1, 0>, GetGridOffset(grid_pos2), 0.0,
PRIM_TEXTURE, RIGHT_FACE, GetGridTexture(grid_pos3), <0.1, 0.1, 0>, GetGridOffset(grid_pos3), -PI_BY_TWO
]);
}

RenderString(string str) {
// Get the grid positions for each pair of characters.
vector GridPos1 = GetGridPos( llSubStringIndex(gCharIndex, llGetSubString(str, 0, 0)),
llSubStringIndex(gCharIndex, llGetSubString(str, 1, 1)) );
vector GridPos2 = GetGridPos( llSubStringIndex(gCharIndex, llGetSubString(str, 2, 2)),
llSubStringIndex(gCharIndex, llGetSubString(str, 3, 3)) );
vector GridPos3 = GetGridPos( llSubStringIndex(gCharIndex, llGetSubString(str, 4, 4)),
llSubStringIndex(gCharIndex, llGetSubString(str, 5, 5)) );

// Use these grid positions to display the correct textures/offsets.
ShowChars(GridPos1, GridPos2, GridPos3);
}

i need to adjust this piece of code in order to show 1 single char centered on 1 face of the prim.

i'm not using the setup script provided here
http://lslwiki.net/lslwiki/wakka.php?wakka=XyText
i don't wanna have a bended prim, lol.

it's amazing how the code can show 2 chars on a prim side.

kind regards
DoteDote Edison
Thinks Too Much
Join date: 6 Jun 2004
Posts: 790
07-18-2007 16:49
Ah, you want only one character per PRIM (as opposed to per face)?
From: someone
////////////////////////////////////////////
// XyText v1.1 Script (Single Texture)*
//
// Written by Xylor Baysklef
// *modified to display one character on one face of one prim
////////////////////////////////////////////

/////////////// CONSTANTS //////////////////
// XyText Message Map
integer DISPLAY_STRING = 204000;
integer SET_CELL_INFO = 204004;

// Face number
integer MIDDLE_FACE = 0;

//////////// GLOBAL VARIABLES //////////////
// This is the key of the font we are displaying.
key gFontTexture = "b2e7394f-5e54-aa12-6e1c-ef327b6bed9e";
// All displayable characters. Default to ASCII order.
string gCharIndex;
// This is the channel to listen on while acting as a cell in a larger display.
integer gCellChannel = -1;
// This is the starting character position in the cell channel message to render.
integer gCellCharPosition = 0;
/////////// END GLOBAL VARIABLES ////////////

ResetCharIndex() {
gCharIndex = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`";
// \" <-- Fixes LSL syntax highlighting bug.
gCharIndex += "abcdefghijklmnopqrstuvwxyz{|}~";
gCharIndex += "\n\n\n\n\n";
}

vector GetGridOffset(integer index) {
// Calculate the offset needed to display this character.
integer Row = index / 10;
integer Col = index % 10;

// Return the offset in the texture.
return <-0.45 + 0.1 * Col, 0.45 - 0.1 * Row, 0.0>;
}

ShowChars(vector grid_offset1) {
// Set the primitive textures directly.
llSetPrimitiveParams([PRIM_TEXTURE, MIDDLE_FACE, (string) gFontTexture, <0.05, 0.1, 0>, grid_offset1, 0.0]);
}

RenderString(string str) {
// Get the grid positions for each pair of characters.
vector GridOffset1 = GetGridOffset( llSubStringIndex(gCharIndex, llGetSubString(str, 0, 0)) );

// Use these grid positions to display the correct textures/offsets.
ShowChars(GridOffset1);
}

default {
state_entry() {
// Initialize the character index.
ResetCharIndex();
}

link_message(integer sender, integer channel, string data, key id) {
if (channel == DISPLAY_STRING) {
RenderString(data);
return;
}
if (channel == gCellChannel) {
// Extract the characters we are interested in, and use those to render.
string TextToRender = llGetSubString(data, gCellCharPosition, gCellCharPosition);

RenderString( TextToRender );
return;
}
if (channel == SET_CELL_INFO) {
// Change the channel we listen to for cell commands,
// and the starting character position to extract from
list Parsed = llCSV2List(data);
gCellChannel = (integer) llList2String(Parsed, 0);
gCellCharPosition = (integer) llList2String(Parsed, 1);
return;
}
}
}
Demon Lilliehook
Registered User
Join date: 8 May 2007
Posts: 25
hahaha ...
07-18-2007 19:00
indeed, i overlooked it.

it works fine.


thnx for pointing out my ....

: )


regards