トップページ > .CELXスクリプトガイド > observerオブジェクト-視点移動
observerオブジェクト - 視点移動
指定した天体に移動したりなど、視点を扱うオブジェクトです。
observer:goto(天体・位置指定)
observer:goto(object/positon:target[, number:duration, start_inter, end_inter])
指定した天体(objectオブジェクトを指定した場合)、あるいは位置(positionオブジェクトを指定した場合)に移動します。
※ 次の視点の動作を伴うコマンドを実行する前にwaitコマンドで継続時間以上待つ必要があります。そうしなければコマンドが実行されません。
※ object:getpositionコマンドを使用して移動した場合、objectオブジェクトを指定して移動する場合とは異なり、天体の中心に移動してしまいます。
例:
obs = celestia:getobserver()
earth = celestia:find("Sol/Earth")
obs:goto(earth, 10)
observer:goto(テーブル指定)
observer:gotoparams(table:gotoparams)
テーブルによりパラメータを設定する事により多彩な動作ができます。
※ 次の視点の動作を伴うコマンドを実行する前にwaitコマンドで継続時間以上待つ必要があります。そうしなければコマンドが実行されません。
例:
obs = celestia:getobserver()
earth = celestia:find("Sol/Earth")
obs:gotoparams(earth, 10)
observer:gotolonglat
observer:gotolonglat(object:target[, number:longitude, number:latitude, number:distance, number:duration])
指定した天体の指定した緯度・経度・距離へ移動します。
度をラジアンに変換するにはmath.rad(...)を使用してください。
※ 次の視点の動作を伴うコマンドを実行する前にwaitコマンドで継続時間以上待つ必要があります。そうしなければコマンドが実行されません。
例:
obs = celestia:getobserver()
earth = celestia:find("Sol/Earth")
celestia:select(earth)
obs:synchronous(earth)
obs:gotolonglat(earth, math.rad(139.541), math.rad(35.6725), earth:radius()+0.05, 5)
wait(6)
v = celestia:newvector(1, 0, 0)
rot = celestia:newrotation(v, -math.pi/2)
obs:rotate(rot)
observer:gotolocation
observer:gotolocation(positon:target[, number:duration])
positionオブジェクトを使用して指定した場所へ移動します。
移動先は現在の追尾モードに依存します。すなわち、追尾モードや参照天体により同じpositionオブジェクトでも移動先が異なります。
※ 次の視点の動作を伴うコマンドを実行する前にwaitコマンドで継続時間以上待つ必要があります。そうしなければコマンドが実行されません。
例:
dec = 35.18
ra = 136.907
distance = 3000
obs = celestia:getobserver()
earth = celestia:find("Sol/Earth")
celestia:select(earth)
obs:synchronous(earth)
r = (earth:radius() + distance) / 9460730.4725808
x = -r * math.cos(math.rad(dec))*math.cos(math.rad(ra))
y = r * math.sin(math.rad(dec))
z = r * math.cos(math.rad(dec))*math.sin(math.rad(ra))
pos = celestia:newposition(x, y, z)
obs:gotolocation(pos,2)
wait(2)
obs:center(earth, 1)
observer:gotodistance
observer:gotodistance(object:target[, number:distance, number:duration])
指定した距離を取って天体に近づきます。
※ 次の視点の動作を伴うコマンドを実行する前にwaitコマンドで継続時間以上待つ必要があります。そうしなければコマンドが実行されません。
例:
obs = celestia:getobserver()
earth = celestia:find("Sol/Earth")
celestia:select(earth)
obs:gotodistance(earth, earth:radius() + 50000, 3)
observer:gotosurface
observer:gotosurface(object:target[, number:duration])
天体表面へ移動します。指定した天体に対しCtrl+Gを押したのと同様の動作をします。
コマンド実行後は追尾モードが自動的にSync Orbit(自転同期)になります。
※ 次の視点の動作を伴うコマンドを実行する前にwaitコマンドで継続時間以上待つ必要があります。そうしなければコマンドが実行されません。
例:
obs = celestia:getobserver()
earth = celestia:find("Sol/Earth")
celestia:select(earth)
obs:gotosurface(earth)
observer:center
observer:center(object:target[, number:duration])
天体を画面中央へ持ってきます。指定した天体に対しCキーを押したのと同様の動作をします。
※ 次の視点の動作を伴うコマンドを実行する前にwaitコマンドで継続時間以上待つ必要があります。そうしなければコマンドが実行されません。
例:
obs = celestia:getobserver()
earth = celestia:find("Sol/Earth")
celestia:select(earth)
obs:center(earth, 3)
observer:centerorbit
observer:centerorbit(object:target[, number:duration])
現在追尾中の天体との距離・画面位置を保ったまま指定した天体が画面中央になるように視点を移動させます。
Shift+Cキーを押したのと同様の動作をします。
※ 次の視点の動作を伴うコマンドを実行する前にwaitコマンドで継続時間以上待つ必要があります。そうしなければコマンドが実行されません。
例:
obs = celestia:getobserver()
earth = celestia:find("Sol/Earth")
celestia:select(earth)
obs:centerorbit(earth, 3)
wait(3)
mars = celestia:find("Sol/Mars")
celestia:select(mars)
obs:centerorbit(mars, 3)
observer:travelling
boolean observer:travelling()
gotoやcenter等で視点移動中の場合にtrueを返します。
例:
obs = celestia:getobserver()
venus = celestia:find("Sol/Venus")
obs:goto(venus, 20)
while obs:travelling() do
celestia:flash("Moving to Venus.")
wait(0.1)
end
observer:cancelgoto
observer:cancelgoto()
gotoやcenter等での視点移動状態を解除します。
例:
--
observer:follow
observer:follow(object:target)
指定した天体に春分点同期で追尾します。
frameオブジェクトでeclipticalを選択し、参照天体を設定した場合と同様です。
例:
obs = celestia:getobserver()
earth = celestia:find("Sol/Earth")
celestia:select(earth)
obs:follow(earth)
obs:goto(earth, 10)
observer:synchronous
observer:synchronous(object:target)
指定した天体に自転同期で追尾します。
frameオブジェクトでplanetographicを選択し、参照天体を設定した場合と同様です。
例:
obs = celestia:getobserver()
earth = celestia:find("Sol/Earth")
celestia:select(earth)
obs:synchronous(earth)
obs:goto(earth, 10)
observer:chase
observer:chase(object:target)
指定した天体に公転同期(Chaseモード)で追尾します。
frameオブジェクトでchaseを選択し、参照天体を設定した場合と同様です。
例:
obs = celestia:getobserver()
earth = celestia:find("Sol/Earth")
celestia:select(earth)
obs:chase(earth)
obs:goto(earth, 10)
observer:lock
observer:lock(object:target)
指定した2つの天体に同期して追尾します。
frameオブジェクトでlockを選択し、参照天体・目的天体を設定した場合と同様です。
例:
obs = celestia:getobserver()
earth = celestia:find("Sol/Earth")
moon = celestia:find("Sol/Earth/Moon")
celestia:select(earth)
obs:follow(earth)
obs:goto(earth, 3)
wait(3)
obs:lock(moon)
observer:track
observer:track(object:target)
指定した天体を画面中央に保持します。
例:
obs = celestia:getobserver()
earth = celestia:find("Sol/Earth")
moon = celestia:find("Sol/Earth/Moon")
celestia:select(earth)
obs:follow(earth)
obs:goto(earth, 3)
wait(3)
obs:track(earth)
obs:goto(moon, 3)
wait(3)
celestia:select(moon)
wait(1)
obs:track(nil)
obs:center(moon, 3)
wait(3)
obs:track(moon)
observer:setposition
observer:setposition(position:pos)
現在の視点の位置を設定します。universal座標系での位置となります。
例:
obs = celestia:getobserver()
pos = celestia:newposition(3000, 0, 0)
obs:setposition(pos)
observer:getposition
position observer:getposition()
現在の視点の位置を取得します。universal座標系での位置となります。
例:
--
observer:setorientation
observer:setorientation(rotation:rot)
現在の視点の回転方向を取得します。universal座標系での方向となります。
例:
obs = celestia:getobserver()
pos = celestia:newposition(3000, 0, 0)
rot = celestia:newrotation(1, 0, -1, 0)
obs:setorientation(pos)
wait(1)
obs:setorientation(rot)
observer:getorientation
rotation observer:getorientation()
現在の視点の回転方向を取得します。universal座標系での方向となります。
例:
--
observer:rotate
observer:rotate(rotation:rot)
視点を指定したrotationオブジェクト分だけ回転させます。
例:
obs = celestia:getobserver()
rot = celestia:newrotation(0, 0, 1, 0)
obs:rotate(rot)
observer:lookat
observer:lookat([position:from, ]position:to, vector:up)
2つの視点を結んだ方向を向かせる事ができます。
例:
obs = celestia:getobserver()
earth = celestia:find("Sol/Earth")
pos = obs:getposition()
v = celestia:newvector(0, 1, 0)
obs:lookat(pos, v)
observer:gettime
number observer:gettime()
現在の視点のシミュレーション時刻をユリウス日で取得します。
現在のところはcelestia:gettimeと同様のようです。(?)
例:
--
observer:getspeed
number observer:getspeed()
現在の視点の速度を取得します。単位は[マイクロ光年(10-6光年)/秒]。
例:
--
observer:setspeed
observer:setspeed(number:speed)
現在の視点の速度を設定します。単位は[マイクロ光年(10-6光年)/秒]。
すぐに設定した速度にはなりません。例えば、1光年/秒の速さからストップする場合、十数秒かかります。
例:
obs = celestia:getobserver()
sol = celestia:find("Sol")
celestia:select(sol)
obs:goto(sol, 3)
wait(3)
obs:setspeed(0)
for i = 0, 10000000, 100000 do
obs:setspeed(i)
wait(0.1)
end
wait(3)
for i = 10000000, 0, -100000 do
obs:setspeed(i)
wait(0.1)
end
obs:center(sol, 3)
wait(3)
obs:goto(sol, 3)
observer:getsurface
string observer:getsurface()
現在使用している表面テクスチャを取得します。"limit of knowledge等が該当します。"
例:
obs = celestia:getobserver()
mercury = celestia:find("Sol/Mercury")
obs:goto(mercury, 3)
wait(4)
if obs:getsurface() == "limit of knowledge" then
celestia:flash("You are already using limit of knowledge texture.")
end
observer:setsurface
string observer:setsurface()
使用する表面テクスチャを設定します。"limit of knowledge"等が該当します。
例:
obs = celestia:getobserver()
mercury = celestia:find("Sol/Mercury")
obs:goto(mercury, 3)
wait(4)
if obs:getsurface() == "limit of knowledge" then
celestia:flash("You are already using limit of knowledge texture.")
else
celestia:flash("Switching to limit of knowledge texture.")
obs:setsurface("limit of knowledge")
end
observer:getlocationflags
table observer:getlocationflags()
地名の種類によるON/OFFをテーブルで取得します。
返されるキーは以下を参照してください。
| キー | 詳細 | キー | 詳細 | キー | 詳細 |
| city | 都市 | rupes | | mensa | |
| observatory | 観測所 | tessera | | rima | |
| landingsite | 着陸地点 | regio | | rima | |
| crater | クレーター/td> | chaos | | undae | |
| vallis | 峡谷 | terra | | reticulum | |
| mons | 山地 | astrum | | planitia | |
| planum | | corona | | linea | |
| chasma | | dorsum | | fluctus | |
| patera | | fossa | | farrum | |
| mare | 海 | catena | | other | その他 |
※ 全ての種類が使われているわけではありません。
例:
--
observer:setlocationflags
observer:setlocationflags(table:locationflags)
地名表示状態を設定します。
observer:getrenderflagsやobserver:setrenderflagsなども参考にしてください。
例:
--
observer:getfov
number observer:getfov()
現在の視野の広さを取得します。単位は[ラジアン]。
例:
--
observer:setfov
observer:setfov(number:fov)
視野の広さを設定します。単位は[ラジアン]。
例:
obs = celestia:getobserver()
earth = celestia:find("Sol/Earth")
venus = celestia:find("Sol/Venus")
celestia:select(earth)
obs:goto(earth, 3)
wait(3)
celestia:select(venus)
fov = obs:getfov()
obs:center(venus, 3)
wait(3)
for i = 1, 1000, 1 do
obs:setfov(fov / i)
wait(0.01)
end
observer:getframe
frame observer:getframe()
現在の視点のframeオブジェクトを取得します。
frameオブジェクトの説明も参照してください。
例:
--
observer:setframe
observer:setframe(frame:f)
現在の視点のframeオブジェクトを設定します。
frameオブジェクトの説明も参照してください。
例:
obs = celestia:getobserver()
earth = celestia:find("Sol/Earth")
f = celestia:newframe("planetographic", earth)
obs:setframe(f)
observer:gettrackedobject
object observer:gettrackedobject()
1.5.0
現在中央保持中の天体を取得します。
中央保持中の天体が無い場合、nilではない空白の天体が返されます。
例:
while 1 do
obs = celestia:getobserver()
tracked = obs:gettrackedobject()
trackedname = tracked:localname()
if trackedname == "?" then
celestia:flash("中央保持天体はありません")
else
celestia:flash(trackedname .. "を中央保持中")
end
wait(0.1)
end
トップページ > .CELXスクリプトガイド > observerオブジェクト - 視点移動