Is Sunflow limited in Sweet Home 3D?

This topic has been viewed 10966 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

Re: Is Sunflow limited in Sweet Home 3D?

Post by enkonyito »

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

Re: Is Sunflow limited in Sweet Home 3D?

Post by ndorigatti »

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
User avatar
Puybaret
Posts: 9440
Joined: Mon Nov 07, 2005 12:00 pm
Country: Paris, France
Contact:

Re: Is Sunflow limited in Sweet Home 3D?

Post by Puybaret »

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

Re: Is Sunflow limited in Sweet Home 3D?

Post by enkonyito »

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

Re: Is Sunflow limited in Sweet Home 3D?

Post by enkonyito »

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
User avatar
Puybaret
Posts: 9440
Joined: Mon Nov 07, 2005 12:00 pm
Country: Paris, France
Contact:

Re: Is Sunflow limited in Sweet Home 3D?

Post by Puybaret »

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

Re: Is Sunflow limited in Sweet Home 3D?

Post by enkonyito »

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
Post Reply New Topic

Who is online

Users browsing this forum: No registered users and 1 guest