2.5.4 漫游参数及键盘热键配置


漫游参数及键盘热键配置

漫游参数及热键是指通过更新对象的方式改变CooRun SDK的漫游速度以及键盘控制按键。

主要包括添加(创建)、更新和删除3种操作。

参数说明

漫游参数及键盘热键配置包含的参数如下表所示:

配置项 配置说明 值类型 备注
OptionsTypeName 更新类型 string 漫游配置更新需设为:RoamConfigOptions
MoveSpeed 键盘移动速度 double 键盘控制场景移动的速度。单位(米).默认为1米
RotateSpeed 键盘旋转速度 double 键盘控制场景旋转的速度。单位(度)。默认为1度
RoamUseType 漫游操作类型 int 漫游操作类型。0-鼠标+键盘;1-键盘;2-鼠标。默认0
ChangeRoamMode 修改漫游模式 int 修改漫游模式。取值范围:-1-修改所有;0-普通模式;1-地下模式;2-室内模式;3-自动滑动模式;4-自动旋转模式;5-自定义滑动模式;6-步行模式;7-车行模式;8-飞行模式
KeyForward 前进键 string 默认W 键
KeyBackward 后退键 string 默认S 键
KeyLeft 向左移动键 string 默认A 键
KeyRight 向右移动键 string 默认D 键
KeyTurnLeft 向左旋转键 string 默认Q 键
KeyTurnRight 向右旋转键 string 默认E 键
KeyHeightUp 高度抬升键 string 默认T 键
KeyHeightDown 高度下降键 string 默认G 键
KeyRotateUp 向上抬头键 string 默认R 键
KeyRotateDown 向下低头键 string 默认F 键
KeyHome 主页键 string 默认H 键
KeyMoveSpeedUp 移动速度增加键 string 默认 ↑ 键
KeyMoveSpeedDown 移动速度减小键 string 默认 ↓ 键
KeyRotateSpeedUp 旋转速度增加键 string 默认 ← 键
KeyRotateSpeedDown 旋转速度减小键 string 默认 → 键

代码调用示例

Javascript调用

var operationPtr = null;
//生效参数配置
function applyParam(){
    var tlo = map.CreateOperationOptions("RoamConfigOptions");//创建更新配置对象,任意名称
    tlo.AddConfig("OptionsTypeName", "RoamConfigOptions");//更新类型,RoamConfigOptions代表漫游配置更新
    //ChangeRoamMode取值范围:-1-修改所有;0-普通模式;1-地下模式;2-室内模式;3-自动滑动模式;4-自动旋转模式;5-自定义滑动模式;6-步行模式;7-车行模式;8-飞行模式
    tlo.AddConfig("ChangeRoamMode", "-1");//ChangeRoamMode-修改漫游模式。
    tlo.AddConfig("RoamUseType", "0");//漫游操作类型。0-鼠标+键盘;1-键盘;2-鼠标。默认0。
    tlo.AddConfig("MoveSpeed", "10");//键盘移动速度。默认1
    tlo.AddConfig("RotateSpeed", "0.1");//键盘旋转速度。默认1°
    if(operationPtr == null){
        operationPtr = map.CreateOperation("RoamConfigOperation", tlo);//创建更新对象。RoamConfigOperation代表漫游配置更新对象
        map.AddOperation(operationPtr);//添加更新对象    
    }
    else{
        operationPtr.UpdateOperationOptions(tlo);//更新更新对象
    }
}
//生效热键配置
function applyHotkey(){
    var tlo = map.CreateOperationOptions("RoamConfigOptions");//创建更新配置对象,任意名称
    tlo.AddConfig("OptionsTypeName", "RoamConfigOptions");//更新类型,RoamConfigOptions代表漫游配置更新
    tlo.AddConfig("KeyForward", "i");//前进键
    tlo.AddConfig("KeyBackward", "k");//后退键
    tlo.AddConfig("KeyLeft", "j");//向左移动键
    tlo.AddConfig("KeyRight", "l");//向右移动键
    tlo.AddConfig("KeyTurnLeft", "u");//向左旋转键
    tlo.AddConfig("KeyTurnRight", "o");//向右旋转键
    tlo.AddConfig("KeyRotateUp", "y");//向上抬头键
    tlo.AddConfig("KeyRotateDown", "h");//向下低头键
    tlo.AddConfig("KeyHeightUp", "t");//高度抬升键
    tlo.AddConfig("KeyHeightDown", "g");//高度下降键
    tlo.AddConfig("KeyHome", "0");//主页键
    tlo.AddConfig("KeyMoveSpeedUp", "+");//移动速度增加键
    tlo.AddConfig("KeyMoveSpeedDown", "-");//移动速度减小键
    tlo.AddConfig("KeyRotateSpeedUp", "z");//旋转速度增加键
    tlo.AddConfig("KeyRotateSpeedDown", "x");//旋转速度减小键
    if(operationPtr == null){
        operationPtr = map.CreateOperation("RoamConfigOperation", tlo);//创建更新对象。RoamConfigOperation代表漫游配置更新对象
        map.AddOperation(operationPtr);//添加更新对象
    }else{
        operationPtr.UpdateOperationOptions(tlo);//更新更新对象
    }
}

//移除配置
function removeapply()
{
    if(operationPtr)
    {
        map.RemoveOperation(operationPtr);//移除更新操作
        operationPtr = null;
    }
}

C++调用

BaseObjectCOMLib::IOperationObjectPtr operationPtr;//更新对象

//生效参数配置
void Cf4c3ApplyDlg::OnBnClickedapplyparam()
{
    ConfigOptionsCOMLib::IOperationOptionPtr tlo = map->CreateOperationOptions("RoamConfigOptions");//创建更新配置对象,任意名称
    tlo->AddConfig("OptionsTypeName", "RoamConfigOptions");//更新类型,RoamConfigOptions代表漫游配置更新
    //ChangeRoamMode取值范围:-1-修改所有;0-普通模式;1-地下模式;2-室内模式;3-自动滑动模式;4-自动旋转模式;5-自定义滑动模式;6-步行模式;7-车行模式;8-飞行模式
    tlo->AddConfig("ChangeRoamMode", "-1");//ChangeRoamMode-修改漫游模式。
    tlo->AddConfig("RoamUseType", "0");//漫游操作类型。0-鼠标+键盘;1-键盘;2-鼠标。默认0。
    tlo->AddConfig("MoveSpeed", "10");//键盘移动速度。默认1
    tlo->AddConfig("RotateSpeed", "0.1");//键盘旋转速度。默认1°
    if(operationPtr == NULL){
        operationPtr = map->CreateOperation("RoamConfigOperation", tlo);//创建更新对象。RoamConfigOperation代表漫游配置更新对象
        map->AddOperation(operationPtr);//添加更新对象    
    }
    else{
        operationPtr->UpdateOperationOptions(tlo);//更新更新对象
    }
}

//生效热键配置
void Cf4c3ApplyDlg::OnBnClickedapplyhotkey()
{
    ConfigOptionsCOMLib::IOperationOptionPtr tlo = map->CreateOperationOptions("RoamConfigOptions");//创建更新配置对象,任意名称
    tlo->AddConfig("OptionsTypeName", "RoamConfigOptions");//更新类型,RoamConfigOptions代表漫游配置更新
    tlo->AddConfig("KeyDefaultState", "false");//是否生效默认键盘按键配置。如要生效自定义配置,请设置为false
    tlo->AddConfig("KeyForward", "i");//前进键
    tlo->AddConfig("KeyBackward", "k");//后退键
    tlo->AddConfig("KeyLeft", "j");//向左移动键
    tlo->AddConfig("KeyRight", "l");//向右移动键
    tlo->AddConfig("KeyTurnLeft", "u");//向左旋转键
    tlo->AddConfig("KeyTurnRight", "o");//向右旋转键
    tlo->AddConfig("KeyRotateUp", "y");//向上抬头键
    tlo->AddConfig("KeyRotateDown", "h");//向下低头键
    tlo->AddConfig("KeyHeightUp", "t");//高度抬升键
    tlo->AddConfig("KeyHeightDown", "g");//高度下降键
    tlo->AddConfig("KeyHome", "0");//主页键
    tlo->AddConfig("KeyMoveSpeedUp", "+");//移动速度增加键
    tlo->AddConfig("KeyMoveSpeedDown", "-");//移动速度减小键
    tlo->AddConfig("KeyRotateSpeedUp", "z");//旋转速度增加键
    tlo->AddConfig("KeyRotateSpeedDown", "x");//旋转速度减小键
    if(operationPtr == NULL){
        operationPtr = map->CreateOperation("RoamConfigOperation", tlo);//创建更新对象。RoamConfigOperation代表漫游配置更新对象
        map->AddOperation(operationPtr);//添加更新对象    
    }
    else{
        operationPtr->UpdateOperationOptions(tlo);//更新更新对象
    }
}

//移除配置
void Cf4c3ApplyDlg::OnBnClickedremoveapply()
{
    if(operationPtr)
    {
        map->RemoveOperation(operationPtr);//移除更新操作
        operationPtr = NULL;
    }
}

C#调用

IOperationObject operationPtr;//更新对象
//生效参数配置
private void applyParam_Click(object sender, EventArgs e)
{
    var tlo = map.CreateOperationOptions("RoamConfigOptions");//创建更新配置对象,任意名称
    tlo.AddConfig("OptionsTypeName", "RoamConfigOptions");//更新类型,RoamConfigOptions代表漫游配置更新
    //ChangeRoamMode取值范围:-1-修改所有;0-普通模式;1-地下模式;2-室内模式;3-自动滑动模式;4-自动旋转模式;5-自定义滑动模式;6-步行模式;7-车行模式;8-飞行模式
    tlo.AddConfig("ChangeRoamMode", "-1");//ChangeRoamMode-修改漫游模式。
    tlo.AddConfig("RoamUseType", "0");//漫游操作类型。0-鼠标+键盘;1-键盘;2-鼠标。默认0。
    tlo.AddConfig("MoveSpeed", "10");//键盘移动速度。默认1
    tlo.AddConfig("RotateSpeed", "0.1");//键盘旋转速度。默认1°
    if (operationPtr == null)
    {
        operationPtr = map.CreateOperation("RoamConfigOperation", tlo);//创建更新对象。RoamConfigOperation代表漫游配置更新对象
        map.AddOperation(operationPtr);//添加更新对象    
    }
    else
    {
        operationPtr.UpdateOperationOptions(tlo);//更新更新对象
    }
}
//生效热键配置
private void applyHotkey_Click(object sender, EventArgs e)
{
    var tlo = map.CreateOperationOptions("RoamConfigOptions");//创建更新配置对象,任意名称
    tlo.AddConfig("OptionsTypeName", "RoamConfigOptions");//更新类型,RoamConfigOptions代表漫游配置更新
    tlo.AddConfig("KeyForward", "i");//前进键
    tlo.AddConfig("KeyBackward", "k");//后退键
    tlo.AddConfig("KeyLeft", "j");//向左移动键
    tlo.AddConfig("KeyRight", "l");//向右移动键
    tlo.AddConfig("KeyTurnLeft", "u");//向左旋转键
    tlo.AddConfig("KeyTurnRight", "o");//向右旋转键
    tlo.AddConfig("KeyRotateUp", "y");//向上抬头键
    tlo.AddConfig("KeyRotateDown", "h");//向下低头键
    tlo.AddConfig("KeyHeightUp", "t");//高度抬升键
    tlo.AddConfig("KeyHeightDown", "g");//高度下降键
    tlo.AddConfig("KeyHome", "0");//主页键
    tlo.AddConfig("KeyMoveSpeedUp", "+");//移动速度增加键
    tlo.AddConfig("KeyMoveSpeedDown", "-");//移动速度减小键
    tlo.AddConfig("KeyRotateSpeedUp", "z");//旋转速度增加键
    tlo.AddConfig("KeyRotateSpeedDown", "x");//旋转速度减小键
    if (operationPtr == null)
    {
        operationPtr = map.CreateOperation("RoamConfigOperation", tlo);//创建更新对象。RoamConfigOperation代表漫游配置更新对象
        map.AddOperation(operationPtr);//添加更新对象
    }
    else
    {
        operationPtr.UpdateOperationOptions(tlo);//更新更新对象
    }
}
//移除配置
private void removeapply_Click(object sender, EventArgs e)
{
    if (operationPtr != null)
    {
        map.RemoveOperation(operationPtr);//移除更新操作
        operationPtr = null;
    }
}

results matching ""

    No results matching ""