Zh-tw/Demo Recording Tools

From Valve Developer Community
Jump to navigation Jump to search

遊戲Demo記錄工具

簡介

Source引擎提供了一串用來紀錄遊戲過程成Demo的工具,重現遊戲流程和編輯demo檔案。這些功能可以從控制列或GUI工具像是「Demo播放介面」、「Demo編輯介面」與「Demo進階介面」來提供。

基本紀錄與播放

想要紀錄一個遊戲流程,在控制列輸入record "名稱"(名稱不能有特殊的字元或空格)。demo檔案 (.dem擴充)將被儲存在您目前執行的遊戲資料夾裡,如:\hl2\name.dem。您能在執行遊戲的期間開始記錄,並且使用停止指令來停止記錄。如果在紀錄期間遊戲執行到換關卡,目前在紀錄的DEMO檔案會關閉,並一個新的DEMO檔案 名稱_2 (名稱_3、名稱_4等等)將被建立。想要重現之前紀錄的遊戲流程,輸入playdemo "名稱"。如果想要重現以系統基準為主的demo,使用timedemo "名稱"。 Timedemo將儘可能的快速播放demo並在呈現播放完成後顯示執行狀態(總共幾個遊戲框架、秒數、每秒平均幾個框架FPS與變異數).

Demo Player(Demo播放介面)

Demoplayback.jpg

在播放DEMO檔時,可以按Shift-F2或在控制列輸入demoui指令呼叫Demo播放介面。Demo播放視窗允許暫停、重新開始、調整播放速度或攝影機的觀點。

載入新的DEMO檔案可以藉由按下"Load..."按鈕,並從硬碟裡選擇一個.dem檔案。目前與總共播放時間會顯示在"Load..."下面。使用右邊的拖動條,您能夠調整播放的速度(速度調動範圍介於慢動作0%與快動作600%之間)。位於進度棒下面的按鈕為"播放"、"暫停"、"重新開始"、前進">"、回到開頭"|<"、來到結尾">|"(有些功能不能作用,像是後退"<"、快速後退"<<")。

內部紀錄DEMO檔案使用時間戳記來標記一個在播放中的遊戲框架。像是目前的框架數與總框架數(在"Goto:"按鈕得左邊)。您能跳到一個指定的框架數(輸入目標框架數到輸入欄裡,並按"Goto:"鈕)。

想要改變攝影機的觀點,按"Drive..."切換到"攝影機控制模式"(Camera drive mode)。當進入"攝影機控制模式",按鈕會保持在被壓下的狀態。移動滑鼠到場景上,並按下滑鼠左鍵並移動滑鼠來控制攝影機方向,W、A、S、D鍵控制攝影機位置。您能藉由Z和X鍵來控制攝影機的上下,並按下SHIFT鍵將移動速度變慢。當暫停時,製作螢幕快照很方便(使用r_drawviewmodel 0cl_drawhud 0清除畫面)。再按一次"Drive..."將切回正常DEMO播放狀態。

Demo Editor(Demo編輯介面)

Demoeditor.jpg

在播放介面中按下"Edit..."打開Demo編輯介面。編輯介面提供在播放DEMO時新增或執行一套的指令。這些 DEMO指令能夠在畫面上顯示文字、淡出入、視角或執行其它的控制列指令。DEMO編輯介面無法改變攝影機觀點,需改為DEMO進階介面來做。DEMO指令不會被儲存在DEMO檔裡面,但會附在一個額外的文字檔上(名稱為 DEMO名稱.vdm)。這些.VDM文字檔會跟著.DEM(同名)一起被載入或被執行。

按下"New->"按鈕並選擇一個想使用的DEMO指令,如PlayCommands來執行一個控制列指令。每個DEMO指令擁有一個使用者給予的名稱和第幾個框架來執行。如果您新增一個PlayCommands,選擇一個新的名稱("My command"),設定"Start on"為"TimeUseTick",輸入一個合法的框架數並輸入控制列指令,如"echo This is my command"。並按下"OK"後會新增一個新的DEMO指令到指令清單裡。現有的指令能夠被更改("Edit...")或是被移除("Delete")。一旦完成了指令清單後,您能儲存他為demoname.vdm("Save")。

底下列出能夠使用的DEMO指令:

SkipAhead DEMO播放跳到指定的框架數並重新播放。
StopPlayback 停止播放。
PlayCommands 執行一個控制列指令。
ScreenFadeStart 畫面淡出入。
TextMessageStart 顯示一個簡單的文字訊息。
PlayCDTrackStart 播放某CD track。
PlaySoundStart 播放某.WAV或.MP3.
Pause 在指定的幾秒內暫停播放。
ChangePlaybackRate 更改播放速度。
ZoomFov 調整畫面的視角遠近。

Demo Smoother(Demo進階介面)

Demo smoother.jpg

Demo進階介面是中最複雜的DEMO工具,它允許忽略掉原本在DEMO檔案裡面現有攝影機觀點。進階介面能夠將紀錄下來的畫面更加平滑的移動或者建立一個全新的攝影機路徑。按下Demo播放介面中的"Smooth..."按鈕來開啟Demo進階介面。

第一件事情需要做的是先暫停播放,然後按下"Reload"載入目前現有存在于DEMO檔案中的視點資訊(攝影機部分的位置)。將"Show All"核取方塊打勾即可看到在DEMO檔案中完整的的攝影機路徑(白線)。在Demo進階介面的任何時候,您仍然可以進入「攝影機控制模式」(DEMO播放介面中的"Drive..."按鈕)並且隨意的在地圖上移動攝影機。如果您不在「攝影機控制模式」,您能夠選取"Back off"核取方塊,將被攝影機擋住的路徑顯示出來。

想要使Demo進階介面作用,您必須選擇一段路徑。您可以在"Start Tick"與"End Tick"欄中填寫路徑範圍(以框架數為單位),並且按下"Select"。這個路徑範圍將是能夠被作用的範圍,而且被選上的範圍將以黃色的線來表示。按下"Show Original"按鈕後,攝影機會跟隨著被選起的路徑移動。注意剛剛我們把"backed off"給選起來,那只是在看的時候,路經不要被攝影機擋住(攝影機在線的後面),而現在可以將勾勾給取消掉。將"lock camera"打勾,並且按下DEMO播放介面中的"Drive..."按鈕,接著向控制攝影機視點與位置的方式,將攝影機往後移動。

Demo smoother2.jpg

現在在看到的畫面中,標記(藍色的方塊跟紅色的方向線)代表現在的觀看位置。如果您在攝影機鎖定("lock camera")的狀態按下"<<"或">>",您將移動這標記往前或往後下一個框架位置。如果您沒有將攝影機鎖定,則當您按下"<<"或">>"時,攝影機觀點會被固定在目前攝影機新的位置。在路徑上被選擇的路經範圍中開始與結尾白色的線代表車出您所選擇的範圍。按下"Process->"將會顯示目前所提供的移動型態選單。

Smooth selection angles

Clicking this averages the view angles over a window of about 10 samples, thereby removing some of the high frequency noise from the camera. The smoothed camera directions are shown as purple samples near each yellow sample line. You can preview the processed positions by clicking the "Show processed" button (make sure you turn off "lock camera" if you want to actually see from the camera position, otherwise you'll just see the blue box/red line move across your selection).

Note that the speed scale slider from the "Demo Playback" UI will influence the Show Original/Show Processed (and Drive Camera) speed in the Demo Smoother UI. Okay, that's pure angle smoothing by just averaging the angles over a small window. To undo this change you can just click the "Undo" button.

Smooth selection origin

This is similar to the above, except the window is applied to the origin samples. Clicking this button can be used to remove a bit of high frequency positional jitter. The smoothed camera path is colored yellowish, which deviates from the gray original path. This is the new smoothed path on which the camera will track. Of course, you can apply both angle and origin smoothing to the selection, etc.

Linear Interp Angles

What this tool does it take only the very first sample in the selection range and the very last sample in the range, and then linearly interpolates the view direction smoothly across the entire range.

Linear Interp Origin

Similar to the above, you can linearly interpolate the origin from the start to end sample. As you will see, the camera position follows a direct path from the start to end position, but the original view pitch/roll/yaw data is preserved. You can choose "Linear Interp Angles" if you want to smooth out the angles over this selection as well.

Spline Angles and Spline Origin

Demo smoother3.jpg

The spline functionality, in general, requires you to mark certain samples as "Key Frames" for creating the spline. By default, the first and last samples are automatically included as "anchor" key frames, but you'll want to add at least one if not multiple additional key frames.

The best way to do this is to think of the original samples as a time reference and use the << and >> buttons to move the blue cursor to the sample at the time you want to mark as a key frame. Once you've done that, you need to unlock the camera if it's locked and then press "Set View" to put your eyes into the current sample point.

You can now move that sample point by clicking "Drive Camera" and moving with the keyboard and mouse, etc. Once you have the sample positioned and oriented (just using the camera) as you like, press the "Make Key" button. If you now back the camera up a bit more you'll see a green box which shows the current point as a key. Smoothing out the Edges

The final component of the smoother is useful for dealing with the edges left after post processing a .dem file selection. For instance, chose the last 5 frames to smooth out the right edge at the end of a sample ( type 5 in the Edge Frames box and selected Smooth Right from the Edge-> menu). As you can see in the inset, the processed/purple line is more smoothly integrated with the first non-selected white direction line. You need to use at least 3 edge frames and then select which edges(s) to smooth from the Edge-> menu.


Demo Console Commands

demo_debug <0/1> Shows additional demo debug info
demo_fastforwardstartspeed <factor> Go this fast when starting to hold FF button.
demo_fastforwardramptime <seconds> How many seconds it takes to get to full FF speed.
demo_fastforwardfinalspeed <factor> Final playback speed when holding the FF button.
demo_interpolateview <0/1> Enables/disabled view interpolation between demo ticks
demo_quitafterplayback <0/1> Quits game after demo playback
demo_recordcommands <0/1> Record commands typed at console into .dem files
demo_pause [seconds] Pauses demo playback, seconds optional
demo_resume Resumes demo playback
demo_togglepause Toggles demo pause/playback
demo_gototick <tick> [relative] [pause] Skips to a tick in demo. If the relative parameter is 1 the tick is an offset to the current tick. If the pause parameter is 1, playback while be paused when tick is reached
demo_timescale <scale> Set the demo playback speed as a factor, 1.0 is normal playback

Video Tutorial

Demo Smoother Video Tutorial

Requires Xvid codec

by Fragalishus

Notes

  • You cannot see yourself in POV demos. YOU are the camera.
  • When in drive mode, use right mouse to change demo speed.
  • If your srctv demo gets stuck on free look, try using cl_predict 0 to unlock it.


Other useful command variables
sv_cheats <0/1> Required for following commands.
r_drawviewmodel <0/1> Hides weapon model.
cl_drawhud <0/1> Hides entire hud.
hud_saytext_time 0 Hides chat text, default = 12.
hideradar Hides radar location text.
cl_radaralpha 0 Hides new radar overviews (def. = 200).
drawradar Enables radar.
thirdperson Enables third person view (firstperson to change back).
cam_command <0/1> Enables camera commands.
cam_idealyaw <value> Rotates the camera around model horizontally (0-360)
cam_idealpitch <value> Rotates camera around model vertically (0-360)
cam_idealdist <value> Sets the distance from player to camera (default = 64)
Use the "find" command to find other camera

options (+camyawleft, etc) Usage: find cam

Bugs

This bug list was compiled by Lunchtimemama on January 24, 2005 and is potentially out of date. Bugs listed here may be fixed and other bugs may exist.

Unfinished Features:

  • The step-back and rewind buttons are disabled.
  • The fast-forward, go-to-beginning, and go-to-end buttons do not work.
  • Half of the "Edit" effects are disabled.

Major Bugs

  • 1. The "Edit" effect configuration windows are immobile and have broken minimize and close buttons.
  • 2. With "lock camera" engaged in the Smoother window and "Drive" engaged in the Playback window, the "Make Key" command will incorrectly use the "driven" camera's position instead of the "locked" camera's.
  • 3. With "lock camera" and "Drive" engaged, the "Show Original" and "Show Processed" commands will not animate the "locked" camera (though the "step-forward" and "step-back" commands (in the Smoother) will).
  • 4. With "lock camera" disengaged and "Drive" engaged, the blue-box camera indicator does not update position when the camera is "driven" around.
  • 5. Some demos suffer jumpiness similar to network lag, even those exported from the Smoother.
  • 6. "Jump to" in the Smoother does not seem to work properly.
  • 7. Some demos will not allow you to make a selection, so smoothing is not possible.
  • 8. Smoother does not work on srctv demos, cannot make a selection. - Fixed in srctv updates, smoother should work now. (#7 still applies, however. Random bug, can't make a selection)
  • 9. When you die, the camera locks to your corpse in "view attacker" mode.

Minor Bugs

  • The "New ->" list in the "Edit" window always opens upward, usually extending off-screen.
  • "Goto" is very slow when going to a tick in the past.
  • If the blue-box camera indicator suffers movement lag during playback, it does not "catch up" when the demo is paused.
  • When "Drive" is engaged, clicking and dragging in VGUI windows will move the camera (making it difficult to highlight text in a textfield).

See Also

Wish List

  • 1. dem_forcesrctv <0/1>
  • Requested functionality that dem_forcehltv 0/1 had.
  • Remove recoil. (true free look) Priority 1!
  • Ability to spectate 1st and 3rd person all other players. (wallhack block notwithstanding of course)
  • Remove muzzle flash and brass ejection. (not a huge deal, we can use sprites, but would be nice)
  • 2. Proper thirdperson mode.
  • Re-orient muzzle flash sprite to world model instead of first person view model.
  • 3. CVAR to override deathcam view.
  • When a player dies, any recammed smoother paths will snap back to the player when the ragdoll spawns and lock on viewing the attacker. A cvar to override that, without overriding the smoother path, would be handy.
  • 4. Timestamps on srctv demos.
  • Same as hltv had. Would be nice on POV demos, too, allowing for start/stop script recording.
  • 5. CVAR to disable flash bang effect on text/death notices.
  • Considering +/-90% of all demos are recorded for frag movie purposes, there needs to be a cvar so death notices are not affected by flash bangs. Even if it's a cheat cvar, available only during demo playback or something.
  • 6. OpenDML compliant avi files
  • Currently, Source's avi utility does not create open-dml 2.0 compliant files, meaning files over 2 gb are corrupt, and has a 4 gb cap.