8,324
edits
Paradox-01 (talk | contribs) (how to get position of objects (moving and sorting more content from MT main page)) |
Paradox-01 (talk | contribs) (read and write text file, change position of object and scene fundamentals) |
||
Line 128: | Line 128: | ||
[...] | [...] | ||
Line 865: | Line 665: | ||
' mark FBXExport and hit F1 to get more options | ' mark FBXExport and hit F1 to get more options | ||
FBXExport (CreateObject("WScript.Shell").SpecialFolders("Desktop") & "\export_test.fbx" ) | FBXExport (CreateObject("WScript.Shell").SpecialFolders("Desktop") & "\export_test.fbx" ) | ||
===Write text file=== | |||
txt_location = "C:\Softimage\Softimage_Mod_Tool_7.5\test.txt" | |||
Set fso = CreateObject ("Scripting.FileSystemObject") | |||
Set wText = fso.CreateTextFile (txt_location, 1) | |||
wText.WriteLine "I'm a test file." | |||
wText.WriteLine "Yo!" | |||
wText.Close | |||
Line 893: | Line 702: | ||
=== | ===Read text file=== | ||
Set objFileToRead = CreateObject("Scripting.FileSystemObject").OpenTextFile("C:\Softimage\Softimage_Mod_Tool_7.5\test.txt", 1) | |||
do while not objFileToRead.AtEndOfStream | |||
strLine = objFileToRead.ReadLine() | |||
logmessage strLine | |||
loop | |||
' INFO : I'm a test file. | |||
' INFO : Yo! | |||
objFileToRead.Close | |||
Set objFileToRead = Nothing | |||
===Read binary file=== | |||
scan_AKEV_file_table | scan_AKEV_file_table | ||
Line 987: | Line 810: | ||
' [...] | ' [...] | ||
' INFO : TXMPWH_DCTRBND | ' INFO : TXMPWH_DCTRBND | ||
Line 1,296: | Line 1,118: | ||
==3D mesh== | ==3D mesh== | ||
===General mesh information=== | ===General mesh information=== | ||
logmessage selection.count | |||
logmessage selection(0).Name | |||
logmessage selection(0).Materials(0).Name | |||
logmessage selection(0).Materials(0).Library.name | |||
logmessage selection(0).Materials(0).shaders(0).name | |||
logmessage selection(0).Materials(0).CurrentImageClip.source.filename.value | |||
logmessage selection(0).Materials(0).CurrentImageClip.source.Parameters("XRes").Value | |||
logmessage selection(0).Material.CurrentImageClip.source.Parameters("YRes").Value | |||
logmessage selection(0).Material.CurrentUV.name | |||
logmessage selection(0).activeprimitive.geometry.clusters(0).name | |||
' look for UV cluster names | |||
' xsi-generated: "Texture_Coordinates_AUTO" | |||
' onisplit-generated: "NodeProperties" | |||
logmessage selection(0).sclx.value | |||
logmessage selection(0).scly.value | |||
logmessage selection(0).sclz.value | |||
logmessage selection(0).rotx.value | |||
logmessage selection(0).roty.value | |||
logmessage selection(0).rotz.value | |||
logmessage selection(0).posx.value | |||
logmessage selection(0).posy.value | |||
logmessage selection(0).posz.value | |||
logmessage selection(0).rotorder.value | |||
====Materials and textures==== | |||
=====Get all targets of an image clip===== | |||
set imgClip = GetValue("Clips._marker_blackness_tga") | |||
set imgClipTargets = imgClip.GetShaderParameterTargets | |||
logmessage imgClipTargets.count | |||
for each t in imgClipTargets | |||
logmessage t | |||
next | |||
=====Get all material libraries and materials===== | |||
for each ml in Application.ActiveProject.ActiveScene.MaterialLibraries | |||
logmessage ml | |||
for each m in ml.items | |||
logmessage m.name ' (material) | |||
next | |||
logmessage "--------------------------" | |||
next | |||
' INFO : Sources.Materials.DefaultLib | |||
' INFO : Scene_Material | |||
' INFO : sosMatBarrier | |||
' INFO : sosMatBlackness | |||
' INFO : sosMatDanger | |||
' INFO : sosMatGhost | |||
' INFO : sosMatImpassable | |||
' INFO : sosMatStairs | |||
' INFO : -------------------------- | |||
' INFO : Sources.Materials.MaterialLibrary | |||
' INFO : AIR_STAIRWALL_LOB1 | |||
' INFO : AIR_WAITSEAT3 | |||
' INFO : AIR_WAITSEAT2 | |||
' INFO : COLLISION | |||
' INFO : -------------------------- | |||
=====Check an object's main material for TwoSided-ness===== | |||
' test and toggles an object's main material for TwoSided-ness | |||
' this is also a prerequired test for transparency | |||
' the difficulty is to get the TextureObject (often named Image) | |||
' the magic happens at FindShaders, I often fail to find such trivial stuff | |||
' imo the xsi is terrible incomplete/unintuitive | |||
' e.g. look at "Find (ShaderCollection)" in the help | |||
' it will give you information about meshes such as cubes ... | |||
matLib = selection(0).Materials(0).Library.name | |||
set mat = selection(0).Material | |||
materialName = mat.name | |||
' let us see if there is an Image TextureObject | |||
set shaders = mat.FindShaders(siShaderFilter) | |||
textureObj = "Image" | |||
'if typename(shaders(textureObj)) = "Texture" then ' if not it is Nothing | |||
' logmessage "material has texture object ""Image""" | |||
'end if | |||
Set list = CreateObject("System.Collections.ArrayList") | |||
for each n in shaders | |||
list.Add n.name | |||
next | |||
foundShaderParameterTransparency = false | |||
'foundUniqueShaderName = false | |||
shaderName = "" | |||
if list.Contains(textureObj) = true then | |||
set oColorShareShader = GetValue("Sources.Materials." & matLib & "." & mat.name & "." & textureObj) | |||
set oTargets = oColorShareShader.GetShaderParameterTargets("") | |||
scriptObjArray = split(oTargets(0), ".") | |||
'logmessage scriptObjArray(0) ' Sources (fixed name? Could be considered a folder.) | |||
'logmessage scriptObjArray(1) ' Materials (fixed name? Could be considered a folder.) | |||
'logmessage scriptObjArray(2) ' MaterialsLib (usually each object has its own MaterialsLib) | |||
'logmessage scriptObjArray(3) ' Material | |||
'logmessage scriptObjArray(4) ' Shader e.g. Phong | |||
shaderName = scriptObjArray(4) | |||
for each t in oTargets | |||
logmessage t | |||
if t.name = "transparency" then | |||
foundShaderParameterTransparency = true | |||
exit for | |||
end if | |||
next | |||
end if | |||
if foundShaderParameterTransparency = false then | |||
logmessage "material is not TwoSided, lets reverse now" | |||
SIConnectShaderToCnxPoint "Sources.Materials." & matLib & "." & materialName & ".Image", "Sources.Materials." & matLib & "." & materialName & "." & shaderName & ".transparency", False | |||
else | |||
logmessage "material is TwoSided, lets reverse now" | |||
RemoveAllShadersFromCnxPoint "Sources.Materials." & matLib & "." & materialName & "." & shaderName & ".transparency", siShaderCnxPointBasePorts | |||
end if | |||
Output example: | |||
' INFO : Sources.Materials.DefaultLib.Material.Phong.diffuse | |||
' INFO : material is not TwoSided, lets reverse now | |||
SIConnectShaderToCnxPoint "Sources.Materials.DefaultLib.Material.Image", "Sources.Materials.DefaultLib.Material.Phong.transparency", False | |||
' INFO : Sources.Materials.DefaultLib.Material.Phong.diffuse | |||
' INFO : Sources.Materials.DefaultLib.Material.Phong.transparency | |||
' INFO : material is TwoSided, lets reverse now | |||
RemoveAllShadersFromCnxPoint "Sources.Materials.DefaultLib.Material.Phong.transparency", siShaderCnxPointBasePorts | |||
===Clusters=== | |||
'does a certain cluster type exist ? | |||
'set cls = selection(0).activeprimitive.geometry.clusters.find( siPolygonCluster ) | |||
' more interesting is how many of that type exist | |||
for each n in selection(0).activeprimitive.geometry.clusters | |||
logmessage "Cluster " & n.name & " is of type " & n.type | |||
next | |||
' "poly" = polygon cluster | |||
' "sample" = UV cluster | |||
Output example: | |||
' INFO : Cluster Polygon4 is of type poly | |||
' INFO : Cluster Polygon1 is of type poly | |||
' INFO : Cluster Texture_Coordinates_AUTO is of type sample | |||
====Bounding box values==== | ====Bounding box values==== | ||
' this could be useful to create a bounding box for [[OBD_talk:OFGA#XML|OFGA files]] | ' this could be useful to create a bounding box for [[OBD_talk:OFGA#XML|OFGA files]] | ||
Line 1,435: | Line 1,414: | ||
===Polygons=== | ===Polygons=== | ||
... | ... | ||
==Layers== | |||
===Check if object is member of layer=== | |||
logmessage isMemberOfLayer(selection(0), "layerNameToTest") | |||
function isMemberOfLayer(obj, layerName) | |||
dim list | |||
set list = selectMembers ("Layers." & layerName, 0) ' 0 = for not changing the current selection | |||
for each o in list | |||
if o = obj then | |||
isMemberOfLayer = "yes" | |||
exit for | |||
end if | |||
next | |||
end function | |||
===Get layer name of an object=== | |||
logmessage RecursiveEnum (selection(0), false, false) | |||
function RecursiveEnum( in_Comp, in_Type, in_FirstParentOnly ) | |||
dim list, elem, layerNameToCheck | |||
set list = EnumElements( in_Comp, in_Type ) | |||
if TypeName(list) <> "Nothing" then | |||
for each elem in list | |||
if instr(elem, "Layers") = 1 and instr(elem, ".Members") > 1 then | |||
layerNameToCheck = replace(replace(elem,"Layers.", ""),".Members", "") | |||
if not layerNameToCheck = "" then | |||
RecursiveEnum = layerNameToCheck | |||
end if | |||
exit for | |||
end if | |||
next | |||
end if | |||
end function | |||
' INFO : Layer_Default | |||
==Property Page== | ==Property Page== |
edits