|
I made this script recently which uses this program called Stanhull.exe in XSI
(which can be downloaded here: http://www.amillionpixels.us/sourcecode.htm )
After working with Source for about 4 years now, I’ve found its quite impossible to compile a decent phy model for the Source engine without being able to generate perfect convex meshes beforehand.
If any object is even minutely NOT convex the physics model turns out based on all the outer vertices on the model, rather than the seperate elements (resulting in a highly inaccurate and uneconomical shrinkwrapped effect).
This script is very rough (WIP) but it really speeds up making accurate phy models for Source as everything required to make the model work is automated. Once converted the convex meshes are reimported, discontinuity is turned off and a simple cube texture projection is added. You end up with a series of polymeshes called hull**. These are then exported as a physics VMF file.
Note: all meshes to be converted should be in the scene root only.
(Hope it’s useful.)
'UBER-quick perfect phyboxes from selected polymeshes
by Jason Wells aka redmotion - Feb 2009
'NOTE: that all scene objects to be converted should be under the scene root
dim name,Objdir,StanhullDir,getObjname,fileOutLoc,cmd,inObj,strCurrentPath
'-------------------------------------------------------------------------------------------
'set up directory paths here 'Objdir = the directory you want the exported Obj to go to (change if you wish)
Objdir = "C:\3d\Stanhull\"
'StanhullDir = the directory you have put stanhull.exe in (change if you wish) StanhullDir = "C:\3d\Stanhull\"
'current path being used by XSI
strCurrentPath = CreateObject("Scripting.FileSystemObject").GetAbsolutePathName(".")
fileOutLoc = strCurrentPath & "\hull.obj"
LogMessage fileOutLoc
'--------------------------------------------------------------------------------------------
set list = GetValue( "SelectionList" )
if list.count = 0 then
MsgBox "Please select at least one polymesh object first!!"
else
'start rendermap make routine - depending on scene size and object complexity this could take a while... :)
for each item in list
name = item.name
if item.type = "polymsh" then
'select objects one by one and export
SelectObj name, , True
getObjname = Objdir & "convert.obj"
ObjExport getObjname, , , , , , , , , , 0, False, , , False
'set up system command to run Stanhull.exe
cmd = StanhullDir & "StanHull " & getObjname
cmdResult = system( cmd )
set inObj = ObjImport( fileOutLoc, 1, 0, True, True, False, True )
'select new object and set up geometry approximation as needed for .phy SMDs
SelectObj inObj, , True
MakeLocal inObj & ".geomapprox", siDefaultPropagation
SetValue inObj & ".geomapprox.gapproxmoad", False
'Create projection and freeze - projection needed to export
CreateProjection , siTxtCubic, siTxtDefaultCubic, , "Texture_Projection"
FreezeModeling
end if
next
end if
INSTRUCTIONS -
unzip stanhull.exe to a directory of your choice and adjust the entries in the script above that start with:
StanhullDir =
(to the path to where you’ve put stanhull.exe)
Objdir =
(to where temp .obj file is put - use the same dir as above for ease)
Select all the meshs to be made convex in the scene, run the script. (convex hull meshes will be piaced back in the scene)
|