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

Author Topic: Cascade of transformations inheriting from Drawable?  (Read 2891 times)

0 Members and 1 Guest are viewing this topic.

nitram_cero

  • Full Member
  • ***
  • Posts: 166
    • View Profile
Cascade of transformations inheriting from Drawable?
« on: June 11, 2009, 06:33:24 pm »
Hi, I'm willing to implement cascading transformations for a skeleton system.

Children joints would have to be transformed as the parent previous to their own transformations.
This will allow me, for example, to have a translated hat as a children of the head joint, but when applying a rotation to the head... the hat would rotate acordingly and be correctly positioned.

If I draw a sprite inside my joint's Draw() function (derived from Drawable), is there a way to make it multiply the transformation matrix (glMultMatrix) instead of loading it (glLoadMatrix)?
Same goes for any drawable (as I will be drawing a Joint tree structure having Sprite's for leafs)

Thanks
-Martín

Imbue

  • Full Member
  • ***
  • Posts: 104
    • View Profile
Cascade of transformations inheriting from Drawable?
« Reply #1 on: June 11, 2009, 09:17:18 pm »
It already works that way. Anything drawn inside of a Drawable's Draw function has its matrix multiplied.

The problem you'll run into next is Z order. OpenGL would handle that too, for free, but I don't know of a good fix with SFML. I found it odd that SFML supports shaders (which my target audience won't have support for) but not Z buffers (which has been supported for-nearly-ever).

See:Manually setting Z-order

Another problem you may have is transforming mouse coordinates down several hierarchy levels. Although SFML has functions for this, they're broken after one level.

IMHO, SFML's biggest limitations for graphics right now is no Z order support and no matrix abstraction. I've found straight OpenGL a viable alternative for specific applications (characters) and SFML's sprites good for general purpose stuff.

Just my two cents.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Cascade of transformations inheriting from Drawable?
« Reply #2 on: June 11, 2009, 11:16:22 pm »
Quote
It already works that way. Anything drawn inside of a Drawable's Draw function has its matrix multiplied.

Correct.

Quote
The problem you'll run into next is Z order. OpenGL would handle that too, for free, but I don't know of a good fix with SFML. I found it odd that SFML supports shaders (which my target audience won't have support for) but not Z buffers (which has been supported for-nearly-ever).

There are three simple reasons why SFML doesn't use Z-Buffer:
- It's not necessary
- It can be disabled explicitely by user on window creation
- It may not be supported; even if probability is very low it is not acceptable to base a core feature on it.

Quote
Another problem you may have is transforming mouse coordinates down several hierarchy levels. Although SFML has functions for this, they're broken after one level.

Maybe it's going to be improved in SFML 2.0, who knows ;)
Laurent Gomila - SFML developer

nitram_cero

  • Full Member
  • ***
  • Posts: 166
    • View Profile
Cascade of transformations inheriting from Drawable?
« Reply #3 on: June 13, 2009, 09:36:19 am »
Thanks a lot for both of your comments!

No problems with z ordering, I'll have two branches for each Joint, one branch will be drawn before (back) and the other after the joint's own sprite (front).

No need for mouse functions, they're just for drawing.

Thanks again!
-Martín