drunken_thor wrote:I would need to calculate the normal/glowmap/material all at once for the draw call and right now I do not know how I could do that while keeping the API relatively simple and not prone to user error.
I would love to see a proposal
Huh? why would you need to calculate normal/glow/mat? When you use anim8 you are applying transformations to normal maps.
So for example you are writing this:
@light world segment from body class
Code: Select all
self.animation:draw(self.img, self.x, self.y, self.rotation, self.scalex, self.scaley, self.ix, self.iy)
@anim8;
Code: Select all
function Animation:draw(image, x, y, r, sx, sy, ox, oy, ...)
local frame = self.frames[self.position]
love.graphics.draw(image, frame, x, y, r, sx, sy, ox, oy, ...)
So what you are actually doing is this:
Code: Select all
love.graphics.draw(self.normal,frame, self.x, self.y, self.rotation, self.scalex, self.scaley, self.ix, self.iy)
And guess what the frame is, Its a quad.
and all of those :flipH and etc are simply uneccesary! All you could do is, body:setParentAnimation(animation) and then the user could specifiy the animation, from which on the update call will set the quad as animation.frames[frame]
so the animation movement would follow that of the parent. All that anim8 does is make quads and then it will apply transformations to them as-well as other stuff such as filpH and so on.
Besides, you apply shaders to the canvas meaning that anything in the canvas will be rendered using the GLSL therefore you won't have to do any calculations on draw calls but instead the GLSL will have more work to do in regards of the tiled images which ideally it should be able to cope with. You can simply use the work you have already done to implement the rest, you already get the width and height of the quad during the update, therefore a set quad function would look something like this
Code: Select all
function body:setQuad(quad)
_,_,self.width, self.height = quad:getViewport()
self.imgWidth, self.imgHeight = self.width, self.height
self.normalWidth, self.normalHeight = self.width, self.height
self.ix, self.iy = self.imgWidth * 0.5,self.imgHeight * 0.5
self.nx, self.ny = self.ix, self.iy
self.quad = quad
end
However there is a more concerning issue at hand. What about shadows? That I cannot yet answer with my insufficient knowledge of how the plugin works, But I am rather interested if you can apply quads to a shadow mesh. I am not sure if I am correct but isn't a mesh an advanced form of a quad?
Please do inform me if any of this is wrong. Mind you I recently started graphical programming and things like GLSL is still quite mysterious for me, so if I am wrong then please do correct me. Thank you!
PS
You might also want to include assert statements so for example under :setQuad(quad) you'd do;
Code: Select all
:setQuad(quad)
assert(quad,"Please specify a quad")
if type ~= quad then
error("Expected quad, got: "..quad)
end
This will avoid most of the user-based errors. The best thing you could do is add enough use ability so new functions could be added and so on.