redeclipse / base

Base environment for Red Eclipse and associated source files.
https://redeclipse.net/
442 stars 90 forks source link

ability to get texture attributes #366

Closed bonifarz closed 7 years ago

bonifarz commented 9 years ago

A feature request that has been around for a while: Getting the attributes of the currently selected texture, such as scale, offset, colour multipliers, shader params etc.

I'd like to suggest that this feature is added to the commands that create new texture slots based on the current selection: These commands could simply return a list of current values when no argument is given.

vrotate, "i"
voffset, "ii"
vscroll, "ff"
vscale, "f"
vlayer, "i"
valpha, "ff"
vcolour, "fff"
vpalette, "ii"
vcoastscale, "f"

I don't think it is a problem to return a list, as there are commands like getcampos that do the same, right?

Probably the same could be done with setgrass to get the grass texture name used on the selected face.

Things are a little more complicated for vshaderparam. It seems reasonable to return the corresponding values if exactly one valid argument is given. In the following list I probably missed some parameters.

vshaderparam, "sffffii" ---> maybe list which arg1 are allowed? 
vshaderparam specscale, "fff"
vshaderparam envscale, "fff"
vshaderparam glowcolour, "fff"
vshaderparam pulseglowcolour "fff"
vshaderparam pulseglowspeed "f"
vshaderparam pulsespeed "f"
vshaderparam parallaxscale, "ff"

It might also be interesting to get the shader keywords used for the selected texture, just as they are specified via a setshader (in the map's cfg). Could we do the same here, and display the keywords for the selection if no argument is given to setshader?

And closely related: If we get textures via gettexname, it is not clear for which channel the textures are used. Maybe the second argument could be a character, such as "c", "s", "n" or "g", instead of an index? In this case, maybe it makes sense to list these characters if only one argument is given to gettexname. E.g.

looplist c (gettexname $getseltex) [echo (gettexname $getseltex $c) is used for $c]

I admit this is a lengthly feature request, and most of the things on the list are not really that useful, but maybe it is helpful as an overview.

Hirato commented 8 years ago

I implemented these in lamiae ages ago, don't know if you want to just adapt the feature from there. Can't just be copied straight since RE is based on regular cube 2 and has other texture parameters on top.

https://github.com/Hirato/lamiae/compare/resynctex-rb#diff-6eac3f48dc325091c332d6e36ef574e1R2254 <-- some unmerged stuff for regular texslots, should just work https://github.com/Hirato/lamiae/blob/f4a1edb8d820fb7f7ff421871a602e2cb5aaf3d5/src/engine/octaedit.cpp#L2387-L2488 <-- ditto for vslots

And since I last touched it, CubeScript gained the 'N' argument type, which gets the number of arguments (there's also '$' which returns the ident for itself), if you'd rather overload the vcommands to return stuff if none or only 1 command is provided. If that's going to be done, their definitions as provided by bonifarz will need to be changed to look like this

vrotate, "i"     -> vrotate, "iN$"
voffset, "ii"    -> voffset, "iiN$"
vscroll, "ff"    -> vscroll, "ffN$"
vscale, "f"      -> vscale, "fN$"
vlayer, "i"      -> vlayer, "iN$"
valpha, "ff"     -> valpha, "ffN$"
vcolour, "fff"   -> vcolour, "fffN$"
vpalette, "ii"   -> vpalette, "iiN$"
vcoastscale, "f" -> vcoastscale, "fN$"

And int *numargs, ident *self appended onto their respective argument lists

graphitemaster commented 7 years ago

This information is going to be obtainable as part of the great newui migration.

acerspyro commented 7 years ago

Functionality added with commit https://github.com/red-eclipse/base/commit/0c29f1835b426093e4185fd8740fb68cab078cbd