Thursday, October 14, 2010

Philippine terrain in OpenSim

I had to drop this from my project as it involve 64 sims. GIS data was used to create the terrain. I'm going to post the documentation on how I did it later.  This proves that OpenSim is not just a toy, it can be used for teaching GIS, geography and geology at a distance.



Some screenshots of the islands...

North Luzon

South Luzon

Central Visayas
Samar-Leyte

Mindanao-Zamboanga Peninsula

Mindanao-Davao

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: http://blog.machinimatrix.org/2010/04/02/sculpted-prims-part-iii/

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
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// 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


default
     {
     state_entry()
          {
          llSetTimerEvent(0);

//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
     {
     state_entry()
         {
         llSetTimerEvent(speed);  //start trot
         }
    
     touch_start( integer num )        //stop trot
         {
         state default;
         }

     timer()
         {
         if (count == framelen) 
             {
             count=0;
             }
         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]);
         ++count;
         }

     }




   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:

http://www.mediafire.com/file/iq5k1njwa5o0nby/animkabayo.iar (172.9 KB ) licenese under Creative Commons Attribution-ShareAlike 3.0 Philippines . Copyright (C) Roel Cantada 2010.

http://www.mediafire.com/file/8rrwq5u76aq1v2k/trot.lsl.zip (1.18 KB) licensed under GNU GPLv3.0. Copyright (C) Roel Cantada 2010.

Saturday, October 9, 2010

How to create animated sculpties for OpenSim in Blender part 1



Prerequisites: This tutorial assumes you know how to use Blender 2.49b with the Primstar plugin and OpenSim.


I found very little information on how to create animated sculpties in Blender in the Internet. What we need are sculpty maps for every frame of animation and an lsl script to change those maps in a loop.  In this part of this tutorial we will create the sculpty maps in Blender with the Primstar plugin.

I will not teach you how to model or rig meshes. I assume you already have a fully rigged sculpty mesh.



Create the sculpty in Blender/Primstar



     1. Select the object you wish to animate and copy (shift-d) in Blender Object mode.
     2. Move the copy to another layer
     3. Go to Blender pose mode and pose the copy
     4. Apply the armature modifier. The armature modifier is in the editing buttons group, modifier panel.



     5. Clear your transformations to reset the original. Blender pose mode Menu-Pose-Clear-Clear User Transform.



Notice that we did not use frames. The animated frames are separate object copies of the original sculptie mesh.





Warning: Do not move/transform the copy in Blender Object mode or the center will change. Change it only in Blender Pose Mode or Edit mode.

The copy will have the original UV image assigned to it. We will need to create new UV images for each copy.

     6. Select each new object
     7. Go to Blender Edit mode
     8. Select all vertices of the copy
     9. In the Blender UV/Image editor click Image-New. Create a 64x64 image and save.




Unfortunately this will be a labor intensive endevour if you use a lot of frames. It will also be prone to error. I hope someone could come up with an automatic way to do this.

Check your sculpty




Make sure the following requirements for baking multi-prim sculpties are followed:

     10. Go to Blender Object mode
     11. Select all objects
     12. Menu-Clear/Apply-Apply Scale/Rotation to ObData
     13. Check if you parented the original and copies to the root mesh. You can check this in the Blender Outliner window. There should only be the root mesh listed at the highest node of the tree.
     14. If you mirrored any of the parts then mirror the UV as well in the Blender UV/Image. Otherwise your sculpty will be inside out in OpenSim.
          a. Select the object mesh
          b. Select all vertices so that the UVs menu item will appear in the UV/Image editor
          c. Go to the UV/Image editor and select all the UV vertices. Your UV grid should be colored yellow.
          d. Click UV/Image editor-UVs-Mirror-X Axis (or Y Axis depending on how you mirrored the object mesh)

Bake the Sculpt Meshes

     1. Go to Blender Object mode
     2. Select all objects (including static parts)
     3. Blender top menu-Render-Bake Sculpt Meshes



     4. Check "Keep Center"




     5. Bake

Save the sculpty as an SL LSL file

     1. Click on Blender top menu-File-Export-Second Life LSL (to dir)

You should have an lsl file and the sculpt maps.

Note that I did not included the textures of the sculpty. For information on texturing sculpty meshes in Primstar see  http://blog.machinimatrix.org/2010/03/10/sculpted-prims-ii-blenderjass2/.

Part two will deal with rezzing the animated sculpty in OpenSim.

Downloads:

The example here uses the Alex horse rig by Wayne Dixon which is licensed under the Creative Commons Attribution 2.5 Australia
http://creativecommons.org/licenses/by/2.5/au/ and can be downloaded at http://www.blendswap.com/3D-models/animals/alex-2-5-2/.


Horse mesh by Roel Cantada copyright 2010.
Creative Commons Attribution-ShareAlike 3.0 Philippines 



http://www.mediafire.com/file/2jdvjrtwlczjtvq/animsculptkabayo.blend.zip (1.1 MB)

Tuesday, October 5, 2010

Garrote prim object

The garrote is a humane execution machine, at least in the same sense as a guillotine.  Humane here is measured in terms of speed of death rather than justice. Contrary to popular belief it is not meant to slowly strangle the victim but to sever the spinal cord with a spike or metal blade attached to the screw. Unfortunately if the executioner do not know how to operate it, it may take a few more tries.


 This is a good example of using Virtual Worlds for NPIRL historical situations. One application is to "garrote" your students when they fail your tests ;-).


In the downloads below I used a basic sit script by Mo Hax posted here http://www.osgrid.org/forums/viewtopic.php?f=5&t=91&start=0. You can replace that with your own sit script.



Downloads

http://www.mediafire.com/file/cobpah7vdlrn8b1/garrote.iar (202.18 KB )

http://www.mediafire.com/file/bn1b6sfo178bz6j/garrote_xml.zip (198.5 KB )

Copyright Roel Cantada 2010

Monday, October 4, 2010

Puente de España en Manila

Prim object of the Puente de España in Manila. It was built in 1875 to replace the Puente Grande that was damaged by the 1863 earthquake. Currently the Jones Bridge stands in its place.








My Indio Look

Downloads



Copyright Roel Cantada 2010

Saturday, October 2, 2010

Prim train station

This is supposed to be modelled after the Tutuban Station in Tondo Manila, but I did not have any photo reference of the interior or the back. So only the facade is represented. The rest is imaginary. The arches of the second floor is also more curved here due to the need to conserve prims. In terms of teaching, this would be a good starting point for research on the history of architecture in the Philippines. Oh, incidentally, the pagoda like facade appears to have been around the American era due to the addition of the roof above the windows of the second floor. There are historical photos showing the station without it.

I am unable to provide as much detail as the prim count for this station had already balooned to 500 prims. I had to abandon the decorations of the first floor, even the doors. The second floor is mostly texture. But I found out that the best way to create textures is to start with a multiprim object and then take a snapshot of that object. The snapshot is then used as the base texture and edited in the Gimp.




http://www.mediafire.com/file/dyf5o8sqq9y651j/tren_istasyon.iar (719.58 KB )

http://www.mediafire.com/file/w38dmkr6l3aqh93/tren_istasyon_xml.zip (789.54 KB )

 Copyright Roel Cantada 2010
Licensed under CC-by-SA 3.0 Philippines.
 
Creative Commons License
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License.