Samstag, 27. Februar 2010

MACS, Part 5.1 - Structuring the controlled device

As next we start with the unit under control. We must know what we want to change on it and group it's prims in accordance to this tasks. For the modell i selected a pair of pretty shoes, that i have with modify permissions in my inventory. They are pretty and simple but complex enough to let me to introduce all necessary tricks in configuring the controlled units.

Picture1, the modell: "Black&GoldShoe" 
by LittleMiss Independent

Step 1: Planing the actions

As first is to decide what is reasonable to change:
  1. the shoe size
  2. other textures instead of gold, perhaps silver and other metalls
  3. color of the diamond
  4. color of the base top side, currently black
  5. color of the base bottom and side of the heel.
     Step 2: Grouping prims

    Now take a close look at prims of the left shoe (the right one is similar)

     Picture 2: All prims of the left shoe

    The first plan: Make four prim groups: The diamond prim will be only in it's own group and have the description "diamond". The straps prims will have the description "straps", the base prims will have the description "base" and both heel prims will have the prim description "heel". Than we can change all straps by targetting a command with "straps", and all base prims will listen to commands targetted to "base".

    Will that work? Yes, but not really good. The first problem we face by handling the task number 2: Changing textures of straps, the base and a lower cylinder of heel prims at once, in one command. Why it is a problem? We have to change textures only on the straps prims, but also textures and colors on the base prims. Ok we could give all the prims two groups, for example strap prims will get the description "straps:gold" and base prims will have "base:gold". Than we could address straps only by using the target "straps" and address straps and base also with one command by using the target "gold".

    Idea saved? Not much better, there is another problem: For instande in the texturing command we have to change a prim face. And this will be the same face number for all primms of the group we target! We can change all faces if we're texturing straps but only one face if we texture the base. And even if we would address only the prims of the base, we would not get it right. The top side of the front cylinder has the face number 0, but the next prim has the face 0 on another place. We could not colorize the black side consistently without to send commands for each base prim individually!

    But this conclusion breaks hardly the idea of SDK. This idea was to send a single command and all the target prims would understand it correctly. Can we save it? Yes, by using a special technique called

    Face replacement

    This technique gives the faces of a prim a nummeric alias, similar as giving the prim a group name. If a face alias is used, the processor script translates the command into one using right LSL face. So we could send a command for the top side of base prims and each processor in those prims would translate the face alias into an actual face number that is visually at top.

    To handle it, the processor script reads it's prim description. Especially it looks for the "@" chars first. The prim description can have this forms:
    • description is empty - the prim is neither given a group name, nor face aliases
    • description has no "@" chars - the prim is given only group names, but no face aliases
    • description has one "@" char - the group names are left hand side and face aliases right hand side of the "@" char
    • description has two or more "@" chars - the group names are left hand side and face aliases right hand side of the last "@" char.
    All group names are glued by the colon. The order is irrelevant, "base:gold" means the same as "gold:base". This part we know already.

    The face aliases are always numbers, glued by colon, but the order is important: The numbers stand inplace of LSL face numbers, starting with 0. LSL uses by now only numbers 0 to 8, there is no negative face number except -1 which means all sides. This 'face' can not be aliased. Examples:

    The replacement declaration "0:1:2:3:4:5:6:7:8"  gives the alias 0 to face 0, alias 1 to face 1 and so on, it does not change anything.

    The replacement declaration "100:101:::101:101" gives the alias 100 to the face 0, the alias 101 to faces 1, 4, 5 and gives no alias to the faces 2 and 3, also no aliases to faces 6, 7, 8: The places 2 and 3 are not used, the list ends with the 5th place. Notice, we gave the sides 1, 4 and 5 the same alias 101. If a command arrives which turn the face 101 red, than the processor will turn all sides using this alias red, i.e. the face 1, 4 and 5 living each other unchanged. This way we can also refine the LSL meaning for 'all sides'.

    The right idea

    Now we can use this to group the prims correctly. The idea is simple: We use the same four groups, diamond, straps, base and heel as before, and we declare three face aliases of the base prims: The black "top" side, the "golden" side for textures and the black "bottom" side. We also continue the base golden side onto straps prims and the lower cylinder of heels, and we continue the base bottom side onto the upper part of the heel.

    For the face aliases we take the numbers, LSL does not use, the 100 for top, 101 for golden and 102 for bottom.We give the alias 101 also to each visible face of straps prims, and of the lower heel's cylinder, the alias 102 will get also the black face of the heel's torus.

    The base prims will get the group name "base", strap prims will have the group names "straps:s-base" and the heel prims will have the group names "heel:h-base". Grouped the prims this way we can address straps, base and heel separatelly by usind the targets "straps", "base" and "heel" respectivelly. But if we use the target "*-base", we address them all. This last addressing way we will use later, connected with a right face alias.

    Step 3: Right face numbers and prim descriptions

    Knowing which number has which face requires some skripting experience, but why we have to learn LSL if we can already use LSL? Look into the prim named "ressources" in the SDK package, there is a script named ">>touched face<<". It does what the name says: Placed it into a root prim of the shoe, we just have to click a prim and the script will tell what face number was touched. This is all we need to know.

    Picture 3: Again the prims we work on.
    Left to right: straps, base and heel prims

    We start with straps prms. We have to be carefull to discover all prims and all visible faces. The halfsphere around the diamond belongs also to straps. To not to touch the diamond, we could move it up a bit and move back after we have done. What numbers we get:
    • All 5 arches have this visible faces: 1, 2, 4, 5
    • The ring around the fetter: 0, 1, 2, 3
    • The halfsphere below the diamond has the face numbers: 0, 1, 2
    We will give the same alias to all visible faces of straps:
    • The arches: "straps:s-base @ :101:101::101:101" (faces 0 and 3 are not changed)
    • Ring: "straps:s-base @ 101:101:101:101"
    • The halpspere: "straps:s-base @ 101:101:101"
    We continue with base prims (we work from front towards heel)
    • The front cylinder has visible faces 0 (top), 1 (golden), 2 (bottom) It's description will be "base @ 100:101:102"
    • The small pipe: 3 (top), 2, 4 (golden sides), 1 (bottom). It's description will be than "base @ :102:101:100:101"
    • The large pipe: 1( top), 2, 4 (golden), 3 (bottom). The description: "base @ :100:101:102:101"
    • The cylinder over the heel: 0 (top), 1 (golden), 2 (bottom). The description: "base @ 100:101:102"
    Now the last part, the heel. To get to the prims is quite tricky. They are covered by invisible prims. To set the heel free, we just move the invisible prims 40cm up after we notice their Z coordinates.
    • upper torus: We see only the side 1, which will be the bottom side, this gives the description "heel:h-base @ :102"
    • lover cylinder: 0 (top), 1 (side), 2 (bottom). All sides wil be golden, so the description will be: "heel:h-base @ 101:101:101"
    The diamond has an independend group, as it wil not continue any face, so we use a group name without any face replacements: "diamond".

    Done. We move the invisible prims and the diamond back at their right position and contniue with the system installation.

    Step 4: Installing processor skript from SDK

    We have two possibilities to do so.
    1. We put the processor script "macs.processor.tasc" into each prim manually. The advantage is, the script is than already running. The disadvantage is, we could forget a prim and we will ruin the shoe shape if we start changing the scale.
    2. We put the processor script into the root prim of the shoe only and also the script ">>distributor<<" in same prim. The distributor script bravelly gives the processor script to each prim of the shoe and removes than itself. The advantage is: It wil not forget any prim. The disadvantage is, the processor scripts are not running, because the sim will not load the VM to run them (a security rstriction). We have to start them manually.
    We go the second way. To start processor scripts we must do what the distributor script said: We pick the shoe up into the inventory and rezz it again. Now we edit the shoe and if we have the editor windows open, we go to viewer's main menu, we need the "Tools" menu, the "Run  scripts in selection" submenu, picture 4.

     Picture 4: Starting the processor skripts

    A windows pops up listing all scripts it starts, that are 16 processor scripts, one in each prim. After the "close" button is active we have started the processors and after starting processors in other shoe we are ready for the last step. Note: While taking the picture, the processor script was stil called "macs.processor.acis". I changd that after givint the SDK the name TASC.

    Step 5: Installing MACS

    Now we have to install the conector scripts in each shoe, root prim only. There are two versions of MACS scripts, the professional version having both, copy and transfer permission and private version wich copy permission only. If you want use professional version, you have to remove copy or transfer permission of controller and connector scripts scripts before using them. But it is good idea to put the configuration notecard into the shoes first.

    The notecard must be named "macs.connector.config" and have this text:

    alias    shoes
    access   me
    distance whisper

    The alias of both shoes is "shoes" this is the name our control HUD will use to address the shoes. Second line says that only the owner of the shoes may control them, no other person else. And the distance parameter says that the shoes will whisper the answer messages. Since we will use the HUD, the whisper distance of 10 meters is more than enough.

    Now we add the connector script "macs.connector" into the shoes, one in each root prim. The scripts read the config notecard and after a short time they are ready.


    If later we notice the face numbers or such was given wrong, or a prim was missed to rename descrition, than after correcting mistakes we must pick the shoe up and rez again. While rezzing the processors check the prim descriptions and actualize their data. While the shoe stay inworld that does not hapen to keep the lag small.

    In the next part

    We are al ready with the shoes. Now we will build our control HUD to perform planed tasks and to see if we did all right by now.

    Keine Kommentare:

    Kommentar veröffentlichen

    Dear creators, internet connection is not a premisse

    Hello everyone reading :) This post targets all the people who design and create all the fancy things, be it in hand or on screen. Pleas...