'
' Orientation constrain two cones to a cube, compensating one of them.
'
dim oCube, oConeCompensated, oConeUncompensated
'
' get a cube and rotate it so we can see how orientation is being constrained.
'
set oCube = GetPrim("Cube")
oCube.length = 2
Scale oCube, 0.5, 3, 0.5, siRelative, siLocal, siObj, siXYZ
Rotate oCube, 45, 0, 45, siRelative, siAdd, siObj, siXYZ
'
' create the two cones and put on either side of the cube
'
set oConeCompensated = GetPrim("Cone")
Translate oConeCompensated, -4, 0, 0, siAbsolute, siParent, siObj, siXYZ
set oConeUncompensated = GetPrim("Cone")
Translate oConeUncompensated, 4, 0, 0, siAbsolute, siParent, siObj, siXYZ
'
' Apply the constraint
' Offset one cone's orientation by 30 degrees about each axis
'
SIApplyConstraint "Orientation", oConeCompensated, oCube, false, 30,30,30
SIApplyConstraint "Orientation", oConeUncompensated, oCube, false
'
' display the constraint relationship in the camera view
'
SetValue "Camera.camvis.*constraint*", True
'
' log the constraint offsets to show
' that one has been compensated
'
dim comp_x,comp_y,comp_z,uncomp_x,uncomp_y,uncomp_z
comp_x = GetValue( oConeCompensated&".kine.oricns.offx")
comp_y = GetValue( oConeCompensated&".kine.oricns.offy")
comp_z = GetValue( oConeCompensated&".kine.oricns.offz")
uncomp_x = GetValue( oConeUncompensated&".kine.oricns.offx")
uncomp_y = GetValue( oConeUncompensated&".kine.oricns.offy")
uncomp_z = GetValue( oConeUncompensated&".kine.oricns.offz")
logmessage "Compensated cone offsets: x= " & comp_x & " y= " & comp_y & " z= " & comp_z
logmessage "Uncompensated cone offsets: x= " & uncomp_x & " y= " & uncomp_y & " z= " & uncomp_z
'Results of running this script:
'INFO : "Compensated cone offsets: x= 30 y= 30 z= 30"
'INFO : "Uncompensated cone offsets: x= 0 y= 0 z= 0"
|