跳轉到內容

Celestia/Celx 指令碼/CELX Lua 方法/CEL 命令鎖定

來自華夏公益教科書,開放的書籍,開放的世界

鎖定 { }

此命令將兩個物件鎖定在一起。第一個選擇的物體稱為參考物體,第二個選擇的物體稱為目標物體。當它們作為一個對被鎖定在一起時,當你旋轉場景時,目標物體保持鎖定到參考物體,並且顯示的距離是兩個物體之間的距離。

在鎖定模式下,您的位置相對於參考物體和目標物體之間的線保持固定。當目標物體圍繞參考物體移動(相對而言)時,您也會移動。因此,如果目標物體是太陽,則參考物體的照亮部分(它的“相位”)保持不變,因為您與太陽同步地圍繞物體移動。

此命令沒有引數。


CELX 等效-1

基於 observer:setframe() 方法。

  • 找到並選擇名為<refstring> 的參考物體並存儲在“objectname_ref”中。
objectname_ref = celestia:find( <refstring> )
celestia:select(objectname_ref)
  • 找到名為<tarstring> 的目標物體,該物體必須與“objectname_ref”鎖定並存儲在“objectname_tar”中。
objectname_tar = celestia:find( <tarstring> )
  • 將參考系的座標系設定為與“objectname_tar”作為目標物體和“objectname_ref”作為參考物體鎖定,並存儲在“frame”中。
frame = celestia:newframe("lock", objectname_ref, objectname_tar)
  • 獲取活動檢視例項的觀察者例項,並將參考系的座標系設定為“frame”。
obs = celestia:getobserver()
obs:setframe(frame)

總結

objectname_ref = celestia:find( <refstring> )
celestia:select(objectname_ref)
objectname_tar = celestia:find( <tarstring> )
frame = celestia:newframe("lock", objectname_ref, objectname_tar)
obs = celestia:getobserver()
obs:setframe(frame)


CELX 等效-2

基於 observer:lock() 方法。

  • 找到並選擇名為<refstring> 的參考物體並存儲在“objectname_ref”中。
objectname_ref = celestia:find( <refstring> )
celestia:select(objectname_ref)
  • 找到名為<tarstring> 的目標物體,該物體必須與“objectname_ref”鎖定並存儲在“objectname_tar”中。
objectname_tar = celestia:find( <tarstring> )
  • 獲取活動檢視的觀察者例項,並在選定物體從“objectname_tar”到“objectname_ref”的軸上啟用鎖定模式。
    鎖定模式與將參考系設定為與“objectname_tar”作為目標物體和“objectname_ref”作為參考物體鎖定相同。
obs = celestia:getobserver()
obs:lock(objectname_tar)

總結

objectname_ref = celestia:find( <refstring> )
celestia:select(objectname_ref)
objectname_tar = celestia:find( <tarstring> )
obs = celestia:getobserver()
obs:lock(objectname_tar)


示例
以下示例將使您的位置相對於地球中心保持不變,並使太陽(太陽)和地球在相機檢視中保持固定位置。這與您在鍵盤上鍵入以下按鍵序列相同:[3] 鍵 → [F] 鍵 → [0] 鍵(零)→ [shift + :] 鍵。

CEL

select { object "Sol/Earth" }
follow { }
select { object "Sol" }
lock   { }

CELX 使用 observer:lock() 方法

-- Activate Lock-mode on target object.
objectname_ref = celestia:find("Sol/Earth")
celestia:select(objectname_ref)
objectname_tar = celestia:find("Sol")
obs = celestia:getobserver()
obs:lock(objectname_tar)

CELX 使用 observer:setframe() 方法

-- Set the coordinate system of the frame of reference to lock.
objectname_ref = celestia:find("Sol/Earth")
celestia:select(objectname_ref)
objectname_tar = celestia:find("Sol")
frame = celestia:newframe("lock", objectname_ref, objectname_tar)
obs = celestia:getobserver()
obs:setframe(frame)


返回 CEL 命令索引

華夏公益教科書