Export Matrix class?
Posted: Tue Dec 02, 2014 4:48 am
I'm trying to build a scene graph library for LOVE.
Every thing goes well except one:
It is hard to implement a hit check function for a rotated and scaled button.
(maybe rotated and scaled by parent nodes).
All I need is a matrix library and best integrated with LOVE graphics module.
With this matrix library, I could translate screen coords to local
The problems are:
1. Where shall i put the Matrix object? love.math.Matrix?
2. The current Matrix class is not an Object, shall we convert it to Object or write a adaptor class?
Every thing goes well except one:
It is hard to implement a hit check function for a rotated and scaled button.
(maybe rotated and scaled by parent nodes).
All I need is a matrix library and best integrated with LOVE graphics module.
Code: Select all
function love.load()
node.mat = love.graphics.newMatrix()
node.image = love.graphics.newImage('my/image.png')
function node:draw()
love.graphics.transform(self.mat)
love.graphics.draw(self.image)
end
end
function love.update(dt)
node.mat.rotate(dt)
end
function love.draw()
node:draw()
end
Code: Select all
function screenToLocal(x, y)
local m = mat1*mat2*mat3
return m:inverse():transform(x, y)
end
The problems are:
1. Where shall i put the Matrix object? love.math.Matrix?
2. The current Matrix class is not an Object, shall we convert it to Object or write a adaptor class?