Krpano全景開發(fā)教程-漢化VR設置界面

Krpano 1.19支持WebVR / MobileVR,MAKE VTOUR生成器內(nèi)置對VR的支持先鱼。配合VR設備使用,可以實現(xiàn)VR效果。默認Web VR主界面和Customize界面為英文钉稍,需要漢化。

VR主界面.png
Customize界面.png

krpano使用簡單的xml文本文件來存儲相關的設置等棺耍,包括提示信息和界面文字贡未。漢化,其實是把英文提示信息和界面文字替翻譯替換成中文蒙袍。
步驟:
下面以krpano-1.19-pr8為例:

  1. 找到全景項目文件夾vtour\plugins的webvr.xml(或者直接把krpano-1.19-pr8文件夾下\templates\xml\plugins的webvr.xml俊卤,這樣以后生成的webvr.xml都是已經(jīng)漢化過的)
  2. 編輯工具(例如sublime)打開webvr.xml。
  3. 將英文對應替換成中文害幅。以下是中英文對比:
英文 中文
No Distortion 無扭曲
[i][u]Simulated WebVR Mode![/u][/i][br]For real WebVR with headset tracking, either use a [a href="http://webvr.info" target="_blank" style="color:#FFFFFF;"]WebVR-API-capable[/a] desktop browser or a mobile device and a VR headset. [i][u]模擬WebVR模式![/u][/i][br]需要體驗頭顯設備跟蹤的真正的WebVR消恍,請使用支持[a href="http://webvr.info" target="_blank" style="color:#FFFFFF;"]WebVR-API[/a]的桌面瀏覽器或手機和VR頭顯設備。
Enter VR 進入VR模式
Exit VR 退出VR模式
VR Setup VR模式設置
inch 英寸
mm 毫米
Custom 自定義
MOBILE VR SETUP VR設置
Device 設備
Screensize 屏幕尺寸
IPD 瞳距
VR Headset VR頭顯或VR頭戴設備
Customize 自定義設置
Calibrate Gyroscope 陀螺儀校準
SAVE 保存
RESET 恢復默認值
CLOSE 關閉
VR HEADSET VR頭顯設備
FOV 垂直視域
Distortion 扭曲參數(shù)
Dist2 附加扭曲參數(shù)
CA Corr 色差校正
Vignette 鏡頭暈影
Overlap 視野重疊
GYROSCOPE 陀螺儀
Place the device on a flat and[br]stable surface and tab calibrate[br]to correct a gyroscope drifting. 將設備放置在[br]水平面上以现,點擊校準[br]修正陀螺儀偏移.
CALIBRATE 校準
Calibrating... 校準中...
Calibration okay. 校準完成.
Calibration failed! 校準失敗!
         <krpano>
            <!-- load the WebVR plugin and assign it to a 'webvr' variable for easier usage -->
            <plugin name="WebVR" devices="html5" keep="true"
            url="webvr.js"
            onloaded="copy(webvr, plugin[WebVR]);"
            mousespeed="0.00125"
            multireslock="true"
            fullscreen_mirroring="true"
            mobilevr_support="true"
            mobilevr_ipd="63.5"
            mobilevr_screensize="auto"
            mobilevr_lens_overlap="1.0"
            mobilevr_lens_fov="96"
            mobilevr_lens_dist="0.6"
            mobilevr_lens_dist2="1|0|0|0"
            mobilevr_lens_ca="0.0"
            mobilevr_lens_vign="100"
            mobilevr_wakelock="true"
            mobilevr_sensor_mode="3"
            mobilevr_autocalibration="false"
            mobilevr_touch_support="true"
            mobilevr_fake_support="false"
            vr_cursor="hotspot[vr_cursor]"
            vr_cursor_enabled="true"
            vr_cursor_onover="if(handcursor, tween(hotspot[vr_cursor].scale,0.4,0.1); vr_auto_click(get(vr_timeout)); );"
            vr_cursor_onout="tween(hotspot[vr_cursor].scale,0.3,0.1);"
            onavailable="webvr_onavailable();"
            onunavailable=""
            onunknowndevice="webvr_onunknowndevice();"
            onentervr="webvr_onentervr();"
            onexitvr="webvr_onexitvr();"
            />

        <!-- a custom xml data structure with the supported VR headsets -->
        <vrheadsets>
        <headset name="cb1" caption="Cardboard A"   overlap="1.10" fov="96.0"  dist="1.00" dist2="1|0|0|0" ca="0.000" vig="100" />
        <headset name="cb2" caption="Cardboard B"   overlap="1.00" fov="96.0"  dist="0.60" dist2="1|0|0|0" ca="0.000" vig="100" />
        <headset name="gvr" caption="GearVR"        overlap="1.00" fov="112.0" dist="0.95" dist2="1|0|0|0" ca="0.090" vig="100" />
        <headset name="hom" caption="HOMiDO"        overlap="1.00" fov="101.0" dist="1.10" dist2="1|0|0|0" ca="0.075" vig="100" />
        <headset name="one" caption="VR ONE"        overlap="1.00" fov="109.9" dist="0.00" dist2="1.139|0.093|0.018|0.207" ca="0.090" vig="35" />
        <headset name="ccr" caption="ColorCross VR" overlap="1.00" fov="70.0"  dist="0.65" dist2="1|0|0|0" ca="0.000" vig="100" />
        <headset name="nod" caption="無扭曲" overlap="1.00" fov="96.0"  dist="0.00" dist2="1|0|0|0" ca="0.000" vig="100" />
        </vrheadsets>

        <!-- the VR cursor hotspot -->
        <hotspot name="vr_cursor" keep="true"
             url="webvr_cursor_80x80_17f.png"
             visible="false"
             enabled="false"
             distorted="true"
             crop="0|0|80|80"
             scale="0.3"
             depth="1000"
             />

       <!-- vr_auto_click() - call this action in the onover event of a
         hotspot to trigger automatically a click after some time.  -->
          <action name="vr_auto_click">
        if(webvr.isenabled,
            if(%1 != null, set(vr_aclk_timeout, %1), set(vr_aclk_timeout, 2000));
            copy(vr_aclk_t1, timertick);
            set(vr_aclk_waiting, true);
            copy(vr_aclk_hotspot, name);
            set(hotspot[vr_cursor].crop,'0|0|80|80');

            asyncloop(vr_aclk_waiting AND vr_aclk_hotspot == name,
                sub(dt, timertick,vr_aclk_t1);

                if(!hovering,
                    set(vr_aclk_waiting, false);
                    set(hotspot[vr_cursor].crop,'0|0|80|80');
                  ,
                    div(f, dt, vr_aclk_timeout);
                    mul(f, 16);
                    roundval(f);
                    Math.min(f, 16);
                    mul(f, 80);

                    txtadd(hotspot[vr_cursor].crop,get(f),'|0|80|80');

                    <!-- wait another 100ms delay after finishing the animation before doing the click -->
                    sub(dt, 100);
                    if(dt GT vr_aclk_timeout,
                        set(vr_aclk_waiting,false);
                        set(hotspot[vr_cursor].crop,'0|0|80|80');
                        <!-- call onclick -->
                        onclick();
                      );
                  );
                );
          );
        </action>

        <!-- by pressing SPACE the Oculus Rift could be re-centered -->
        <events name="webvr_events" devices="html5" keep="true"
            onkeydown="if(webvr AND webvr.isenabled AND keycode==32, webvr.resetSensor() );"
            onmousedown="if(webvr AND webvr.isenabled, webvr_showbuttons() );"
            />

        <!-- when WebVR support is available show an EnterVR button -->
        <action name="webvr_onavailable">
        webvr.loadsettings();
        delayedcall(0.5, tween(layer[webvr_enterbutton].alpha,1.0); );
        </action>
    
        <action name="webvr_onunknowndevice">
        if(webvr.isfake AND device.desktop AND webvr.havesettings == false,
            <!-- set the 'no distortion' headset for fake desktop usage -->
            set(webvr.mobilevr_lens_overlap, 1.0);
            set(webvr.mobilevr_lens_fov, 96.0);
            set(webvr.mobilevr_lens_dist, 0.0);
            set(webvr.mobilevr_lens_dist2, '1|0|0|0');
            set(webvr.mobilevr_lens_ca, 0.0);
            set(webvr.mobilevr_lens_vign, 100);
          ,
            set(ask_user_for_screensize,true);
          );
        </action>

        <action name="webvr_onentervr">
        tween(layer[webvr_enterbutton].alpha,0,0);

        webvr_showbuttons();
        webvr_hide_all_non_vr_layers();

        <!-- when the screen size is unknown an no custom size is set, open the setup screen on entering the VR mode -->
        if(webvr.ismobilevr == true AND !webvr.isfake AND ask_user_for_screensize == true AND webvr.mobilevr_screensize == 'auto',
            set(ask_user_for_screensize, false);
            vr_setup();
          );
        if(webvr.isfake,
            webvr_show_fakemode_info(true);
          );
        </action>

        <action name="webvr_onexitvr">
        stopdelayedcall(vr_button_fadeout);

        tween(layer[webvr_enterbutton].alpha,1);
        tween(layer[webvr_exitbutton].alpha,0);
        tween(layer[webvr_setupbutton].alpha,0);
        
        webvr_show_fakemode_info(false);

        webvr_restore_layers();
        </action>

        <action name="webvr_hide_all_non_vr_layers">
        for(set(i,0), i LT layer.count, inc(i),
            copy(lr, layer[get(i)]);
            if(lr.vr !== true,
                copy(lr.vr_backup_visible, lr.visible);
                set(lr.visible, false);
              );
          );
        </action>

        <action name="webvr_restore_layers">
        for(set(i,0), i LT layer.count, inc(i),
            copy(lr, layer[get(i)]);
            if(lr.vr_backup_visible,
                copy(lr.visible, lr.vr_backup_visible);
                delete(lr.vr_backup_visible);
              );
          );
        </action>
    
        <action name="webvr_show_fakemode_info">
        if('%1' == 'true',
            addlayer(webvr_fakemode_info);
            set(layer[webvr_fakemode_info].url, '%SWFPATH%/plugins/textfield.swf');
            set(layer[webvr_fakemode_info].keep, true);
            set(layer[webvr_fakemode_info].align, 'bottom');
            set(layer[webvr_fakemode_info].y, 80);
            set(layer[webvr_fakemode_info].background, false);
            set(layer[webvr_fakemode_info].css, 'color:#FFFFFF;text-align:center;');
            set(layer[webvr_fakemode_info].html, '[i][u]模擬WebVR模式![/u][/i][br]需要體驗頭顯設備跟蹤的真正的WebVR狠怨,請使用支持[a  target="_blank" style="color:#FFFFFF;"]WebVR-API[/a]的桌面瀏覽器或手機和VR頭顯設備约啊。');
          ,
            removelayer(webvr_fakemode_info);
          );
        </action>
    
        <!-- ensure the same scaling on mobiles (regardless if mobilescale is 0.5 or 1.0) -->
        <krpano webvr_setup_scale="calc:(1.0 + 1.0*(device.mobile AND stagescale LT 1.0)) / (1.0 + 1.0*device.mobile)"
            webvr_button_scale.normal="1.0"
            webvr_button_scale.mobile="1.6"
            />

        <!-- the EnterVR/ExitVR and SetupVR buttons -->
        <style name="webvr_button_style"
           url="%SWFPATH%/plugins/textfield.swf"
           backgroundcolor="0x000000"
           backgroundalpha="0.5"
           roundedge="calc:9*webvr_setup_scale*webvr_button_scale"
           css="calc:'color:#FFFFFF;font-size:' + 20*webvr_setup_scale*webvr_button_scale + 'px;'"
           padding="calc:6*webvr_setup_scale*webvr_button_scale + ' ' + 10*webvr_setup_scale*webvr_button_scale"
           />
    
         <layer name="webvr_enterbutton" keep="true" vr="true"
           style="webvr_button_style"
           html="進入VR模式"
           align="top" y="24"
           autoalpha="true" alpha="0.0"
           onclick="webvr.enterVR();"
           />

        <layer name="webvr_exitbutton" keep="true" vr="true"
           style="webvr_button_style"
           html="退出VR模式"
           align="top" y="24"
           autoalpha="true" alpha="0.0"
           onclick="webvr.exitVR();"
           />

        <layer name="webvr_setupbutton" keep="true" vr="true"
           style="webvr_button_style"
           html="VR模式設置"
           align="bottom" y="24"
           autoalpha="true" alpha="0.0"
           onclick="vr_setup()"
           />

        <action name="webvr_showbuttons">
        stopdelayedcall(vr_button_fadeout);
        if(webvr.ismobilevr,
            tween(layer[webvr_exitbutton].alpha|layer[webvr_setupbutton].alpha, 1.0|1.0, 0.25);
            delayedcall(vr_button_fadeout, 3.0, tween(layer[webvr_exitbutton].alpha|layer[webvr_setupbutton].alpha, 0.0|0.0, 1.0); );
          ,
            tween(layer[webvr_exitbutton].alpha, 1.0, 0.25);
            delayedcall(vr_button_fadeout, 3.0, tween(layer[webvr_exitbutton].alpha, 0.0, 1.0); );
          );
        </action>

        <!--
        VR Setup
        -->

        <action name="vr_setup">
        <!-- disable cursor -->
        set(webvr.vr_cursor_enabled, false);
        
        <!-- hide VR buttons -->
        tween(layer[webvr_exitbutton].alpha,0);
        tween(layer[webvr_setupbutton].alpha,0);
        
        <!-- create background layer -->
        addlayer(vr_setup_bg);
        set(layer[vr_setup_bg].type, container);
        set(layer[vr_setup_bg].bgcolor, 0x000000);
        set(layer[vr_setup_bg].bgalpha, 0.5);
        set(layer[vr_setup_bg].bgcapture, true);
        set(layer[vr_setup_bg].handcursor, false);
        set(layer[vr_setup_bg].align, lefttop);
        set(layer[vr_setup_bg].width, 100%);
        set(layer[vr_setup_bg].height, 100%);
        set(layer[vr_setup_bg].zorder, 99999);
        
        <!-- get and prepare device infos and settings -->
        copy(i_screensize, webvr.mobilevr_screensize);
        if(i_screensize == 'auto', copy(i_screensize, webvr.devicesize));
        if(i_screensize LE 0, set(i_screensize, 5.0));
        roundval(i_screensize, 1);
        txtadd(i_screensize, ' 英寸');

        copy(i_ipd, webvr.mobilevr_ipd);
        roundval(i_ipd, 1);
        txtadd(i_ipd, ' 毫米');

        copy(i_fov, webvr.mobilevr_lens_fov);
        roundval(i_fov, 1);

        copy(i_dist, webvr.mobilevr_lens_dist);
        roundval(i_dist, 2);
        
        copy(i_dist2, webvr.mobilevr_lens_dist2);
        txtsplit(i_dist2, '|', i_dist2_k1, i_dist2_k2, i_dist2_k3, i_dist2_k4);
        mul(i_dist2_k1,1);
        mul(i_dist2_k2,10);
        mul(i_dist2_k3,10);
        mul(i_dist2_k4,10);
        roundval(i_dist2_k1,2);
        roundval(i_dist2_k2,2);
        roundval(i_dist2_k3,2);
        roundval(i_dist2_k4,2);

        copy(i_vig, webvr.mobilevr_lens_vign);
        roundval(i_vig, 0);
        
        copy(i_overlap, webvr.mobilevr_lens_overlap);
        roundval(i_overlap, 2);
        
        copy(i_ca, webvr.mobilevr_lens_ca);
        roundval(i_ca, 3);

        set(i_headset, '自定義');
        for(set(i,0), i LT vrheadsets.headset.count, inc(i),
            copy(hs, vrheadsets.headset[get(i)]);
            if(i_overlap == hs.overlap AND i_fov == hs.fov AND i_dist == hs.dist AND i_dist2 == hs.dist2 AND i_ca == hs.ca AND i_vig == hs.vig , copy(i_headset, hs.caption));
           );

        <!-- when the screen size is unknown, mark it red -->
        set(known_size, true);
        set(sizcol, #FFFFFF);
        copy(i_devicename, webvr.devicename);
        if(i_devicename == 'Unknown',
            if(webvr.mobilevr_screensize == 'auto',
                set(sizcol, #AA0000);
                set(known_size, false);
              ,
                set(i_devicename, '自定義');
              );
          );

        <!-- create layer for the main menu -->
        addlayer(vr_setup_m1);
        set(layer[vr_setup_m1].type, container);
        set(layer[vr_setup_m1].parent, vr_setup_bg);
        set(layer[vr_setup_m1].align, lefttop);
        set(layer[vr_setup_m1].width, 100%);
        set(layer[vr_setup_m1].height, 100%);
        
        <!-- create layer for the headset customization menu -->
        addlayer(vr_setup_m3);
        set(layer[vr_setup_m3].type, container);
        set(layer[vr_setup_m3].parent, vr_setup_bg);
        set(layer[vr_setup_m3].align, lefttop);
        set(layer[vr_setup_m3].width, 100%);
        set(layer[vr_setup_m3].height, 100%);
        set(layer[vr_setup_m3].visible, false);
        
        <!-- create layer for the calibration menu -->
        addlayer(vr_setup_m2);
        set(layer[vr_setup_m2].type, container);
        set(layer[vr_setup_m2].parent, vr_setup_bg);
        set(layer[vr_setup_m2].align, lefttop);
        set(layer[vr_setup_m2].width, 100%);
        set(layer[vr_setup_m2].height, 100%);
        set(layer[vr_setup_m2].visible, false);
        
        <!-- create the text elements -->
        set(vr_setup_text_parent, 'vr_setup_m1');
        vr_setup_createtext(vr_setup_title, 'VR設置',       center, center, 0, -225, #FFFFFF,     false);

        vr_setup_createtext(vr_setup_dvn1, '設備:',         center, right,  0, -145, #FFFFFF,     true, vr_setup_select('screen') );
        vr_setup_createtext(vr_setup_dvn2, get(i_devicename), center, left,   0, -145, get(sizcol), true, vr_setup_select('screen') );
        vr_setup_createtext(vr_setup_siz1, '屏幕尺寸:',     center, right,  0, -105, #FFFFFF,     true, vr_setup_select('screen') );
        vr_setup_createtext(vr_setup_siz2, get(i_screensize), center, left,   0, -105, get(sizcol), true, vr_setup_select('screen') );

        vr_setup_createtext(vr_setup_ipd1, '瞳距:',            center, right,  0,  -35, #FFFFFF,     true, vr_setup_select('ipd') );
        vr_setup_createtext(vr_setup_ipd2, get(i_ipd),        center, left,   0,  -35, #FFFFFF,     true, vr_setup_select('ipd') );

        vr_setup_createtext(vr_setup_hmd1, 'VR頭顯:',     center, right,  0,  +35, #FFFFFF,     true, vr_setup_select('headset') );
        vr_setup_createtext(vr_setup_hmd2, get(i_headset),    center, left,   0,  +35, #FFFFFF,     true, vr_setup_select('headset') );
        
        vr_setup_createtext(vr_setup_hmd3, '自定義設置',       center, center, 0,  +75, #FFFFFF,     true, set(background,true), set(background,false), vr_setup_customize_headset() );

        if(webvr.iswebvr == false,
            vr_setup_createtext(vr_setup_cal, '陀螺儀校準',   center, center,    0, +145, #FFFFFF,     true, set(background,true), set(background,false), vr_setup_calibration() );
          );

        vr_setup_createtext(vr_setup_sav, '保存',          center, center, -200, +225, #FFFFFF,     true, set(background,true), set(background,false), vr_setup_save() );
        vr_setup_createtext(vr_setup_rst, '恢復默認值',         center, center,    0, +225, #FFFFFF,     true, set(background,true), set(background,false), vr_setup_reset() );
        vr_setup_createtext(vr_setup_cls, '關閉',         center, center, +200, +225, #FFFFFF,     true, set(background,true), set(background,false), vr_setup_close() );
        
        <!-- and the adjusting buttons -->
        vr_setup_createbutton(vr_setup_btn1, '<', left,  left,  5%, -35, #FFFFFF, true, null);
        vr_setup_createbutton(vr_setup_btn2, '>', right, right, 5%, -35, #FFFFFF, true, null);
        
        <!-- create the customize_headset text elements -->
        set(vr_setup_text_parent, 'vr_setup_m3');
        vr_setup_createtext(vr_setup_m31, 'VR頭顯設備', center, center, 0, -225, #FFFFFF, false);
        
        vr_setup_createtext(vr_setup_fov1,  '垂直視域:',           center, right,  0,  -80,  #FFFFFF,    true, vr_setup_select('fov') );
        vr_setup_createtext(vr_setup_fov2, get(i_fov),        center, left,   0,  -80,  #FFFFFF,    true, vr_setup_select('fov') );
        vr_setup_createtext(vr_setup_dst1, '扭曲參數(shù):',     center, right,  0,  -32,  #FFFFFF,    true, vr_setup_select('dist') );
        vr_setup_createtext(vr_setup_dst2, get(i_dist),       center, left,   0,  -32,  #FFFFFF,    true, vr_setup_select('dist') );
        vr_setup_createtext(vr_setup_d2tx, '附加扭曲參數(shù):',          center, right,  0,  +16,  #FFFFFF,    true, vr_setup_select('dist2k1') );
        vr_setup_createtext(vr_setup_d2k1, get(i_dist2_k1),   center, left,   0,  +16,  #FFFFFF,    true, vr_setup_select('dist2k1') );
        vr_setup_createtext(vr_setup_d2k2, get(i_dist2_k2),   center, left, +100, +16,  #FFFFFF,    true, vr_setup_select('dist2k2') );
        vr_setup_createtext(vr_setup_d2k3, get(i_dist2_k3),   center, left, +200, +16,  #FFFFFF,    true, vr_setup_select('dist2k3') );
        vr_setup_createtext(vr_setup_d2k4, get(i_dist2_k4),   center, left, +300, +16,  #FFFFFF,    true, vr_setup_select('dist2k4') );
        
        vr_setup_createtext(vr_setup_cac1, '色差校正:',        center, right,  0,  +64,  #FFFFFF,    true, vr_setup_select('ca') );
        vr_setup_createtext(vr_setup_cac2, get(i_ca),         center, left,   0,  +64,  #FFFFFF,    true, vr_setup_select('ca') );
        vr_setup_createtext(vr_setup_vig1, '鏡頭暈影:',       center, right,  0, +112,  #FFFFFF,    true, vr_setup_select('vignette') );
        vr_setup_createtext(vr_setup_vig2, get(i_vig),        center, left,   0, +112,  #FFFFFF,    true, vr_setup_select('vignette') );
        vr_setup_createtext(vr_setup_olp1, '視野重疊:',        center, right,  0, +160,  #FFFFFF,    true, vr_setup_select('overlap') );
        vr_setup_createtext(vr_setup_olp2, get(i_overlap),    center, left,   0, +160,  #FFFFFF,    true, vr_setup_select('overlap') );
                
        vr_setup_createtext(vr_setup_m35, '關閉',       center, center, 0, +225, #FFFFFF, true, set(background,true), set(background,false), vr_setup_close_sub_menus() );
        
        <!-- create the calibration text elements -->
        set(vr_setup_text_parent, 'vr_setup_m2');
        vr_setup_createtext(vr_setup_cb1, '陀螺儀', center, center, 0, -225, #FFFFFF, false);
        vr_setup_createtext(vr_setup_cb2, '將設備放置在[br]水平面上包蓝,點擊校準[br]修正陀螺儀偏移.', center, center, 0, -95, #FFFFFF, false, vr_setup_select('screen') );
        vr_setup_createtext(vr_setup_cb3, '校準',   center, center, 0,  +55, #FFFFFF, true, set(background,true), set(background,false), vr_setup_do_calibration() );
        vr_setup_createtext(vr_setup_cb4, '恢復默認值',       center, center, 0, +125, #FFFFFF, true, set(background,true), set(background,false), webvr.resetcalibration() );
        vr_setup_createtext(vr_setup_cb5, '關閉',       center, center, 0, +225, #FFFFFF, true, set(background,true), set(background,false), vr_setup_close_sub_menus() );
        
        vr_setup_createtext(vr_setup_cb6, '校準中...',      bottom, center, 0, 40, #FFFFFF, false, null );
        vr_setup_createtext(vr_setup_cb7, '校準完成.',   bottom, center, 0, 40, #FFFFFF, false, null );
        vr_setup_createtext(vr_setup_cb8, '校準失敗!', bottom, center, 0, 40, #FFFFFF, false, null );
        set(layer[vr_setup_cb6].autoalpha, true);
        set(layer[vr_setup_cb7].autoalpha, true);
        set(layer[vr_setup_cb8].autoalpha, true);
        set(layer[vr_setup_cb6].alpha, 0.0);
        set(layer[vr_setup_cb7].alpha, 0.0);
        set(layer[vr_setup_cb8].alpha, 0.0);
        
        <!-- pre-select the screen size for adjusting when it is unknown, otherwise the IPD -->
        if(known_size == false,
            vr_setup_select('screen', true);
          ,
            vr_setup_select('ipd', true);
          );
        </action>

        <action name="vr_setup_createtext">
        <!--
            %1 = name
            %2 = text
            %3 = align
            %4 = edge
            %5 = x
            %6 = y
            %7 = color
            %8 = enabled
            %9 = ondown
            %10 = onup
            %11 = onclick
        -->
        addlayer(%1);
        set(layer[%1].parent, get(vr_setup_text_parent));
        set(layer[%1].url, '%SWFPATH%/plugins/textfield.swf');
        set(layer[%1].css, calc('text-align:%3;color:%7;font-size:'+40*webvr_setup_scale+'px;font-weight:bold;'));
        set(layer[%1].padding, calc(0 + ' ' + 8*webvr_setup_scale));
        set(layer[%1].roundedge, calc(8*webvr_setup_scale));
        set(layer[%1].background, false);
        set(layer[%1].backgroundcolor, 0xFFFFFF);
        set(layer[%1].backgroundalpha, 0.25);
        set(layer[%1].align, %3);
        set(layer[%1].edge, %4);
        set(layer[%1].x, calc(%5 * webvr_setup_scale));
        set(layer[%1].y, calc(%6 * webvr_setup_scale));
        set(layer[%1].html, %2);
        set(layer[%1].enabled, %8);
        set(layer[%1].ondown, %9);
        set(layer[%1].onup, %10);
        set(layer[%1].onclick, %11);
        </action>

        <action name="vr_setup_createbutton">
        vr_setup_createtext(%1,%2,%3,%4,%5,%6,%7,%8,%9);
        set(layer[%1].css, calc('vertical-align:middle;text-align:center;color:%7;font-size:'+60*webvr_setup_scale+'px;font-weight:bold;'));
        set(layer[%1].background, true);
        set(layer[%1].padding, 0);
        set(layer[%1].roundedge, calc(40 * webvr_setup_scale));
        set(layer[%1].width, calc(70 * webvr_setup_scale));
        set(layer[%1].height, calc(70 * webvr_setup_scale));
        set(layer[%1].vcenter, true);
        </action>

        <action name="vr_setup_reset">
        <!-- reset to the defaults -->
        set(webvr.mobilevr_screensize, 'auto');
        copy(i_screensize, webvr.devicesize);
        if(i_screensize LE 0, set(i_screensize, 5.0); );
        roundval(i_screensize, 1);
        set(layer[vr_setup_dvn2].html, get(webvr.devicename));
        txtadd(layer[vr_setup_siz2].html, get(i_screensize), ' 英寸');

        set(webvr.mobilevr_ipd, 63.5);
        copy(i_ipd, webvr.mobilevr_ipd);
        roundval(i_ipd, 1);
        txtadd(layer[vr_setup_ipd2].html, get(i_ipd), ' 毫米');

        <!-- set fake custom lens settings and call 'next' headset to switch to the default 'Cardboard' settings -->
        set(webvr.mobilevr_lens_fov, 100);
        set(webvr.mobilevr_lens_dist, 0.5);
        set(webvr.mobilevr_lens_dist2, '1|0|0|0');
        set(webvr.mobilevr_lens_vign, 100);
        set(webvr.mobilevr_lens_overlap, 1.0);
        set(webvr.mobilevr_lens_ca, 0.0);
        
        if(webvr.isfake AND device.desktop,
            <!-- select 'no distortion' headset for fake desktop usage -->
            vr_setup_change_headset(-1);
          ,
            <!-- select 'Cardboard A' headset for Mobile-VR usage -->
            vr_setup_change_headset(+1);    
          );

        vr_setup_select(get(selected_var));
        </action>

        <action name="vr_setup_close">
        <!-- 2. parameter == true => remove children elements too -->
        removelayer(vr_setup_bg, true);
        
        <!-- enable cursor -->
        set(webvr.vr_cursor_enabled, true);
        </action>

        <action name="vr_setup_save">
        webvr.saveSettings();
        vr_setup_close();
        </action>
    
        <action name="vr_setup_customize_headset">
        set(layer[vr_setup_bg].bgalpha, 0.1);
        
        set(layer[vr_setup_m1].visible,false);
        set(layer[vr_setup_m2].visible,false);
        set(layer[vr_setup_m3].visible,true);
        
        set(layer[vr_setup_hmd1].parent, vr_setup_m3);
        set(layer[vr_setup_hmd2].parent, vr_setup_m3);
        set(layer[vr_setup_btn1].parent, vr_setup_m3);
        set(layer[vr_setup_btn2].parent, vr_setup_m3);
        
        set(layer[vr_setup_hmd1].y, calc(-145 * webvr_setup_scale));
        set(layer[vr_setup_hmd2].y, calc(-145 * webvr_setup_scale));
        
        copy(old_selection, selected_var);
        vr_setup_select('headset');
        </action>
    
        <action name="vr_setup_calibration">
        set(layer[vr_setup_m1].visible,false);
        set(layer[vr_setup_m2].visible,true);
        </action>
    
        <action name="vr_setup_close_sub_menus">
        set(layer[vr_setup_bg].bgalpha, 0.5);
        
        set(layer[vr_setup_m1].visible,true);
        set(layer[vr_setup_m2].visible,false);
        set(layer[vr_setup_m3].visible,false);
        
        set(layer[vr_setup_hmd1].parent, vr_setup_m1);
        set(layer[vr_setup_hmd2].parent, vr_setup_m1);
        set(layer[vr_setup_btn1].parent, vr_setup_m1);
        set(layer[vr_setup_btn2].parent, vr_setup_m1);
        
        set(layer[vr_setup_hmd1].y, calc(+35 * webvr_setup_scale));
        set(layer[vr_setup_hmd2].y, calc(+35 * webvr_setup_scale));
        
        if(old_selection,
            vr_setup_select(get(old_selection));
            delete(old_selection);
          );
        </action>
    
        <action name="vr_setup_do_calibration">
        if(!webvr.isfake,
            tween(layer[vr_setup_cb6].alpha, 1.0, 0.1);
            tween(layer[vr_setup_cb7].alpha, 0.0, 0.1);
            tween(layer[vr_setup_cb8].alpha, 0.0, 0.1);
            webvr.calibrate(
                tween(layer[vr_setup_cb6].alpha, 0.0, 0.1);
                tween(layer[vr_setup_cb7].alpha, 1.0, 0.1);
                delayedcall(2.0, tween(layer[vr_setup_cb7].alpha, 0.0, 0.25) );
              ,
                tween(layer[vr_setup_cb6].alpha, 0.0, 0.1);
                tween(layer[vr_setup_cb8].alpha, 1.0, 0.1);
                delayedcall(2.0, tween(layer[vr_setup_cb8].alpha, 0.0, 0.25) );
              );
          );
        </action>

        <action name="vr_setup_update_dist2">
        txtadd(webvr.mobilevr_lens_dist2, get(i_dist2_k1), '|', calc(i_dist2_k2/10.0), '|', calc(i_dist2_k3/10.0), '|', calc(i_dist2_k4/10.0));
        vr_setup_change_headset(0);
        </action>

        <action name="vr_setup_select">
        <!-- select a setting for adjusting -->
        set(layer[vr_setup_siz2].background, false);
        set(layer[vr_setup_ipd2].background, false);
        set(layer[vr_setup_hmd2].background, false);
        set(layer[vr_setup_fov2].background, false);
        set(layer[vr_setup_dst2].background, false);
        set(layer[vr_setup_d2k1].background, false);
        set(layer[vr_setup_d2k2].background, false);
        set(layer[vr_setup_d2k3].background, false);
        set(layer[vr_setup_d2k4].background, false);
        set(layer[vr_setup_vig2].background, false);
        set(layer[vr_setup_cac2].background, false);
        set(layer[vr_setup_olp2].background, false);

        set(selected_setting, null);
        delete(selected_var_value);

        set(layer[vr_setup_btn1].ondown, vr_setup_change_ondown(-1) );
        set(layer[vr_setup_btn2].ondown, vr_setup_change_ondown(+1) );
        set(selected_var_callback, null);

        set(selected_var, %1);

        if(selected_var == 'screen',
            set(selected_setting,      vr_setup_siz2);
            set(selected_var_name,     'webvr.mobilevr_screensize');
            set(selected_var_postfix,  ' 英寸');
            copy(selected_var_value,   get(selected_var_name));
            if(selected_var_value == 'auto', copy(selected_var_value, webvr.devicesize));
            if(selected_var_value LE 0, set(selected_var_value, 5.0));
            set(selected_var_step,     0.1);
            set(selected_var_min,      4);
            set(selected_var_max,      10);
            set(selected_var_round,    1);
            set(selected_var_callback, vr_setup_change_screen() );
          );

        if(selected_var == 'ipd',
            set(selected_setting,      vr_setup_ipd2);
            set(selected_var_name,     'webvr.mobilevr_ipd');
            set(selected_var_postfix,  ' 毫米');
            copy(selected_var_value,   get(selected_var_name));
            set(selected_var_step,     0.1);
            set(selected_var_min,      40);
            set(selected_var_max,      80);
            set(selected_var_round,    1);
          );

        if(selected_var == 'headset',
            set(selected_setting,      vr_setup_hmd2);
            set(layer[vr_setup_btn1].ondown, vr_setup_change_headset(-1) );
            set(layer[vr_setup_btn2].ondown, vr_setup_change_headset(+1) );
          );

        if(selected_var == 'fov',
            set(selected_setting,      vr_setup_fov2);
            set(selected_var_name,     'webvr.mobilevr_lens_fov');
            set(selected_var_postfix,  '');
            copy(selected_var_value,   get(selected_var_name));
            set(selected_var_step,     0.1);
            set(selected_var_min,      40);
            set(selected_var_max,      179);
            set(selected_var_round,    1);
            set(selected_var_callback, vr_setup_change_headset(0) );
          );

        if(selected_var == 'dist',
            set(selected_setting,      vr_setup_dst2);
            set(selected_var_name,     'webvr.mobilevr_lens_dist');
            set(selected_var_postfix,  '');
            copy(selected_var_value,   get(selected_var_name));
            set(selected_var_step,     0.01);
            set(selected_var_min,      0);
            set(selected_var_max,      5);
            set(selected_var_round,    2);
            set(selected_var_callback, vr_setup_change_headset(0) );
          );
        
        if(selected_var == 'dist2k1',
            set(selected_setting,      vr_setup_d2k1);
            set(selected_var_name,     'i_dist2_k1');
            set(selected_var_postfix,  '');
            copy(selected_var_value,   get(selected_var_name));
            set(selected_var_step,     0.01);
            set(selected_var_min,      -9);
            set(selected_var_max,      +9);
            set(selected_var_round,    2);
            set(selected_var_callback, vr_setup_update_dist2() );
          );
        
        if(selected_var == 'dist2k2',
            set(selected_setting,      vr_setup_d2k2);
            set(selected_var_name,     'i_dist2_k2');
            set(selected_var_postfix,  '');
            copy(selected_var_value,   get(selected_var_name));
            set(selected_var_step,     0.01);
            set(selected_var_min,      -9);
            set(selected_var_max,      +9);
            set(selected_var_round,    2);
            set(selected_var_callback, vr_setup_update_dist2() );
          );
        
        if(selected_var == 'dist2k3',
            set(selected_setting,      vr_setup_d2k3);
            set(selected_var_name,     'i_dist2_k3');
            set(selected_var_postfix,  '');
            copy(selected_var_value,   get(selected_var_name));
            set(selected_var_step,     0.01);
            set(selected_var_min,      -9);
            set(selected_var_max,      +9);
            set(selected_var_round,    2);
            set(selected_var_callback, vr_setup_update_dist2() );
          );

        if(selected_var == 'dist2k4',
            set(selected_setting,      vr_setup_d2k4);
            set(selected_var_name,     'i_dist2_k4');
            set(selected_var_postfix,  '');
            copy(selected_var_value,   get(selected_var_name));
            set(selected_var_step,     0.01);
            set(selected_var_min,      -9);
            set(selected_var_max,      +9);
            set(selected_var_round,    2);
            set(selected_var_callback, vr_setup_update_dist2() );
          );

        if(selected_var == 'vignette',
            set(selected_setting,      vr_setup_vig2);
            set(selected_var_name,     'webvr.mobilevr_lens_vign');
            set(selected_var_postfix,  '');
            copy(selected_var_value,   get(selected_var_name));
            set(selected_var_step,     1);
            set(selected_var_min,      10);
            set(selected_var_max,      200);
            set(selected_var_round,    0);
            set(selected_var_callback, vr_setup_change_headset(0) );
          );

        if(selected_var == 'ca',
            set(selected_setting,      vr_setup_cac2);
            set(selected_var_name,     'webvr.mobilevr_lens_ca');
            set(selected_var_postfix,  '');
            copy(selected_var_value,   get(selected_var_name));
            set(selected_var_step,     0.01);
            set(selected_var_min,      -1.0);
            set(selected_var_max,      +1.0);
            set(selected_var_round,    2);
            set(selected_var_callback, vr_setup_change_headset(0) );
          );
          
        if(selected_var == 'overlap',
            set(selected_setting,      vr_setup_olp2);
            set(selected_var_name,     'webvr.mobilevr_lens_overlap');
            set(selected_var_postfix,  '');
            copy(selected_var_value,   get(selected_var_name));
            set(selected_var_step,     0.01);
            set(selected_var_min,      0.5);
            set(selected_var_max,      2.0);
            set(selected_var_round,    2);
            set(selected_var_callback, vr_setup_change_headset(0) );
          );

        if(selected_setting != null,
            set(layer[get(selected_setting)].background, true);
            if(%2 == true,
                set(layer[vr_setup_btn1].y, get(layer[get(selected_setting)].y));
                set(layer[vr_setup_btn2].y, get(layer[get(selected_setting)].y));
              ,
                tween(layer[vr_setup_btn1].y, get(layer[get(selected_setting)].y));
                tween(layer[vr_setup_btn2].y, get(layer[get(selected_setting)].y));
              );
          );
        </action>

        <action name="vr_setup_change_screen">
        set(layer[vr_setup_dvn2].html, '自定義');
        set(layer[vr_setup_dvn2].css, calc('color:#FFFFFF;font-size:'+40*webvr_setup_scale+'px;font-weight:bold;'));
        set(layer[vr_setup_siz2].css, calc('color:#FFFFFF;font-size:'+40*webvr_setup_scale+'px;font-weight:bold;'));
        </action>

        <action name="vr_setup_change_ondown">
        copy(t0,timertick);
        set(t1,0);
        asyncloop(pressed,
            copy(t2,timertick);
            sub(dt,t2,t1);
            if(dt GT 100,
                copy(t1,t2);
                sub(dt,t1,t0);
                div(dt,1000);
                Math.max(dt,1);
                mul(dt,%1);
                vr_setup_adjust(get(dt));
              );
          );
        </action>

        <action name="vr_setup_adjust">
        if(selected_setting != null,
            mul(change, selected_var_step, %1);
            add(selected_var_value, change);
            Math.max(selected_var_value, selected_var_min);
            Math.min(selected_var_value, selected_var_max);
            roundval(selected_var_value, get(selected_var_round));
            tween(get(selected_var_name), get(selected_var_value), 0.1);
            txtadd(layer[get(selected_setting)].html, get(selected_var_value), get(selected_var_postfix));
            if(selected_var_callback != null, selected_var_callback());
          );
        </action>

    <action name="vr_setup_change_headset">
        set(i_headset, '自定義');
        if(%1 != 0,
            copy(i_fov, webvr.mobilevr_lens_fov);
            roundval(i_fov, 1);
            copy(i_dist, webvr.mobilevr_lens_dist);
            roundval(i_dist, 2);
            copy(i_dist2, webvr.mobilevr_lens_dist2);
            copy(i_vig, webvr.mobilevr_lens_vign);
            roundval(i_vig, 0);
            copy(i_ca, webvr.mobilevr_lens_ca);
            roundval(i_ca, 3);
            copy(i_overlap, webvr.mobilevr_lens_overlap);
            roundval(i_overlap, 2);
            set(i_hsindex, -1);
            copy(i_hscount, vrheadsets.headset.count);
            for(set(i,0), i LT i_hscount, inc(i),
                copy(hs, vrheadsets.headset[get(i)]);
                if(i_overlap == hs.overlap AND i_fov == hs.fov AND i_dist == hs.dist AND i_dist2 == hs.dist2 AND i_ca == hs.ca AND i_vig == hs.vig , copy(i_hsindex, i); copy(i_headset, hs.caption); );
               );

            if(%1 GT 0,
                <!-- loop right -->
                add(i_hsindex, 1);
                if(i_hsindex GE i_hscount, set(i_hsindex,0));
              ,
                <!-- loop left -->
                sub(i_hsindex, 1);
                if(i_hsindex LT 0, sub(i_hsindex,i_hscount,1));
              );

            copy(hs, vrheadsets.headset[get(i_hsindex)]);
            copy(i_headset, hs.caption);
            copy(i_overlap, hs.overlap);
            copy(i_fov,     hs.fov);
            copy(i_dist,    hs.dist);
            copy(i_dist2,   hs.dist2);
            copy(i_ca,      hs.ca);
            copy(i_vig,     hs.vig);
          );

        copy(layer[vr_setup_hmd2].html, i_headset);
        if(%1 != 0,
            copy(webvr.mobilevr_lens_overlap, i_overlap);
            copy(webvr.mobilevr_lens_fov, i_fov);
            copy(webvr.mobilevr_lens_dist, i_dist);
            copy(webvr.mobilevr_lens_dist2, i_dist2);
            copy(webvr.mobilevr_lens_ca, i_ca);
            copy(webvr.mobilevr_lens_vign, i_vig);
            copy(layer[vr_setup_olp2].html, i_overlap);
            copy(layer[vr_setup_fov2].html, i_fov);
            copy(layer[vr_setup_dst2].html, i_dist);
            
            txtsplit(i_dist2, '|', i_dist2_k1, i_dist2_k2, i_dist2_k3, i_dist2_k4);
            mul(i_dist2_k1,1);
            mul(i_dist2_k2,10);
            mul(i_dist2_k3,10);
            mul(i_dist2_k4,10);
            roundval(i_dist2_k1,2);
            roundval(i_dist2_k2,2);
            roundval(i_dist2_k3,2);
            roundval(i_dist2_k4,2);
            copy(layer[vr_setup_d2k1].html, i_dist2_k1);
            copy(layer[vr_setup_d2k2].html, i_dist2_k2);
            copy(layer[vr_setup_d2k3].html, i_dist2_k3);
            copy(layer[vr_setup_d2k4].html, i_dist2_k4);
            
            copy(layer[vr_setup_cac2].html, i_ca);
            copy(layer[vr_setup_vig2].html, i_vig);
          );
    </action>
</krpano>

最終效果:


VR主界面.png
Customize界面.png
最后編輯于
?著作權歸作者所有,轉載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末划鸽,一起剝皮案震驚了整個濱河市如失,隨后出現(xiàn)的幾起案子睦疫,更是在濱河造成了極大的恐慌敏释,老刑警劉巖捐下,帶你破解...
    沈念sama閱讀 206,839評論 6 482
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件探越,死亡現(xiàn)場離奇詭異哪轿,居然都是意外死亡蹂午,警方通過查閱死者的電腦和手機栏豺,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 88,543評論 2 382
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來豆胸,“玉大人奥洼,你說我怎么就攤上這事⊥砗” “怎么了灵奖?”我有些...
    開封第一講書人閱讀 153,116評論 0 344
  • 文/不壞的土叔 我叫張陵,是天一觀的道長估盘。 經(jīng)常有香客問我瓷患,道長,這世上最難降的妖魔是什么遣妥? 我笑而不...
    開封第一講書人閱讀 55,371評論 1 279
  • 正文 為了忘掉前任擅编,我火速辦了婚禮,結果婚禮上箫踩,老公的妹妹穿的比我還像新娘爱态。我一直安慰自己,他們只是感情好境钟,可當我...
    茶點故事閱讀 64,384評論 5 374
  • 文/花漫 我一把揭開白布锦担。 她就那樣靜靜地躺著,像睡著了一般吱韭。 火紅的嫁衣襯著肌膚如雪吆豹。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 49,111評論 1 285
  • 那天理盆,我揣著相機與錄音痘煤,去河邊找鬼。 笑死猿规,一個胖子當著我的面吹牛衷快,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播姨俩,決...
    沈念sama閱讀 38,416評論 3 400
  • 文/蒼蘭香墨 我猛地睜開眼蘸拔,長吁一口氣:“原來是場噩夢啊……” “哼师郑!你這毒婦竟也來了?” 一聲冷哼從身側響起调窍,我...
    開封第一講書人閱讀 37,053評論 0 259
  • 序言:老撾萬榮一對情侶失蹤宝冕,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后邓萨,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體地梨,經(jīng)...
    沈念sama閱讀 43,558評論 1 300
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 36,007評論 2 325
  • 正文 我和宋清朗相戀三年缔恳,在試婚紗的時候發(fā)現(xiàn)自己被綠了宝剖。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 38,117評論 1 334
  • 序言:一個原本活蹦亂跳的男人離奇死亡歉甚,死狀恐怖万细,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情纸泄,我是刑警寧澤赖钞,帶...
    沈念sama閱讀 33,756評論 4 324
  • 正文 年R本政府宣布,位于F島的核電站聘裁,受9級特大地震影響仁烹,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜咧虎,卻給世界環(huán)境...
    茶點故事閱讀 39,324評論 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望计呈。 院中可真熱鬧砰诵,春花似錦、人聲如沸捌显。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,315評論 0 19
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽扶歪。三九已至理肺,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間善镰,已是汗流浹背妹萨。 一陣腳步聲響...
    開封第一講書人閱讀 31,539評論 1 262
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留炫欺,地道東北人乎完。 一個月前我還...
    沈念sama閱讀 45,578評論 2 355
  • 正文 我出身青樓,卻偏偏與公主長得像品洛,于是被迫代替她去往敵國和親树姨。 傳聞我的和親對象是個殘疾皇子摩桶,可洞房花燭夜當晚...
    茶點故事閱讀 42,877評論 2 345

推薦閱讀更多精彩內(nèi)容