+ | blocker : _Scene |
阻挡场景。
|
+ | blockRebound : number |
摄像机碰撞后的回弹距离。默认值为0。
|
+ | eye : _Vector3 |
摄像机的eye点位置。
|
+ | fov : number |
摄像机的fov角度。
|
+ | interpolationMode: number |
设置摄像机move移动时候的方式,默认是速度由快到慢。
|
+ | lockEye : bool |
是否锁定eye点。
|
+ | lockFov : bool |
是否锁定fov角度。
|
+ | lockLook : bool |
是否锁定look点。
|
+ | lockPhi : bool |
是否锁定phi值。
|
+ | lockRadius : bool |
是否锁定radius值。
|
+ | lockTheta : bool |
是否锁定theta值。
|
+ | lockUp : bool |
是否锁定上方向。
|
+ | look : _Vector3 |
摄像机的look点位置。
|
+ | name : string |
摄像机名称。
|
+ | ortho : bool |
摄像机的正交性。
|
+ | phiMax : number |
摄像机在球坐标系下phi的最大值。
|
+ | phiMin : number |
摄像机在球坐标系下phi的最小值。
|
+ | radiusMax : number |
摄像机在球坐标系下radius的最大值。
|
+ | radiusMin : number |
摄像机在球坐标系下radius的最小值。
|
+ | thetaMax : number |
摄像机在球坐标系下theta的最大值。
|
+ | thetaMin : number |
摄像机在球坐标系下theta的最小值。
|
+ | up : _Vector3 |
摄像机的上方向。
|
+ | viewFar : number |
摄像机的远剪裁面。
|
+ | viewNear : number |
摄像机的近剪裁面。
|
+ | viewport : _Rect |
摄像机的ViewPort。
|
+ | phi : number |
摄像机在球坐标系下的phi值。
|
+ | radius : number |
摄像机在球坐标系下的radius值。
|
+ | theta : number |
摄像机在球坐标系下的theta值。
|
+ | function clone() : _Camera |
克隆一个_Camera。
|
+ |
function focus(v : _Vector3, time :uint) function focus(x : number, y : number, z : number, time :uint) |
保持摄像机方向不变,将look点设为参数指定的点(即平移过去)。
|
+ | function lookLeft(phi : number, time :uint) |
以上方向为轴,以逆时针方向转动phi弧度,如果设了time, 则在time时间内匀速转过去。
|
+ | function lookUp(theta : number, time : uint) |
摄像机以右方向为轴, 向着上方向转动theta弧度, 如果设了time, 则在time时间内匀速转过去。
|
+ | function move(cam : _Camera, time : uint) |
在time时间内匀速移动本摄像机到传入摄像机的位置。
|
+ | function moveEye(x : number, y : number, z : number[, time : uint]) |
移动eye点的位置。可选参数,在time时间内将eye点从当前位置移到(x, y, z)点。time缺省值为0。 示例
|
+ | function moveFov(f : number[, time : uint]) |
改动fov的值。可选参数,在time时间内将fov从当前值变化到f。time缺省值为0。
|
+ | function moveLook(x : number, y : number, z : number[, time : uint]) |
移动look点的位置。可选参数,在time时间内将look点从当前位置移到(x, y, z)点。time缺省值为0。
|
+ | function movePhi(p : number[, time : uint]) |
改动phi的值。可选参数,在time时间内将phi从当前值变化到phi + p。time缺省值为0。
|
+ | function moveRadius(r : number[, time : uint]) |
改动radius的值。可选参数,在time时间内将radius从当前值变化到radius + r。time缺省值为0。
|
+ | function moveTheta(th : number[, time : uint]) |
改动theta的值。可选参数,在time时间内将theta从当前值变化到theta + th。time缺省值为0。
|
+ | function moveUp(x : number, y : number, z : number[, time : uint]) |
移动up方向。可选参数,在time时间内将up方向从当前方向移到(x, y, z)。time缺省值为0。
|
+ | function set(cam : _Camera) |
赋值操作。
|
+ | function setBlocker(blocker : _Scene, pickFlag : uint, pickGroup : uint) |
设置摄像机碰撞。参数blocker为摄像机碰撞的场景,参数pickFlag与pickGroup为碰撞时使用的标志位。
|
+ | function shake(min : number, max : number, time : uint) |
晃动摄像机。可选参数,在time时间内晃动摄像机。晃动距离最小值为min, 最大值为max。
|
_sys:addPath('res') -- 将路径加入到资源库中。加入后该路径下的文件与目录都,可以在资源库中直接访问。msh1 = _Mesh.new('moon.msh') -- 创建网格对象mat1 = _Matrix3D.new() -- 创建矩阵对象mat1:mulTranslationRight(20, 0, 0)mouse = {mousex = 0, mousey = 0}function render() _rd:drawAxis(100) if _sys:isKeyDown(_System.KeyLeft) then mat1:mulTranslationRight(0.05, 0, 0) end if _sys:isKeyDown(_System.KeyRight) then mat1:mulTranslationRight(-0.05, 0, 0) end if _sys:isKeyDown(_System.KeyUp) then mat1:mulTranslationRight(0,0.05,0) end if _sys:isKeyDown(_System.KeyDown) then mat1:mulTranslationRight(0, -0.05, 0) end-- if _sys:isKeyDown(_System.KeyRight) then-- mat1:mulTranslationRight(-0.05, 0, 0)-- end-- if _sys:isKeyDown(_System.KeyRight) then-- mat1:mulTranslationRight(-0.05, 0, 0)-- end _rd:pushMatrix3D(mat1) msh1:drawMesh() _rd:popMatrix3D() endfunction mouseMove(x, y) if _sys:isKeyDown(_System.MouseLeft) then _rd.camera:movePhi((x - mouse.mousex) * 0.005) _rd.camera:moveTheta((y - mouse.mousey) * 0.005) else if _sys:isKeyDown(_System.MouseRight) then lookDir = _Vector3.sub(_rd.camera.look, _rd.camera.eye) vecX = _Vector3.cross(lookDir, _rd.camera.up) vecX:normalize() vecY = _Vector3.cross(lookDir, vecX) vecY:normalize() nearMoveX = _Vector3.mul(vecX, -(mouse.mousex - x) * 0.00015) nearMoveY = _Vector3.mul(vecY, (mouse.mousey - y) * 0.00015) LookMoveX = _Vector3.mul(nearMoveX, lookDir:magnitude() / _rd.camera.viewNear) LookMoveY = _Vector3.mul(nearMoveY, lookDir:magnitude() / _rd.camera.viewNear) LookMove = _Vector3.add(LookMoveX , LookMoveY) _rd.camera:moveEye(_rd.camera.eye.x + LookMove.x, _rd.camera.eye.y + LookMove.y, _rd.camera.eye.z + LookMove.z) _rd.camera:moveLook(_rd.camera.look.x + LookMove.x, _rd.camera.look.y + LookMove.y, _rd.camera.look.z + LookMove.z) end end mouse.mousex = x mouse.mousey = yendfunction mouseWheel(a) if a == 1 then _rd.camera:moveRadius(a * 3) end if a== -1 then _rd.camera:moveRadius(a * 3) endendfunction mouseDbclick(a, x, y) _rd.camera:shake(5, 20, 1000)end_app:onIdle(render)_app:onMouseDbclick(mouseDbclick)_app:onMouseWheel(mouseWheel)_app:onMouseDown(mouseDown)_app:onMouseUp(mouseUp)_app:onMouseMove(mouseMove)