This is a simple snippet that can be used with a command line or keyboard input to allow the user to create a webpage showing basic information about a model file, such as how long it took to load, how many animation frames it has and what limbs it has and what their parent limbs are.
Requires
Matrix1 utilities.
`bMTool_ObjectDetails
`bMTool_ObjectDetails.dba
`======================
Global Dim OutputLimbs(0)
Print "Model details"
Print "======================================"
` Obtain optional file from the command line
clFile$ = Cl$()
` Continue to request model file names
Repeat
` Request file name
Print
If clFile$ <> ""
sFile$ = clFile$
clFile$ = "" ` Command line file no longer required
Else
Input "Enter a model filename to examine: ", sFile$
Endif
iTime = Timer()
` If we have been given a file, proceed
If sFile$ <> ""
` Make sure 1 ms passes if the close button was not pressed
Wait 1
IF File Exist( sFile$ )
iExtLen = 0
If Fast Lower$( Fast Right$( sFile$, 2 ) ) = ".x" Then iExtLen = 2
If Fast Lower$( Fast Right$( sFile$, 4 ) ) = ".dbo" Then iExtLen = 4
` The extention must be valid to proceed.
If iExtLen = 0
Print sFile$; " is an invalid model file"
Print
Else
Print "Opening model file"
iMs = Timer()
Load Object sFile$, 1
` Hide the camera
Set Camera View 0,0,0,0
iMs = Timer() - iMs
Print "Loaded in "; iMs; " ms"
sOutFile$ = Fast Left$( sFile$, Fast Len( sFile$ ) - iExtLen) + ".html"
If File Exist( sOutFile$ ) Then Delete File sOutFile$
Open To Write 1, sOutFile$
Split String sFile$, "\" : iFileNameIndex = Split Count()
sFileName$ = Split Word$( iFileNameIndex )
` Write information to the HTML file
Write String 1, "<html>"
Write String 1, " <head>"
Write String 1, " <title>Model Data : " + sFileName$ + "</title>"
Write String 1, " </head>"
Write String 1, " <body>"
Write String 1, " <h1>" + sFileName$ + "</h1><hr/>"
Write String 1, " <i>Loaded in " + Str$(iMs) + " milliseconds</i>"
Write String 1, " <div>Total limbs: " + Str$( Get Limb Count(1) ) + "</div>"
Write String 1, " <div>Total Animation Frames: " + Str$( Total Object Frames(1) ) + "</div>"
Write String 1, " <div>FVF format: " + Str$( Get Limb FVF(1,0) ) + "</div>"
Write String 1, " <h2>Limbs</h2>"
iLimbCount = Get Limb Count(1)
` Write each limb to the file
For i = 0 to iLimbCount - 1
OutputLimb(i,"")
Next i
Print "Saved model details in "; sOutFile$
Write String 1, " </Body>"
Write String 1, "</html>"
Close File 1
Delete Object 1
Endif
Else
Print
Print "File does not exist"
Endif
Endif
` If the close button is pressed, end.
` We know the close button is pressed if the time passed is less than 1 ms
If Timer() = iTime Then End
` End if a commandline was used
If cl$() <> "" Then End
Until EscapeKey()
End
//================================================================
Function OutputLimb(i, sPrefix$)
For l = 1 to Array Count( OutputLimbs() )
If OutputLimbs(l) = i Then ExitFunction
Next l
Array Insert At Bottom OutputLimbs()
l = Array Count( OutputLimbs() )
OutputLimbs(l) = i
` Write the limb name
Write String 1, " <div>" + sPrefix$ + "<strong>" + Str$(i) + "</strong> Name: " + Limb Name$(1,i) + "</div>"
For cl = 0 to Get Limb Count(1) - 1
lp = Get Limb Parent(1,cl)
If lp = i
` Output the child limb
OutputLimb(cl, sPrefix$ + "---")
Endif
Next cl
Endfunction
