Get world vector of point at screen (with CalcView modifications...)
1 replies, posted
G'Day. I need to get world vector of point that my mouse points. Here is screenshot why ScreenToVector CANT be used. [url]http://dl.dropbox.com/u/3766002/freespace06_v2-10013.jpg[/url]
Cursor is in down left corner. Any ideas? The thing i want to do is, i press C so mouse pops out, i aim with mouse and when i press M1 it sets my yaw/pitch to the position and shoots. I think that shooting part is best to make with GUIMousePressed and GUIMouseReleased. I handle angles in CreateMove. But how can i get the damn vector?
Okay, i seen this : [url]http://www.facepunch.com/showpost.php?p=22370248&postcount=26[/url] . That is what i need. I just cant use it >:|.
My calcview hook [lua]hook.Add("CalcView", "2D:CalcView", function(ply, origin, angles, fov)
if not enable:GetBool() then return end
local view = {}
local h = heigth:GetInt()
view.origin = origin + Vector(h,h,h)
view.angles = (ply:GetShootPos()-view.origin):Angle()
view.fov = fovz:GetInt()
return view
end)
[/lua]
I have NO idea if fov is in rads or something. I call function like that
[lua] local scrw=ScrW()
local scrh=ScrH()
local mx=gui.MouseX()
local my=gui.MouseY()
local ang= LPCameraScreenToVector(mx,my,scrw,scrh,Angle(35.264, 225, 0),fovz:GetInt()):Angle()
[/lua]
I tryed to input fovz with math.rad and math.deg. It didnt hit the ground anyways :|.
Sorry, you need to Log In to post a reply to this thread.