Mod Tool
general information
Various modders of the community use "Autodesk Softimage Mod Tool". Usually we just call it "Mod Tool".
Beside the free version, there's also the retail and student version "Autodesk Softimage [year]"
- Those versions are also available as 64-bit versions.
- If you are a student you can get Autodesk Software for free if your school is a partner of Autodesk.
- In that case you can register with your email address given by your school.
But in the very most cases "Mod Tool" isn't really in disadvantage towards the retail version when it comes to modding Oni.
There's also the possibility to get files that extent Mod Tool's range of functions.
- Those are scripts (*.vbs, js), toolbars (*.xsitb) and addons (*.xsiaddon).
- They can be create on one's own and even shared with other users.
extensions
links
- OBJ exporter
- OBJ + OFGA exporter for Oni
- might need the regular OBJ exporter to be installed first
- adjusting existing fw throws (instructions)
- put more links here
how to bind scripts to buttons (embedded code or .vbs / .js)
- You can enable/disable the Main Shelf over "View" > "Optional Panels" > "Main Shelf". Then click the "Custom" tab.
- A) Right-click the free gray space, click on "Customize Toolbar...". Select "Toolbar Widgets" > "Script Button".
- Enter your code and make sure you selected the correct Scripting Language. Click okay when you are done.
- B) You can also drag'n'drop your script file directly onto the free gray space.
- A new window pops up, check the settings and click okay when done.
- Right-click the Main Shelf and use the "Save" option. ("Save As" let you save the Main Shelf as toolbar file.)
how to install toolbars (.xsitb)
- creation: goto "View" > "New custom toolbar"
- Now you can add buttons like in Main Shelf. Remember to save your changes. (Right-click, "Save As".)
- installation: Drag'n'drop the xsitb file onto the viewport (it's simply the window where you can see 3D objects).
- access: goto "View" > "Toolbars"
- deletion: goto "View" > "Manage..." Check a toolbar and click Delete button.
- The file will remain with a new file suffix ".bak" You can restore this backup if you remove the ".bak" from the name.
how to install addons (.xsiaddon)
- A) drag'n'drop the file into the so-called viewport (it's simply the window where you can see 3D objects), then restart Mod Tool
- B) if drag and drop doesn't work, goto "File" > "Add-On" > "Install"
- Then click on the "..." button to search for the file. When you found it, click the "Install" button.
- building addon file seems so far to be the most difficult among those 'extension' files but for the end user it's best because it can all other files: toolbars, plugins, scripts, etc.
selected wisdom
We've also a tutorial thread on OCF.
- move camera: [S]+[LClick]+[Moving_Mouse]
- rotate camera: [S]+[RClick]+[Moving_Mouse]
- zoom camera: [S]+[Scrolling]
- reset view: [R]
mesh
- extracting a polygon from an object: select polygon, right-click, "Extract Polygons (Delete)"
- copying an polygon from an object: select polygon, right-click, "Extract Polygons (Keep)"
- merging two objects: select one of them, goto Model>Modify>Poly.Mesh>Boolean>Union, select second object
- (this makes a copy of the second object and attaches it to the first one, the merged objects must be freezed before the original second object can be removed)
- filling a hole: select all edges surrounding the hole and choose one of the following methods
- A) goto Model > Modify > Poly.Mesh > Weld Boundary Points/Edges
- B) goto Model > Modify > Poly.Mesh > Bridge Boundary Points/Edges (if blue lines appear try to disable the checkbox "Angle > 90")
- merging two objects at blue lines: merge the objects at first, then proceed with the point above "filling a hole"
- hiding a single polygon: select polygon and hit [H], use [Control]+[H] to unhide
- mirroring an object: select object, Edit > Duplicate/Instantiate > Duplicate Symmetry (center rotation might need to be changed afterwards)
- working with symmetry mode
- select object, Property > Symmetry Map (YZ/XZ/XY) (press [W] to preview symmetry plane)
- click on Sym buttom (in Transform area) to enable/disable symmetry mode
- changing the Symmetry plane: Explorer [8] > unfold object > Polygon Mesh > Cluster > delete SymmetryMapCls; then add a new symmetry plane
material and texture
- objects use the scene material by default, objects need their own material if they should have individual textures
- selecting a material and surface: Model>Material>Phong (simply close the windows that pops up)
- connecting the texture with the material:
- [7] to open Render Tree
- in first column: "Texture"
- in second column: drag'n'drop "Image" into the free space
- click and hold the red point of "Image", then move it to "Phong" and release the mouse click
- choose "diffuse" as illumination mode (for instance "ambient" won't work - the texture would be visible in Mod Tool but Onisplit can't use it)
- now "Image" can be double-clicked (the Texture Editor will pop up), in the section "Image" click on "New" to choose an image
projection and UV
getting started
- in section "Texture Projection" click on "New", choose a projection similar to the mesh shape (planar / cylindrical / cubic / spherical)
- select the object
- Texture editor: [Alt]+[7] (open it while being in selection mode "Object" or "Polygon", otherwise the UVs aren't shown)
modify single/all UVs
- rotate 90°: [R]
- rotate: [C]
- scale: [X]
- move: [V]
- tearing single UV parts: [Control]+[T], then move [V]
- heal (re-connect) selected UV parts: click on the plus symbol (the parts should be very near to each other, best if the points are on same spot)
- snap function for move tool: Snap > Enable Snapping; check "Points" (if not already active)
- relax (smooth warped UVs): [Control]+[R] (usually pressing several times that combination)
- a new projection can also be applied to currently selected UV parts
- freeze object to bake projections (green lines in the 3D view will disappear)
- getting a picture of the UV: apply first a black texture then enter the Texture Editor [Alt]+[7], Edit > Stamp UV Mesh [Shift]+[S], save the texture
scripting
- open the Script Editor: [Alt]+[4]
- run the current code in the Script Editor window: [F5]
- clear the log: Edit > Clear History Log
- Actions from button embedded code will be logged.
- Actions from code files that are linked in a button won't be logged. (This results in a performance boost.)
- Logged stuff will be rewritten if you change the script language. (File > Preferences...)
- You can also change the language by right-click the white script box and click on "Set to JScript" or "Set to VBScript".
- Same way you can load a few code piece, e.g. "Syntax Help" > "If..Else" or "Catch Error".
- Mark code you want to disable ("Comment Out") or enable ("Comment Remove").
- You can save your code to a file via "File" > "Save As..." or "Save Selection"
links
- using external scripts
- progress bar and open file dialog
- xsi wiki page about scripting
- many vbscript examples
notes about polygon extraction
- a grid of 9 polygons (ID 0 to 8)
- you extract the middle polygon (ID 4)
- grid's polygon of ID 8 will change to ID 4
- if you now extract 5th, the 7th gets the ID
- now the ID order is: 0, 1, 2, 3, 6, 5, 4
- this means that an automatic extraction of several polygons requires two changes in the code
- 1) the ID array of selected polygons must be sorted
- 2) the extraction must start with the last ID to avoid ID shift during the process (see code pieces)
some basics of VBScript
- In VBS you declare variables only as a variant e.g. "dim PolygonCount". Mod Tool decides what type it becomes when it uses the variable the first time.
- You can put "option explicit" at the start of your script. Then you will be forced to declare all variables with "dim". That looks quite unnecessary but help to find mistakes for example if you mistyped a variable somewhere in a long script.
- The commands are not case-sensitive, e.g. you can write "LogMessage" or "logmessage".
- Some common vbs functions can be found HERE.
' while it is possible to use + in strings, ' you should actually use & only for strings ' and + only for numbers logmessage "How about ... " + "a riddle?" logmessage "Where can you find following phrase in Oni? " & "The day is mine !!" logmessage "Did you know that Bungie likes to hide sevens? The digits of the year 2032 add up to " & cstr(2 + 0 + 3 + 2) & "." ' INFO : How about ... a riddle? ' INFO : Where can you find following phrase in Oni? The day is mine !! ' INFO : Did you know that Bungie likes to hide sevens? The digits of the year 2032 add up to 7.
some ModTool commands in vbs language that might be interesting for Oni related stuff
Everywhere "logmessage" stands you can replace it with a variable (in that case don't forget the = sign.)
LogMessage [string | var] | A command to log information. It requires a string or a variable. Example:
|
logmessage selection(0).Name | Logs the object name. |
logmessage selection(0).Material.Name | Logs the material name. |
logmessage selection(0).Material.CurrentImageClip.Name | Logs the texture name. "." before the file suffix is replaced by "_". Also a number might follow after the file suffix. Output example:
|
logmessage selection(0).sclx.value | Logs object's X scaling. |
logmessage selection(0).scly.value | Logs object's Y scaling. |
logmessage selection(0).sclz.value | Logs object's Z scaling. |
logmessage selection(0).rotx.value | Logs object's X rotation. |
logmessage selection(0).roty.value | Logs object's Y rotation. |
logmessage selection(0).rotz.value | Logs object's Z rotation. |
logmessage selection(0).posx.value | Logs object's X position. |
logmessage selection(0).posy.value | Logs object's Y position. |
logmessage selection(0).posz.value | Logs object's Z position. |
logmessage selection(0).rotorder.value | Logs object's rotation order.
|
SelectObj [string | var] | select one or more objects. Comma serves as separator. Example:
|
ToggleSelection [string | var] | Adds one or more objects from current selection. If the objects are already selected then they become subtracted from the selection. Example:
|
SelectAllUsingFilter [SelFilter], [CheckComponentVisibility], [AffectSelectionList], [CheckObjectSelectability] | Selects everything that matches the filter and other options. Example:
|
DeselectAll | deselects everything |
DeleteObj [string | var] | Deletes one or more objects. Comma used as separator. Example:
|
FreezeObj | Makes all changes final. But saving those changes is still necessary. (Click on key symbol so it gets red.) |
Translate [InputObjs], [X], [Y], [Z], [Delta], [RefMode], [Center], [AxesFilter], [Snap], [SnapReference], [SnapFilter], [SplitLocalComponents], [PropTagOnly], [Pivot], [PivotX], [PivotY], [PivotZ], [ConstructionMode], [SlideComponents] | see link |
Rotate [InputObjs], [X], [Y], [Z], [Delta], [RefMode], [Center], [AxesFilter], [Reference], [SplitLocalComponents], [PropTagOnly], [Pivot], [PivotX], [PivotY], [PivotZ], [ConstructionMode], [SlideComponents] | see link |
code pieces (VB Script)
Remember that you can use the search function of your web browser.
If you see absolute paths adapt them so that the code works on your system too.
[1] making an array | [2] check selection mode | [3] getting the IDs of selected polygons plus sorting them |
[4] converting euler rotations (in degrees) to quaternions | [5] converting quaternions to euler rotations (in degrees) | [6] get and set values of the playcontrol (timeline) |
[7] get keyframes | [8] message box | [9] input box |
[10] getting the desktop path | [11] selecting a folder | [12] selecting a file of a specific type |
[13] reading out environment variables | [14] check if file exist | [15] check if folder exist + create folder |
[16] write xml file | [17] create txt file + write lines | [18] read txt file |
[19] check onisplit version | [20] call CMD, e.g. to use onisplit | [21] building forms in ModTool |
[22] UserDataBlob | [23] getting the position of points (with selection mode point) | [24] getting the position of points (with selection mode object) |
[25] getting and setting the position of points (without selection) |
' [1] making an array ' make some object, select them and run the code dim y y = selection.count redim x (y - 1) ' redim is needed for arrays ' () sets the number of array items for i = 0 to y - 1 x(i) = selection(i).fullname logmessage x(i) next logmessage "counted objects: " & y
' [2] check selection mode checkfilter 'use sub to make use of the exit command sub checkfilter Select Case Selection.Filter.Name 'caution: case-sensitive Case "object" logmessage "object mode" Case "Edge" logmessage "edge mode" Case "Vertex" logmessage "point mode" Case "Polygon" logmessage "polygon mode" polymode Case Else logmessage "Choose Object or Polygon selection mode." exit sub End Select end sub
' [3] getting the IDs of selected polygons plus sorting them poly_count = Selection(0).SubComponent.ComponentCollection.count logmessage "poly_count: " & poly_count redim selected (poly_count) logmessage "Show ID as it is." for i=0 to poly_count - 1 ' build ID array selected(i) = Selection(0).SubComponent.ComponentCollection(i).index logmessage selected(i) next ' change sort order by replacing ">" with "<" For i = 0 To poly_count - 1 For j = 0 To poly_count - 1 If selected(i) > selected(j) Then tmp = selected(i) selected(i) = selected(j) selected(j) = tmp End If Next Next logmessage "Show sorted ID." for i=0 to poly_count - 1 logmessage selected(i) next
' [4] converting euler rotations (in degrees) to quaternions dim x, y, z, dRotation, qRotation x = 90 y = 0 z = 0 set dRotation = XSIMath.CreateRotation(XSIMath.DegreesToRadians(x), XSIMath.DegreesToRadians(y), XSIMath.DegreesToRadians(z)) set qRotation = XSIMath.CreateQuaternion() dRotation.GetQuaternion (qRotation) LogMessage qRotation.W LogMessage qRotation.X LogMessage qRotation.Y LogMessage qRotation.Z ' INFO : 0,707106781186548 ' INFO : 0,707106781186547 ' INFO : 0 ' INFO : 0
' [5] converting quaternions to euler rotations (in degrees) dim qW, qX, qY, qZ, qRotation, x, y, z qW = 0.707106781186548 qX = 0.707106781186547 qY = 0 qZ = 0 set qRotation = XSIMath.CreateQuaternion (qW, qX , qY, qZ) qRotation.GetXYZAngleValues x, y, z logmessage XSIMath.RadiansToDegrees(x) logmessage XSIMath.RadiansToDegrees(y) logmessage XSIMath.RadiansToDegrees(z) ' INFO : 89,9999999999999 ' INFO : 0 ' INFO : 0
' [6] get and set values of the playcontrol (timeline) ' timeline variables (tl) dim tlStart, tlEnd, tlCurrent ' get values tlStart = GetValue ("PlayControl.In") tlEnd = GetValue ("PlayControl.Out") tlCurrent = GetValue ("PlayControl.Current") ' set values SetValue ("PlayControl.In"), 7 SetValue ("PlayControl.Out"), 70 SetValue ("PlayControl.Current"), 14
' [7] get keyframes
' [8] message box msgbox "message", , "title"
' [9] input box logmessage inputbox ("message", "title" , "pre-entered content")
' [10] getting the desktop path ' this can be useful for default locations like when selecting a folder DesktopPath = CreateObject("WScript.Shell").SpecialFolders("Desktop") logmessage DesktopPath
' [11] selecting a folder ' the default path is in this case my desktop ' to make it work on other systems, you would need the code of "getting the desktop path" section and replace my path with the DesktopPath logmessage XSIUIToolkit.PickFolder("C:\Users\RMM\Desktop\", "title" )
' [12] selecting a file of a specific type set oFileBrowser = XSIUIToolkit.FileBrowser oFileBrowser.DialogTitle = "Select an image file (png/tga/jpg)" ' (default folder) oFileBrowser.InitialDirectory = "c:\" oFileBrowser.Filter = "JPEG (*.jpg)|*.jpg|PNG (*.png)|*.png| Targa (*.tga)|*.tga||" oFileBrowser.ShowOpen If oFileBrowser.FilePathName <> "" Then logmessage "User selected " & oFileBrowser.FilePathName Else logmessage "User pressed cancel" End If
' [13] reading out environment variables ' some infos about env vars: (1), (2), (3) ' those variables are stored inside the setenv.bat, two disadvantages: ' adding or editing those vars appears to not work in vbs or I just did it wrong ' anyway, new vars can only be read out after app restart ' therefore let's concentrate on reading out existing ones and how to set up out own vars via txt files in the next section ' code for reading out: logmessage = XSIUtils.ResolvePath("$SI_HOME/")
' [14] check if file exist Set objFSO = CreateObject("Scripting.FileSystemObject") If objFSO.FileExists ("C:\folder\file.txt") then logmessage "File exists." else logmessage "File doesn't exist." end if
' [15] check if folder exist + create folder dim strDirectory strDirectory = "C:\test" Set objFSO = CreateObject("Scripting.FileSystemObject") If objFSO.FolderExists(strDirectory) Then Set objFolder = objFSO.GetFolder(strDirectory) logmessage strDirectory & " already exists" Else Set objFolder = objFSO.CreateFolder(strDirectory) logmessage "created folder " & strDirectory End If
' [16] write xml file FolderName = CreateObject("WScript.Shell").SpecialFolders("Desktop") FileName = "test" FilePath = FolderName & "\OBAN" & FileName & ".xml" Set oFS = CreateObject("Scripting.FileSystemObject") Set objXMLFile = oFS.OpenTextFile(FilePath, 2, True, 0) ' quote sign in a string needs two quote signs objXMLFile.WriteLine "<?xml version=""1.0"" encoding=""utf-8""?>" objXMLFile.WriteLine "<Oni>" objXMLFile.WriteLine "..."
' [17] create txt file + write lines
' [18] read txt file
' [19] check onisplit version Set objFSO = CreateObject("Scripting.FileSystemObject") logmessage objFSO.GetFileVersion("F:\Program Files (x86)\Oni\Edition\install\onisplit.exe") ' result looks like this: ' INFO : 0.9.59.0
' [20] call CMD, e.g. to lunch onisplit or the game ' relative path ' the "GameDataFolder" isn't inside the "install" folder ' so we will use ..\ to go one folder backwards ' ' additional quote signs tells the program where the ' paths strings start and end in case the path contains spaces ' ' if you are going to use the xml file right after its extraction (which is likely) ' then the "/wait" argument inside the onisplit_action string is important ' without it the code would continue and might try to read the not existing xml file and produce an error onisplit_location = "F:\Program Files (x86)\Oni\Edition\install" input_folder = """..\GameDataFolder\level19_Final\ONLVcompound.oni""" output_folder = """..\GameDataFolder""" onisplit_action = "cmd /C start /wait OniSplit.exe -extract:xml " & output_folder & " " & input_folder logmessage "relative path: " & onisplit_action ' expected logmessage: ' INFO : relative path: cmd /C start OniSplit.exe -extract:xml "..\GameDataFolder" "..\GameDataFolder\level19_Final\ONLVcompound.oni" XSIUtils.LaunchProcess onisplit_action, 1, onisplit_location ' absolute path 'adapt paths so it works on your computer onisplit_location = "F:\Program Files (x86)\Oni\Edition\install" input_folder = """F:\Program Files (x86)\Oni\Edition\GameDataFolder\level19_Final\ONLVcompound.oni""" output_folder = """F:\Program Files (x86)\Oni\Edition\GameDataFolder""" onisplit_action = "cmd /C start /wait OniSplit.exe -extract:xml " & output_folder & " " & input_folder logmessage "absolute path: " & onisplit_action ' expected logmessage: ' INFO : absolute path: cmd /C start OniSplit.exe -extract:xml "F:\Program Files (x86)\Oni\Edition\GameDataFolder" "F:\Program Files (x86)\Oni\Edition\GameDataFolder\level19_Final\ONLVcompound.oni" XSIUtils.LaunchProcess onisplit_action, 1, onisplit_location ' you can also lunch bat files onibat = "cmd /C start run_wind.bat" onilocation = "F:\Program Files (x86)\Oni\Edition" XSIUtils.LaunchProcess onibat, 0, onilocation
' [21] building a form (PPG)
' [22] UserDataBlob ' you can attach data to objects, e.g. properties of Trigger Volumes ' the so-called "UserDataBlob" can't be saved in *.dae, so save the whole scene to keep your progress ' [...]
' [23] getting the position of points (with selection mode point) ' a point must be selected ' gets xyz position of first selected point of the first selected object logmessage Selection(0).SubComponent.ComponentCollection(0).position.x logmessage Selection(0).SubComponent.ComponentCollection(0).position.y logmessage Selection(0).SubComponent.ComponentCollection(0).position.z
' [24] getting the position of points (with selection mode object) ' an object must be selected ' gets xyz position of point 0 of the first selected object logmessage selection(0).activeprimitive.geometry.Points(0).Position.x logmessage selection(0).activeprimitive.geometry.Points(0).Position.y logmessage selection(0).activeprimitive.geometry.Points(0).Position.z
' [25] getting and setting the position of points (without selection) right after object creation ' those are relative position calculated from the objects center ' to get the real positions add relative poition to that center position ' don't confuse this with the center that can be moved around ' it's the mathematical center of the object set oRoot = application.activeproject.activescene.root set oObj = oRoot.addgeometry( "Cube", "MeshSurface", "TRGV" ) logmessage "TriggerVolumes." & oObj FreezeObj oObj set oGeometry = oObj.activeprimitive.geometry aPositions = oGeometry.Points.PositionArray ' xyz, 0 = value logmessage aPositions(0, 0) logmessage aPositions(1, 0) logmessage aPositions(2, 0) ' changing x position of point 0 to value -12 aPositions(0, 0) = -12 ' you can add more changes here ' update the array oGeometry.Points.PositionArray = aPositions ' apply the changes for point 0 (in this case we changed only x dimension to -12) Translate oObj, aPositions(0, 0), aPositions(1, 0), aPositions(2, 0), siAbsolute, siView, siCtr, siXYZ, , , , , , , , , , 0 SaveKey oObj & ".kine.local.posx," & _ oObj & ".kine.local.posy," & _ oObj & ".kine.local.posz", 1, , , , True
script ideas
- autoheal discontinuities (blue lines) of overlaying edges (for repairing google sketchup objects that weren't yet textured)
- making loops from parts of animations
- copying animation data from one character to another
The following sections are about ideas that are checked right now for their possibility of realization or already in the making.
trigger volumes export/import
exported warehouse TVs |
- Oni to ModTool
- conversion of oni to xml [-]
- import of TV collection [done]
- adding a new TV [done]
- texturing the TVs [-]
- TV properties form (PPG) [wip]
- ModTool to Oni [-]
new door animations
creating new door animations
After a few experiments onisplit v0.9.54.0 seems to output XYZ-W instead of XYZW.
Example:
X Y Z Rotation in Mod Tool 40 0 0 -------------------------------------------------------------- X Y Z W Q.Rotation in Mod Tool 0,342 0 0 0,939 -------------------------------------------------------------- X Y Z -W Q.Rotation onispl. v54 0,334 0 0 -0,94
Following code is "WIP", it gets quaternions and write them into an OBAN*.xml
It wasn't tested yet and will probably need some tweaks to meet Oni's door orientation. Also, OBAN flag "ZAxisUp" needs some more investigation.
hierarchy builder for characters
(Automatic rigging.) Maybe null objects could stand for the centers of body parts. Then one click and the real centers gets positioned. The rotations are known and the names would lead to the correct hierarchy.
In order to make edits there is also a need of destroying the hierarchy again. Child object need the rotation of the parent and get cut. I'm not yet sure if the values needs to be subtracted, added or something else.
code pieces
hierarchy breaker
step 1: getting a starting point (in this case the pelvis)
'SelectNeighborObj [parameter1], [parameter2], [parameter3], [parameter4] 'options of the second parameters '0 go one level up '1 go one level down '2 go to next silbing '3 go to previous silbing '4 go to highest level '5 go to deepest level if selection.count > 0 then ' user could have selected anything, let's find the pelvis ' check current obj, if it isn't the pelvis go one level up do until instr(1, current_obj, "pelvis") = 1 or not_found = 1 previous_obj = current_obj current_obj = selection(0) if instr(1, selection(0), "pelvis") = 1 then logmessage "found pelvis" end if if previous_obj = current_obj then not_found = 1 logmessage "couldn't find pelvis" msgbox "Make sure that the pelvis object holds the word ""pelvis""." & vbCRLF & "It must be part of the name.", , "error" else ' we work with selection here, so first parameter is optional and can be left out ' the second parameter is 0 by default so we can also left it out ' SelectNeighborObj [parameter1], [parameter2] SelectNeighborObj end if loop else msgbox "One part of your character must be selected.", , "error" end if
step 2: getting the names, positions and rotations of all body parts and apply value to null refs
step 3: destroying the hierarchy
hierarchy builder
[...]