Color Picker

Post Reply
User avatar
clintonman
Captain
Posts: 5430
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California
Contact:

Color Picker

Post by clintonman »

ColorPickerWIP.jpg
A general color picker based on the Unofficial Updates(UU) Lights color picker. The goal was to make a color picker that didn't have the undo issues of the UU lights based colorpicker. I wasn't able to solve that. This script has it's own undo issues, but it mostly works. On occasion it runs out of undos or it may be too aggressive and over-undo it.

To try it out, some version of the UU should be installed. Download from the link and copy into /Scripts/CustomCommands.
Select some scene item and press the open panel button. The color picker will not run if the color picker is selected.

The controls from top to bottom:
Main area that has the clickable hue-saturation
The color bar below is a preview for the final color.
The slider is for luminosity.
The color box is the system based color picker with red,green,blue controls to the right.

The color picker can run in 2 modes. Undo and no undos. When undo is enabled use the Undo button on the panel instead of the shortcut or the toolbar undo button. When undo is disabled the color changes are immediate and fully interactive. The "Undoable" control is in another panel aspect and must be set before opening the panel. Any changes when the panel is open are ignored.

Only "Lum", luminosity is setup at this time. Sat, Kelvin and Color are disabled.

When you select an item all it's color attributes are added to a dropdown list. In the image above the torus is selected and I chose the Points Color of the Object Render Attributes node and set the color to blue. The dropdown will default to the material color for meshes and to the light color for lights.
Press the Update button after making a selection.

The last 3 buttons are temporary testing buttons that can be used to open and close the panel. And a button to kill it if the scripts get out of hand.
ColorPickerWIP_undo.jpg
ColorPickerWIP_undo.jpg (25.39 KiB) Viewed 810 times
Attachments
Color Picker.RsObj
(539.09 KiB) Downloaded 51 times
Clinton Reese

http://clintons3d.com
User avatar
trueBlue
Captain
Posts: 5214
Joined: 06 Jul 2009, 22:50
Type the number ten into the box: 10

Re: Color Picker

Post by trueBlue »

Really impressive Clinton!
I am using a Blank DX Material from the Materials - DX9 library.
I am seeing Unknown attributes as shown in the screenshot.
Unknown Attributes.png
.
The one highlighted and the two Color_InputColor.

Not sure if this is a bug but the Luminosity bitmap is being replaced with a solid black color when adding Primitives.
Seems to me, that bitmap should never change and works like the Windows Color Picker

Been noticing the Panel X being left open on several occasions.
Edit: Both panels are missing a WinID. I added {F021DF25-F4AA-41DD-86CC-8FF15C2E278A} to both panels

Is there any way to limit the Object Render Attributes from showing in the Drop-down list?
Like adding an Advanced option (Boolean)?

Edit2:
Update button error if nothing is selected
ERR Source object: /Scripts/CustomCommands/Color Picker/UpdateConnChoice Error: Microsoft JScript runtime error Description: 'undefined' is null or not an object Error code: 0x800a138f - (null) Line: 16, Char: 1 Script text: var colorArr = colorStr.split("\t");
UpdateConnChoice script
Add:

Code: Select all

	var selcount = Node.SelectedCount();
	if(selcount == 0) return;
User avatar
clintonman
Captain
Posts: 5430
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California
Contact:

Re: Color Picker

Post by clintonman »

trueBlue wrote: 26 Jan 2023, 19:17 Really impressive Clinton!
I am using a Blank DX Material from the Materials - DX9 library.
I am seeing Unknown attributes as shown in the screenshot.
Unknown Attributes.png
.
The one highlighted and the two Color_InputColor.

Not sure if this is a bug but the Luminosity bitmap is being replaced with a solid black color when adding Primitives.
Seems to me, that bitmap should never change and works like the Windows Color Picker

Been noticing the Panel X being left open on several occasions.
Edit: Both panels are missing a WinID. I added {F021DF25-F4AA-41DD-86CC-8FF15C2E278A} to both panels

Is there any way to limit the Object Render Attributes from showing in the Drop-down list?
Like adding an Advanced option (Boolean)?

Edit2:
Update button error if nothing is selected
ERR Source object: /Scripts/CustomCommands/Color Picker/UpdateConnChoice Error: Microsoft JScript runtime error Description: 'undefined' is null or not an object Error code: 0x800a138f - (null) Line: 16, Char: 1 Script text: var colorArr = colorStr.split("\t");
UpdateConnChoice script
Add:

Code: Select all

	var selcount = Node.SelectedCount();
	if(selcount == 0) return;
The script is finding all the color connectors. So it sees the color connectors inside the SolidColorShader and inside the DefaultModelShader. It should skip color connectors if they are exported to a higher level.

Black when add primitive is correct for the way it's working, which is different from my earlier tests that used compiled d3d materials. So it needs to be fixed to use the actual material color by default for node based materials. Also will need to check vray and yafaray materials to see how they come up.

There's some weirdness to the x close panel. I made adjustments for it but may have missed something by using compiled materials. The weirdness I refer to is that before I "fixed it", the x panel would hide behind the color picker if any floating window was open, including any error popups(which I saw a lot of). Just selecting any window would bring it back.
I have an idea to setup a timer so that if the panel is closed but still active, the timer will properly end it and disconnect all the watchdogs etc.
Another case of weirdness that was never fully solved is that opening the system color picker by double click on the color square might cause the luminosity connector to think it has changed and that throws the undo counts off. This is before even using it, opening is all it takes. It's random so pretty much impossible to fix.

Option to turn off ORA in the list sounds good.
Clinton Reese

http://clintons3d.com
User avatar
trueBlue
Captain
Posts: 5214
Joined: 06 Jul 2009, 22:50
Type the number ten into the box: 10

Re: Color Picker

Post by trueBlue »

Since adding the WinID to both panels, I have not seen any issues so far and the X panel now adds SnappedTo, I guess from your OpenPanel script

I found a setting that works pretty good
TheNode

Code: Select all

if(Node.IsRenderable(firstSel)) {
	var selstr = colorSource.GetStringAt(4);
i = 1;
colorSource.SetSelectedString(selstr);
}
Also added:
if(Node.IsCamera(firstSel)) {
return
}
User avatar
clintonman
Captain
Posts: 5430
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California
Contact:

Re: Color Picker

Post by clintonman »

trueBlue wrote: 26 Jan 2023, 21:20 Since adding the WinID to both panels, I have not seen any issues so far and the X panel now adds SnappedTo, I guess from your OpenPanel script

I found a setting that works pretty good
TheNode

Code: Select all

if(Node.IsRenderable(firstSel)) {
	var selstr = colorSource.GetStringAt(4);
i = 1;
colorSource.SetSelectedString(selstr);
}
Also added:
if(Node.IsCamera(firstSel)) {
return
}
Good news about the x panel. :bananathumb:

"GetStringAt(4)", that 4 might change for different object types, like is SDS applied, will flattening or point edit change the order... testing will be needed

return if camera will make it not work for the ORA colors - small detail esp since you cant see color changes while the camera is selected
Clinton Reese

http://clintons3d.com
User avatar
trueBlue
Captain
Posts: 5214
Joined: 06 Jul 2009, 22:50
Type the number ten into the box: 10

Re: Color Picker

Post by trueBlue »

Ugh, automatically applying a color is not a very good idea.

Can you make it work like the Windows Color Picker?
Select a Color and press a button that applies the color.
User avatar
clintonman
Captain
Posts: 5430
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California
Contact:

Re: Color Picker

Post by clintonman »

trueBlue wrote: 26 Jan 2023, 22:25 Ugh, automatically applying a color is not a very good idea.

Can you make it work like the Windows Color Picker?
Select a Color and press a button that applies the color.
Automatically applying color is an excellent idea. Would be more helpful if you said why its not a very good idea.

Do nothing until press a button option seems doable.
Clinton Reese

http://clintons3d.com
User avatar
trueBlue
Captain
Posts: 5214
Joined: 06 Jul 2009, 22:50
Type the number ten into the box: 10

Re: Color Picker

Post by trueBlue »

Sorry: oops:
I struggled with that statement.
I did not notice it was automatically applying the color until I made that change to theNode script, it was changing an ORA color that was not obvious because the ORA's 'Enable Obj Mode' was not enabled.
Now, after using the Color Picker on an object and selecting a different object, the last used color is applied.
Is that a tiny bit better? :)
User avatar
clintonman
Captain
Posts: 5430
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California
Contact:

Re: Color Picker

Post by clintonman »

trueBlue wrote: 26 Jan 2023, 23:10 Sorry: oops:
I struggled with that statement.
I did not notice it was automatically applying the color until I made that change to theNode script, it was changing an ORA color that was not obvious because the ORA's 'Enable Obj Mode' was not enabled.
Now, after using the Color Picker on an object and selecting a different object, the last used color is applied.
Is that a tiny bit better? :)
What!? You mean selecting an object is changing it's color. OK, yeah, that's not good. I haven't seen it, but I'll look out for it.
Clinton Reese

http://clintons3d.com
User avatar
trueBlue
Captain
Posts: 5214
Joined: 06 Jul 2009, 22:50
Type the number ten into the box: 10

Re: Color Picker

Post by trueBlue »

Yep!
If you add the following you can see this behavior.
TheNode script

Code: Select all

if(Node.IsRenderable(firstSel)) {
	var selstr = colorSource.GetStringAt(4);
i = 1;
colorSource.SetSelectedString(selstr);
}
Post Reply