OsSetDynamicTextureDataBlendFace
De DigiWiki.
(Différences entre les versions)
(Page créée avec « <lsl> // Example / Sample Script to show function use. // // Script Title: osSetDynamicTextureURLBlendFace.lsl // Script Author: // Threat Level: VeryLow // // Notes: T… ») |
|||
Ligne 1 : | Ligne 1 : | ||
<lsl> | <lsl> | ||
- | // Example | + | // Example of osSetDynamicTextureDataBlendFace used to put a number on each face of a prim |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | string FontName = "Arial"; | |
- | { | + | integer FontSize = 128; |
- | + | ||
- | { | + | NumberEachFace() { |
- | + | integer face = llGetNumberOfSides(); | |
+ | while (face--) { | ||
+ | string text = (string)face; | ||
+ | vector size = osGetDrawStringSize("vector", text, FontName, FontSize); | ||
+ | integer xpos = (256 - (integer)size.x) >> 1; | ||
+ | integer ypos = (256 - (integer)size.y) >> 1; | ||
+ | |||
+ | string commandList = ""; | ||
+ | commandList = osMovePen(commandList, xpos, ypos); | ||
+ | commandList = osSetFontName(commandList, FontName); | ||
+ | commandList = osSetFontSize(commandList, FontSize); | ||
+ | commandList = osDrawText(commandList, text); | ||
+ | |||
+ | osSetDynamicTextureDataBlendFace("", "vector", commandList, "width:256,height:256", | ||
+ | FALSE, 2, 0, 255, face); | ||
} | } | ||
- | + | } | |
- | + | ||
- | + | default { | |
- | + | state_entry() { | |
- | + | NumberEachFace(); | |
- | + | } | |
- | + | changed(integer change) { | |
- | + | if (change & CHANGED_SHAPE) | |
- | + | NumberEachFace(); | |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
} | } | ||
} | } | ||
</lsl> | </lsl> |
Version du 23 novembre 2012 à 14:44
// Example of osSetDynamicTextureDataBlendFace used to put a number on each face of a prim string FontName = "Arial"; integer FontSize = 128; NumberEachFace() { integer face = llGetNumberOfSides(); while (face--) { string text = (string)face; vector size = osGetDrawStringSize("vector", text, FontName, FontSize); integer xpos = (256 - (integer)size.x) >> 1; integer ypos = (256 - (integer)size.y) >> 1; string commandList = ""; commandList = osMovePen(commandList, xpos, ypos); commandList = osSetFontName(commandList, FontName); commandList = osSetFontSize(commandList, FontSize); commandList = osDrawText(commandList, text); osSetDynamicTextureDataBlendFace("", "vector", commandList, "width:256,height:256", FALSE, 2, 0, 255, face); } } default { state_entry() { NumberEachFace(); } changed(integer change) { if (change & CHANGED_SHAPE) NumberEachFace(); } }