Rotating Textures In Code

Discussions about Coding and Scripting
Post Reply
1337GameDev
Skilled
Posts: 198
Joined: Thu Apr 16, 2020 3:23 pm
Personal rank: GameDev

Rotating Textures In Code

Post by 1337GameDev »

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: 1462
Joined: Mon Jun 01, 2015 7:08 pm
Personal rank: Resident Wallaby
Location: Porto Alegre, Brazil
Contact:

Re: Rotating Textures In Code

Post by Gustavo6046 »

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.
"Everyone is an idea man. Everybody thinks they have a revolutionary new game concept that no one else has ever thought of. Having cool ideas will rarely get you anywhere in the games industry. You have to be able to implement your ideas or provide some useful skill. Never join a project whose idea man or leader has no obvious development skills. Never join a project that only has a web designer. You have your own ideas. Focus on them carefully and in small chunks and you will be able to develop cool projects."

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

Re: Rotating Textures In Code

Post by Feralidragon »

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).
Post Reply