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

Author Topic: Nonlinear Transformations  (Read 1142 times)

0 Members and 1 Guest are viewing this topic.

Randomini

  • Newbie
  • *
  • Posts: 1
    • View Profile
Nonlinear Transformations
« on: August 01, 2013, 03:08:48 am »
Hi Everyone;

I've been messing around with SFML, and was wondering if there was any in-built method to perform nonlinear transforms on a sprite? When I say nonlinear, I've specifically got two aims: I want to be able to map a square sprite to the shape of the side of a cylinder (in other words, the 2D shape that is the side of https://upload.wikimedia.org/wikipedia/commons/thumb/3/36/Circular_cylinder_rh.svg/200px-Circular_cylinder_rh.svg.png). In addition (and this is a little trickier) I want to use a UV map for a sphere like https://en.wikipedia.org/wiki/File:UVMapping.png, but again only mapping to the 2D projection of the final 3D image.

Basically, the linear transforms in SFML let you map
Code: [Select]
[A B TX] [X]   [AX + BY + TX]
[C D TY] [Y] = [CX + DY + TY]
[0 0 1 ] [1]   [     1      ]

But what I'm after is an end result for any image in XY co-ordinates and arbitrary functions u and v to
Code: [Select]
[u(X,Y)]
[v(X,Y)]
[   1  ]

Is there support for this in SFML itself, or if not, has anyone written an extension to do this?

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: Nonlinear Transformations
« Reply #1 on: August 01, 2013, 04:09:56 am »
SFML's sprites can not do this, after all they are just simple wrappers around a four point vertex array quad. In order to do what you want you will need to bind an SFML texture to your own sphere with OpenGL code.
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor