Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Enhanced sf::View  (Read 23127 times)

0 Members and 2 Guests are viewing this topic.

Caspin

  • Newbie
  • *
  • Posts: 10
    • MSN Messenger - j_nick_terry@hotmail.com
    • View Profile
Enhanced sf::View
« on: April 09, 2008, 05:03:46 pm »
Really this is two suggestions, but they are tightly coupled to each other.

Convert MouseX/Y to worldX/Y.
This would have be done through the view.  I suppose it could be done through the sf::RenderWindow, but that would artificially limit which views could be used to translate the coordinates.  I am not suggesting this be done automatically, but be provided as a method of the sf::View class.

   The major hurdle here is the View will need to know the screen dimensions to correctly convert the coordinates.  I would suggest passing the App as a reference to the method so that it can access the window dimensions.  Or if that is sharing too much information, just a sf::Vector2i that stores the X and Y dimensions of the window.

   This is just boring when the user has a default view.  It is a nicety when using a custom view, It is very useful if the custom view is scaled or a different size than the window, It is absolutely necessary if the View where allowed to rotate.

-

Rotating sf::View
   Allow the sf::View to rotated.  It's very simple at the OpenGL layer, but a bit more complicated at the SFML API layer.  The View would be defined as a lookAt point, a view width and height, and a rotation.  This provides absolute flexibility with how the View is placed.

   The current way sf::View is defined (Right, Top, Left, Bottom) is incompatible with a rotating view.  So I would suggest a new class sf::ViewEx or whatever the name doesn't matter.  The old sf::View class would inherit from sf::ViewEx and constrain it to hide the new functionality.

-

Why do I care:

   In my game the players are playing on circular world, a planet.  Gravity is not +/-Y, it is to the center.  When a player is on the "south" side of the world I want to rotate the view so that all the controls work as he would imagine, left button moves his player left on the screen.

   I was performing translations in game.  Then I got to problem of mapping the screen coords back to world coords.  It's difficult once you through in rotations.  There is a function gluUnProject that does all this for you.  However, this information is abstracted away in the library (thank goodness).  Which means the library is in much better situation to perform the call than I am.

-Nick

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Enhanced sf::View
« Reply #1 on: April 09, 2008, 05:38:06 pm »
Quote
Convert MouseX/Y to worldX/Y.

Done two days ago (with a complete rewrite of sf::View) ;)

Quote
Rotating sf::View

The first version of views allowed this. But I removed the possibility to rotate views for some good reasons (that I don't remember of course :lol:).
I'll see if it would still be a problem in the new implementation.
Laurent Gomila - SFML developer

Caspin

  • Newbie
  • *
  • Posts: 10
    • MSN Messenger - j_nick_terry@hotmail.com
    • View Profile
Good stuff
« Reply #2 on: April 10, 2008, 02:34:51 am »
I'm glad to see that stuff is done already..  I had to change my own class that worked it's magic around sf::View but all of it was a simplification.  I really like the sf::View's new interface.

I think the rotating view stuff should easily blend with the new sf::View, I don't see how it could have been implemented with the old one.  Maybe that was the reason it was removed :).

I don't want to duplicate work again.  I would like to go in add the rotation stuff to the view in my own copy.  But I don't want to waste my time if that will be done in the library any time soon.

thanks for all the great work you've done with the library

-Nick

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Enhanced sf::View
« Reply #3 on: April 10, 2008, 03:30:42 am »
To be honest, I can't tell you if the rotation stuff will be added soon or not. So you should consider customizing sf::View if you really need this feature.

I'll keep you informed if there's any news ;)
Laurent Gomila - SFML developer

dewyatt

  • Jr. Member
  • **
  • Posts: 75
    • View Profile
    • http://dewyatt.blogspot.com
Enhanced sf::View
« Reply #4 on: July 08, 2008, 05:37:03 am »
Well this post is a few months old.
But I wanted to say I would also like the view rotation feature.
I came to SFML from HGE as you know, and miss this feature.
I've stayed away from direct OpenGL calls for now and I'm trying to keep it that way.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Enhanced sf::View
« Reply #5 on: July 08, 2008, 06:48:08 am »
I have tons of things to improve, fix or implement, but I'll try to work on this as soon as possible (which doesn't mean I will implement rotation -- first I have to do some tests).
Laurent Gomila - SFML developer

dewyatt

  • Jr. Member
  • **
  • Posts: 75
    • View Profile
    • http://dewyatt.blogspot.com
Enhanced sf::View
« Reply #6 on: July 08, 2008, 09:31:26 am »
I understand that you have many things to do.
There's no rush.
We all appreciate SFML, it's great!