---------------------------------------------------- -- UCX Collision Box -- 05.10.2010 -- Sam Deiter --------------------------------------------------- --------------------------------------------------- -- This script allows you to make a a UCX collision box using your current selection -- in edit poly mode. --------------------------------------------------- macroscript UCXCollisionBoxMacro category:"Parabellum Tools" buttonText:"UCX Collision Box" toolTip:"Make a single UCX Collision Box" ( --Set up the min and max values that will need to create the box fn minimum a b = ( if a > b then return b return a ) fn maximum a b = ( if a < b then return b return a ) -- Get your current selection selectedFaces = polyop.GetFaceSelection selection[1] selectedVerts = polyop.getVertsUsingFace selection[1] selectedFaces -- Min and Max of your selection boxmin = point3 0 0 0 boxmax = point3 0 0 0 firstVertex = true -- Loop to see the min and max of your selection for i = 1 to selectedVerts.count do ( if selectedVerts[i] == true do ( vertex = selection[1].verts[i] if firstVertex == true then ( boxmin.x = vertex.pos.x boxmax.x = vertex.pos.x boxmin.y = vertex.pos.y boxmax.y = vertex.pos.y boxmin.z = vertex.pos.z boxmax.z = vertex.pos.z firstVertex = false ) else ( boxmin.x = minimum vertex.pos.x boxmin.x boxmin.y = minimum vertex.pos.y boxmin.y boxmin.z = minimum vertex.pos.z boxmin.z boxmax.x = maximum vertex.pos.x boxmax.x boxmax.y = maximum vertex.pos.y boxmax.y boxmax.z = maximum vertex.pos.z boxmax.z ) ) ) center = point3 0 0 0 center.x = (boxmax.x - boxmin.x) * 0.5 + boxmin.x center.y = (boxmax.y - boxmin.y) * 0.5 + boxmin.y center.z = (boxmax.z - boxmin.z) * 0.5 + boxmin.z print center print boxmax print boxmin --for i in obj = selection[1].selectedFaces collect i.index do --for i in local obj = selection[1] do -- Creat a collision prim using your selection ( l = (boxmax.y - boxmin.y) w = (boxmax.x - boxmin.x) h = (boxmax.z - boxmin.z) c = center - [0, 0, (h/2)] the_box = Box prefix: "UCX_Collision_Hull_" lengthsegs:1 widthsegs:1 heightsegs:1 length:l width:w height:h pos:c convertToPoly(the_box) the_box.wireColor = (color 255 0 255 ) the_box.xray = on ) )