1. Hello Guest! It's with a heavy heart that we must announce the removal of the Legacy GMC Archive. If you wish to save anything from it, now's the time! Please see this topic for more information.
    Dismiss Notice

GM:S 1.4 Problem with the draw_sprite_pos() function

Discussion in 'Programming' started by Shut, Jun 28, 2016.

  1. Shut

    Shut Member

    Joined:
    Jun 21, 2016
    Posts:
    185
    Hi there,

    I would really appreciate some help with draw_sprite_pos() I'm having. What I'm trying to achieve is a fake 3D effect and so far everything works just fine except that the sprite that is transformed ends up looking weird and not being transformed/scaled properly.

    Here is a screenshot

    Also, I've tried looking around the old forums and found a topic with a similar problem, though I couldn't really understand the solution. Link to the topic

    If you could please explain or provide an example of the solution, I'd be really thankful!

    Thanks!
     
  2. jo-thijs

    jo-thijs Member

    Joined:
    Jun 20, 2016
    Posts:
    2,844
    Hi and welcome to the GMC!

    The issue you're having is a typical limitation of affine transformations.
    The solution by it is using projective transformations.

    Here's the problem in a nutshell:
    When GameMaker uses draw_sprite_pos, it divides the sprite into 2 triangles.
    It then transforms the triangles to fit your quadrilateral by using affine transformations.

    However, as you can see, this method is not fit for mimicking 3D effects.
    Projective transformations are though.

    What does this mean in GameMaker?
    You'll have to use 3D, as that's when projective transformations are used to do these kind of things.

    I don't have a lot of experience with 3D in GameMaker, so I'm not sure how you'd best do this, but I do know it is the best way to go.
    There are other ways around it, by for example splitting your sprite up in many many triangles,
    so that you have a lot of control over how it looks (this can be very slow),
    or by using shaders (which would likely almost be the same as using 3D directly),
    but I'd suggest you first try to look how to use GameMaker's 3D for solving this issue.
     
    Shut likes this.
  3. Shut

    Shut Member

    Joined:
    Jun 21, 2016
    Posts:
    185
    jo-thisjs thanks a lot for your reply, I really appreciate your help and better understand the problem now.

    I want to avoid 3D functions, so I think I will experiment with splitting the sprite or shaders. :)
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice