Matrix:transformPoint

From GiderosMobile

Available since: Gideros 2013.9
Class: Matrix

Description

Transforms the matrix to an array of points. This function applies the geometric transform represented by the Matrix to a specified array of points.

Matrix:transformPoint()

Example

In this example we reset the player1 matrix by transforming it to the points (0, 0, 0) and we use the result for the lighting

-- game loop
function LevelX:onEnterFrame(e)
	local matrix = self.player1.body:getTransform()
	local playerx, playery, playerz = self.player1.body:getTransform():getPosition()
	-- move player
	local force = 12
	if self.player1.isleft and not self.player1.isright then
		self.player1.body:applyLocalForceAtCenterOfMass(0, 0, force)
	elseif self.player1.isright and not self.player1.isleft then
		self.player1.body:applyLocalForceAtCenterOfMass(0, 0, -force)
	end
	-- position the player model along its body
	self.player1:setMatrix(matrix)
	-- the camera FPS style
	self.camera:lookAt(playerx+0.1, playery+24, playerz+4,
		playerx, playery, playerz+4
	)
	-- lighting
	local px, py, pz = matrix:transformPoint(0, 0, 0) -- hgy29
	Lighting.setLight(px, py+8, pz+1, 0.2)
	Lighting.setLightTarget(px, py, pz, 32, 20)
	--Compute shadows
	Lighting.computeShadows(self.scene)
end