Print at Dec 24, 2025, 9:31:45 PM

Posted by enkonyito at Apr 25, 2018, 9:29:31 PM
Re: Is Sunflow limited in Sweet Home 3D?
Emmanuel, how can we retrieve the coordinates of the vertices of a plane object so that its rotations are taken into account as light?

My attempt is not very conclusive.

I transformed this plane object
g Plane_1_1_1
usemtl None
v 0.0 100.0 -0.05
v 100.0 100.0 -0.05
v 100.0 250.0 -0.05
v 0.0 250.0 -0.05
vn 0.0 0.0 1.0
f 1//1 2//1 3//1
f 1//1 3//1 4//1
in light,
id#1=Meshlight#Vertical
name#1=Vertical shape sh3d
category#1=Light sources 2
icon#1=/Vertical shape sh3d.png
model#1=/vertical_shape_sh3d.obj
width#1=100
depth#1=0.1
height#1=150
movable#1=true
doorOrWindow#1=false
## Mandatory for light source
lightSourceX#1=50
lightSourceY#1=0
lightSourceZ#1=75
lightSourceColor#1=#919189
## Optional for light source
##lightSourceDiameter#1=
elevation#1=100
modelSize#1=325
creator#1=Enko Nyito
which gives in the Home.xml file.
<light catalogId='Meshlight#Vertical' name='Vertical shape sh3d' creator='Enko Nyito' model='1' icon='0' x='50.0' y='-0.05' elevation='100.0' width='100.0' depth='0.1' height='150.0' modelSize='325' power='0.1'>
<lightSource x='0.5' y='0.0' z='0.5' color='00919189'/>
</light>

I notice that the position of the light source is not the same.

By implementing the TriangleMeshLight type,
...
int samples = 4;
int np = 4;
int nt = 2;
power = power / 100;
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));
this.sunflow.parameter("samples", samples);
this.sunflow.parameter("points", "point", "vertex", parseFloatArray(np * 3, light, lightSourceLocation));
this.sunflow.parameter("triangles", parseIntArray(nt * 3));
this.sunflow.light(UUID.randomUUID().toString(), "triangle_mesh");
...

private int[] parseIntArray(int size) {
int[] data = {0, 1, 2,
0, 2, 3};
return data;
}

private float[] parseFloatArray(int size, HomeLight light, Point3f lightSourceLocation) {
float[] data = {lightSourceLocation.getX() - light.getWidthInPlan()/2, lightSourceLocation.getY() - light.getHeightInPlan()/2, lightSourceLocation.getZ() - light.getDepthInPlan()/2,
lightSourceLocation.getX() + light.getWidthInPlan()/2, lightSourceLocation.getY() - light.getHeightInPlan()/2, lightSourceLocation.getZ() - light.getDepthInPlan()/2,
lightSourceLocation.getX() + light.getWidthInPlan()/2, lightSourceLocation.getY() + light.getHeightInPlan()/2, lightSourceLocation.getZ() + light.getDepthInPlan()/2,
lightSourceLocation.getX() - light.getWidthInPlan()/2, lightSourceLocation.getY() + light.getHeightInPlan()/2, lightSourceLocation.getZ() + light.getDepthInPlan()/2};
return data;
}
I get those results.



The TriangleMeshLightWithNoRepresentation class
public static class TriangleMeshLightWithNoRepresentation extends TriangleMeshLight {
public Instance createInstance() {
return null;
}
}
does not allow to have a wire 3D shape like the SphereLight type.

For comparison, the same light panel with the type

----------------------------------------
EnkoNyito