This topic has been viewed 10968 times and has 16 replies
Thread status:
Active
Questions about extending features and developing plug-ins [img]http://www.sweethome3d.com/images/flags/en_small.gif[/img]
enkonyito
Posts: 607 Joined: Thu May 28, 2015 4:52 pm
Post
by enkonyito » Fri May 04, 2018 4:38 am
When I apply the RGB color #91895E (
9537886 in decimal) to the furniture, the
HomePieceOfFurniture.getColor() or
HomeMaterial.getColor() method returns
-7239330 (in decimal).
How can I convert this signed integer to an unsigned integer?
The value -7239330, processed by
Code: Select all
this.sunflow.parameter("radiance", null,
power * (lightColor >> 16) * (this.homeLightColor >> 16),
power * ((lightColor >> 8) & 0xFF) * ((this.homeLightColor >> 8) & 0xFF),
power * (lightColor & 0xFF) * (this.homeLightColor & 0xFF)); does not give the expected color.
EnkoNyito
ndorigatti
Posts: 66 Joined: Fri May 12, 2017 9:54 am
Country: Italia
Post
by ndorigatti » Fri May 04, 2018 2:04 pm
Hi, looking online:
#91895E is rgb(145, 137, 94)
if I take the negative value:
Code: Select all
int negative = -7239330;
int r = (negative >> 16) & 0xFF;
int g = (negative >> 8) & 0xFF;
int b = negative & 0xFF;
System.out.println(r);
System.out.println(g);
System.out.println(b);
the output is:
145
137
94
Puybaret
Posts: 9440 Joined: Mon Nov 07, 2005 12:00 pm
Country: Paris, France
Contact:
Post
by Puybaret » Fri May 04, 2018 3:34 pm
Hum, I think you should learn how to handle colors with hexadecimal or binary notation, rather than like integers...
enkonyito, your code should be:
Code: Select all
this.sunflow.parameter("radiance", null,
power * ((lightColor >> 16) & 0xFF) * ((this.homeLightColor >> 16) & 0xFF),
power * ((lightColor >> 8) & 0xFF) * ((this.homeLightColor >> 8) & 0xFF),
power * (lightColor & 0xFF) * (this.homeLightColor & 0xFF));
You need to apply a 0xFF filter on the color bits after they are shifted from 16 bits, because the 8 higher bits may contain the transparency value, 0xFF being a full opaque value.
Emmanuel Puybaret, Sweet Home 3D creator
enkonyito
Posts: 607 Joined: Thu May 28, 2015 4:52 pm
Post
by enkonyito » Sat May 05, 2018 12:23 am
Thank you both, I get the right color now!
I think that the TriangleMeshLight class does not allow to have a visible object in the 3D view and that is not visible in the rendering. [:(]
EnkoNyito
enkonyito
Posts: 607 Joined: Thu May 28, 2015 4:52 pm
Post
by enkonyito » Wed May 09, 2018 11:35 pm
I think that the TriangleMeshLight class does not allow to have a visible object in the 3D view and that is not visible in the rendering. [:(]
I solved this problem by adding the
sweethome3d_light prefix. [:)]
Light type libraries will be provided with the next version of the plug-in.
EnkoNyito
Puybaret
Posts: 9440 Joined: Mon Nov 07, 2005 12:00 pm
Country: Paris, France
Contact:
Post
by Puybaret » Fri May 11, 2018 11:22 am
Just to be sure that you used it correctly, the sweethome3d_light prefix is used to name shapes like light sources that should be visible in the 3D view only when selected.
Emmanuel Puybaret, Sweet Home 3D creator
enkonyito
Posts: 607 Joined: Thu May 28, 2015 4:52 pm
Post
by enkonyito » Fri May 11, 2018 7:05 pm
Yes exactly and not viewable when rendering. That's what I was trying to get from the start.
Now I can have several models that can be used as needed. Differentiation is done at the object's properties and processed by the PhotoRenderer class.
EnkoNyito
Users browsing this forum: No registered users and 0 guests