-- -- File:: rockstar/helpers/scenestats.ms -- Description:: Gta Scene Statistics -- -- Author:: Greg Smith 1 then ( matID = "multiple" ) else ( matID = matID as string ) append RsTexInfoList (objTexInfo texmaplist[i] objPolys[i] (objWidth[i] / 2) (objHeight[i] / 2) objSize[i] matID objTexMaps[i] objObjects[i] objObjectFaces[i]) ) RefreshSelectedTextures() ) --//////////////////////////////////////////////////////////// -- events --//////////////////////////////////////////////////////////// on lstObjectOrder selected arg do ( RefreshSelectedObjects() ) on lstTextureOrder selected arg do ( RefreshSelectedTextures() ) on cmdSaveReport pressed do ( saveFilename = getsavefilename caption:"Save report to:" filename:"out.csv" types:"Comma Seperated (*.csv)|*.csv" if saveFilename == undefined then return 0 saveFile = openfile saveFilename mode:"wb" if saveFile == undefined then return 0 allobj = #() RsGetMapObjectsWithXrefs rootnode.children allobj RsSetupBlocks true -- create blocks BlockNames = #() SelectionSets = #() BlockAreas = #() BlockObjects = #() idxBlockID = getattrindex "Gta Object" "BlockID" idxBlockIDMilo = getattrindex "Gta MILOTri" "BlockID" for obj in allobj do ( blockName = "" if getattrclass obj == "Gta Object" then ( blockName = RsLowercase(getattr obj idxBlockID) ) else if getattrclass obj == "Gta MILOTri" then ( blockName = RsLowercase(getattr obj idxBlockIDMilo) ) if blockName == "" then blockName = "unassigned" idxFound = finditem BlockNames blockName if idxFound == 0 then ( objFoundList = getnodebyname blockName exact:true all:true objValid = #() areaValue = 0.0 for objFound in objFoundList do ( if classof objFound == GtaBlock then ( append objValid objFound areaValue = objFound.plane.length * objFound.plane.width ) ) append BlockNames blockName append SelectionSets #(obj) append BlockAreas areaValue append BlockObjects objValid ) else ( append SelectionSets[idxFound] obj ) ) blockTotalPolys = #() blockTotalCollPolys = #() blockTotalModelSize = #() blockTotalTXDSize = #() blockTotalTXDCount = #() blockTotalLodSize = #() blockTotalInteriorSize = #() blockTotalPropSize = #() blockTotalXrefSize = #() for i = 1 to BlockNames.count do ( blockName = BlockNames[i] UpdateObjectInfo SelectionSets[i] true true true updateProgress:false barLoad.value = ((i as float) / BlockNames.count) * 100.0 format ("Block: " + blockName + "\n\n") to:saveFile format ("Name" + ",") to:saveFile format ("Textures" + ",") to:saveFile format ("Polys" + ",") to:saveFile format ("Collision Polys" + ",") to:saveFile format ("LOD Distance" + ",") to:saveFile format ("Size (k)" + ",") to:saveFile format ("TXD" + ",") to:saveFile format ("TXD Size (k)" + ",") to:saveFile format ("TXD Textures" + ",") to:saveFile format ("Volume" + ",") to:saveFile format ("Poly Density" + ",") to:saveFile format ("Mem Density" + ",") to:saveFile format ("TXD Percent" + ",") to:saveFile format ("Is Lod" + ",") to:saveFile format ("Is Xref" + ",") to:saveFile format ("Is Prop" + ",") to:saveFile format ("Is Interior" + "\n") to:saveFile currTotalPolys = 0 currTotalCollPolys = 0 currTotalModelSize = 0 currTotalTXDSize = 0 currTotalLodSize = 0 currTotalInteriorSize = 0 currTotalPropSize = 0 currTotalXrefSize = 0 blockTxds = #() for j = 1 to RsObjList.count do ( thisTotalPolys = RsObjList[j].polys as number thisTotalCollPolys = RsObjList[j].collpolys as number thisTotalModelSize = RsObjList[j].size as number thisTotalTXDSize = RsObjList[j].txdsize as number if thisTotalPolys != undefined then currTotalPolys = currTotalPolys + thisTotalPolys if thisTotalCollPolys != undefined then currTotalCollPolys = currTotalCollPolys + thisTotalCollPolys if thisTotalModelSize != undefined then ( currTotalModelSize = currTotalModelSize + thisTotalModelSize if RsObjList[j].islod then currTotalLodSize = currTotalLodSize + thisTotalModelSize if RsObjList[j].isxref then currTotalXrefSize = currTotalXrefSize + thisTotalModelSize if RsObjList[j].isprop then currTotalPropSize = currTotalPropSize + thisTotalModelSize if RsObjList[j].isinterior then currTotalInteriorSize = currTotalInteriorSize + thisTotalModelSize ) if finditem blockTxds RsObjList[j].txd == 0 then ( append blockTxds RsObjList[j].txd if thisTotalTXDSize != undefined then ( currTotalTXDSize = currTotalTXDSize + thisTotalTXDSize if RsObjList[j].islod then currTotalLodSize = currTotalLodSize + thisTotalTXDSize if RsObjList[j].isxref then currTotalXrefSize = currTotalXrefSize + thisTotalTXDSize if RsObjList[j].isprop then currTotalPropSize = currTotalPropSize + thisTotalTXDSize if RsObjList[j].isinterior then currTotalInteriorSize = currTotalInteriorSize + thisTotalTXDSize ) ) format (RsObjList[j].name + ",") to:saveFile format (RsObjList[j].textures + ",") to:saveFile format (RsObjList[j].polys + ",") to:saveFile format (RsObjList[j].collpolys + ",") to:saveFile format (RsObjList[j].loddistance + ",") to:saveFile format (RsObjList[j].size + ",") to:saveFile format (RsObjList[j].txd + ",") to:saveFile format (RsObjList[j].txdsize + ",") to:saveFile format (RsObjList[j].txdtextures + ",") to:saveFile format (RsObjList[j].volume + ",") to:saveFile format (RsObjList[j].polydensity + ",") to:saveFile format (RsObjList[j].memdensity + ",") to:saveFile format (RsObjList[j].txdpercent + ",") to:saveFile format ((RsObjList[j].islod as string) + ",") to:saveFile format ((RsObjList[j].isxref as string) + ",") to:saveFile format ((RsObjList[j].isprop as string) + ",") to:saveFile format ((RsObjList[j].isinterior as string) + "\n") to:saveFile ) append blockTotalPolys currTotalPolys append blockTotalCollPolys currTotalCollPolys append blockTotalModelSize currTotalModelSize append blockTotalTXDSize currTotalTXDSize append blockTotalLodSize currTotalLodSize append blockTotalXrefSize currTotalXrefSize append blockTotalPropSize currTotalPropSize append blockTotalInteriorSize currTotalInteriorSize append blockTotalTXDCount blockTxds.count format ("\n\n") to:saveFile ) format ("Block Summary\n\n") to:saveFile format ("Name" + ",") to:saveFile format ("Object Count" + ",") to:saveFile format ("TXD Count" + ",") to:saveFile format ("Total Poly Count" + ",") to:saveFile format ("Total Collision Poly Count" + ",") to:saveFile format ("Total Model Size (k)" + ",") to:saveFile format ("Total TXD Size (k)" + ",") to:saveFile format ("Total (k)" + ",") to:saveFile format ("Lod Size (k),") to:saveFile format ("Xref Size (k),") to:saveFile format ("Prop Size (k),") to:saveFile format ("Interior Size (k),") to:saveFile format ("Volume (m2)" + ",") to:saveFile format ("Polys/m2" + ",") to:saveFile format ("Coll Polys/m2" + ",") to:saveFile format ("Memory/m2" + "\n") to:saveFile totalObjectCount = 0 totalTXDCount = 0 totalPolyCount = 0 totalCollPolyCount = 0 totalModelSize = 0 totalTXDSize = 0 totalVolume = 0 totalLodSize = 0 totalXrefSize = 0 totalPropSize = 0 totalInteriorSize = 0 for i = 1 to BlockNames.count do ( if BlockAreas[i] != -1.0 then ( totalObjectCount = totalObjectCount + SelectionSets[i].count totalTXDCount = totalTXDCount + blockTotalTXDCount[i] totalPolyCount = totalPolyCount + blockTotalPolys[i] totalCollPolyCount = totalCollPolyCount + blockTotalCollPolys[i] totalModelSize = totalModelSize + blockTotalModelSize[i] totalTXDSize = totalTXDSize + blockTotalTXDSize[i] totalVolume = totalVolume + BlockAreas[i] totalLodSize = totalLodSize + blockTotalLodSize[i] totalXrefSize = totalXrefSize + blockTotalXrefSize[i] totalPropSize = totalPropSize + blockTotalPropSize[i] totalInteriorSize = totalInteriorSize + blockTotalInteriorSize[i] ) format (BlockNames[i] + ",") to:saveFile format ((SelectionSets[i].count as string) + ",") to:saveFile format ((blockTotalTXDCount[i] as string) + ",") to:saveFile format ((blockTotalPolys[i] as string) + ",") to:saveFile format ((blockTotalCollPolys[i] as string) + ",") to:saveFile format ((blockTotalModelSize[i] as string) + ",") to:saveFile format ((blockTotalTXDSize[i] as string) + ",") to:saveFile format (((blockTotalTXDSize[i] + blockTotalModelSize[i]) as string) + ",") to:saveFile format ((blockTotalLodSize[i] as string) + ",") to:saveFile format ((blockTotalXrefSize[i] as string) + ",") to:saveFile format ((blockTotalPropSize[i] as string) + ",") to:saveFile format ((blockTotalInteriorSize[i] as string) + ",") to:saveFile format ((BlockAreas[i] as string) + ",") to:saveFile if BlockAreas[i] != -1.0 then ( format ((((float)blockTotalPolys[i] / BlockAreas[i]) as string) + ",") to:saveFile format ((((float)blockTotalCollPolys[i] / BlockAreas[i]) as string) + ",") to:saveFile format ((((float)(blockTotalTXDSize[i] + blockTotalModelSize[i]) / BlockAreas[i]) as string) + "\n") to:saveFile ) else ( format ("0,0,0\n") to:saveFile ) ) format ("TOTAL (without unasssigned),") to:saveFile format ((totalObjectCount as string) + ",") to:saveFile format ((totalTXDCount as string) + ",") to:saveFile format ((totalPolyCount as string) + ",") to:saveFile format ((totalCollPolyCount as string) + ",") to:saveFile format ((totalModelSize as string) + ",") to:saveFile format ((totalTXDSize as string) + ",") to:saveFile format (((totalModelSize + totalTXDSize) as string) + ",") to:saveFile format ((totalLodSize as string) + ",") to:saveFile format ((totalXrefSize as string) + ",") to:saveFile format ((totalPropSize as string) + ",") to:saveFile format ((totalInteriorSize as string) + ",") to:saveFile format ((totalVolume as string) + ",") to:saveFile format ((((float)totalPolyCount / totalVolume) as string) + ",") to:saveFile format ((((float)totalCollPolyCount / totalVolume) as string) + ",") to:saveFile format ((((float)(totalModelSize + totalTXDSize) / totalVolume) as string) + "\n") to:saveFile close saveFile mapName = (filterstring maxfilename ".")[1] RsCopyFilename = RsConfigInfos[RsCurrentConfig].genstreamdir + "mapstats_details/" + mapName + ".csv" RsMakeSurePathExists RsCopyFilename copyfile saveFilename RsCopyFilename RsTotalFilename = RsConfigInfos[RsCurrentConfig].genstreamdir + "mapstats/" + mapName + ".csv" saveFile = openfile RsTotalFilename mode:"w" if saveFile != undefined then ( format ("Name" + ",") to:saveFile format ("Object Count" + ",") to:saveFile format ("TXD Count" + ",") to:saveFile format ("Total Poly Count" + ",") to:saveFile format ("Total Collision Poly Count" + ",") to:saveFile format ("Total Model Size (k)" + ",") to:saveFile format ("Total TXD Size (k)" + ",") to:saveFile format ("Total (k)" + ",") to:saveFile format ("Lod Size (k),") to:saveFile format ("Xref Size (k),") to:saveFile format ("Prop Size (k),") to:saveFile format ("Interior Size (k),") to:saveFile format ("Volume (m2)" + ",") to:saveFile format ("Polys/m2" + ",") to:saveFile format ("Coll Polys/m2" + ",") to:saveFile format ("Memory/m2" + "\n") to:saveFile for i = 1 to BlockNames.count do ( format (BlockNames[i] + ",") to:saveFile format ((SelectionSets[i].count as string) + ",") to:saveFile format ((blockTotalTXDCount[i] as string) + ",") to:saveFile format ((blockTotalPolys[i] as string) + ",") to:saveFile format ((blockTotalCollPolys[i] as string) + ",") to:saveFile format ((blockTotalModelSize[i] as string) + ",") to:saveFile format ((blockTotalTXDSize[i] as string) + ",") to:saveFile format (((blockTotalTXDSize[i] + blockTotalModelSize[i]) as string) + ",") to:saveFile format ((blockTotalLodSize[i] as string) + ",") to:saveFile format ((blockTotalXrefSize[i] as string) + ",") to:saveFile format ((blockTotalPropSize[i] as string) + ",") to:saveFile format ((blockTotalInteriorSize[i] as string) + ",") to:saveFile format ((BlockAreas[i] as string) + ",") to:saveFile if BlockAreas[i] != -1.0 then ( format ((((float)blockTotalPolys[i] / BlockAreas[i]) as string) + ",") to:saveFile format ((((float)blockTotalCollPolys[i] / BlockAreas[i]) as string) + ",") to:saveFile format ((((float)(blockTotalTXDSize[i] + blockTotalModelSize[i]) / BlockAreas[i]) as string) + "\n") to:saveFile ) else ( format ("0,0,0\n") to:saveFile ) ) close saveFile ) RsTotalFilename = RsConfigInfos[RsCurrentConfig].genstreamdir + "mapstats/blockmap/" + mapName + ".csv" RsMakeSurePathExists RsTotalFilename saveFile = openfile RsTotalFilename mode:"w" if saveFile != undefined then ( format ("VER2\n") to:saveFile for i = 1 to BlockNames.count do ( if BlockNames[i] == "unassigned" then continue format (BlockNames[i] + ",") to:saveFile format ((BlockObjects[i].count as string) + ",") to:saveFile for blockObj in BlockObjects[i] do ( format ((blockObj.pos.x as string) + ",") to:saveFile format ((blockObj.pos.y as string) + ",") to:saveFile format (((blockObj.rotation as eulerangles).z as string) + ",") to:saveFile format ((blockObj.plane.length as string) + ",") to:saveFile format ((blockObj.plane.width as string) + ",") to:saveFile ) format ((SelectionSets[i].count as string) + ",") to:saveFile format ((blockTotalTXDCount[i] as string) + ",") to:saveFile format ((blockTotalPolys[i] as string) + ",") to:saveFile format ((blockTotalCollPolys[i] as string) + ",") to:saveFile format ((blockTotalModelSize[i] as string) + ",") to:saveFile format ((blockTotalTXDSize[i] as string) + ",") to:saveFile format (((blockTotalTXDSize[i] + blockTotalModelSize[i]) as string) + ",") to:saveFile format ((blockTotalLodSize[i] as string) + ",") to:saveFile format ((blockTotalXrefSize[i] as string) + ",") to:saveFile format ((blockTotalPropSize[i] as string) + ",") to:saveFile format ((blockTotalInteriorSize[i] as string) + ",") to:saveFile format ((BlockAreas[i] as string) + ",") to:saveFile if BlockAreas[i] != -1.0 then ( format ((((float)blockTotalPolys[i] / BlockAreas[i]) as string) + ",") to:saveFile format ((((float)blockTotalCollPolys[i] / BlockAreas[i]) as string) + ",") to:saveFile format ((((float)(blockTotalTXDSize[i] + blockTotalModelSize[i]) / BlockAreas[i]) as string) + "\n") to:saveFile ) else ( format ("0,0,0\n") to:saveFile ) ) close saveFile ) UpdateSelectedObjects() ) on cmdSaveCurrent pressed do ( saveFilename = getsavefilename caption:"Save report to:" filename:"out.csv" types:"Comma Seperated (*.csv)|*.csv" if saveFilename == undefined then return 0 saveFile = openfile saveFilename mode:"wb" if saveFile == undefined then return 0 format ("Name" + ",") to:saveFile format ("Textures" + ",") to:saveFile format ("Polys" + ",") to:saveFile format ("Collision Polys" + ",") to:saveFile format ("LOD Distance" + ",") to:saveFile format ("Size (k)" + ",") to:saveFile format ("TXD" + ",") to:saveFile format ("TXD Size (k)" + ",") to:saveFile format ("TXD Textures" + ",") to:saveFile format ("Volume" + ",") to:saveFile format ("Poly Density" + ",") to:saveFile format ("Mem Density" + "\n") to:saveFile for i = 0 to (axObjectList.Items.Count - 1) do ( -- format (axObjectList.Items.Item[i].Text + ",") to:saveFile for j = 0 to 10 do ( format (axObjectList.Items.Item[i].SubItems.Item[j].Text + ",") to:saveFile ) format (axObjectList.Items.Item[i].SubItems.Item[11].Text + "\n") to:saveFile ) close saveFile ) on cmdUpdate pressed do ( UpdateSelectedObjects() ) on axTextureList ItemSelectionChanged args do ( if (axTextureList.SelectedItems.Count == 0) then ( return 0 ) img = bitmap 200 200 rm = rendermap RsTexInfoList[args.ItemIndex + 1].texmap into:img size:[200,200] bmpTex.bitmap = img close rm ) on axObjectList DoubleClick do ( objFound = getnodebyname axObjectList.SelectedItems.Item[0].Text exact:true if objfound != undefined do ( select objfound max zoomext sel ) ) on cmdEdit pressed do ( try( shelllaunch ("Photoshop.exe") RsTexInfoList[axTextureList.SelectedItems.Item[0].Index + 1].texmap.filename ) catch (Messagebox "Select a texture from the texture list before clicking edit") ) fn RecSelectByName name rootobj outList = ( if rootobj != rootnode and getattrclass rootobj == "Gta Object" then ( objName = RsLowercase(rootobj.name) if classof rootobj == XRefObject then ( objName = RsLowercase(rootobj.objectname) ) if objName == name then ( append outList rootobj ) ) for childobj in rootobj.children do ( RecSelectByName name childobj outList ) ) on cmdSelectObj pressed do ( /* ActiveX version if axObjectList.ListItems.Count < 1 then return false */ if axObjectList.SelectedItems.Count < 1 then return false objName = RsLowercase(axObjectList.SelectedItems.Item[0].Text) if objName[1] == "{" then ( objName = substring objName 2 (objName.count - 2) ) objList = #() print objName RecSelectByName objName rootnode objList select objList ) on cmdSelect pressed do ( subobjectlevel = 0 if axTextureList.SelectedItems.Count < 1 then ( return 0 ) idxFound = (axTextureList.SelectedItems.Item[0].Index + 1) if RsTexInfoList[idxFound].objects.count == 1 then ( objFound = RsTexInfoList[idxFound].objects[1] select objfound max zoomext sel if idxFound != 0 and idxObject != 0 then ( faceSel = #{} faceSel.count = objFound.numfaces for item in RsTexInfoList[idxFound].objectfaces[1] do ( faceSel[item] = true ) if classof objFound == Editable_Mesh then ( setFaceSelection objFound faceSel ) else ( polyOp.setFaceSelection objFound faceSel ) setCommandPanelTaskMode(#modify) subobjectlevel = 3 ) ) else ( selObjs = #() for i = 1 to RsTexInfoList[idxFound].objects.count do ( objFound = RsTexInfoList[idxFound].objects[i] append selObjs objFound if idxFound != 0 and idxObject != 0 then ( faceSel = #{} faceSel.count = objFound.numfaces for item in RsTexInfoList[idxFound].objectfaces[1] do ( faceSel[item] = true ) if classof objFound == Editable_Mesh then ( setFaceSelection objFound faceSel ) else ( polyOp.setFaceSelection objFound faceSel ) ) ) select selObjs max zoomext sel messagebox "multiple objects selected" ) ) on axObjectList MouseUp Button Shift x y do ( print("axObjectList MouseUp") UpdateSelectedTextures() ) on cmdOK pressed do ( DestroyDialog RsSceneStatsRoll ) on RsSceneStatsRoll open do ( LoadIDEFilenames() --showevents axObjectList --showproperties axObjectList axObjectList.FullRowSelect = true axObjectList.Columns.add "Name" 120 axObjectList.Columns.add "Textures" 56 axObjectList.Columns.add "Poly" 56 axObjectList.Columns.add "Coll Polys" 60 axObjectList.Columns.add "LOD Distance" 60 axObjectList.Columns.add "Size (k)" 60 axObjectList.Columns.add "TXD" 60 axObjectList.Columns.add "TXD Size (k)" 80 axObjectList.Columns.add "TXD Textures" 80 axObjectList.Columns.add "Volume" 76 axObjectList.Columns.add "Poly Density" 76 axObjectList.Columns.add "Mem Density" 76 axObjectList.Columns.add "TXD Percent" 76 axObjectList.Columns.add "Instances" 80 axObjectList.Columns.add "Total Size (k)" 85 axObjectList.View = (dotNetClass "System.Windows.Forms.View").Details axTextureList.Columns.add "Name" 160 axTextureList.Columns.add "Polys" 60 axTextureList.Columns.add "Width" 60 axTextureList.Columns.add "Height" 60 axTextureList.Columns.add "Size (k)" 60 axTextureList.Columns.add "Material ID" 80 axTextureList.View = (dotNetClass "System.Windows.Forms.View").Details ) on RsSceneStatsRoll close do ( RsObjList = #() RsTexInfoList = #() ) on RsSceneStatsRoll resized pntSize do ( currPos = GetDialogPos RsSceneStatsRoll RsSettingWrite "rsstatsroll" "width" (pntSize[1]) RsSettingWrite "rsstatsroll" "height" (pntSize[2]) DestroyDialog RsSceneStatsRoll CreateDialog RsSceneStatsRoll pos:currPos modal:false width:pntSize[1] height:pntSize[2] style:#(#style_resizing, #style_titlebar, #style_border, #style_sysmenu ) RefreshSelectedObjects() RefreshSelectedTextures() ) ) DestroyDialog RsSceneStatsRoll CreateDialog RsSceneStatsRoll modal:false width:1150 height:(RsSettingsReadInteger "rsstatsroll" "height" 520) style:#(#style_resizing, #style_titlebar, #style_border, #style_sysmenu )