Sunday, October 10, 2010

How to create animated sculpties for OpenSim in Blender part 2

In part 1 we have created the sculpty maps for an animated sculpty with Blender/Primstar. Now we will rez the animated sculpty in OpenSim.

I assume you have a running OpenSim server and know how to use a viewer like Imprudence or Hippo.

Prepare the Primstar box for rezzing the sculpty

     1. Build a box and name it "Primstar". Make sure the first letter P is capitalized.
     2. Take this box into your inventory.
     3. Build another box, we will call Box-X.
     4. Edit the Box-X and in the contents, drop the Primstar box into it.
     5. Upload all your sculpt maps from the previous tutorial.
     6. Drop the sculpt maps in Box-X contents.
     7. Create a new script inside Box-X.
     8. Open the lsl script exported by Primstar in an editor outside your OpenSim viewer e.g. gedit or notepad.
     9. Select all and copy.
   10. Paste the contents in the new script in Box-X in OpenSim and save.
   11. Close the OpenSimn editor.
   12. Box-X will ask for the permission to link objects. Answer “yes”.
   13. Click Box-X to generate your sculpty.

For additional information on creating multi-sculpties in Primstar please check out this tutorial:

Edit the sculpty. Delete extra appendages.

   14. You can now take Box-X to your inventory as we will no longer need it.
   15. In the horse example in this tutorial there will be a lot of legs. One sculpty prim for each leg.
   16. Unlink all the extra legs and delete. We only need the original. If you want you could've taken care of this during the baking of the sculpty in Blender/Primstar. Select only the original mesh and bake a new SL lsl file. Do not overwrite your animated sculpty lsl directory! You can use this second lsl file to generate the sculpty so you don't have to erase legs.
   17. Drop all of the leg sculpt maps in the horse.
   18. Create a new script in the contents of the horse.
   19. Copy and paste this trot lsl script I've written.

//Trot sculpty animation script. 
//Copyright (C) 2010 Roel Cantada.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see .

string flegLrest="flegL"; //legs at rest or standing position
string flegRrest="flegR";
string hlegRrest="hlegR";
string hlegLrest="hlegL";

string flegLmap;
string flegRmap;
string hlegRmap;
string hlegLmap;

//make sure number of sculptmaps for all list are the same! Put all maps in the prim with the script.
list flegLsculpts=["flegL2", "fleg4", "flegL6", "flegL8"]; //left front leg frames
list flegRsculpts=["flegR2", "flegR4", "flegR6", "flegR8"]; //right front leg frames
list hlegRsculpts=["hlegL2", "hlegL4", "hlegL6", "hlegL8"]; //right hind leg  frames
list hlegLsculpts=["hlegR2", "hlegR4", "hlegR6", "hlegR8"]; //left hind leg  frames

integer count;
float speed=0.2; //speed of frame change in seconds
integer framelen = 4; //number of sculpt maps per leg


//make sure the link number of the child prim is correct, 1 is the root prim and the rest are child prims.
//the last prim to be linked will be 2.
          llSetLinkPrimitiveParams(8,[PRIM_TYPE, PRIM_TYPE_SCULPT, flegLrest, PRIM_SCULPT_TYPE_CYLINDER]);
          llSetLinkPrimitiveParams(7,[PRIM_TYPE, PRIM_TYPE_SCULPT, flegRrest, PRIM_SCULPT_TYPE_CYLINDER]);
          llSetLinkPrimitiveParams(6,[PRIM_TYPE, PRIM_TYPE_SCULPT, hlegRrest, PRIM_SCULPT_TYPE_CYLINDER]);
          llSetLinkPrimitiveParams(5,[PRIM_TYPE, PRIM_TYPE_SCULPT, hlegLrest, PRIM_SCULPT_TYPE_CYLINDER]);

     touch_start(integer num)
          state walk; //switch to walk state
state walk
         llSetTimerEvent(speed);  //start trot
     touch_start( integer num )        //stop trot
         state default;

         if (count == framelen) 
         flegLmap=llList2String(flegLsculpts, count);
         flegRmap=llList2String(flegRsculpts, count);
         hlegRmap=llList2String(hlegRsculpts, count);
         hlegLmap=llList2String(hlegLsculpts, count);

//make sure the link number of the child prim is correct, 1 is the root prim and the rest are child prims.
//the last prim to be linked will be 2.

          llSetLinkPrimitiveParams(8,[PRIM_TYPE, PRIM_TYPE_SCULPT, flegLmap, PRIM_SCULPT_TYPE_CYLINDER]);
          llSetLinkPrimitiveParams(7,[PRIM_TYPE, PRIM_TYPE_SCULPT, flegRmap, PRIM_SCULPT_TYPE_CYLINDER]);
          llSetLinkPrimitiveParams(6,[PRIM_TYPE, PRIM_TYPE_SCULPT, hlegRmap, PRIM_SCULPT_TYPE_CYLINDER]);
          llSetLinkPrimitiveParams(5,[PRIM_TYPE, PRIM_TYPE_SCULPT, hlegLmap, PRIM_SCULPT_TYPE_CYLINDER]);


   20. Make sure that the child prims' link numbers are in order. 1 is for root prim, 2 for the last prim to be linked etc.
   21. Click on the horse and watch it run. Click on it again to stop.

The trot script makes the horse run in place. There is still a need to probably merge this script with a drive script to make the thing run around OpenSim.

Have fun!

Downloads: (172.9 KB ) licenese under Creative Commons Attribution-ShareAlike 3.0 Philippines . Copyright (C) Roel Cantada 2010. (1.18 KB) licensed under GNU GPLv3.0. Copyright (C) Roel Cantada 2010.

No comments:

Creative Commons License
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License.