Quantcast
Channel: marchのBLOG
Viewing all articles
Browse latest Browse all 20

ソース(2):【日本語対応メッセージボード v05】

$
0
0
>【日本語対応メッセージボード Japanese-MessageBoard v05】 のソースです。 以下は子プリムのスクリプトです。 見所は、getTextureUuid 関数の中にあるテクスチャのUUIDです。 16*16の文字が並んでいるテクスチャのUUIDです。 私の技術不足で、拡大するとガタガタが目立ちますが、 Secondlife内で自由に漢字を表示したい場合には役立つと思います。 これを作るためにGIMP2でBMPから透過tgaに変換するために Script-Fuに手を出してみたものの時間切れになり、 結局はキー操作を記録再生するプログラムを使ったという思い出があります(^_^;)。 では、子プリムのスクリプトです。 ライセンスは、親プリムのスクリプトと一緒です。 // //v03:5face. //v04:comment_out llOwnerSay at init() //v05:transparent_texture.,, // integer PANEL_ID = -1; integer PRIM_PER_CHARACTOR = 5; //1prim-5face integer INPRIM_LEFT_LEFT = 0; integer INPRIM_LEFT_CENTER = 1; integer INPRIM_CENTER = 2; integer INPRIM_RIGHT_CENTER = 3; integer INPRIM_RIGHT_RIGHT = 4; key BLANK_TEXTURE = "5748decc-f629-461c-9a36-a35a221fe21f"; //blank image (100% white image with no alpha) //key TRANSPARENT_TEXTURE = "f54a0c32-3cd1-d49a-5b4f-7b792bebc204"; //a 100% alpha (fully transparent) texture vector FAIL_MAPPING_VECTOR = ; //use when mapping fail. integer xmax = 16; integer ymax = 16; integer isDebugMode = FALSE; integer getPanelId() { string originalObjectDesc; integer originalObjectDescLen; integer resultId = -1; integer timeupCounter = 0; string tmpStr; string tmpSubStr; // originalObjectDesc = llGetObjectDesc(); originalObjectDescLen = llStringLength(originalObjectDesc); //llOwnerSay("getPanelId" + ": original ObjectDesc length = " + (string)originalObjectDescLen + "."); if(originalObjectDescLen > 120) // MAX(127 charactor) - 6 - 1; //ID = 6 DIGITS. { llOwnerSay("getPanelId" + ": original ObjectDesc too long(" + (string)originalObjectDescLen + ")"); return -1; } // llMessageLinked(LINK_THIS , 0, "getPanelId", NULL_KEY); do { tmpStr = llGetObjectDesc(); tmpSubStr = llGetSubString(tmpStr, originalObjectDescLen, llStringLength(tmpStr)); if(llStringLength(tmpSubStr) > 0) { // check first character of gotten ID is Numeric? if(llSubStringIndex("0123456789", llGetSubString(tmpSubStr, 0, 0)) >= 0) { resultId = (integer)tmpSubStr; llSetObjectDesc(originalObjectDesc); return resultId; } } // no found id. timeupCounter++; llSleep(0.5); }while(timeupCounter < 10); llOwnerSay("getPanelId" + ": time up."); llSetObjectDesc(originalObjectDesc); return -1; } init() { //llResetScript(); //reset the historic low memory mark. //DO NOT DO IT cause script DONT RUN!! //llOwnerSay("---init " + llGetObjectName() + " with " + llGetScriptName() + "---"); llSetTexture("5748decc-f629-461c-9a36-a35a221fe21f", ALL_SIDES); //Blank Texture llOffsetTexture(1.0, 1.0, ALL_SIDES); llRotateTexture(0.0, ALL_SIDES); llScaleTexture(1.0, 1.0, ALL_SIDES); // PANEL_ID = getPanelId(); //llOwnerSay("---id = " + (string)PANEL_ID + ", " + llGetObjectName() + " with " + llGetScriptName() + "---"); //if(llGetListLength(unicodeTextureList) xmax || x < 0) { x = 0; } pos.x = (1.0 / xmax) * ((xmax / 2) - x - 0.5); pos.x *= (-1); // y = code / xmax; //xmax is. NOT ymax. if(y > ymax || y < 0) { y = 0; } pos.y = (1.0 / ymax) * ((ymax / 2) - y - 0.5); // return pos; } integer inPrimPos2face(integer inPrimPos) { //for prism prim if(inPrimPos == INPRIM_LEFT_LEFT ){ return 3; } //left-left if(inPrimPos == INPRIM_LEFT_CENTER ){ return 7; } //left-center if(inPrimPos == INPRIM_CENTER ){ return 4; } //center if(inPrimPos == INPRIM_RIGHT_CENTER){ return 6; } //right-center if(inPrimPos == INPRIM_RIGHT_RIGHT ){ return 1; } //right-right return -1; } float inPrimPos2angle(integer inPrimPos) { //for prism prim return 0.0; } // prism-center face is shrinked and shifted. vector inPrimPos2prismOffset(integer inPrimPos) { if(inPrimPos == INPRIM_LEFT_LEFT ){ return ; } //left-left// ; } //left-left if(inPrimPos == INPRIM_LEFT_CENTER ){ return ; } //left-center if(inPrimPos == INPRIM_CENTER ){ return ; } //center if(inPrimPos == INPRIM_RIGHT_CENTER){ return ; } //right-center if(inPrimPos == INPRIM_RIGHT_RIGHT ){ return ; } //right-right// ; } //right-right return ZERO_VECTOR; } // prism-center face is shrinked and shifted. vector inPrimPos2prismScale(integer inPrimPos) { if(inPrimPos == INPRIM_LEFT_LEFT ){ return ; } //left-left if(inPrimPos == INPRIM_LEFT_CENTER ){ return ; } //left-center if(inPrimPos == INPRIM_CENTER ){ return ; } //center if(inPrimPos == INPRIM_RIGHT_CENTER){ return ; } //right-center if(inPrimPos == INPRIM_RIGHT_RIGHT ){ return ; } //right-right return ZERO_VECTOR; } vector normalizeTextureOffset(vector offset) { //llOwnerSay("normalize input= " + (string)offset); while(offset.x > 1.0){ offset.x = (2.0 - offset.x) * (-1);} while(offset.x < -1.0){ offset.x = (1.0 + offset.x);} while(offset.y > 1.0){ offset.y = (2.0 - offset.y) * (-1);} while(offset.y < -1.0){ offset.x = (1.0 + offset.y);} //llOwnerSay("normalize output=" + (string)offset); return offset; } vector setCharactor(integer utf16Code, integer inPrimPos) { key textureUuid; //range check. if(utf16Code < 0) { llSay(DEBUG_CHANNEL, (string)utf16Code + "is code range error"); return ; } if(PRIM_PER_CHARACTOR < inPrimPos) { llSay(DEBUG_CHANNEL, (string)inPrimPos + "is prim range error.(only " + (string)PRIM_PER_CHARACTOR + "charactor can set."); return ; } // //get texture infomation. // integer faceNum = inPrimPos2face(inPrimPos); //hide texture while change. if(isDebugMode == FALSE) { llSetAlpha(0.0, faceNum); } //get texture uuid. textureUuid = getTextureUuid(utf16Code); llSetTexture(textureUuid, faceNum); //return IF cannot mapping. if(textureUuid == BLANK_TEXTURE) { //llSetAlpha(0.0, faceNum); //still transparent. return FAIL_MAPPING_VECTOR; } // //set texture to face. // //shift texture. vector pos = utf16Code2pos(utf16Code); pos = pos + inPrimPos2prismOffset(inPrimPos); pos = normalizeTextureOffset(pos); llOffsetTexture(pos.x, pos.y, faceNum); //llOwnerSay("setCaractor " + (string)pos); //rotete texture float angle = inPrimPos2angle(inPrimPos); llRotateTexture(angle, faceNum); //streatch texture. vector scale = ; vector prismScale = inPrimPos2prismScale(inPrimPos); scale.x = scale.x * prismScale.x; scale.y = scale.y * prismScale.y; llScaleTexture(scale.x, scale.y, faceNum); // kakudai if(isDebugMode == FALSE) { llSetAlpha(1.0, faceNum); } //for debug. //llOwnerSay("offset=" + (string)pos + ", scale=" + (string)scale + ", prismOffset=" + (string)inPrimPos2prismOffset(inPrimPos)); return pos; } default { state_entry() { init(); } on_rez(integer start_param) { init(); } link_message(integer sender_num, integer charactorUtf16Code, string charactorPosStr, key id) { integer charactorPos; charactorPos = (integer)charactorPosStr; if((PANEL_ID * PRIM_PER_CHARACTOR

Viewing all articles
Browse latest Browse all 20

Trending Articles