-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
how to handle camera usage? #218
Comments
does it work without gamera?
…On Thu, May 16, 2019, 17:07 Philipp, ***@***.***> wrote:
I have a problem when i use sti with a camera like gamera
<https://github.com/kikito/gamera>. If i use no special window and
display the map in the full window everything is ok. But when i use a
defined window where the map should be drawn, the viewport is displaced
anywhere at the screen. when i use a static image instead of the sti-map it
looks fine. I suppose that the problem is something with the translating of
the draw-elements. Maybe because gamera takes a translating and sti takes
another translating and in the result the display is shifted to anywhere...
something like this. I dont think that there is an issue in the sti-lib but
in the way how i use it. Maybe you have an idea how to handle this.
[image: tiletest]
<https://user-images.githubusercontent.com/9694928/57883404-60d25c00-7826-11e9-92ee-0234bd91cecb.png>
The attached zip-file is a love-demo.
Thanks.
tiletest.love.zip
<https://github.com/karai17/Simple-Tiled-Implementation/files/3188816/tiletest.love.zip>
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#218?email_source=notifications&email_token=AAEQD7FXLUKYWM2Y4W6N42TPVW5IXA5CNFSM4HNPYXT2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4GUIIAYQ>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAEQD7HUXPQFHYM3WHIVIJLPVW5IXANCNFSM4HNPYXTQ>
.
|
yes, without a camera lib it works correct. and with a camera which uses the complete window it works too. |
It is not really recommended to use a camera lib with STI; I've always
found them to be troublesome and they provide very little, if any actual
benefit. Just use love.graphics.translate/scale/rotate manually and you
should be fine.
…---
Landon Manning
[email protected]
On Thu, 16 May 2019 at 17:12, Philipp ***@***.***> wrote:
does it work without gamera?
yes, without a camera lib it works correct. and with a camera which uses
the complete window it works too.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#218?email_source=notifications&email_token=AAEQD7EXYM6LQ5QVKJTBPJ3PVW53JA5CNFSM4HNPYXT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODVS52YI#issuecomment-493215073>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAEQD7C3JAKAWN6YLIHVCPDPVW53JANCNFSM4HNPYXTQ>
.
|
Ok. Not the answer i hoped for. A reason for using gamera in this project is to work with multiple windows (minmap and also use a splitscreen for coop). Maybe i find another solution for this. Thanks so far. |
That's a usecase that I've never really had to deal with before. I'msure
there would be some way to make sti and gamera work better together, but I
haven't really seen one. I'd be open to a PR if you want to tinker with it
a bit?
…---
Landon Manning
[email protected]
On Thu, 16 May 2019 at 18:30, Philipp ***@***.***> wrote:
Ok. Not the answer i hoped for. A reason for using gamera in this project
is to work with multiple windows (minmap and also use a splitscreen for
coop).
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#218?email_source=notifications&email_token=AAEQD7EP37TUVLUZPGTSAYTPVXG6XA5CNFSM4HNPYXT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODVTDU4A#issuecomment-493238896>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAEQD7AXUMVDHCKES6MKROTPVXG6XANCNFSM4HNPYXTQ>
.
|
I dont think that as PR is necessary. If i find a solution for this i will give a feedback. |
I just returned to an old project and just checked just translating does not work. at all. Translating did not affect the map at all like it affected the bump_draw or me drawing my active characters. They don't line up. |
@Bobbyjoness Has the bump plugin been updated to match sti's draw function? perhaps there is a discrepency in how map.bump_draw acts. @flamendless Yes, that is why I said just use those directly. The camera lib wrapper doesn't really add much since it's ultimately just using those main functions anyway. |
Over the past few years I've struggled with getting STI to act properly when the map is moved around or scaled. I've tried several different methods and the only one that seems to have really worked correctly is to just take over the graphics state while rendering the map and anything in it. This means that all transforms done with regards to the map are done by the map. Because of this, it makes using a camera library both unnecessary for typical use cases, and incompatible for edge cases like the one described in this issue. For 99% of STI users, just tossing in the trnasform values into the draw function (like you would in any love.graphics function) works without issue. The map moves where you expect it to, it scales without weird graphical glitches, etc. That being said, as I stated above, I am open to a PR that keeps STI's current state of rendering (no known graphical glitches) while also being able to hand over control to a camera library. I've tried in the past and could not find a solution, but if someone else can, I am all for it. |
The reason people use camera libraries is that it abstracts away the code making the code more readable. It also provides convenient tweening methods and other conveniences that would just be a waste of time to reimplement over and over. To solve this problem we can store the translate, scale, and rotation values in variables internal to the library. Then provide methods to edit those values. This should allow for a good camera plugin to be created. As of right now, I do not believe a camera plugin can be created unless it provides its own map draw. |
Maybe sti |
I don't want STI to depend on other libraries, so unless there is a "common camera" implementation I can design against, I don't think having |
Editgrid doesn't depend on gamera or HUMP camera, but supports both. Maybe this can be added as a plugin? |
I am definitely down for more plugins, as long as they are optional. |
hiya! just wanted to share that I encountered this problem, while using gamera, and I've (temporarily) solved it like this: ( function TiledMapRenderer:draw(pipeline)
pipeline:setZ(0)
local camera = pipeline.camera
camera:draw(function(l, t, w, h)
for _, e in ipairs(self.entities) do
local map = e[TiledMapComponent].map
for _, layer in ipairs(map.layers) do
if layer.visible and layer.opacity > 0 then
map:drawLayer(layer)
end
end
do
local collision = map.box2d_collision
for _, obj in ipairs(collision) do
local points = {obj.body:getWorldPoints(obj.shape:getPoints())}
local shape_type = obj.shape:getType()
if shape_type == "edge" or shape_type == "chain" then
love.graphics.line(points)
elseif shape_type == "polygon" then
love.graphics.polygon("line", points)
else
error("sti box2d plugin does not support "..shape_type.." shapes")
end
end
end
end
end)
end it's a hack and I plan to fix it up later but it shows how you can force STI to work with a camera if you're as pissed off and stubborn as I am about it. I just copy/pasted the rendering code from Map.draw and box2d_draw in since at this stage that's what I care about; anyways, point is since you have |
I wonder if there is a way to go about it the other way: Writing an STI plugin that works with a gamera object instead of injecting code into the gamera object? |
Hmm, I think it should be doable. I think I'll take a stab at it today if I can grok the plugin API well enough. |
Oh, I should mention: injecting code into the gamera instance is how gamera works; there's no way around that one, short of modifying gamera to return an instance. It does |
Alright! I have a little gamera-enabled proof of concept over in my fork here. To test it, I added Anyhow, I've found that there are a number of drawbacks to using a plugin as they currently exist over directly modifying STI to add a few more hooks to support custom coordinate transformations. The biggest one is that if you use this and then you use, say, To give STI the ability to support custom coordinate transformations, it should be as simple as allowing plugins/the user to specify some sort of function to override the Unfortunately, the big issue with rendering something through gamera is that since the camera rotates, the AABB of the visible section of the screen may be larger than the screen itself. This means that the size of the canvas used internally by STI would need to be made larger to support that, specifically made square, with sides as long as the longest diagonal of the screen. With the canvas resized to support rotation, the current STI method of rendering at scale=1, rounding the unscaled offset to an integer, and then scaling up would still work, and rotating could be added at the end of that. If custom coordinate transformation hooks were added then there would also need to be hooks added to modify With custom transform hooks, it would become possible to write a If STI were given these hooks, then the Sorry for rambling, this got a bit long. Cheers! |
I have a problem when i use sti with a camera like gamera. If i use no special window and display the map in the full window everything is ok. But when i use a defined window where the map should be drawn, the viewport is displaced anywhere at the screen. when i use a static image instead of the sti-map it looks fine. I suppose that the problem is something with the translating of the draw-elements. Maybe because gamera takes a translating and sti takes another translating and in the result the display is shifted to anywhere... something like this. I dont think that there is an issue in the sti-lib but in the way how i use it. Maybe you have an idea how to handle this.
The attached zip-file is a love-demo.
Thanks.
tiletest.love.zip
The text was updated successfully, but these errors were encountered: