GMLscripts.com

Discuss and collaborate on GML scripts
Invert

You are not logged in.

#1 2008-09-05 03:04:29

EyeGuy
Member
Registered: 2007-10-18
Posts: 19

transform_set_HUD

A quick, but useful function for drawing a HUD that's not effected by any of the transformations of views (translation, scale, and rotation) without going through the trouble of setting up and optimizing an additional view.

Description:
Sets up a transform which nullifies the scale, translation, and rotation of a given view, making it so that anything you draw afterwards will be drawn unaffected by view.  Calling d3d_transform_set_identity() will change it back to normal.

Expand/*
**  Sample Usage:
**      transform_set_HUD( view_index);
**      // Draw HUD components with position and such as they'll appear on-screen
**      d3d_transform_set_identity();
**
**
**  Arguments:
**      view_index : the index of the view you wish to nullify
**          (in general, this should be view_current)
**
**  Notes:
**      don't forget to call d3d_transform_set_identity(); after you're done drawing
**      all the components of the HUD.  That changes the view back to normal.
**
**  GMLscripts.com
*/
{
    d3d_transform_set_scaling( view_wview[argument0]/view_wport[argument0], 
                                             view_hview[argument0]/view_hport[argument0],0);
    d3d_transform_add_translation(-view_wview[argument0]/2,-view_hview[argument0]/2,0);
    d3d_transform_add_rotation_z(-view_angle[argument0]);
    d3d_transform_add_translation( view_wview[argument0]/2 + view_xview[argument0],
                                                   view_hview[argument0]/2 + view_yview[argument0],0);
}

Offline

#2 2008-09-24 13:58:26

Grand-High Gamer
Member
Registered: 2007-10-09
Posts: 18

Re: transform_set_HUD

Maybe I'm being dull but this appears to have the exact same functionality of setting the projection to orthographic?


sigimage1.png

Offline

#3 2008-10-16 06:31:46

EyeGuy
Member
Registered: 2007-10-18
Posts: 19

Re: transform_set_HUD

Yes and no.  One's the projection transform and the other's the world transform.  They're pretty much the same thing only in different positions.  And I believe that Game Maker views mess with the projection transforms and not the world transforms, so if you change the projection transforms, you can't just clear them to get them back to normal, you have to re-set them to what they were before.  You can certainly use both of them to the same effects, anyway.

Also if you want to get technical, I think d3d_set_projection_ortho nullifies perspective if you have it set, but my method doesn't necessarily (not that that's a particularly good thing for HUDs).

Offline

Board footer

Powered by FluxBB