Good day all,
i am trying to create a scroll basis game and looking for a function which can ZOOM in any point of the my viewport
So that the visual effect is stunning. But to clarify, a zoom in doesn't mean to increase scale of all my sprites on screen
and looking at http://love2d.org/wiki/love.graphics.scale
love.graphics.scale( sx, sy )
it doesn't really mean to zoom at any point of the viewport.
Maybe we need some offset param, and based on that offset as zoom reference point?
Appreciate for the guiding.
Thanks!
Request for Camera Example in Love
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: Request for Camera Example in Love
When I write def I mean function.
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Request for Camera Example in Love
kikito is right. Mind, scale and translate are rather low-level functions, so they're not exactly written for ease of use. You can, of course, write a much higher lib on top of them, much like CAMERA did in the pre-0.6 days.
Help us help you: attach a .love.
Re: Request for Camera Example in Love
love.graphics.push() and love.graphics.pop() are the most useful functions for making layered guis...Robin wrote:kikito is right. Mind, scale and translate are rather low-level functions, so they're not exactly written for ease of use. You can, of course, write a much higher lib on top of them, much like CAMERA did in the pre-0.6 days.
Hello, I am not dead.
Re: Request for Camera Example in Love
So, just that I understand you correctly:weilies wrote:But to clarify, a zoom in doesn't mean to increase scale of all my sprites on screen
You want to have a zoom function, that preserves the size of your objects, but increases the distance between them, much like this?
Then, love.graphics.zoom/love.graphics.translate is not what you want. You will need to implement the zoom yourself:
I assume your camera looks at point (cx,cy) and has zoom z.
For every image with position (x,y), you need to calculate the zoomed position (x',y'):
- Move (x,y) so that (cx,cy) would be at point (0,0): (x1,y1) = (x,y) - (cx,cy)
- Then you zoom, which is just multiplying the coordinates (x1,y1) with zoom value z: (x2,y2) = z * (x1,y1)
- Move (x2,y2), so that (0,0) would be at (cx,cy): (x',y') = (x2,y2) + (cx,cy)
(x',y') = z * [ (x,y) - (cx,cy) ] + (cx, cy)
You can also add rotation, but this is a bit more complicated.
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Request for Camera Example in Love
Or, in Lua:vrld wrote:(x',y') = z * [ (x,y) - (cx,cy) ] + (cx, cy)
Code: Select all
x = z * (x - cx) + cx
y = z * (y - cy) + cy
Help us help you: attach a .love.
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: Request for Camera Example in Love
Interesting interpretation of the question. I still think he just needs simple translation, though.
When I write def I mean function.
Re: Request for Camera Example in Love
hi all,
Thanks for all the guiding,
I am actually come from 3D Game Authoring Software like Shiva Engine, Blender
So, what i know bout Camera Zoom in, is while we put object to screen, we define their X, Y (2D), or X, Y, Z (3D)
Then in order to SEE the object, we need to define a Camera Object, same, we need to define XYZ/XY position for it
So, when we need ZOOM, we actually do not change the position or scale any object that we put on screen, so there
Vrld
Robin
looks like i have missed out this http://love2d.org/wiki/HUMP
can only comment further after i try out this baby
Thanks for all the guiding,
I am actually come from 3D Game Authoring Software like Shiva Engine, Blender
So, what i know bout Camera Zoom in, is while we put object to screen, we define their X, Y (2D), or X, Y, Z (3D)
Then in order to SEE the object, we need to define a Camera Object, same, we need to define XYZ/XY position for it
So, when we need ZOOM, we actually do not change the position or scale any object that we put on screen, so there
Vrld
isn't a ZOOM ( move camera closer i mean), we shouldn't change the distance between two object, but yet, we can see the object getting biggerYou want to have a zoom function, that preserves the size of your objects, but increases the distance between them, much like this?
Robin
Yea, it would be good if the framework does provided with camera object. I am not so hardcore framework developer, and all i can do is put my idea into game by using available functionkikito is right. Mind, scale and translate are rather low-level functions, so they're not exactly written for ease of use. You can, of course, write a much higher lib on top of them, much like CAMERA did in the pre-0.6 days.
looks like i have missed out this http://love2d.org/wiki/HUMP
can only comment further after i try out this baby
Re: Request for Camera Example in Love
OK, so I misunderstood you
For understanding our answers, note that there is (mathematically) really no difference between a camera transformation, i.e. "see what the camera sees", and moving/scaling/rotating objects in a scene. In order to do the transformation, you need to move every object in the scene, so that the camera would be at the origin of the coordinate system (point (0,0)), scale everything to the zoom level and rotate all objects so that the camera would not be rotated anymore.
That is what actually happens in hump's camera:predraw(). The function camera:postdraw() reverts the transformations, so you can f.e. draw gui-elements after drawing the scene.
The cameras in Blender (and other tools) work just the same. It's just a handy abstraction of all the moving, scaling and translating.
For understanding our answers, note that there is (mathematically) really no difference between a camera transformation, i.e. "see what the camera sees", and moving/scaling/rotating objects in a scene. In order to do the transformation, you need to move every object in the scene, so that the camera would be at the origin of the coordinate system (point (0,0)), scale everything to the zoom level and rotate all objects so that the camera would not be rotated anymore.
That is what actually happens in hump's camera:predraw(). The function camera:postdraw() reverts the transformations, so you can f.e. draw gui-elements after drawing the scene.
The cameras in Blender (and other tools) work just the same. It's just a handy abstraction of all the moving, scaling and translating.
Who is online
Users browsing this forum: Majestic-12 [Bot] and 7 guests