GetUnProjectedPoint

(Difference between revisions)
Jump to: navigation, search
Anael (Talk | contribs)
(Created page with "Returns the un-projected point of a screen-space point : point = getUnProjectedPoint(Camera, vec3(x, y, z)) It can be used for example to pick a 3d object using the mouse p...")
Newer edit →

Revision as of 16:23, 5 February 2013

Returns the un-projected point of a screen-space point :

point = getUnProjectedPoint(Camera, vec3(x, y, z))

It can be used for example to pick a 3d object using the mouse position :

function onSceneUpdate()

	mx = getAxis("MOUSE_X")
	my = getAxis("MOUSE_Y")	

	V1 = getUnProjectedPoint(Camera, vec3(mx, my, 0))
	V2 = getUnProjectedPoint(Camera, vec3(mx, my, 1))

	point, object = rayHit(V1, V2) -- note that rayHit only detects objects with physics enabled

	if point then
		rotate(object, {0, 0, -1}, 1) -- rotate the selected object
	end

end
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox