Difference between revisions of "Matrix:transformPoint"

From GiderosMobile
(added example)
m (Text replacement - "<source" to "<syntaxhighlight")
Line 5: Line 5:
 
=== Description ===
 
=== 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.
 
Transforms the matrix to an array of points. This function applies the geometric transform represented by the Matrix to a specified array of points.
<source lang="lua">
+
<syntaxhighlight lang="lua">
 
Matrix:transformPoint()
 
Matrix:transformPoint()
 
</source>
 
</source>
Line 11: Line 11:
 
=== Example ===
 
=== 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'''
 
'''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'''
<source lang="lua">
+
<syntaxhighlight lang="lua">
 
-- game loop
 
-- game loop
 
function LevelX:onEnterFrame(e)
 
function LevelX:onEnterFrame(e)

Revision as of 14:28, 13 July 2023

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. <syntaxhighlight lang="lua"> Matrix:transformPoint() </source>

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 <syntaxhighlight lang="lua"> -- 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 </source>