Menu

Blue TGLcube with red edges

Help
Sergio
2015-09-21
2017-05-17
  • Sergio

    Sergio - 2015-09-21

    Suppose I have a TGLcube which I I put a blue color
    How can I see just the edges as red lines ?

     
  • SBlade

    SBlade - 2015-10-07

    Hi Sergio,

    as far as I know there is no direct way with lgcube to change its edge colors within object easily, the best option would be using offset polygon for the given object, in the old forum there was an example for that IRC but since old forums is gone I couldn't get and acces to it.

     
  • SBlade

    SBlade - 2015-10-07

    Take a look at that example It doesn't work totally correctly but may give you the hint how the edges can be rendered. Also take a look at the www.glasm.ru very nice site about programming.

     

    Last edit: SBlade 2015-10-07
  • Sergio

    Sergio - 2015-10-07

    Thank you SBlade . The site you indicated is great. I installed the GLSviewer and run but when I try to use the functions in the cube nothing happen (only rotate). I remember that some time ago I could show the cube edges colored using shaders in an easy way

     
  • SBlade

    SBlade - 2015-10-07

    yes the program doesn't render properly, but follow the codes under the flat shades with lines. As you mentioned the gist there is to create shader which implements polygon offseting and the corresponding code is there THiddenLineShader so you can copy paste and try to modify it to suit your needs.

     
  • Sergio

    Sergio - 2015-10-08

    Thanks
    Using the opportunity I went to https://sourceforge.net/p/glscene/code/HEAD/tree/trunk/Samples/Delphi/AdvDemos/GLSViewer/ and opened it with my Delphi XE7

    When I tried to compile there was and error that I did not understand at System.ImegeList

    [dcc32 Fatal Error] FMain.pas(11): F1026 File not found: 'C:\GLScene_VCL\Samples\Delphi\AdvDemos\GLSViewer\System.ImageList.dcu' (unit scope "System" indicates OSX32, Win64, Win32 only)

    So I blocked // System.ImageList, and could compile
    I tried to run and it runs and the cubbe appear and I can rotate it but clicking any of the buttons nothing happens . Is it because System.ImageList is not there ?

     
  • Jerome.D (BeanzMaster)

    Hi you can uses TGLHiddenLineShader or TGLOutlineShader , it 's the easiest way i think

    Cheers

     

    Last edit: Jerome.D (BeanzMaster) 2015-10-09
  • Sergio

    Sergio - 2015-10-09

    Hi Delauney
    Thank you and solved . This is what I was looking for
    Actually now I see that the complete easy solution is in the demo Rendering/Lining in the GLAnnulusOutlined using GLOutlineShader1

     
  • Sergio

    Sergio - 2017-05-17

    In the demo rendering/lining there is a GLAnnulusOutlined blue with a red shader GLoutlineShader1 . Which property should I change to make the blue body 50% transparent but maintaining the red edges ?
    I ask this question because I am trying to do some run time cubes with red edges using the code below. The problem is that when I do not use the shader the figure is like in the left side of the attached figure (OK but without edges). When I insert the two lines for the edges the transparencies disapear becoming gray (see right side of the figure)
    Another question is how to draw only the edges without the diagonals.

    Thank you in advance

    procedure TF_3DD.Make_a_Cube(Est_or_Dyn:boolean; var cubi:TGLCube;cubiName:string; position_X,position_Y,position_Z:single;cores:Tvector;EmissColor:single;
    cub_width,cub_height,cub_depth:single;dirX,dirY,dirZ,upX,upY,upZ,pitchAng,rollAng,turnAng:single; visivel:boolean; transparMode:integer);
    begin
    if cubi<>nil then cubi.free;

     Cubi := TGLCube(DC1.AddNewChild(TGLCube));
     with cubi do
     begin
      name:= cubiName;
      Position.AsVector := VectorMake(position_X,position_Y,position_Z);
    

    // Material.MaterialLibrary := GLMaterialLibrary1 ; << to have red edges
    // Material.LibMaterialName := 'LibMaterialGLoutlineShader11' ;

      Material.FrontProperties.Emission.Color:=cores   ;       
      Material.FrontProperties.diffuse.alpha:=EmissColor ;      
      if transparMode=0 then Material.BlendingMode := bmTransparency
      else                   Material.BlendingMode := bmOpaque;
    
      CubeDepth := cub_depth;
      CubeHeight := cub_height;
      Cubewidth  := cub_width;
      Direction.AsVector := VectorMake(dirX,dirY,dirZ );
      Up.AsVector        := VectorMake(upX,upY,upZ);
      pitchAngle:= pitchAng;
      rollAngle := rollAng;
      turnAngle := turnAng;
      visible:= visivel;
      StructureChanged ;
     end;
    

    end;
    //___

     
  • Jerome.D (BeanzMaster)

    Hi you cannot remove Middle egdge because it's an edge it's normal but if are separated objects you can take loo to the "silhouette" demos or just an idea have youmay try to inverse normal and use hiddenline shader

     
  • Sergio

    Sergio - 2017-05-17

    Thank you Jerome. I will try with hiddenline and check sillhouette. I remember that I could do this easily many years ago without doing anything special (not sure if with transparency)
    When I do not use the shadder the material properties which are used come from the cube. It seems that when I insert the shader the material propertirs of the shader prevails over the one of the cube.(but not the transparency)

     
  • Sergio

    Sergio - 2017-05-19

    Writing again but in the right place

    Dear PW Thank you very much. Good material.
    TGLDummyCube has the property edgecolor that is quite useful. In many-many cases cubes are characterized just by the edges. I imagine that this is the reason why TGLDummyCube , which has very few properties, has it.
    My suggestion is to include in TGLcube component an “edge color property”
    If it is not easy to do it or there is another reason for not implementing , please help me to implement in my codes a component like a “TGLcube with a coloredge property”. Thank you all in advance

     
  • Sergio

    Sergio - 2017-05-23

    Just to close the post , I could do what I was looking for (see figure attached) .
    These are cubes without diagonals but using a not elegant solution (draw a normal TGLcune + TGLines in the edges). .
    To do it in a easier to use way it is necessary to add in the PolygonMode an additional attribute (pmfil pmlines pmpoints PMLINESWITHOUT DIAGONALS ).
    Unfortunatelly I do not know how to it.

    The working code I used is below
    procedure TF_3DD.Make_a_Cube(CubNum:integer;Est_or_Dyn:boolean;
    cubi:TGLCube;cubiName:string;
    posX,posY,posZ:single;
    CubeColor:TColorVector;EmissColor:single;
    cub_width,cub_height,cub_depth:single;
    dirX,dirY,dirZ,upX,upY,upZ,pitchAng,rollAng,turnAng:single;
    visivel:boolean; transparMode:integer);
    var
    squareBase,squareTop,squareRight,squareLeft:TGLLines;
    begin
    if cubi<>nil then cubi.free;
    if EstaticODE<>nil then EstaticODE.Free;
    if dynamicODE<>nil then dynamicODE.Free;
    Cubi := TGLCube(DC1.AddNewChild(TGLCube));
    with cubi do
    begin
    name:= cubiName;
    Position.AsVector := VectorMake(posX,posY,posZ);
    CubeDepth := cub_depth;
    CubeHeight := cub_height;
    Cubewidth := cub_width;
    Direction.AsVector := VectorMake(dirX,dirY,dirZ );
    Up.AsVector := VectorMake(upX,upY,upZ);
    pitchAngle:= pitchAng;
    rollAngle := rollAng;
    turnAngle := turnAng;
    visible:= visivel;
    Material.MaterialLibrary := GLMaterialLibrary1 ;
    if cubNum = 1 then // using hiddenlineshader withdiagonals May be useful in some cases
    begin
    Material.LibMaterialName := 'LibMaterial1' ;
    GLMaterialLibrary1.Materials[2].Material.BlendingMode := bmTransparency;
    GLMaterialLibrary1.Materials[2].shader:= GLhiddenLineShader1;
    GLHiddenLineShader1.BackgroundColor.DirectColor:= clrGreen ;
    GLHiddenLineShader1.BackLine.Color.DirectColor:= clrGreen ;
    GLHiddenLineShader1.FrontLine.Color.DirectColor:= clrGreen ;
    GLHiddenLineShader1.BackgroundColor.alpha:= EmissColor ; // like 0,3
    end
    else
    // not using shaders – non elegante solution using TGLlines to do the edges
    // the good way would be to create inside polygonmode one more posibility
    // ( pmfill pmlines (with diagonals) pmpoints and the new pmlinesNoDiagonals)
    begin
    GLMaterialLibrary1.Materials[2].Material.FrontProperties.Diffuse.Color:=cubeColor ;
    Material.FrontProperties.Emission.Color:=cubeColor ;
    Material.FrontProperties.diffuse.alpha:=EmissColor ;
    if transparMode=0 then Material.BlendingMode := bmTransparency
    else Material.BlendingMode := bmOpaque;
    // base square
    squareBase := TGLLines(DC1.AddNewChild(TGLLines)); // areastas
    with squareBase do
    begin
    NodesAspect := lnaInvisible;
    LineWidth := 4;
    LineColor.Color := CubeColor;
    AddNode(posX + 0.5cub_width , posY - 0.5cub_height , posZ + 0.5cub_depth); // pt1
    AddNode(posX + 0.5
    cub_width , posY - 0.5cub_height , posZ - 0.5cub_depth); //pt2
    AddNode(posX - 0.5cub_width , posY - 0.5cub_height , posZ - 0.5cub_depth); //pt2
    AddNode(posX - 0.5
    cub_width , posY - 0.5cub_height , posZ + 0.5cub_depth); // pt4
    AddNode(posX + 0.5cub_width , posY - 0.5cub_height , posZ + 0.5*cub_depth);
    end;
    // top square
    squaretop:= TGLLines(DC1.AddNewChild(TGLLines)); // edges
    with squareTop do
    begin
    NodesAspect := lnaInvisible;
    LineWidth := 4;
    LineColor.Color := CubeColor;

              AddNode(posX + 0.5*cub_width , posY + 0.5*cub_height , posZ + 0.5*cub_depth);     // pt1
              AddNode(posX + 0.5*cub_width , posY + 0.5*cub_height , posZ - 0.5*cub_depth);    //pt2
              AddNode(posX - 0.5*cub_width , posY + 0.5*cub_height , posZ - 0.5*cub_depth);    //pt2
              AddNode(posX - 0.5*cub_width , posY + 0.5*cub_height , posZ + 0.5*cub_depth);     // pt4
              AddNode(posX + 0.5*cub_width , posY + 0.5*cub_height , posZ + 0.5*cub_depth);
             end;
              // rigth square 
            squareRight:= TGLLines(DC1.AddNewChild(TGLLines));            // edges
            with squareRight do
             begin
              NodesAspect := lnaInvisible;
              LineWidth := 4;
              LineColor.Color := CubeColor;
              AddNode(posX - 0.5*cub_width , posY - 0.5*cub_height , posZ + 0.5*cub_depth);     // pt1
              AddNode(posX - 0.5*cub_width , posY - 0.5*cub_height , posZ - 0.5*cub_depth);    //pt2
              AddNode(posX - 0.5*cub_width , posY + 0.5*cub_height , posZ - 0.5*cub_depth);    //pt2
              AddNode(posX - 0.5*cub_width , posY + 0.5*cub_height , posZ + 0.5*cub_depth);     // pt4
              AddNode(posX - 0.5*cub_width , posY - 0.5*cub_height , posZ + 0.5*cub_depth);
             end;
    
          end;
            // left square                     
          squareLeft:= TGLLines(DC1.AddNewChild(TGLLines));     // edges
          with squareLeft do
           begin
            NodesAspect := lnaInvisible;
            LineWidth := 4;
            LineColor.Color := CubeColor;
            AddNode(posX + 0.5*cub_width , posY - 0.5*cub_height , posZ + 0.5*cub_depth);     // pt1
            AddNode(posX + 0.5*cub_width , posY - 0.5*cub_height , posZ - 0.5*cub_depth);    //pt2
            AddNode(posX + 0.5*cub_width , posY + 0.5*cub_height , posZ - 0.5*cub_depth);    //pt2
            AddNode(posX + 0.5*cub_width , posY + 0.5*cub_height , posZ + 0.5*cub_depth);     // pt4
            AddNode(posX + 0.5*cub_width , posY - 0.5*cub_height , posZ + 0.5*cub_depth);
           end;
      StructureChanged ;
     end;
     // create static or dynamic behaviour
     if Est_or_Dyn then  CreateStaticBehaviour_Cube (EstaticODE,cubi)    
     else                CreateDyn_Behaviour_Cube   (dynamicODE, cubi);
    

    end;

     

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.