Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    DrawPoly not drawing correctly with scene lights

    SDK Help
    0
    3
    314
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      Helper
      last edited by

      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.

      1 Reply Last reply Reply Quote 0
      • H
        Helper
        last edited by

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

        Here is a video showing what is going on:

        1 Reply Last reply Reply Quote 0
        • H
          Helper
          last edited by

          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);   
          
          1 Reply Last reply Reply Quote 0
          • First post
            Last post