home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2002 April / maximum-cd-2002-04.iso / Software / Apps / gmax / gmaxinst.exe / gmaxsetup11.cab / controllerfunctions.ms < prev    next >
Encoding:
Text File  |  2001-09-12  |  3.5 KB  |  95 lines

  1. -- Functions for Controller Access, MacroScript File
  2. --
  3. -- Created:          May 17 2000
  4. -- Last Updated:     Jan 4 2000
  5. --
  6. -- Author :   Frank DeLise
  7. -- Version:  3D Studio Max Version 4.0
  8. --
  9. -- 
  10. -- Functions for accessing Controllers
  11. --***********************************************************************************************
  12. -- MODIFY THIS AT YOUR OWN RISK
  13. -- Removed IsPosXYZ() filters, moved them into FilterFunctions.ms
  14. -- Removed Prompting to the listner window Aug 15, 2000 -FD
  15. -- Updated Target additions for the new constraint function publishing October 6 2000
  16. -- Jan 4 Added support for HI and HD IK
  17.  
  18. fn AddListController OBJ Trans ListType = 
  19. (
  20.     Try
  21.     (
  22.         local xformC
  23.         -------------------------------------------------------------------------------------------
  24.         -- If object has IK assigned apply to subController, if it's an IK goal apply to Ik goal  if not, apply to controller
  25.         -------------------------------------------------------------------------------------------
  26.         if classof OBJ.controller == IKControl then  xformC = OBJ.controller.fk_sub_control.controller
  27.             else if classof OBJ.controller == IKChainControl then  xformC = OBJ.controller.IK_goal.controller
  28.                 else xformC = OBJ.controller
  29.         
  30.         if classof xformC == IK_ControllerMatrix3Controller do
  31.         (    if (substring (Trans as string) 1 3) as name == #pos then Trans = getsubanimname xformC 1
  32.             else if (substring (Trans as string) 1 3) as name == #rot then Trans = getsubanimname xformC 2
  33.         )
  34.  
  35.         if classof xformC == Link_Constraint do xformC = xformC.link_params
  36.  
  37.         local oldC = getPropertyController xformC trans
  38.         if classof oldC != ListType then
  39.         (    local newC = execute (ListType as string + "()")
  40.             if (setPropertyController xformC trans newC) == undefined do throw 0
  41.             newC
  42.         )
  43.         else
  44.             oldC
  45.     )
  46.     Catch (MessageBox "List Controller Error!" Title:"Controller Functions";throw())
  47.  
  48. fn AddConstraint OBJ Trans Constraint List =
  49. (
  50.     Try
  51.     (    
  52.         local xformC
  53.         -------------------------------------------------------------------------------------------
  54.         -- If object has IK assigned apply to subController, if not, apply to controller
  55.         -------------------------------------------------------------------------------------------
  56.         if classof OBJ.controller == IKControl then xformC = OBJ.controller.fk_sub_control.controller
  57.             else if classof OBJ.controller == IKChainControl then xformC = OBJ.controller.IK_goal.controller
  58.                 else xformC = OBJ.controller
  59.         
  60.         if classof xformC == IK_ControllerMatrix3Controller do
  61.         (    if (substring (Trans as string) 1 3) as name == #pos then Trans = getsubanimname xformC 1
  62.             else if (substring (Trans as string) 1 3) as name == #rot then Trans = getsubanimname xformC 2
  63.         )
  64.  
  65.         if classof xformC == Link_Constraint do xformC = xformC.link_params
  66.         
  67.         local newC = execute (constraint as string + "()")
  68.         If List == True then
  69.         (    local oldC = getPropertyController xformC  trans
  70.             oldC.available.controller = newC
  71.         )
  72.         Else 
  73.             if (setPropertyController xformC trans newC) == undefined do throw 0
  74.         newC
  75.     )
  76.     Catch (MessageBox "Constraint Error!" Title:"Controller Functions";throw())
  77. )
  78.  
  79. fn SetActiveController Controller subController =
  80. (
  81.     Try
  82.     (    local index
  83.         for i = 1 to (Controller.numsubs-1) do
  84.             if controller[i].controller == subController do index = i
  85.         if index != undefined do
  86.         (    listCtrl.setActive controller index
  87.             format "Setting % as active controller\n" (listCtrl.getName controller index)
  88.         )
  89.     )
  90.     Catch ( MessageBox "Set Active Controller Error" Title:"Controller Functions")
  91. )
  92.  
  93.  
  94.