Wednesday, July 30, 2008
AE / rotate3DPoint
3D 座標の立体が、平面上で回転しているようにポリゴンを描く値を返します。図参照。
基本形体の XYZ座標は、右の表のように ae3dConvertToScreen で変換した
立体を描くポリゴンのグループです。 基本形体に回転のアングルをパラメータで与えて、
それぞれのポイントを得ます。
基本構文:
rotate3DPoint(基本形体のX座標, 基本形体のY座標, 基本形体のZ座標, \
Xの回転アングル,Yの回転アングル,Zの回転アングル[, 焦点距離])
rotate3DPoint(x,y,z,XRotation,Yrotation,Zrotation[,pFocalLength])
サンプル:
X軸だけの回転、 Y軸だけの回転、 Z軸だけの回転、その他複合の回転ができるように
rX, rY, rZ のチェックボックスを作ります。
-- まず、ボタン「tStart」に、カスタムプロパティにフィールド「tPoints」にある、
-- 基本形体の XYZ座標をセットします。
set the cPoints of btn "tStart" to field "tPoints"
-- ボタン「スタート」のスクリプト
local lPoints,lAngleX,lAngleY,lAngleZ
on mouseUp
put the cPoints of me into lPoints
-- カスタムプロパティのcPoints を基本形体のポイントリストにする
if the flag of me is empty then set the flag of me to false
set the flag of me to not the flag of me
if the flag of me then
-- XYZ の回転アングルを 0 に
put 0 into lAngleX
put 0 into lAngleY
put 0 into lAngleZ
set the label of me to "stop"
rotateMe
else
set the label of me to "start"
end if
end mouseUp
-- send rotate to me があるので、 Rev 3.0 では private command は使えません
on rotateMe
lock screen
-- チェックボックスがハイライトになっていたら、アングルを 1 づつ加える
if the hilite of btn "rX" then
put lAngleX+1 into lAngleX
end if
if the hilite of btn "rY" then
put lAngleY+1 into lAngleY
end if
if the hilite of btn "rZ" then
put lAngleZ+1 into lAngleZ
end if
-- 基本形体のポイント数だけリピート
repeat for each line theLine in lPoints
if theLine is not empty then
-- 回転アングルの数値の 3D ポイントを得て theLine2に入れる
put rotate3DPoint(item 1 of theLine,item 2 of theLine,item 3 of theLine,\
lAngleX,lAngleY,lAngleZ) into theLine2
-- 上の 3D ポイントを平面上のポイントに変換する
put ae3DConvertToScreen(item 1 of theLine2,item 2 of theLine2,item 3 of theLine2,\
the loc of this cd,800)&cr after screenPoints
else
-- ひと筆描きのポリゴンのブレーク
put cr&cr after screenPoints
end if
end repeat
-- 得られた screenPointsでポリゴンを描く
set the points of grc "threeD" to screenPoints
wait 0 milliseconds with messages
unlock screen
if the flag of me then send rotateMe to me in 5 milliseconds
end rotateMe
始めにAnimation Engineを開いて、start using stack "animationEngine"
サンプルスタックは、下記をメッセージボックスにコピペしてリターンキーを
go stack \
url "http://homepage.mac.com/kenjikojima/jrevnote/rotate3DPoint.rev"
50,50,50
50,-50,50
-50,-50,50
-50,50,50
50,50,50
50,50,-50
-50,50,-50
-50,50,50
50,-50,50
50,-50,-50
50,50,-50
-50,50,-50
-50,-50,-50
50,-50,-50
-50,-50,-50
-50,-50,50