-----------------------------------------------------------------
delete objects
b = box height:0.5 length:5 width:5
for i = 0 to 30 do(
for j = 0 to 30 do(
instance b pos: [b.length*i, b.length*j, 0]
)
)
s = sphere radius:5 name:"ms" pos:[-10,-10,0] wirecolor:red
for i in $box* do(
i.rotation.controller.X_Rotation.controller = float_script ()
i.rotation.controller.X_Rotation.controller.script = "dependsOn $ms.transform.controller\n" +
"dependsOn $"+i.name+".transform.controller\n"+
"p1 = $ms.transform.controller.Position\n" +
"p2 = $"+i.name+".transform.controller.Position\n" +
"if (length (p1 - p2)) < 50 then degtorad ((length (p1 - p2))*3.6) else degtorad 180"
)
for i in $box* do(
i.visibility = bezier_float()
i.visibility.controller = float_script ()
i.visibility.controller.script = "dependsOn $ms.transform.controller\n" +
"dependsOn $"+i.name+".transform.controller\n"+
"p1 = $ms.transform.controller.Position\n" +
"p2 = $"+i.name+".transform.controller.Position\n" +
"if (length (p1 - p2)) < 100 then ((length (p1 - p2))/100.0) else 1"
)
/* --return
for i in $box* do(
i.visibility.controller = bezier_float()
i.rotation.controller.X_Rotation.controller = bezier_float()
)
-----------------------------------------------------------------
Если немного доработать код, то можно поменять ось вращения зависимых объектов следующим образом:
--------------------------------------------------------------------
for i in $box* do(
i.rotation.controller = rotation_script ()
i.rotation.controller.script = "dependsOn $ms.transform.controller\n" +
"dependsOn $"+i.name+".transform.controller\n"+
"p1 = $ms.transform.controller.Position\n" +
"p2 = $"+i.name+".transform.controller.Position\n" +
"dirVec = normalize(p1-p2)\n"+
"rotax = cross dirVec [0, 0, 1]\n"+
"quat (720.0/(length (p1 - p2))) rotax"
--"if (length (p1 - p2)) < 50 then (quat (720.0/(length (p1 - p2))/3.6) rotax) else (quat 0 0 0 1)"
)
--------------------------------------------------------------------
Комментариев нет:
Отправить комментарий