_Indicator

用来描述一个场景指示器。它绑定在一个transform上,可以通过鼠标拖动改变该transform。 全部展开

属性展开

  • + mode : uint

    指示器模式,分为Global模式和Local模式

  • + rotationGridSize : number

    旋转格子尺寸

    • 示例

       indicator.rotationGridSize = 10
  • + scalingGridSize : number

    缩放格子尺寸

    • 示例

       indicator.scalingGridSize = 10
  • + state : int

    显示和操作状态,可以为下列枚举值:0移动目标位置,1旋转目标,2缩放目标。

    • 示例

       indicator.state = 0
  • + transform : _Matrix3D

    绑定的transform。

    • 示例

       indicator.transform = _Matrix3D.new(1, 1, 1)
  • + translationGridSize : number

    平移格子尺寸

    • 示例

       indicator.translationGridSize = 10

静态属性展开

  • + Global : uint

    指示器世界模式,以世界坐标系为基准

  • + Local : uint

    指示器自身模式,以模型自身坐标系为基准

  • + Rotation : uint

    指示器旋转状态

  • + Scale : uint

    指示器缩放状态

  • + Translation : uint

    指示器平移状态

公共方法展开

  • + function draw(x : int, y : int)

    绘制自己。

    • 参数
    • x, y : 可选参数。如果不填,则绘制在目标transform在屏幕投影的位置。如果填入,则绘制在屏幕的( x, y )位置。
      • 示例
    •  indicator = _Indicator.new()
      indicator:draw(0, 0)
  • + function onChange(change : function)

    _Indicator发生改变时的回调。

    • 参数
    • change : 改变时的回调函数。
      • 示例
    •  indicator = _Indicator.new()
      indicator:onChange(function()
       print("onChange!")
      end)
  • + function operEnd()

    接收鼠标抬起的消息。

    示例

        indicator = _Indicator.new()
    function mouseUp(x, y)
    indicator:operEnd(x, y)
    end
    _app:onMouseUp(mouseUp)
  • + function operMove(x : int, y : int)

    用于接收鼠标移动的消息。

    • 参数
    • x, y : 鼠标的当前位置。
      • 示例
    •  indicator = _Indicator.new()
      function mouseMove(x, y)
      indicator:operMove(x, y)
      end
  • + function operStart(x : int, y : int)

    用于接收鼠标按下的消息。

    • 参数
    • x, y : 鼠标按下的 x, y 坐标。
      • 示例
    •  indicator = _Indicator.new()
      function mouseDown(button, x, y)
      indicator:operStart(x, y)
      end
      _app:onMouseDown(mouseDown)

代码示例

    _sys:addPath('res')
    curMesh = _Mesh.new("earth.msh");
    mat = _Matrix3D.new();

    indicator = _Indicator.new();
    indicator.transform = mat;

    font = _Font.new('Arial', 10)
    font.textColor = _Color.Yellow

    _app:onKeyDown(function(key)
    if key == _System.Key1 then
    indicator.state = 0
    elseif key == _System.Key2 then
    indicator.state = 1
    elseif key == _System.Key3 then
    indicator.state = 2
    end
    end)

    function render( e )
    font:drawText(0, 0, 'Press 1 to adjust by move')
    font:drawText(0, 14, 'Press 2 to adjust by revolve')
    font:drawText(0, 28, 'Press 3 to adjust by zoom')
    _rd:push3DMatrix(mat);
    curMesh:drawMesh( );
    _rd:pop3DMatrix();
    indicator:draw();
    end

    _app:onIdle( render );

    function mouseDown(button , x , y )
    indicator:operStart( x , y );
    end

    _app:onMouseDown( mouseDown )

    --operMove must write in onMouseMove
    function mouseMove( x , y )
    indicator:operMove( x , y );
    end

    _app:onMouseMove( mouseMove )

    --operEnd must write in onMouseUp
    function mouseUp( x , y )
    indicator:operEnd( x , y );
    end

    _app:onMouseUp( mouseUp )
问题反馈(登录才可以发表哦!)