luxcore::Scene::DefineMesh parameters

Discussion related to the LuxCore functionality, implementations and API.
Post Reply
bartek_zgo
Posts: 116
Joined: Mon Oct 26, 2020 11:42 am

luxcore::Scene::DefineMesh parameters

Post by bartek_zgo »

Hi Guys,
could you be so kind and tell me what should I pass to define normals in funcion DefineMesh?
I should pass one normal / triangle or one normal / vertex?
I'm trying with a simple cube taken from example: luxcorescenedemo.cpp
DefineMesh("myName", 24, 12, float[24 * 3], uint[12 * 3], null, null, null, null). -> works corectly
float[] normals = float[24 * 3];
for (int i = 0; i < 24; i++) //init with some default values
{
normals[i *3] = 0; normals[i *3 + 1] = 0; normals[i *3 + 2] = 1;
}
DefineMesh("myName", 24, 12, float[24 * 3], uint[12 * 3], normals, null, null, null). -> gives me segmentation fault when I start rendering
User avatar
Dade
Developer
Developer
Posts: 5672
Joined: Mon Dec 04, 2017 8:36 pm
Location: Italy

Re: luxcore::Scene::DefineMesh parameters

Post by Dade »

bartek_zgo wrote: Mon Oct 26, 2020 12:12 pm I should pass one normal / triangle or one normal / vertex?
Vertex normals (they are optional and used to have "smooth" surfaces). For instance, they are required to have a "smooth" sphere. If you want a faceted one, they are not required.

Triangle normals can and are computed directly by LuxCore.
bartek_zgo wrote: Mon Oct 26, 2020 12:12 pm I'm trying with a simple cube taken from example: luxcorescenedemo.cpp
DefineMesh("myName", 24, 12, float[24 * 3], uint[12 * 3], null, null, null, null). -> works corectly
float[] normals = float[24 * 3];
for (int i = 0; i < 24; i++) //init with some default values
{
normals[i *3] = 0; normals[i *3 + 1] = 0; normals[i *3 + 2] = 1;
}
DefineMesh("myName", 24, 12, float[24 * 3], uint[12 * 3], normals, null, null, null). -> gives me segmentation fault when I start rendering
I assume it is "float[] normals = new float[24 * 3];" :?: Are you using C++ or something else ?

luxcorescenedemo.cpp doesn't have an exmaple of normal usage but has an example of UV usage: https://github.com/LuxCoreRender/LuxCor ... o.cpp#L182

UV and normals work exactly in the same way aside form the size: 2 Vs 3 floats.

Note: there are 2 overloaded versions of DefineMesh(), one that take a single pointer UV/Normal/etc. buffer and one that take an array for pointers. The second is used to define multiple sets of UVs/Normals/etc. for the mesh.
Support LuxCoreRender project with salts and bounties
Post Reply