Share

Texture and color

Methods

Name Syntax Description
colortriangle mesh:colortriangle(index: number; blue, green, red, alpha:number) The triangle with the given index receives new color. The color values range from 0 to 255. An alpha of 255 means full opacity, a triangle with an alpha of 0 is effectively invisible.
colortriangles mesh:colortriangles(blue, green, red, alpha:number) All triangles get a new color. The color values range from 0 to 255. An alpha of 255 means full opacity, a mesh with an alpha of 0 is effectively invisible.
getcolortriangle mesh:getcolortriangle(index: number, node1, node2, node3:LuaVector4) Get color info of triangle of the given index. The color info (BGRA) for each node is written into a LuaVector4. The values for each color range from 0 to 255. Returns the same number that was given for index.
hastexture mesh:hastexture() Returns true when a mesh has a texture.
savetexturetofile mesh:savetexturetofile(filepath:String) Saves the texture of a mesh into a JPG file. The file type extension is appended automatically.

Back to top

Example

function gettrianglecolors(luamesh)
  node1 = system:createvector4();
  node2 = system:createvector4();
  node3 = system:createvector4();
  for j=0, luamesh.facecount -1 do
    luamesh:getcolortriangle(j,node1,node2,node3);
    system:log(j .. " 1wxyz " .. node1.w .. " "  .. node1.x .. " "  .. node1.y .. " " .. node1.z ..
             " " .. " 2wxyz " .. node2.w .. " "  .. node2.x .. " "  .. node2.y .. " " .. node2.z ..
             " " .. " 3wxyz " .. node3.w .. " "  .. node3.x .. " "  .. node3.y .. " " .. node3.z);
  end;
end;  

Back to top

Was this information helpful?