GM:S 1.4 [Solved] d3d camera mirrors everything

Discussion in 'Programming' started by DekuNut, Dec 6, 2018.

  1. DekuNut

    DekuNut Member

    Joined:
    Jun 29, 2016
    Posts:
    39
    Solved! Working code below!

    Was making a 2d logic puzzle game, and saw a tutorial showing me how to turn 2d sprites and give them 3d block models (which would be perfect for my game). the camera mirrors everything though.

    Been looking for a solution couple hours now. What is causing it, and what function do I need to mirror it back?

    Currently I've only added a camera object and set it up to project.

    The following code creates a Top-Down d3d camera that will view the entire room.

    Create:
    Code:
    d3d_start();
    d3d_set_hidden(false);
    d3d_set_lighting(false);
    d3d_set_culling(false);
    draw_set_color(c_white);
    
    Draw:
    Code:
    d3d_set_projection( room_width/2, room_height/2, max(room_width, room_height),
                        room_width/2, room_height/2, 0,
                        0, -1, 0);
    
     
    Last edited: Dec 7, 2018
  2. marasovec

    marasovec Member

    Joined:
    Sep 15, 2016
    Posts:
    153
    Post your camera code
     
  3. DekuNut

    DekuNut Member

    Joined:
    Jun 29, 2016
    Posts:
    39
    Added code to OP.
     
  4. DekuNut

    DekuNut Member

    Joined:
    Jun 29, 2016
    Posts:
    39
    changed some of the parameters in the draw event:

    Code:
    d3d_set_projection_perspective(0, room_height, room_width, -room_height, 0);
    
    All the text is now in the right place but all the instances are still mirrored.
     
  5. BattleRifle BR55

    BattleRifle BR55 Member

    Joined:
    Jun 24, 2016
    Posts:
    832
    I've never used the perspective projection (to be honest, I don't actually know what its purpose is :p) - I'd just use a regular projection instead with the yup set to -1.
     
  6. marasovec

    marasovec Member

    Joined:
    Sep 15, 2016
    Posts:
    153
    I've never used d3d_set_projection_perspective. Try the regular d3d_set_projection instead as like @BattleRifle BR55 said
     
    BattleRifle BR55 likes this.
  7. DekuNut

    DekuNut Member

    Joined:
    Jun 29, 2016
    Posts:
    39
    Ok, so I switched to d3d_set_projection() as suggested and I've almost got the desired effect (thanks guys :D). I just need help figuring out the correct z value for zfrom.

    Code:
    
    d3d_set_projection( room_width/2, room_height/2, 1000,
                        room_width/2, room_height/2, 0,
                        0, -1, 0);
    
    1000 is almost perfect, but the top and left side clip off the edge of the screen just a small bit. I could trial and error the number until I get it perfect, but I'm wondering if there is a function or something that can help me get the perfect zfrom parameter without guestimating?

    EDIT:


    I feel really dumb now. All I needed to do was insert the largest of the 2 resolution values (in this case room_width), so that the camera was far enough away to view the entire room. I'll update the OP with the final code and the title.
     
    Last edited: Dec 6, 2018

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