DrawPoly not drawing correctly with scene lights



  • On 28/06/2014 at 18:42, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   14 
    Platform:   Windows  ;   Mac OSX  ; 
    Language(s) :     C++  ;

    ---------
    I have set the drawing to be performed taking into account the scene lights, with:

      
    bd->SetLightList(BDRAW_SETLIGHTLIST_SCENELIGHTS);   
    

    For the DrawPoly command, I use the normals that I get from the Phong tag, with:

      
    SVector* smooth_n;   
    BaseTag* phongtag = op->GetTag(Tphong,0L);   
    if (phongtag)   
    {   
         smooth_n=poly_op->CreatePhongNormals();   
    }   
    

    If i is the index of the face that I get the coordinates of, I get the normals of the points of the polygon with:

      
    if (phongtag)   
         {   
         normals[0]=smooth_n[i*4].ToRV()*(!op_matrix);   
         normals[1]=smooth_n[i*4+1].ToRV()*(!op_matrix);   
         normals[2]=smooth_n[i*4+2].ToRV()*(!op_matrix);   
         normals[3]=smooth_n[i*4+3].ToRV()*(!op_matrix);   
         }   
    

    However, the polygons are drawn with the correct color but with the incorrect shading (illumination).
    How can I set the normals to make it display correctly?

    p.s. By the way, if there is no Phong tag, I simply use the normal of the face with:

      
    N = CalcFaceNormal(pt_list, pol);   
    

    and fill the normals array with:

      
    normals[0]=normals[1]=normals[2]=normals[3]=N;   
    

    But this also produces erroneous shading.



  • On 29/06/2014 at 12:01, xxxxxxxx wrote:

    Here is a video showing what is going on:

    https://vimeo.com/99471533



  • On 29/06/2014 at 16:39, xxxxxxxx wrote:

    FIXED!!

    I had my calculations in camera space, with:

      
    bd->SetMatrix_Camera();   
    

    but I had to make them in object space, with:

      
    bd->SetMatrix_Matrix(NULL, op->GetMg(), 0);   
    

Log in to reply