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

    Backface culling in BaseDraw?

    Scheduled Pinned Locked Moved SDK Help
    7 Posts 0 Posters 534 Views
    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 Offline
      Helper
      last edited by

      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

      On 08/07/2012 at 03:37, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   R12/R13 
      Platform:      
      Language(s) :     C++  ;

      ---------
      Hello people.  🙂

      My ToolData plugin draws some lines into the editor. I want the lines behind the object to be hidden, but they're still rendered.

      Thanks,
      -Niklas

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

        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

        On 08/07/2012 at 06:10, xxxxxxxx wrote:

        Never done this myself but if I did I'd start with BaseView::BackfaceCulling and would use that to only draw the lines for non-hidden faces.

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

          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

          On 08/07/2012 at 07:26, xxxxxxxx wrote:

          ah, I haven't found this function! Thank you very much! It looks exactly like what I search for. 🙂

          -Nik

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

            THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

            On 09/07/2012 at 05:48, xxxxxxxx wrote:

            Hi spedler,

            Hm, the method doesn't work for me. Do I call it the wrong way?

                if (!bd->BackfaceCulling(c_normal->v3, c_normal->off))  
                  bd->DrawLine(c_normal->off, c_normal->off + c_normal->v3 * 10, 0);
            

            The result is awkward:


            (It doesn't even change when rotating the camera!)

            However, I found a way to compute a quick & dirty Backface Culling. ^^

                    Bool BackfaceCulling(const Vector& campos, const Vector& normal,  
                                              const Vector& pos) {  
                      Vector delta = campos - pos;  
                      return normal.Dot(campos) < (M_PI / 2.0);  
                  }
            

            This is the result:

            Cheers,
            -Nik

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

              THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

              On 09/07/2012 at 06:52, xxxxxxxx wrote:

              Originally posted by xxxxxxxx

              Hi spedler,Hm, the method doesn't work for me. Do I call it the wrong way?

                  if (!bd->BackfaceCulling(c_normal->v3, c_normal->off))        bd->DrawLine(c_normal->off, c_normal->off + c_normal->v3 * 10, 0);
              

              I don't know, as I say I've never used this function. It looks like you're not using it correctly - you draw the line if bd->BackfaceCulling returns TRUE (i.e. the face is visible). It also depends on what is in your variable c_normal - you need the centre of the polygon and the face normal. You can get the normal with CalcFaceNormal, the centre you have to calculate yourself from the coordinates of the points which make up the polygon concerned.

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

                THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                On 09/07/2012 at 07:32, xxxxxxxx wrote:

                Hello spedler,

                right I forgot to add this. 🙂 c_normal->off contains the polygon's center while ->v3 contains the normal. I've calculated myself (to resolve function-call overhead) but the values are correct. (Otherwise the drawn lines would be messed up or incorrect)

                > you draw the line if bd- >BackfaceCulling returns TRUE (i.e. the face is visible).
                Well, that's what I want. 🙂

                Thank you,
                Niklas

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

                  THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                  On 09/07/2012 at 08:46, xxxxxxxx wrote:

                  Sorry, I should have been clearer. In your code you are testing if BackfaceCulling() returns FALSE. That means a poly isn't visible, but then you are drawing the line. You need it the other way round. Remove the '!' before bd->BackfaceCulling.

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post