System/UnprojectFromScreen

From Blue Mars Developer Guidebook

Jump to: navigation, search
There are security restrictions on this article


This is a System function

Contents

Function

UnprojectFromScreen(point)
tranform screen coordinate into world coordinates
return value - vector transformed point

Usage

Notes

  • This function is useful in conjunction with Physics/RayWorldIntersectionAR for mouse selection of objects.
  • The selection may be offset in the Sandbox Editor

Examples

From Game/Scripts/Utils/AR/ARMouse.lua

function ARMousePick(type,flags,num)
   local uix,uiy = System.GetWindowMouse();
  local width,height = HUD.GetSize();
  local s= {x=uix,y=height-uiy,z=1.0};
  local p=System.UnprojectFromScreen(s);
  local vSrc=System.GetViewCameraPos();
  local vDir = DifferenceVectors(p,vSrc);
   return Physics.RayWorldIntersectionAR(vSrc,vDir,num,type,flags,nil,g_HitTable);

History

  • 1/15/2009 - added by Avatar Reality
  • 3/18/2009 - fixed to always use current game camera
Problems with this wiki page? Contact us either by: Support Email or Support Ticket System

Blue Mars Guidebook Privacy Policy
Blue Mars Guidebook Community Guidelines

Personal tools