User:Gimisa

From OpenSimulator

Revision as of 04:28, 18 February 2017 by Gimisa (Talk | contribs)

Jump to: navigation, search

I am opensim user and simulator operator sharing my notes so its usefull to others.  :


VOCABULARY: my understanding of the following terms.

   AIML: Artificial Intelligence Markup Language  is a specialised xml  with defined tag for conversational bot.
   ARC:  Avatar Rendering Cost, a relative figure that provide indication as to the load an avatar represent. 
   CHILD AVATAR: A number of mirror avatar creates in adjacent region. This is the mechanism by which the viewer is aware of the other adjacent regions. 
   CONSOLE: in opensim its the dos or linux running screen. This screen provide information and takes commands.
   GRID: One ore more simulator (SIM) supported by one or more robust.exe instance. 
   MESH: In virtual universe its an imported collada file that creates a 3 object instead of using sculpty or prims.
   LOD:  Level of detail is the mechanism by which the scene object details are reduce with increasing distance.
   MOP Media on prim: the possibility to present a web page content on the face of a prim. 
   NPC: Abbreviation for Non Player Character.  The NPC is a bot, a computer controlled skim down player that you can rez in your world.
   OAR: Archiving file for region. 
   PARCEL a subdivision of a region minimum size is 4mx4m= 16 meter square
   PRIM: is the primitive building block of opensim virtual world . They can be created with in world building  tool .
   REGION a 256mx256m = 65,536 meters square area in opensim.
   REZ; Stand for putting a new player, NPC , or  object in a region.  
   REZ DATE: the day you register a new avatar and rezing him in a region of the grid. 
   SCULPTY : sculpty is a hack that permit  importing regular UV images maps specifically encoded for 3d object creation from RGB to XYZ conversion.
   SIMULATOR: also call SIM one opensim.exe instance running supporting one ore more region(s).
   STANDALONE: The simulator and the supporting  services are all run from one instance of opensim.exe 
   VARREGION: a region with variable dimension. At time of writing limited to square values of multiples of regions (ex. 4x4 = 16 region area) .  
   VIEWER REACH: is the distance define in the viewer reach window or preference that a user will perceive object. 
   XENGINE: The opensim module responsible for of the script LSL / OSL  language use in scripting inworld with opensim.  


OAR.

I advocate the use of OAR for backup similarly to any other software file extension. I believe that creators in opensim shall be able to save their work as easily as someone using word or excel. Bring it back in aopensimulator.org.orgs easy. OpenSim already allow that through the use of OAR. In opensimulator.org JustinCC introduced OAR file extension and a mechanism to create (save) and upload (load) that file content inworld in any opensimulator . More can be read in http://opensimulator.org/wiki/OpenSim_Archives . That mechanism is available through operator console of the simulator. But not to the majority of creator whom normaly are hosted only and have no console access. I propose here a method to do that with a script inworld to save the region content in OAR automatically. That script command is high treat level as define in opensim. Therefor the intervention of the simulator owner is necessary to allow the function . The best is for operator to create an object and put the following script. The operator should enable the osConsoleCommand command for him in XENGINE script access control section of ini file. See here for detail http://opensimulator.org/wiki/OSSL_Enabling_Functions. Using his UUID the simulator operator can enforce the treat level for osConsoleCommand and rez the object for his guess to use while limiting its use to the script function.
What I propose is a script to automatically save an oar when the prim count change by more then 10 .OAR saving can also be initiated by touch :
   //gimisa@yahoo.fr 130502
   //oar saver rez on region you are owner 
   //see read.me for instruction
   //130502 add interaction with hud
   //gimisa@yahoo.fr 130120
   
   integer setup=FALSE;//Chnage to false to complete setup
   string dir="/home/gimisa/Bureau/oar/gimisa/";//the location where to sa ve the oar so your user can access it.
   //_________________________________
   key id = "598c76d4-a9d0-2fd6-0a81-fc72dca068b5";//default key 
   string idName="gimisa";
   key dtc;//detected avatar
   string region;//region name
   string cmd;//command
   integer ok;//status
   integer pcount;//number of prim cunt
   integer ppcount;//previous prim count
   integer flag=FALSE;//save oar flag
   
   //_________________________________
   integer dbug=FALSE;
   
   saveOAR(){
         region=llGetRegionName();
         ok=osConsoleCommand("change region "+ region);
         string tme=llGetTimestamp();
         llSay(0,"Region: "+ region);
         llInstantMessage(id,"saving oar " +dir+region + "."+tme + ".tgz" );  
         llSay(0, "please wait a few minutes to complete");  
         if(!setup) ok=osConsoleCommand("save oar " +dir+region + "."+ tme + ".tgz"); 
         osMakeNotecard(dir+region + "."+ tme + ".tgz","");//storgage is done by notecard name
         llSetObjectDesc((string)pcount);//count is store in object description  
   }
   
   sayPrimCount(){   
       llSay(PUBLIC_CHANNEL,
           "There are " + primCountThisParcel(PARCEL_COUNT_TOTAL) + " total prims on this parcel."); 
       llSay(PUBLIC_CHANNEL,
           primCountThisParcel(PARCEL_COUNT_OWNER) + " prims are owned by the parcel owner.");
       llSay(PUBLIC_CHANNEL,
           primCountThisParcel(PARCEL_COUNT_GROUP) + " prims set to or owned by the parcel's group.");
       llSay(PUBLIC_CHANNEL,
           primCountThisParcel(PARCEL_COUNT_OTHER) + " prims that are not set to the parcel group or owned by the parcel owner."); 
       llSay(PUBLIC_CHANNEL,
           primCountThisParcel(PARCEL_COUNT_SELECTED) + " prims are selected."); 
       llSay(PUBLIC_CHANNEL,
           primCountThisParcel(PARCEL_COUNT_TEMP) + " prims are temp-on-rez.");
       }
   string primCountThisParcel(integer flag)
   {
       vector currentPosition = llGetPos();
       pcount=llGetParcelPrimCount(currentPosition, PARCEL_COUNT_TOTAL, FALSE); 
       return
       (string)llGetParcelPrimCount(currentPosition, flag, FALSE);
   }
   
   default
   { state_entry(){
       id=llGetLandOwnerAt(llGetPos());
       idName=llKey2Name(id);
       llSetTouchText(idName);
       llSetSitText("-");
       llSetTimerEvent(1.);
    }
   
    
   touch_start(integer num_detected)
   {  dtc=llDetectedKey(0);
      if ( !(dtc==id | dtc ==llGetOwner())) {
      llSay(0, "sorry but only "+ idName + " can use this");
      return;} 
            
   sayPrimCount();//say in open chat prim counts of the sim 
   saveOAR();//save oar
   state wait;
  }
  timer(){
     llSetTimerEvent(1800.);
     ppcount=(integer) llGetObjectDesc();
     primCountThisParcel(PARCEL_COUNT_TOTAL); 
     if(pcount==0) return;
     if(ppcount==0){ ppcount=pcount;llSetObjectDesc((string)pcount); }
     if((pcount-ppcount>10 | pcount-ppcount<-10) && !flag){flag=TRUE; llSetTimerEvent(60.*15.);return;}
     flag=FALSE;
     llSetTimerEvent(3600.);
     if(!(pcount-ppcount>10 | pcount-ppcount<-10) )return;
     sayPrimCount();//say in open chat prim counts of the sim 
     saveOAR();//save oar  
     }
   }
   
   state wait {
        state_entry(){ llSetTimerEvent(5.0*60.);}
   
   timer(){ llSay(0,"will appear on FTP when complete");
        llSetTimerEvent(0.);
        llLoadURL(dtc, "OAR FTP SITE", "ftp://where.to.access.the.oar.file"); 
        llResetScript();}
   }


You can find a free copy along with a tutorial about oars and the object oarsaver in the little grid I operate for testing purpose call gimisaOS. You can reach it via Hypergrid using your viewer map with search for 3d.gimisa.ca:9000

MOP.

Media on prim can be very interesting. The way to add a media on the face of a prim is straightforward selecting a prim face in the build tool and then activating the media of choice in the texture tab media selector ( varies with viewer). Se tutorial in gimisa5 tutorial area for more detail and picture. You should display a picture of some kind ( you can use the same prim by texturing it) as default texture to illustrate to your visitor that you are using media on prim. Most viewer disable the auto play of media prim forcing user to seek them for display. The advantage of Media on prim is that it has no impact server side since the viewer is handling the request via its internal browser. Please note that the view is asynchronous. Specially if video it meaning that what you see is not what other will see or hear on the same prim face. Just like if you are visiting the page by yourself on the web. The web browser in viewer is Mozilla compatible with QTWebKit. Therefor it has NONE of the HTML5 capabilities.
I am using MOP to overcome the sound limit in OpenSim. A sound file play in world is limited to 10 sec per file. One Technic use to overcome that limit is to cut a longer sound file in 10 sec sections and to piggy back the set with a proper script . That has a detrimental effect on your region cause of the bandwidth required to send the sound file in this way. The advantage is that the sound is heard by all avatar in the vicinity.
The way I use to do that is via MOP. The sound file can be built from any mixer software you like and can have any length. The trick is to convert it to swf (flash) so it can be compatible with any operating system (mac, window, linux ) . There is a number of online converter that will be fine for the job. The file need to be accessible to the web. That is a serious limitation to causal users unfortunately comment on the later as to how to do that direcly in opensim would be nice. Then you need a wrapper in the form of a standard web page with the following embed tag. <embed src="http://locationOfYourSoundFile/Here.swf" width="100%" height="100%" type="application/x-shockwave-flash" loop="false" autostart="true" > Sorry your viewer does not support flash (swf) </embed>
As a useful alternate in case your user viewer does not support swf is to provide a hyperlink giver on touch of the prim pointing to the same web page. In this way a HTML5 code wrapper can be use in your web page as follow:
<audio controls autoplay> <source. src="myOriginalFile.mp3" type="audio/mpeg"> <embed src="http://locationOfYourSoundFile/Here.swf" width="100%" height="100%" type="application/x-shockwave-flash" loop="false" autostart="true" > Sorry your viewer does not support flash (swf) </embed> </audio>
You can get a demo of the effect of this trick by hypergrid visiting 3d.gimisa.ca:9000 and search for gimisa4 region in map.



ARC.

ARC, Avatar Rendering Cost is an information the user should be sensitive too for a pleasant grid or hypergrid travel


The load an avatar represent in being rendered is an interesting figure to be considered by user. For local or hypergrid traveling the impact of the integration of avatar in the region scene is more or less loosely represented by that figure. This relative amount can be use comparatively as a guide for the amount represented by the avatar in rendering effort. In general the travelers should pack the avatar with as little as is needed to make a personality to minimise the load the region they are visiting. This is as much to have a pleasant experience for themselves as to help the experience of other by the same principles . They can put in their suitcase the travel avatar and the regular flashy model for convenience so they could switch while they traveling if they are in need to go to something more .
A good tool to judge the weight of one avatar is to use the avatar rendering cost display available in viewers. When activated with shortcut key ctl-alt-sht-C you are displayed a number over your head as well as avatar surrounding you . When green the avatar is good to travel. Yellow is limited while RED is no no. Its an interesting experience to make to remove part of an your avatar outfit and see the impact on that display. Good outfit part does show not only by the look they provide but also by the weight they represent for that results.
People should think about how much a traveling avatar has to transfer to the other grid (HG travel) server and how much information the region server has to handle to render the result they and other in the vicinity sees. This is all their texture, mesh and prim to be added to their scripts compiled. The few second required to render see a lot of activity both in the robust server and the region servers. This time is spent to acquiring that information (prim scultp mesh shapes , textures, compiled scripts) . The result is use to create the rendering information for the avatar and its numerous child avatars in the region and adjacent regions for the new arrival (max of 9).
More about avatar rendering cost calculation and detail can be read on "http://wiki.secondlife.com/wiki/Avatar_Rendering_Cost"



CHAT_BOT.

I use a number of way to interact with visitor. Making the visit more interactive can be a challenge to try to make the visit more interesting. Scripting provides the tool to do that and touch is the perfect function to trigger interactivity while not causing annoyance. Its also low on lag so this is my interactive function of choice. AIML is the language to give brain to your chat bot. Its interest is in the apparent two way communication it provide much like natural languages. There is script to do that inworld in lslWiki but scripting memory is too limited to do a good job so external service is required. I have tried that and will come back to it later.
What I found more intuitive and accessible using the dialogue blue box tool also offered with scripting . It is possible to construct with it a rather easy two way communication in the form of multiple choice discussion. That way is less interactive then a true conversational discussion but can be as attractive as a story book where you are the Hero. Using OSL notecard feature one can rig a notecard to provide for extensive exchange with the visitor. The line length of the OSL card is 1024 bytes ample for supporting multiple choices and trends in the discussion. The visitor reads the story line and make one choice out for the continuation. I use three choices the story direction can take but that is an arbitrary limit. And while at it why stopping to chat lines. The same tool can be use to hand out interactively LandMark, Object texture notecard and the like by refering to them in the story notecard. Add to it sound wave files of story and choice recording and you have a voice reader to accompany you visitor. Put that in a NPC (more about that in AIML) and you have the perfect guide to your exhibit. And top it with choice of language and you have a rather interesting interactive feature pack. A demo and code of that way of using interaction in opensim is available in gimisaOS my little test grid.
gimisaOS landing welcome have two demo Brat at the gimisaOS welcome sign and Joe at the OAR loader both you cant miss them. Joe has also voice in addition to the dialogue blue box both french / english .


I have considered AIML as stated above. There is an old script in lslwiki about AIML decoding done inworld. This methode is presented in ALICE chat bot web site http://www.alicebot.org/about.html. It was also integrated in Radegast text viewer . To my knowledge it never took ground in opensim/SL . I guess its cause the feasability is not there to search notecard bank having a few 100M typical for a bot to be somehow smart . You will find in opensim a well know bar tender bot using pandora bot.( http://www.pandorabots.com/) That bot can be easly configured to use an account you would create in pandora. But unfortunately the terms of service of pandora prevent you from doing so in the following terms:
5.3 You agree not to access (or attempt to access) any of the Services by any means other than through the interface that is provided by Pandorabots, unless you have been specifically allowed to do so in a separate agreement with Pandorabots. You specifically agree not to access (or attempt to access) any of the Services through any automated means (including use of scripts or web crawlers) and shall ensure that you comply with the instructions set out in any robots.txt file present on the Services.


What I did therefor is implement an external server. Unfortunately that make it not an application that can be easly implement by causual user compare to the pandora bot solution. The server use pyAiml a python aiml interpreter that is interrogated by the inworld bot to reply to visitor. I have added to it a personalisation notecard that overide the request to the external server for specific such as gimisaOS grid. Asking about the grid bypass the external request and get the reply from the notecard. You will find walking NPC all around the few region of my test grid . For instance, the dancer in welcome first floor , the lady around pise tower in gimisa5 the firewoman , the paramedic and the two astronaut in gimisa8 nasa exibit.
I dont know if explaining how the server is implemented is something of interest to opensim user platform but certainly an email asking for that information is something I would be glad to reply to.
You can reach the demos via Hypergrid using your viewer map with search for 3d.gimisa.ca:9000 .

SCALING.

Scale a mesh can be rather spectacular at time. Any attempt will litteraly explode out the object and fill you screen with a mess.
Any builders know how to scale a prim. You select the build scale tool grap the guides and expend or contract the prim as you like. An other way is to change the x,y,z size of the object in the prim size data block just bellow position. In opensim the prim upper size limit is set in opensim.ini configuration file. The default size is 256m. But its possible to rez object that are already sized bigger then that. Naturaly scaling them after rezzing will cause the limit to be applied. Similarly scaling down is also limited. The opensim built in limit is 0.01m. That means that any attempt to change a prim x,y,z size to lower then 0.01 will fail and the scale change will not be applied . When you try to scale that low with the guides the scaling down stop and block at that point.
Now if the prim is part of a link set the discussion above also applies and that link will limit the scaling of the whole object when one of it child prims reach either the upper or lower limit imposed. To change the upper limit is rather simple if you have access to your opensim.ini. I have successfully use 512m and 1024m as upper prim size limits. But there is no way to change the lower size limit pass 0.01. There is trick to "see" smaller prim size by using partial transparencies. But when it comes to scaling an object down any prim that one of its dimension falls below 0.01 will block that scaling downward for the whole object so proportionality is maintained.
A mesh is imported as an object of a certain size.The imported size might be far different then its creation size in the 3d software. Regardless the above discussion applies. As long as there is no attempt to scale the mesh object simulator limits applicable are NOT imposed. A simple inspection of a linked set mesh will show that some of its links might contain element that are over the upper limit and or under the 0.01 lower limit. When trying to scale the object system limits will be enforced and if the mesh contain mesh link having smaller dimensions then 0.01 the size of the object will IMMEDIATLY be resized to fit the limit. I have seen case where the a mesh link original size is 0.001 for one of its dimension x,y, or z. This kind of situation will be leading to litteraly explode out the object with 10x scaling. and fill you screen with a mess.
The solution is easy. Inspect each element for size and correct any value lower then 0.01 up to at least that. Well that is nice for a mesh object with one to few links but what if we talking about few hundreds ( yes opensim can accept a lot of links no limit unless enforce in opensim.ini) . So the justification for a tool I did . The tool is a prim that you add to you link set. Then clic /touch. It will inspect each element of the linkset for size and correct any value lower then 0.01 up to at least that. The tool will confirm complete. You can then scale down. Unlink that tool and done .
You can get this tool via Hypergrid using your viewer map with search for 3d.gimisa.ca:9000 .

XENGINE.

A strange situation happen to me on one region of my test grid. All scripts stop responding for two days. You can stop a script or a whole simulator script set from running by issuing a >> scripts stop command in sim console. This will stop all script and give you a list in console . A very useful debugging feature to know if you have offending script to pin point (more on that in following article) . You can also disable scripts in the debug tab of the estate manager window . These are perfectly normal way to have script not responding in region. That will be indicated by the missing run mark in the check box on the lower corner of the script edition window of any script in the simulator.
But that was not my problem , and I had no idea why it was acting like this . Yes I have added a few scripts more in the late days before that happen. But nothing that could explain a complete failure of xengine in my humble opinion. There was no log entry either to point me in the right direction. So here is what I tried.
1) in console script stop / script start
2) in estate window make sure script is enable
3) restart region from console
4) save oar of region and reload
5) search the net and mantis for xengine trouble

In all these case the script would run for a bit then would stop responding without warning nor indication at script level of not running state. Putty amazing is it.
In the trouble region the script will save normally with save script message appearing in both script window and blue warning. Running tag is normal on script window but no response from script and that is for any script in the region.
The main trouble to me is not a failure but mainly the lack of indication of what is happening in failure mode, at least with something in log or in console window.
I had backups I could roll back but the idea of experimenting is to take the opportunity of a failure to improve and learn so her was my solution for your benefit:

The solution is somewhere in http://opensimulator.org/wiki/XEngine

6)  ; How many threads to start at maximum load
MaxThreads = 100
XEngine will not start more than this many scripts, even if that means blocking script execution


I had 15 for maxThreads value which seem to be the default of opensim install.
Changing it to 100 prove to be a bit on the high side as I had region crash on low memory.
Trying 50 these days and it seem to hold ok.

A few facts should you be interested in details:

A)3d.gimisa.ca:9000 is the a 10 regions grid running under robust stable 0.8.1.
B)Robust and simulators are all served from same machine ubuntu 14.04.
C)Simulator are running from same set of files using alternate config ini.
D)Except for gimisa5 the trouble region , anything else is running normaly.
E)gimisa5 is the only region on its simulator.



SCRIPT PROBLEM.

Debuging and mainly finding offending scripts might be hard on users. An impossible task if one dont have console access. Window / Linux provides monitoring means of reporting CPU and/or memory usage. The TASK MANAGER for window and TOP for linux are well know ones among them.

So using such a tool , I notice on one of my simulator a high CPU rate while no one was on any region. Thinking it was a script running wild I used the inworld estate manager debug window to see if it could point me to the problem. It did had a script listing and I try it to disable the few mentionned. But it did not cure my problem. Still using estate manager I disable all the scripts. That had the expected effect of dropping CPU confirming script was the cause of the situation. But which one. I was left clueless. How could I possibly find and investigate the 1600+ scripts of my simulator . Searching google left me with a lot of links but no answers.

What I found useful in that case is to use the console script stop command. Yes it stop all script just like the estate manager disable. But more over it provides a listing of all script in the region. Its easy to copy that list and paste it in a spreadsheet. Then, and that is where it become interesting, its an other easy step to modify that spreasheet to add the script start console command prefix to each individual script entries and to save that file. Next, using the command-script console command, pointing to that file just created, run that file and restart ALL script . But more over one can fine tune, individually via prefix to each line of the speadsheet , which script to start, and stop.

Armed with that tool and using a well know iterative technic by trial an error, each time narrowing the number of scripts. I found the single script among the 1600 that had my CPU jump by 60% and correct it.


AGE - STAT

We are all getting older , really and virtual. Virtually you have a rez date , that is a date you created you avatar in a grid. That rez date for that grid derive your age measured in days and show up in your profile. The other day , in my little test grid , I had a new born HG visitor. This attracted my attention cause it peculiarly young to be hg jumping when first register into a grid. If you new to opensim even if former SL resident , HG jump is not something that come natural. Your first days in a new grid will usually be devoted to getting around and installed in your new world . So it intrigued me as to what is the age distribution of my visitors. I have a 30 days rolling graphic presentation of the number of visitor per day and daily tally time done with osl draw functions that you can check and grab in gimisa5 hypergrid dome . So I though why not add a plot of age distribution on it.

On grid that have profile activated in opensim.ini / robust.ini (see this for more detail http://opensimulator.org/wiki/UserProfiles) right clic on the avatar and asking for profile will give you avatar name including ,home grid url with port and born date and age in days and general profil data via profil tabs. To gather statistics you need to have access to those figures in scripts. For local user a script can access the born date via llRequestAgentData(key, DATA_BORN) ref: http://wiki.secondlife.com/wiki/LlRequestAgentData .

The problem is that no command exist that will provide you with that data for HG visitor. All the scripts can provide about HG visitors is the name with llDetectedName() script or llKey2Name or oslGetAgent(). It is possible from the name information to get the url of the avatar home location. With a bit more gymnastic using a xml_rpc request to the home server of the visitor you will finaly get the born date of the visitor coded as unix time stamp. That time can be translated using LlGetUnixTime into age in days. TADA!!! A demo of that solution is available in gimisa3 welcome.Just touch the age cube.


PERFORMANCE

I know you probably know this . As you witness with experimented hoster for opensim they usually restart their region at frequent intervals. But how much important this practice is . Using linux top command I was able to obtain the following data after 24 days of opensim uninterupted operation of my little grid. top - 08:04:34 up 24 days, 2:54, 1 user, load average: 6.48, 5.68, 5.27

What does this mean. Well load average three numbers are for 1min 5min and 15min average of the load on the machine, The number themselves means the number of CPU cycle necessary to process the items in queue. So is 6.48 CPU cycles bad. No if you have 12 CPU to handle the task they will team up to take only 1 clock tick. But this is very bad if you only have 2 CPUs teaming as in my case . It translate into sluggish server response on teleporting to region and rezzing object. Script processing is also painfull.

Now what is happening after restarting the 4 simulator running on my computer. top - 12:00:04 up 24 days, 6:49, 1 user, load average: 1.36, 1.49, 1.66. Yes this is the same load, gimisaOS grid. Same 4 simulator with same content now takes up 1.66 15min average load a very acceptable value on a 2 CPU chips.

To restart you region you can use the estate manager window and on the debug tab you can hit the restart button. This function is accessible to any estate manager. For server system operator the console command region restart bluebox restart 15sec 15 will do a restart in the next 15 second. But these method will require your attention everytime you want to restart you region.

For an automated method one can use the above feature with a OSL script. One can enable OsRegionRestart opensim scripting function and put an appropriate timer on it to restart the region at interval (ref: http://opensimulator.org/wiki/OsRegionRestart) . An example of such a script is available in gimisa5 store.Just drop this box in any region you have estate management rights and it will restart at interval set by timer.

For an other automated method one can use remote console command. This feature has to be enable in the opensim.ini . [RemoteAdmin] enabled = true port = 221 (select a port that in NOT open to external) access_password = "passwd" enabled_methods = all . I do this setup for my 5 simulators, from port 221 to port 225. Next you need a program to run the required command. I am using python as follows :
#!/usr/bin/python 
# Author : gimisa

import xmlrpclib 
import sys
#this is the UUID list of the region to restart

g1='c794b362-fb61-4bff-90b2-5fc273df7df8'
g2='30bb9b86-bae5-425b-8c55-02d788858953'
g3='772c0b5e-bf67-4ace-8b34-735f102f1aff'
g4='9b5c28de-5a07-4cd6-b3a6-c353d988b929'
g5='1285196d-4288-4ebc-a312-cbff001a6165'
g6='9d2d5dbe-2714-4df5-bfde-b2ad81505e06'
g7='1285196d-4288-4ebc-a312-cbff001a6167'
g8='1285196d-4288-4ebc-a312-cbff001a6168'
g9='d87ad5db-08eb-4c91-8004-3a057574aaa9'
gr='d87ad5db-08eb-4c91-8004-3a057574aaaa'


# XML-RPC URL (http_listener_port) 
simulatorUrl = "http://127.0.0.1:"+str(sys.argv[1])
# instantiate server object 
simulator = xmlrpclib.Server(simulatorUrl) 
#I am using port 221 to 225 for the 5 simulator
#for simulator 221 there is 4 regions for the others one simulator one region
if str(sys.argv[1])== "221" :
	simulator.admin_restart({'password': 'pass1', 'region_id': g1})
	simulator.admin_restart({'password': 'pass1', 'region_id': g7})
	simulator.admin_restart({'password': 'pass1', 'region_id': g8})
	simulator.admin_restart({'password': 'pass1', 'region_id': gr})
elif str(sys.argv[1])== "222" :
	print simulator.admin_restart({'password': 'pass2', 'region_id': g2})
elif str(sys.argv[1])== "223" :
	print simulator.admin_restart({'password': 'pass3', 'region_id': g3})
elif str(sys.argv[1])== "224" :
	print simulator.admin_restart({'password': 'pass4', 'region_id': g4})
elif str(sys.argv[1])== "225" :
	print simulator.admin_restart({'password': 'pass5', 'region_id': g5})



Next is to schedule that task. In my linux case this is through cron. Here is the cron file I am using to start this task every weekday as follows. 1 is monday ....5 is friday .

1 1 * * 1 /home/gimisa/Bureau/python/remoteResart.py 221
2 1 * * 2 /home/gimisa/Bureau/python/remoteResart.py 222
3 1 * * 3 /home/gimisa/Bureau/python/remoteResart.py 223
4 1 * * 4 /home/gimisa/Bureau/python/remoteResart.py 224
5 1 * * 5 /home/gimisa/Bureau/python/remoteResart.py 225



After about a year of using the method above I notice that some script were hangning and a general detarioration in the simulator behavior happen even if the CPU usage was apparently good. It seem the remote restart available through the remote admin simulator command ( http://opensimulator.org/wiki/RemoteAdmin:admin_restart ) or through the estate manager window is not perferming a deep enought restart in comparaison to a cold quit command.
So as presented in the following link http://opensimulator.org/wiki/Automating_Tasks and since I am using ubuntu screen , its possible to send a direct command to the simulator via a screen -xS screenName -X stuff "alarm restart in 1 minute " to alarm, quit , and restart the simulator. So I replace the simulator.admin_restart from the python routine above with a screen command and replace that bash routine in my crontab job list.

The code is :

    #!/bin/bash
    screen -xS $1 -X stuff "alert region restart in 2 minutes
    "
    sleep 1m
    screen -xS $1 -X stuff "alert region restart in 1 minute
    "
    sleep 30 
    screen -xS $1  -X stuff "alert region restart in 30 secondes
    "
    sleep 20
    screen -xS $1  -X stuff "alert region restart in 10 seconds
    "
    sleep 5 
    screen -xS $1  -X stuff "alert region stopping will restart in 5 minutes 
    "
    sleep 5
    screen -xS $1 -X stuff "quit 
    "
    sleep 600
    
    screen -X -S $1 quit
    
    sleep 5
    
    
    case $1 in 
       "go" )
       sh /home/gimisa/goar.sh
       ;;
       "g3" )
       sh /home/gimisa/g3.sh
       ;;
       "gi" )
       sh /home/gimisa/gi.sh
       ;;
       "g4" )
       sh /home/gimisa/g4.sh
       ;;	
       "g5" )
       sh /home/gimisa/g5.sh
       ;;	
       
       esac




MESH

I have made a whole series of tutorial in gimisa5 about mesh , mesh and material , mainly blender importing up to rigged avatar creation see paragraph bottom of article for new addition. I also work out a comparaison between prim, sculpty and mesh as building block for your project. The limitations of each medium is spell out for each of those tool and illustrated in the different tutorials . But I lately came across this article from http://blog.nalates.net/2015/10/01/second-lifes-limits/#more-15460 where they indicate that not only there is a upper limit on material of 8 and total of triangle count per object of 174,752 for you mesh, which was already documented . But they mention there is also a limit per material of 175,752/8 = 21,969 triangles . This later limit is not documented (but would explain failure of loading a MESH even if everything else is in order). Validating this situation in loading up in my grid I did not witness any effect for a mesh with one material having a total triangle count OVER 21,969. Nevertheless the step to improve you builds in this respect is the same as the step to overcome the material count limit of 8 as suggestion in my tutorial,is to split the work in multiple objects, that you import together so they combine properly in world.

So keep an additional eye on your triangle counts if you doing object for import. My way of doing this is to do my object. Then assign material. Split my final build per material. Make sure I dont exceed the triangle count limit per material. Sometimes I recombine a maximum of 8 object into one in a logical way to do my final object(s). There is nothing wrong in leaving the object splitted which give additional flexibility with only one face ( similar to sculpty) at the cost of larger linked object set. As far as I can see UVmaps will follow properly in the recombination so that texturing will still be maintain proper inworld.

Not so lately ( 2016-01 ) I have added four new tutorial about meshes. They can be found in the import-house in gimisa5. Two are rather advance UVTexturing using clone tool and the other one is about patching holes via the blender grid tool . The other two are more accessible to none blender initiates. One is about making 3D lettering using blender text tool to import inworld. Without much knowledge of blender it is possible to intuitively create lettering text that can be converted in mesh to DAE file and import inworld. The second tutorial in the Mesh import house is about creating 3D object out of simple pictures using autodesk cloud software freely available for small project. Its amazingly simple to use and the results are awesome. The 123dcatch depot in itself is a source of very interesting mesh constructions for you to explore.
Lately ( 2016-03) I have added a tutorial on how to create mesh using regular picture set. The tutorial provide an example using a del arte mask mesh creation using as few as 9 pictures. The internet line tool to do that will created stl extension that can easily be converted and repaired using blender. The tutorial and de la arte mask can be found in the import mesh tutorial building in gimisa5 of my little test grid.



MONEY

I dont think this need definition in Real World. But what about Opensim. My idea here is experimentation and play money. A monopoly of opensim sort of to have fun and play with. My idea is to use coins as point to collect statistics from visitor in my experimental grid. The money system and component help achieve that result by providing supporting data on transactions . There is a good article about it here so I dont need to repeat that information (http://opensimulator.org/wiki/Money). Money not being a core Opensim element its implementation is left to third parties . The one I use for experimentation is http://www.nsl.tuis.ac.jp/xoops/modules/xpwiki/?OpenSim%2FMoneyServer version 0.8.2.0 . Its a current installment at time of writing this article. Its not built using new mono add ins feature (see http://opensimulator.org/wiki/Developing_OpenSim_Addins ) . Nevetherless its download and build was rather straightforward in my case ( linux ubuntu box). I did follow the read.me instructions provided with the download successfully.

Basically the steps are:

1)move the file in appropriate folders ( opensim and opensim/bin )
2)create the money database
3).\build the package
4)modify the moneyServer.ini file .
5)execute the created moneyServer.exe



My moneyServer.ini is available in the dome of gimisa5 region should you be interested in that. I did not implement the helper part. I have direct access to database of my server which makes it much simpler to adjust money balance using sql language. So is it to gather statistical information from the database collection.

The interest for me is that now All of the LSL function related to money become available. llSetPayPrice, llGiveMoney, llRequestPermissions. Also as the object buy function and pay function with a set value. All those will trigger the money(key id, integer amount) event that should prove very interesting to explore.

I noted in my early experimentation that the money event has a problem. The event cannot handle more then one function. That is ONE line of code. A work around I found is to make the two variable provide by money event ( id and amount) global and to use a timer to operate the supporting functions to be implemented.

More important, in my case, I have an experimental grid with only me as resident. So play money is for my HG visitors. I notice on installation that the money system does not work for them since they are grid outsiders. I am great full to developers that provides the code of their work in open sourcing. With the help of a C# introduction book and a bit of fiddling I was able to modify the code to make my HG visitors happy. HG visitors rezzing in the grid are granted the initial amount set in moneyServer.ini. They can do then same as grid resident and make transaction with those coins for the length of their stay. On a subsequent visit to the grid, they retrieve their previous balance and proceed with play money fun. As usual you can test by making a visit to my test server at 3d.gimisa.ca:9000. All regions have money enable. If server fails to catch your arrival, as it happen at time, please consider changing region. That most of the time solve the issue.


LANGUAGE

Opensim is an international application. There is grid hosted in many countries. The viewer supports a number of language that can be set in preference either to be system language or manually entered to fit the user need. This is the same idea as a web browser. For the web browser the language information is available to servers so the user experience can be adapted for the visitor language. The same is also possible to the opensim server / viewer. A script function supports the adaptability of the interaction with the user. The function LlGetAgentLanguage (see http://wiki.secondlife.com/wiki/LlGetAgentLanguage for more detail) is actively supported since 2015 for all grid users.

Unfortunately , this function still does not support the Hypergrid visitors. The function in that case will reply with the default language set by developers ( en-us ) . So I did seek in to try to have a better look at what is going on . A little check in SL shows that this function only works for a request about an avatar that is in the region of the request for language. This would be compatible with  a direct request to the client viewer. I did validate the way the code is made for this function in opensim. Its design is through call to database. The database information itself is updated when the user logs in. So there is no direct exchange from the function call that the viewer would reply to. The result is fine for local users as the information is refresh in grid database when they log in. But since Hypergrid visitors by definition belongs to an other grid their language information is store in the visitors grid database and not made available to visited function call.

So I had to jump in an see if a direct communication is feasible between the viewer and server so that the server can request information out of the viewer after connection to the opensim server. See Hacking Opensim bellow. The conclusion of this effort is that its not possible to obtain the avatar language information, from its viewer configuration settings, out of the login process.


HACKING OPENSIM

I started trying to hack opensim to answer my language question above. I got the source of opensim 0.8.2.0 here http://dist.opensimulator.org/ .Download the source and run the runprebuild.sh so that the solution file are generated.Then in order to read the source of openism 0.8.2.0 I needed mono-develop in linux or microsoft studio in window. Since I work from Linux , I use the former. MonoDevelop can open the opensim.sln file and provides access to the source code and reading of all the code files. With it I am also able to directly "build" and "run" or "debug" the opensim server solution. I can connect my viewer to it and make test as I like. Adding break point in debug mode and using some other debug technics. I had fun exploring the server code in action. But trying to make sense of all those files is not obvious to a new comer. There is this web page provided for developers http://opensimulator.org/wiki/Codebase_overview that got me going . I also found the discussion between Diva and cinderblocks in mantis 7157 ( http://opensimulator.org/mantis/view.php?id=7157 ).

For my language hacking I found that in login process the AgentPreferencesModule is call in to store the values of the login avatar language. This happen only once from the region the avatar log into. Contrary to my original belief. There is no direct communication between the viewer and the server when the script function is called. Instead the function call a database request process internally within the grid server database. A default reply is sent for HG visitor request since they have no entry in database.
I use the console command "show caps list" to get the capacity created for the AgentPreference that includes the language. Those capacities are registered every time the user teleport to a new simulator. That is happening regardless if the user is local or HG visitor in each simulator visited.
AgentPreferences /CAPS/7d28b612-88ad-4d85-a47b-567d8faaa9c0
UpdateAgentLanguage /CAPS/7d28b612-88ad-4d85-a47b-567d8faaa9c0


The AgentPreferenceModule uses a delegate call on region creation. This is typically an event handling function. Every time a cap is created this delegate event is added with the appropriate variable .scene.EventManager.OnRegisterCaps += delegate(UUID agentID, OpenSim.Framework.Capabilities.Caps . This call register the capacities for AgentPreferences and UpdateAgentLanguage and provide for support by the viewer. In the login procedure, the viewer replies to that capability with some appropriate response. But when an avatar teleport to a new region the related capability is announced just the same as in the login process but NO answer is received to this announcement from the viewer. I am clueless as to how to induce the viewer to provide the information as I have no idea how this part of the job is done . In order to understand better the viewer to server communication next step is to use the pcampBot supplied with the source code of the opensim. Using a separate instance of monoDevelop I select the pcampBot solution and in the menu for that file I set the option to the run and debug that program with the argument required including the credentials of your bot avatar as follow after creating that account in local test grid:


firstname Test -lastname User -password 12 -l http://127.0.0.1:9000/ -s "home" -b n -c

But deception running it fails with delegate error in openmetaverse. So the bot is not created. Doing same direcly in terminal did the same error . Downloading 0.8.2.1 and running pcampBot from stable version did same. So no luck there ...


HACKING VIEWER

Following my language tread my next stop from above is to tackel the viewer communication. I was not successfull in getting a viewer compile. But I found this C# library that contains some basic viewer code . http://lib.openmetaverse.co/wiki/Main_Page . Following instuction in this page I was successfull in downloading the source code with project file and to build and run it in debug mode with monodevelopp on ubuntu 14.04 . There is a nice little application attached to this code call testClient that you can run. In monoDevelop you select that projet folder , and in the pull down menue edit its option to add in the run argument the credentials of your bot avatar as follow after creating that account in local test grid

--first Test --last User_0 --pass xx --loginuri="http://127.0.0.1:9000"


Also tick the run on external console if you want to be able to provide inputs via terminal.
Then simply set as startup project in the pull down menu with that solution selected and proceed with running it in debug mode .
Type help in console and look in amazement your bot solution with numerous commands available for testing. Thanks to Hiro for this work . Its a great upgraded NPCs ... Naturally it requires an account for each bots. But unfortunately for my language test testBot does not seem to reply to AgentPreferences.
Fortunately and thanks to Latif Khalifa Radegast in C# with source is available here http://radegast.org/wiki/Radegast . Its a minimal viewer text base with only with a bit of graphic interface. Once downloaded and runprebuild is done it can be open with monoDevelop and compile and run in debug mode. Its a bit more equipped then testBot and to top it, it react to AgentPreferences with a predefine setting of "en". Testing for my language experimentation reveal that there was no way for a direct request from the opensim server to obtain the language configuration direcly from radegast. At least no way I could find. If someone has suggestion I will be happy to read them .


LANGUAGE SOLUTION

Well I was out of ideas to solve the language problem, and suddenly I cross the path of Ernie Serieman. He suggest to use the web kit embedded with the viewer to obtain the language just the same as one get the language from a web browser . To do that he put up a script that use media on prim. By magic his script show the user language right on the media on prim face. The point was to be able to use that information in a script same as llGetLanguage(). With a bit more work we got it to work as plan. Thanks to Ernie for this bright idea and his help with this. This solution has a lot of advantage. It works with HG and local visitors and it does not require database storage. Sole problem it only work with media on prim active . A demo version is available in welcome of my little grid.



ON LINE INDICATION

Lately ( 0.8.2) I have notice its difficult to create friend link for HG people across grid. Not that the link does not appear and the calling card does not get exchanged between friends. But some friend link seem to be broken for the online indication as it fails in its accuracy to indicate proper online status. Note you can still instant message these friend if they are online but the message will not save if they are not on line. One way to solve the issue is to move to the grid your friend is. This will show his online status correcly and will allow off line message saving. Some time ago (2012) I had made a phone system base on HTML server capability of opensim to communicate between grids. Communication using these was possible between closed and open opensim grids as well as SL . That little tool also included a online indicator which is simple enough to work rather well even under 0.8.2. Should you have an interest in that please visit gimisa5 tutorial area for you test copy .

EVENT

Event can be gathering like danse or live performance. I like srcipting so here we mean scripting events. Timer is an event in scripting . It is trigged at the end of the delay your specify in your script.Its low lag for long delays (minutes) . You have many events that can trigger scripts reaction . Touch (clic object) collision sensor html request are other exemple. There is an interesting Mantis http://opensimulator.org/mantis/view.php?id=7061 that discuss Timer limit and in general offer guidance for events in opensim .

For exemple timers are trottle to a delay not lower then 0.5 second. This makes timer very poor when use as progression clock in non physic movement as the human eye will see anything higher then 0.1sec (10fps and lower). In this tread it says if you need a faster timer, consider using the not_at_target() event which will fire every frame. Beware that might be a lagging idea.

I think that that mantis tread is offering very good guidance from Melanie and should be consulted for detail. I retake a large part here cause its sound information that should be easy to find for whom ever is interested in scripting his world. See SCRIPT PROBLEM. above for more detail on the effect of abuse of some of the event available in scripting and how hard it is to find the offending source once release inworld .

Collision is mention as one of the worst event to handle in term of lag. Collision contrary to touch can happen many times as the object bounce back on it . That is why a low lag trick is to turn everything not needing contact with to phantom. Its interesting that inworld people will avoid going through a wall even if the wall is phantom just because its a wall. Physics step size corresponds to 11fps internally, so the length for an object collision to be detected is speed divided by fps . For exemple a 30ms speed object under 11fps we will compute about 3m for the size of the object in direction of contact needed for detection. At walk speed 1ms the same lenght is compute to about anything thicker then 0.1m . That is why colision between avatar works well while firearms bullet collision is tricky and use llCastRay .

So Melanie recommands NO listeners if they can be avoided, ABSOLUTELY NO LISTENERS on channel 0. I will add that Dialogue is more approriate then channel 0 for object commands. In generale osMessageObject is better for object direct communication. But copy of object need to be specifically addressed. And for a reason I ignore object inworld have changed UUID on me so this solution is not perfect expect a bit of tweeking to gain performance.
As she says every script on the receiving side needs to wake up, even if all it does is discard the request with a IF . Stuff that uses chat commands, use specific listeners so the filtering is done by the sim, not the script. So to me in other words use many specific listener instead of many IF . Also as she says It's cheaper to wake one script multiple times instead of many scripts one time and that is true for all event I would say. So one event handler per object is probably desireable.

Same idea linkMessaging is better as more specific than listen . And the better if specific link is targeted.
Finaly she point to avoiding physics like the plague. llKeyFrame is your friend for non physic movement. Also Repeat raycast or sensor is laggy too. Use a packed message protocol, messages have overhead so of you can pack more than one message to one object do it .

Thanks to Melanie to have provided insigth into better scripting form the developper standpoint.

MEMORY

gimisOS is running on two machines. And as I am building and pilling script I get more and more slugish response. So I was wondering if my work load is properly spread. One of the thing that makes a respond sluggish on a server is if you dont have enough ram for the task . System is using swap to swing pieces of data or code not use for a while in exchange for free space to take in new stuff.That mean that if all your simulator data is not in memory the swap is call for in the rescue and cpu has to work to get that data back in memory and sent it to your user. So here is a take of my memory usage and simulator division. :

Server regions Mem size(Mb) Swap(Mb) Threads ! Scripts Prims OAR(Mb)
g5 5 3,758 33 94 1,593 13,314 153
g4 4,6 2,025 396 82 1,491 17,100 107
g3 3,rose 1,856 0 95 1,008 7,085 37
gi 1,7,8,9 1,935 374 113 618 8,859 35
go 2 to the other by 256m or more of empty space 460 2 to the other by 256m or more of empty space 54 13 53
ro - 164 4 23
my - 40 17 37
total 10 10,238 826 4,723 46,411
11,064 (mem + swap)


You might notice that a bare bone simulator pick up about half a gig for running with only one region. You might also notice that the quantity of prim is not an indicator of memory load so is script number . Something more indicative is the size of the corresponding OAR . So my two machine should have 6 Gb of ram to face the load and a good spread would be g5,g3 and the remaining on the other one .


RELIABILITY

Is an important element of any server. Adding features is nice but if these features are not reliable to perform each time consistently its a problem. And if after a while the system crashes because of accumulation of micro failure its even worst. Unfortunately because of the nature of open source opensim and the creation content done unequally by users ( like me!! ) Opensim is prone to instability that lead to crashes. In average one or two crash a week is happening on my region even on weekly restarting of the simulator. Its hard to pin what exactly lead to that crash specially with the message provided in log for linux system where open file is not identified. And even if it was that message is more meaningful to developers then to casual operator like me. So for all those good or not so good reason I have added a routine in my cron job to validate if the simulator is running.
Running on linux I edit my cron tab to add that checking routine every so often ( 4 hours ) with the name of the screen session like:
sh checkRunning.sh g1 g5 with my opensim starting bash being g1.sh and g5.sh and my screens names being g1 and g5 .
The Code is :
     #!/bin/bash
     for var in "$@"
     do 
       if ! screen -S $var  -X select . ; then
          sh ~/$var.sh
          echo 'restart' $var  $(date ) >> ~/log/$var.log
       fi
     done

CONSOLE COMMANDS

Those are the commmand you can use to control and get information from you running simulator or grid server. The list and detail can be found on this web site here opensim console command list . Help can be obtain on those command by typing help then the command to get help. The reference page is not updated as it seem some command name have changed ( version 0.8.2.1) . For example
     delete object uuid <UUID> should be ''delete object id <UUID>'' 
     show   object uuid <UUID> should be  ''show object id <UUID'' 

GRID LAYOUT



What is the impact of grid layout and what about varregion and regular region effects. Let start with viewer reach. The reach maximum value is 1024m . That set distance act like a fog that limit the perception of object. Note that for people with low graphic card reducing that value help performance by reducing the number of object the card has to handle .

That is an avatar will perceive an object and apply level of details to it from that set value down. Like in real life you perceive object detail as you move closer to them . In openism / second life the switch distances for an object are proportional to the object "radius", which is the half-diagonal of the bounding box. It can be calculate as r = sqrt(x*x + y*y + z*z)/2, where x, y and z are the dimensions of the object in meters. The first switch, high to medium LOD, is at: rvlf * r/0.24; the next at 4 times that distance, and the last at 8 times. For a 1m cube,that is 3.3, 13 and 27.

Sound complex , let try to shed a bit of light on this idea. A good representation of the level of detail of an object is its triangle count. A standard prim cube of 1m x 1m use (6 x 9 x 2) 108 triangles in all its faces as seen from a 3.3m location. At a 13 m the viewer will present only ( 6 x 4 x 2) 48 triangles and finally at 27m the viewer will present ( 6 x 1 x 2) 12 triangles.

So what does that have to do with grid layout. I might need to be corrected here but every time you log in a region you get sent all the object texture and shapes detail to your reach distance. If the scene is static and you dont move that is all you need for rendering. The proof of that is when the region lag a lot, rotating on yourself is always performed and rendered properly.

A static scene like a picture is limited in interest . Moving is what give life to virtual. Moving in the scene can be rendered by simple recalculation done at the graphic card . But moving updated information is required to present object that were previously out of your reach distance and to correct object/avatar that themselves are moving. in the scene.

Grid layout yes, we are getting there. When an avatar log in a region it creates child avatars. There is a maximum of 8 child avatar created in each of the region adjacent to the landed region. This allow the other region information to be communicated to the viewer. This is the mechanism providing perception of object at the reach distance across the region boarder. More importantly these are the ONLY region the avatar can perceive cross boarder. That is even if the reach distance is 1024m and the avatar is standing on the middle region of huge grid , he will only perceive object in the region that have created child avatar for him .

Is this fact important for Grid layout. You bet. Say I want to create a huge city . With opensim 0.9 its possible to stack varregion side by side and say make a 10,240m x 10,240m plot. We cant go with varregion size higher then 8192 so you would be a bit short with only one varregion. You could divide it say in 5 x 5 2048 varregion.. But if I am correct , in any of those case your avatar standing on the city center would have child avatar in a surface representing a huge amount compare to the reach distance of the viewer. This would be a waste of resources by a large margin. In this case since we want the scene to appear continuous we would like to select the varregion size to fit the reach distance to the closes possible. In this case ..10 x 10 of 1024 x 1024 varregion would be feasible. This will provide for a continous rendering at maximum viewer reach.

But who want to make a huge scene like that. If performance is your concern then you prefer people NOT to perceive scene object from you neighbors .So the trick in that way of thinking is opposite and you want to have an empty region ( no region at all ) in all direction centered on your scenery. So that NO child avatar are created around you region that will drain down viewer bandwith. Once you have establish a no man land zone around your area, selecting varregion size is up to how much of you scenery should be perceived in one glow. Standard region size of 256x256, with teleporter sending people in layer of 1024m in height is still a valid sizing to consider particularly for smaller areas.



Hope it helps
170216
email gimisa
hypergrid secondlife:///app/teleport/3d.gimisa.ca:9000
web: http://3d.gimisa.ca:9090

Personal tools
General
About This Wiki