Rotating Textures In Code

Discussions about Coding and Scripting
1337GameDev
Experienced
Posts: 85
Joined: Thu Apr 16, 2020 3:23 pm
Personal rank: GameDev

Rotating Textures In Code

Post by 1337GameDev » Wed Jan 06, 2021 5:20 pm

I am currently working with Canvas and textures, and was curious on an easy way to rotate or manipulate textures.

I want to avoid having to create textures for each cardinal angle of a basic icon.

Is there an easy way to rotate them, such as by 45degrees, in code instead?

I understand if not, but I haven't seen anything on my searches.

User avatar
Gustavo6046
Godlike
Posts: 1158
Joined: Mon Jun 01, 2015 7:08 pm
Personal rank: Zeta Group leader

Re: Rotating Textures In Code

Post by Gustavo6046 » Wed Jan 06, 2021 6:07 pm

You mean drawing in a ScriptedTexture or to the HUD? Like a PostRender callback?

In either case, I'd probably hope there is already something that does that in the interface provided by Canvas, or by wherever you're using Canvas (ScriptedTexture, HUD, etc subclass?). If not, then you might want to look into implementing it yourself; these reads should be helpful, or at the very least interesting! In fact I think I want to try it myself.

User avatar
Feralidragon
Godlike
Posts: 5300
Joined: Wed Feb 27, 2008 6:24 pm
Personal rank: Work In Progress
Location: Liandri

Re: Rotating Textures In Code

Post by Feralidragon » Thu Jan 07, 2021 1:36 am

No, you can't rotate textures in Canvas.
You can flip them (I believe, never tried), by providing a negative scale, but as far as actually rotating them is something you cannot currently do.

The closest you can achieve to a rotating texture in the canvas, is to create a square mesh actor, render it to the canvas and rotate that instead, however since you don't have the option in this engine to render 3D things isometrically, your mesh would be affected and warped by the FOV applied (plus, you would no longer have color blending, unless you rendered multiple mesh overlays, each representing an RGB channel, which is something I have done before in one of my mods).

Although, if I ever develop anything else for UT99, one thing I have been meaning to experiment with, is to create rotating textures by creating actors as triangle sheets, but with one of the vertices animated to manipulate the overall triangle vertices positions through anim tweening and scaling (similar to a technique I already used in my gore mod and a few other things), in order to place the vertices right at the points where they should actually be on the screen be if the shape was rendered isometrically, but I am not sure that if it would work out correctly mathematically by just manipulating one of the vertices instead of 2 at least, and even if it did, if the overall rendering wouldn't have any glitches or artifacts, hence being more of an experimental thought of mine at this point, but which may give you some ideas perhaps (thinking outside the box here).