Menu

Spectrum color on Mesh Triangle

Help
2017-12-05
2017-12-05
  • shine world

    shine world - 2017-12-05

    Hi,
    I'm using TMeshObject to add vertices on a GLFreeForm object and create a graphical form.

    var
      Mesh: TMeshObject;
    begin
      GLFreeForm1.MeshObjects.Clear;
      GLFreeForm1.Skeleton.Clear;
      GLFreeForm1.StructureChanged;
    
      Mesh := TMeshObject.CreateOwned(GLFreeForm1.MeshObjects);
      Mesh.Mode := momTriangles;
      Mesh.Vertices.Clear;
      Mesh.Colors.Clear;
    
      Mesh.Vertices.Add(0, 0, 0);
      Mesh.Vertices.Add(10, 0, 0);
      Mesh.Vertices.Add(5, 5, 0);
      Mesh.Colors.Add(ConvertWinColor(Rainbow(0.0)));
      Mesh.Colors.Add(ConvertWinColor(Rainbow(0.0)));
      Mesh.Colors.Add(ConvertWinColor(Rainbow(1.0)));
    

    In my program Rainbow get a value from 0.0 to 1.0 and return a related TColor object from Violet (390nm) to Red (720nm). So for 0% height I want to see Violet and for 100% I would like to see Red and between them all spectrum colors. This works very fine using single points but not with Mesh which don't do same transactions colors:

     

    Last edit: shine world 2017-12-05
  • shine world

    shine world - 2017-12-05

    In 001 you can see the wrong transation from violet to red.
    In 002 there is the final program which collect data ad a cloud of points objects with right spectrum color where height of Z determinate spectrum color.
    In 003 the points cloud is used to create a mesh but giving related color to each vertex depending by Height of Z the colors aren' fine.
    In 004 is more simply to watch the wrong transation of mesh from violet to red.

    So, there is a way to define how a single mesh triangle should be coloured and what transition colors are used from vertex A to B to C ?

     

    Last edit: shine world 2017-12-06

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.