As indicated in the title, I am attempting to change the emissive color of several materials in a mesh to mimic illumination. I am attempting to use oapi.set_materialex(hMesh, matidx, matprp, col). From the Lua documentation, the parameters for this function are defined as:
The material index matidx is known to exist in the mesh file (8 in this example) There are 23 materials so there doesn't seem to be a problem with this.
The material property matprp is apparently a number, but no further information is available in the Lua documentation. Looking at the API Reference there is a MatProp enumeration type and the numbers are defined in a materials property list, but there is no similar enumeration type listed in the Lua documentation. Searching through the code on Github in Atlantis.lua shows a usage of MATPROP.LIGHT in this function, so that was used. Again, this is information that should be added to the Lua documentation.
The color is defined as a color table as described in the Lua documentation:
But when I attempt to put it all together:
oapi.dbg_out(test) immediately after this line returns 'nil' and there is no visual change in the panel emissivity.
Some checks on the parameters entered:
oapi.dbg_out(hdevmesh) returns a hexadecimal code with 'object'. (hdevmesh is needed elsewhere and it seems to be referenced properly).
oapi.dbg_out(MATPROP.LIGHT) returns '3', which matches the index of Light in the enum table.
oapi.dbg_out(cockpit_lights_on_emissive_color) returns the rgba color table as entered.
There are no errors on screen or in Orbiter.log, but this function simply returns 'nil'. I'm at a loss. It's not even throwing an error so apparently the method exists.
I am using Orbiter 2024.
- hMesh handle mesh handle
- matidx number material index
- matprp number material property to be set
- col colour material property value
Code:
function clbk_visualcreated(vis, refcount)
hdevmesh = vi:get_devmesh(vis,0)
end
The material index matidx is known to exist in the mesh file (8 in this example) There are 23 materials so there doesn't seem to be a problem with this.
The material property matprp is apparently a number, but no further information is available in the Lua documentation. Looking at the API Reference there is a MatProp enumeration type and the numbers are defined in a materials property list, but there is no similar enumeration type listed in the Lua documentation. Searching through the code on Github in Atlantis.lua shows a usage of MATPROP.LIGHT in this function, so that was used. Again, this is information that should be added to the Lua documentation.
The color is defined as a color table as described in the Lua documentation:
Code:
cockpit_lights_on_emissive_color = {r= 0.906, g=0.906, b=0.906, a= 1.0}
But when I attempt to put it all together:
Code:
test = oapi.set_materialex(hdevmesh, 8, MATPROP.LIGHT, cockpit_lights_on_emissive_color)
oapi.dbg_out(test) immediately after this line returns 'nil' and there is no visual change in the panel emissivity.
Some checks on the parameters entered:
oapi.dbg_out(hdevmesh) returns a hexadecimal code with 'object'. (hdevmesh is needed elsewhere and it seems to be referenced properly).
oapi.dbg_out(MATPROP.LIGHT) returns '3', which matches the index of Light in the enum table.
oapi.dbg_out(cockpit_lights_on_emissive_color) returns the rgba color table as entered.
There are no errors on screen or in Orbiter.log, but this function simply returns 'nil'. I'm at a loss. It's not even throwing an error so apparently the method exists.
I am using Orbiter 2024.
Last edited:


