How to Python script objects to explode:
1. Once objects are imported into realXtend, .csv files must be created in c:\Program Files\realxtend-server-0.5-empty-standalone\rexserver. One of these files will have the coordinates for where each object originates, and the other is where it will move to. They should be named “orig___.csv” and “eplo___.csv” where the blanks are a unique identifier.
2. To fill in the .csv, go into realXtend, from the View menu select Object List. Select the prim associated with each mesh (there should be two for each model, one for the inside and one for the outside). With a prim selected in the list, click Copy UUID.
3. In your orig___.csv spreadsheet, in row 1, paste the UUID. It should be a long string of numbers, letters and dashes.
4. In the same row/column, after the UUID put a semi-colon, followed by the x,y,z coordinates. They should go to 3 decimal places, and each one is separated by another semi-colon.
5. After your x,y,z coordinate, you will enter the rotation of each prim. It will likely be all 0’s, and will have 4 number i.e. x,y,z,w. Your final row should look something like this: f828acfa-e1d1-4103-ae7d-37efa737f89a;80.000;135.000;36.000;0;0;0;0
6. Copy that orig___.csv file and name it eplo___.csv. In this file, change the coordinates to where the objects will explode to and save. Make sure both the realXtend viewer and sever are closed for the following steps.
7. Next go into \ScriptEngines\PythonScript. There should be a folder called MyScripts.
8. If there is no folder called MyScripts, create one.
9. Go into RXCore and copy the __init__.py file and paste it into MyScripts.
10. Open __init__.py in MyScripts and change “Python:RXCore init” to “Python:MyScripts init”
11. Erase all other text. Type: Import explode
12. Create a .py file named explode.py (if you cannot create one, copy one from another folder and paste it into MyScripts and erase all the text inside it). In it type:
import rxactor import rxavatar import sys import clr
openmv = clr.LoadAssemblyByName('OpenMetaverseTypes.dll') UUID = openmv.OpenMetaverse.UUID Vector3 = openmv.OpenMetaverse.Vector3 Quaternion = openmv.OpenMetaverse.Quaternion
import random import math
@staticmethod def GetScriptClassName(): return "explode.Exploder"
def EventCreated(self): super(self.__class__,self).EventCreated() self.Exploded = False
#read original positions from file self.PartsOrigPos =  origPosFile = open("origpos.csv") while 1: line = origPosFile.readline() if not line: break self.PartsOrigPos.append(line)
#read exploded positions from file self.PartsExplPos =  explPosFile = open("explpos.csv") while 1: line = explPosFile.readline() if not line: break self.PartsExplPos.append(line) print "Exploder EventCreated"
def EventTouch(self,vAvatar): if(self.Exploded == False): #move objects
for line in self.PartsExplPos: partId = UUID(line.split(';')) part = self.MyWorld.CS.World.GetSceneObjectPart(partId) if part != None: #print part.GroupPosition newPos = Vector3(float(line.split(';')), float(line.split(';')), float(line.split(';'))) newRot = Quaternion(float(line.split(';')), float(line.split(';')), float(line.split(';')), float(line.split(';'))) part.UpdateGroupPosition(newPos) part.UpdateRotation(newRot) else: print "part not found" self.Exploded = True else: #move objects for line in self.PartsOrigPos: partId = UUID(line.split(';')) part = self.MyWorld.CS.World.GetSceneObjectPart(partId) if part != None: #print part.GroupPosition newPos = Vector3(float(line.split(';')), float(line.split(';')), float(line.split(';'))) newRot = Quaternion(float(line.split(';')), float(line.split(';')), float(line.split(';')), float(line.split(';'))) part.UpdateGroupPosition(newPos) part.UpdateRotation(newRot) else: print "part not found" self.Exploded = False
13. This file will be copied for each object you want to be able to be exploded on its own. Inside each script you will change 3 lines for each object. For example, if you are naming a file “jaw” then in the explode.py file you copy, which you would name “jaw.py” you would change:
return “explode.Exploder” return “jaw.Exploder” origPosFile = open(“origpos.csv”) origPosFile = open(“origjaw.csv”) explPosFile = open(“explopos.csv”) explPosFile = open(“expljaw.csv”)
This is assuming your csv files are named origjaw.csv and expljaw.csv
14. Once this is created, in the __init__.py file inside MyScripts, you would add the line: import jaw
15. Launch the realXtend server. In this OpenSim window, you will get a large block of text after “Python:RXCore init”. After that you should see: Python:Chambers of Ikuturso Python:MyScripts init Python:Samples init
16. If there is any kind of warning, likely in yellow text, that says MyScripts, explode or the name of your python script were not loaded, a previous step has been done improperly.
17. Launch the realXtend viewer. Inside, create a new prim.
18. Name this prim “jaw button”
19. Select the prim, choose edit and go to the reX tab. Then select the misc sub-tab.
20. In the “Class Name” area type the name of your python script, followed by a period and then Exploder. In this case, it would be “jaw.Exploder”
21. Press enter and the OpenSim server window should read a new event has been created. If an error message comes up, either in the server window or in the realXtend viewer, a previous step has been done improperly.
22. This prim should now act as a button. Make sure to close the edit window, and then left click the prim. This should cause your object to switch between the coordinates specified in your .csv files.
23. Feel free to colour your prim button, or associate a mesh made in Blender with it for a custom look.