An-Cadsolutions      Imgsystems

Kirjoittaja Aihe: 3dsmax: Get controller info  (Luettu 538 kertaa)

xcx

  • Administrator
  • *****
  • Viestejä: 2302
  • Sukupuoli: Mies
    • Profiili
    • Verajankorva.com
    • Sähköposti
3dsmax: Get controller info
« : Toukokuu 11, 2006, 01:44:59 pm »
Muutin ketjun niin että edaan tätä yhtä postia. Ei tule niin pitkä.

Supporttaa nyt
- Lookat
- Position constraint
- Orientation constraint
- Path constraint

Koodia: [Valitse]
-- Version 0.4b

getConstraintInfo = -1
getAllControllersFromList = -1
getOrientationConstraintValues = -1
getPositionConstraintValues = -1
getPathConstraintValues = -1


------------------------------------------------------------------------------------------------
-- Get controller info
------------------------------------------------------------------------------------------------
fn getConstraintInfo fpObj =
(
if (selection.count == 0) then
return false

positionlist = fpObj.position.controller
rotationlist = fpObj.rotation.controller
scalelist = fpObj.scale.controller

poscont = -1
rotcont = -1
scacont = -1

positioncontrollers = #()
rotationcontrollers = #()
scalecontrollers = #()

iPosCount = 0
if (classof positionlist) != Position_List then
(
iPosCount = 1
poscont = (classof positionlist)
)
else
(
iPosCount = positionlist.count
poscont = "Position_List"
positioncontrollers = (getAllControllersFromList positionlist)
)

iRotCount = 0
if (classof rotationlist) != Rotation_List then
(
iRotCount = 1
rotcont = (classof rotationlist)
)
else
(
iRotCount = rotationlist.count
rotcont = "Rotation_List"
rotationcontrollers = (getAllControllersFromList rotationlist)
)

iScaCount = 0
if (classof scalelist) != Scale_List then
(
iScaCount = 1
scacont = (classof scalelist)
)
else
(
iScaCount = scalelist.count
scacont = "Scale_List"
scalecontrollers = (getAllControllersFromList scalelist)
)



format "\n\n******************************************\n\n"
format "\nController info from object %\n\n" (fpObj.name)
/*
format "\t% position controllers\n" iPosCount
format "\t% rotation controllers\n" iRotCount
format "\t% scale controllers\n" iScaCount
format "\n"
format "\tPosition controller\t : %\n" poscont
format "\tRotation controller\t : %\n" rotcont
format "\tScale controller\t : %\n" scacont
format "\n"
*/

if (positioncontrollers.count != 0) do
(
format "\tPositionList controllers :\n"
for i=1 to positioncontrollers.count do
(
format "\t|- [%] %\n" i (positioncontrollers[i].name)
values = #()
printvalues = false

if (classof (positioncontrollers[i].controller) == Position_Constraint) do
(
values = getPositionConstraintValues (positioncontrollers[i].controller)
printvalues = true
)

if (classof (positioncontrollers[i].controller) == Path_Constraint) do
(
values = getPathConstraintValues (positioncontrollers[i].controller)
printvalues = true
)

if (printvalues) do
(
printvalues = false
if values.count != 0 do
(
for j=1 to values.count do
format "\t|\t|- %\n" (values[j])
)
)
)
)

format "\n"

if (rotationcontrollers.count != 0) do
(
format "\tRotationList controllers :\n"
for i=1 to rotationcontrollers.count do
(
format "\t|- [%] %\n" i (rotationcontrollers[i].name)
values = #()
printvalues = false

if (classof (rotationcontrollers[i].controller) == LookAt_Constraint) do
(
values = getLookAtValues (rotationcontrollers[i].controller)
printvalues = true
)

if (classof (rotationcontrollers[i].controller) == Orientation_Constraint) do
(
values = getOrientationConstraintValues (rotationcontrollers[i].controller)
printvalues = true
)

if printvalues do
(
printvalues = false
if (values.count != 0) do
(
for j=1 to values.count do
format "\t|\t|- %\n" (values[j])
)
)
)
)

format "\n"

if (scalecontrollers.count != 0) do
(
format "\tScaleList controllers :\n"
for i=1 to scalecontrollers.count do
format "\t%\t%\n" i (scalecontrollers[i].name)
)

format "\n\n******************************************\n\n"
)
------------------------------------------------------------------------------------------------



------------------------------------------------------------------------------------------------
-- Get all controllers from controller list.
------------------------------------------------------------------------------------------------
fn getAllControllersFromList fpControllerList =
(
if (fpControllerList == undefined) do
return undefined

aControllers = #()
for i=1 to fpControllerList.count do
append aControllers (fpControllerList[i])

return aControllers
)
------------------------------------------------------------------------------------------------



------------------------------------------------------------------------------------------------
-- Get lookat values
------------------------------------------------------------------------------------------------
fn getLookAtValues fpLAt =
(
aLatValues = #()

if (fpLAt == undefined) do
return aLatValues

append aLatValues ((fpLAt.getNumTargets() as string) +"\t\t\t\tTarget(s)")
for i=1 to fpLAt.getNumTargets() do
append aLatValues ("T"+(i as string)+"\t\t\t\t"+(fpLAt.getNode i).name)

if (fpLAt.upnode_ctrl == 0) then
(
append aLatValues ("UpNode control\tLookAt")
if (fpLAt.upnode_world == false) then
append aLatValues ("UpNode\t\t\t"+(fpLAt.pickUpNode).name)
else
append ALatValues ("UpNode\t\t\tWorld")
)
else
append aLatValues ("UpNode control\tAxis Alignment")

case (fpLAt.target_axis) of
(
0 :
append aLatValues ("LookAt axis\t\tX1 Y0 Z0 Flip : " + (fpLAt.target_axisflip as string))
1:
append aLatValues ("LookAt axis\t\tX0 Y1 Z0 Flip : " + (fpLAt.target_axisflip as string))
2:
append aLatValues ("LookAt axis\t\tX0 Y0 Z1 Flip : " + (fpLAt.target_axisflip as string))
)

case (fpLAt.StoUP_axis) of
(
0 :
append aLatValues ("Source axis\t\tX1 Y0 Z0 Flip : " + (fpLAt.StoUP_axisflip as string))
1:
append aLatValues ("Source axis\t\tX0 Y1 Z0 Flip : " + (fpLAt.StoUP_axisflip as string))
2:
append aLatValues ("Source axis\t\tX0 Y0 Z1 Flip : " + (fpLAt.StoUP_axisflip as string))
)

if (fpLAt.upnode_ctrl == 1) do
(
case (fpLAt.upnode_axis) of
(
0 :
append aLatValues ("Upnode axis\t\tX1 Y0 Z0")
1:
append aLatValues ("Upnode axis\t\tX0 Y1 Z0")
2:
append aLatValues ("Upnode axis\t\tX0 Y0 Z1")
)
)

append aLatValues ("Relative\t\t\t"+(fpLAt.relative as string))
append aLatValues ("View Len. Abs.\t"+(fpLAt.viewline_length_abs as string))

return aLatValues
)
------------------------------------------------------------------------------------------------



------------------------------------------------------------------------------------------------
-- Orientation constraint values
------------------------------------------------------------------------------------------------
fn getOrientationConstraintValues fpOC =
(
aOriValues = #()

if (fpOC == undefined) do
return aOriValues

append aOriValues ((fpOC.getNumTargets() as string) + "\t\t\tTarget(s)")
for i=1 to (fpOC.getNumTargets()) do
append aOriValues ("T"+(i as string)+"\t\t\t"+(fpOC.getNode i).name)
append aOriValues ("Relative\t\t" + (fpOC.relative as string))
return aOriValues
)
------------------------------------------------------------------------------------------------



------------------------------------------------------------------------------------------------
-- Position constraint values
------------------------------------------------------------------------------------------------
fn getPositionConstraintValues fpPC =
(
aPosValues = #()

if (fpPC == undefined) do
return aPosValues

append aPosValues ((fpPC.getNumTargets() as string) + "\t\t\tTarget(s)")
for i=1 to (fpPC.getNumTargets()) do
append aPosValues ("T"+(i as string)+"\t\t"+(fpPC.getNode i).name)
append aPosValues ("Relative\t" + (fpPC.relative as string))

return aPosValues
)
------------------------------------------------------------------------------------------------



------------------------------------------------------------------------------------------------
-- Path constraint values
------------------------------------------------------------------------------------------------
fn getPathConstraintValues fpPC =
(
aPathValues = #()

if (fpPC == undefiden) do
return aPathValues = #()

append aPathValues ((fpPC.getNumTargets() as string) + "\t\t\t\t\tTarget(s)")
for i=1 to (fpPC.getNumTargets()) do
append aPathValues ("T"+(i as string)+"\t\t\t\t\t"+(fpPC.getNode i).name)
append aPathValues ((fpPC.percent as string)+"\t\t\t\t\t% Along Path")
append aPathValues ("Follow\t\t\t\t" + (fpPC.follow as string))
if (fpPC.follow) do
(
append aPathValues ("Allow Upside Down\t" + (fpPC.allowUpsideDown as string))
append aPathValues ("Bank\t\t\t\t\t" + (fpPC.bank as string))
if (fpPC.bank) do
(
append aPathValues ((fpPC.bankamount as string)+"\t\t\t\t\tBank Amount")
append aPathValues ((fpPC.smoothness as string)+"\t\t\t\t\tSmoothness")
)

case (fpPC.axis) of
(
0 :
append aPathValues ("Axis\t\t\t\t\tX1 Y0 Z0 Flip : " + (fpPC.axisflip as string))
1:
append aPathValues ("Axis\t\t\t\t\tX0 Y1 Z0 Flip : " + (fpPC.axisflip as string))
2:
append aPathValues ("Axis\t\t\t\t\tX0 Y0 Z1 Flip : " + (fpPC.axisflip as string))
)

)
append aPathValues ("Constant Vel.\t\t" + (fpPC.constantVel as string))
append aPathValues ("Loop\t\t\t\t\t" + (fpPC.loop as string))
append aPathValues ("Relative\t\t\t\t" + (fpPC.relative as string))

return aPathValues
)
------------------------------------------------------------------------------------------------

getConstraintInfo $
« Viimeksi muokattu: Elokuu 31, 2008, 02:02:34 am kirjoittanut xcx »
Senior Technical Artist - Remedy Games
http://www.verajankorva.com

xcx

  • Administrator
  • *****
  • Viestejä: 2302
  • Sukupuoli: Mies
    • Profiili
    • Verajankorva.com
    • Sähköposti
Re: Get controller info
« Vastaus #1 : Toukokuu 11, 2006, 01:57:10 pm »
Scriptin tulostus esimerkki.


******************************************


Controller info from object Box02

   PositionList controllers :
   |- [1] Position XYZ
   |- [2] Position Constraint
   |   |- 1         Target(s)
   |   |- T1      Box01
   |   |- Relative   true
   |- [3] Path Constraint
   |   |- 1               Target(s)
   |   |- T1               Line01
   |   |- 44.0               % Along Path
   |   |- Follow            true
   |   |- Allow Upside Down   false
   |   |- Bank               true
   |   |- 0.64               Bank Amount
   |   |- 0.5               Smoothness
   |   |- Axis               X1 Y0 Z0 Flip : false
   |   |- Constant Vel.      true
   |   |- Loop               true
   |   |- Relative            false

   RotationList controllers :
   |- [1] Euler XYZ
   |- [2] Orientation Constraint
   |   |- 1         Target(s)
   |   |- T1         Box01
   |   |- Relative      false
   |- [3] LookAt Constraint
   |   |- 1            Target(s)
   |   |- T1            Box01
   |   |- UpNode control   Axis Alignment
   |   |- LookAt axis      X1 Y0 Z0 Flip : false
   |   |- Source axis      X0 Y0 Z1 Flip : false
   |   |- Upnode axis      X0 Y0 Z1
   |   |- Relative         false
   |   |- View Len. Abs.   true



******************************************
« Viimeksi muokattu: Toukokuu 11, 2006, 03:03:12 pm kirjoittanut xcx »
Senior Technical Artist - Remedy Games
http://www.verajankorva.com