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

Author Topic: A new name for RenderTarget::convertCoords  (Read 8944 times)

0 Members and 1 Guest are viewing this topic.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
A new name for RenderTarget::convertCoords
« on: October 29, 2012, 11:15:23 am »
Hi :)

Recently, I realized that the inverse of convertCoords (i.e. converting from world units to target pixels) would really be useful, and was tricky to implement with the current API. So I thought about adding it.

But I need a new name, because "convertCoords" is not clear at all about what is converted, and what it is converted to. So I need two names: a clearer replacement for convertCoords, and the corresponding name for the inverse function.

And... I can't find something good enough, that's why I ask here :)
Laurent Gomila - SFML developer

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
Re: A new name for RenderTarget::convertCoords
« Reply #1 on: October 29, 2012, 12:26:02 pm »
Maybe this could help you. Here a Rect is a structure having both an origin and a size. But you could change it to an origin/point only. In the OS X API there are methods for this in the Window class:
Quote
Window::convertRectFromScreen(Rect) : Rect
Converts the rectangle from the screen coordinate system to the window’s coordinate system
Quote
Window::convertRectToScreen(Rect) : Rect
Converts the rectangle to the screen coordinate system from the window’s coordinate system.

There are also methods to do the same transformation but between widgets:
Quote
Widget::convertRectToWidget(Rect, Widget targetWidget) : Rect
Converts a rectangle from the receiver’s coordinate system to that of another widget.
Quote
Widget::convertRectFromWidget(Rect, Widget) : Rect
Converts a rectangle from the coordinate system of another widget to that of the receiver.

Note that I've modified the names a little bit, as it originally comes from an Objective-C documentation where Widgets are named Views.

Edit: after reading View Geometry: Transforming the Coordinate System I guess the second part (conversion from widget to widget) is a little bit too advanced for SFML.
« Last Edit: October 29, 2012, 12:33:54 pm by Ceylo »
Want to play movies in your SFML application? Check out sfeMovie!

Foaly

  • Sr. Member
  • ****
  • Posts: 453
    • View Profile
Re: A new name for RenderTarget::convertCoords
« Reply #2 on: October 29, 2012, 12:35:08 pm »
Ogre uses the rather long but discribtive name Ogre::Node::convertLocalToWorldPosition and Ogre::Node::convertWorldToLocalPosition.

See here: http://www.ogre3d.org/docs/api/html/classOgre_1_1Node.html#a57cd15b649fad2def94ba08e6ef230ed

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: A new name for RenderTarget::convertCoords
« Reply #3 on: October 29, 2012, 01:00:51 pm »
Quote
Maybe this could help you
So... RenderTarget::convertPointToWorld? That could work.

Quote
Ogre uses the rather long but discribtive name Ogre::Node::convertLocalToWorldPosition
Here it's not from local to global, it's from global to render-target.
Laurent Gomila - SFML developer

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
Re: A new name for RenderTarget::convertCoords
« Reply #4 on: October 29, 2012, 01:27:35 pm »
Quote
Maybe this could help you
So... RenderTarget::convertPointToWorld? That could work.
Yup, looks fine to me.
Want to play movies in your SFML application? Check out sfeMovie!

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: A new name for RenderTarget::convertCoords
« Reply #5 on: October 29, 2012, 10:02:14 pm »
«World» sounds odd here, don't you think ?

What about convertPointToBase ? Base is vague enough but unlike world it doesn't make be think of the game/app environment (especially if there's a World class). In fact, when I hear/read «world» I don't think at a coordinate system at all. On the other hand, «base» is (mathematically) directly bound to the coordinates.
SFML / OS X developer

FRex

  • Hero Member
  • *****
  • Posts: 1845
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: A new name for RenderTarget::convertCoords
« Reply #6 on: October 29, 2012, 10:36:48 pm »
Maybe pixelsToUnits and unitsToPixels?
Back to C++ gamedev with SFML in May 2023

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: A new name for RenderTarget::convertCoords
« Reply #7 on: October 29, 2012, 10:53:35 pm »
toTargetCoords
toTargetPixels


toWorldCoords
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 878
    • View Profile
Re: A new name for RenderTarget::convertCoords
« Reply #8 on: October 29, 2012, 11:55:31 pm »
I'd try to keep it short/simple:

sf::Point sf::View::transform(const &sf::Point);
sf::Point sf::View::inverse(const &sf::Point);

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: A new name for RenderTarget::convertCoords
« Reply #9 on: October 30, 2012, 08:05:35 am »
The conversion needs both the RenderTarget and the View. So it must be a function of sf::RenderTarget (sf::View doesn't "know" sf::RenderTarget so I prefer this way).

And it's not clear that "inverse" is the inverse operation of "transform". And I prefer clear names rather than short names ;)
Laurent Gomila - SFML developer

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: A new name for RenderTarget::convertCoords
« Reply #10 on: October 30, 2012, 07:26:11 pm »
What about FRex' and my suggestions? If we know what doesn't please you, maybe we can come up with improvements :)
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: A new name for RenderTarget::convertCoords
« Reply #11 on: October 30, 2012, 07:49:07 pm »
Sorry :)

Your suggestions are ok too, that's why I said nothing about them.
Laurent Gomila - SFML developer

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: A new name for RenderTarget::convertCoords
« Reply #12 on: October 30, 2012, 08:55:09 pm »
Okay, sorry for the misunderstanding. I never know if you have overlooked something if you don't comment it... But since it's a brainstorming thread, you're actually right ;)

Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: A new name for RenderTarget::convertCoords
« Reply #13 on: November 05, 2012, 02:17:20 pm »
I had almost forgotten this thread, sorry.

I don't like functions that begin directly with "to", because it feels like we're trying to convert the render-target itself to something.

The word "world" is very clear to me but this is because I worked a lot with engines with scenegraphs, and entities were always in the "world" or "scene". I don't know how this word would be interpreted by other users.

So... it could be:
convertCoordsToPixel
convertPixelToCoords

"Coords" is a little vague, maybe we could use "Unit" instead.
Laurent Gomila - SFML developer

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: A new name for RenderTarget::convertCoords
« Reply #14 on: November 05, 2012, 02:28:01 pm »
what's your position on 'base' (cf my previous post) ?
SFML / OS X developer