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

    Stop rotation on collision [CLOSED]

    SDK Help
    0
    15
    1.4k
    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 12/01/2015 at 07:48, xxxxxxxx wrote:

      Hi,

      Well, the reason why I don't use the dynamics system is because the object I want to rotate simply isn't dynamic. I want to rotate it myself, and never use gravity on that object.

      All the rest is clear to me, except how to calculate the "collision rotation".
      I've searched on google for a while, but everything I found with collisions has dynamics.
      I'm quite sure I know what I need to calculate, just not how to do it.
      Are there helper-functions inside C4D that I can use?
      Or should I calculate it from nil?

      Thanks for looking into this!!

      Cheers,
      Casimir

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

        On 13/01/2015 at 09:12, xxxxxxxx wrote:

        At least I'm not aware of any convenience function to calculate what you need.
        In C++ (not in Python) there's the GeColliderEngine, but even that does only help you to calculate, if there's a collision. And what you want, is quite the opposite.
        I'll leave this question open to the community for some time. I'm sure there are solutions in literature and surely also on the net for this problem.

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

          On 13/01/2015 at 09:29, xxxxxxxx wrote:

          this can be easily solved, but I need to know how do you set the variable "global newRotation"

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

            On 13/01/2015 at 10:06, xxxxxxxx wrote:

            Well,

            Andreas already pointed me on the fact that I don't need to declare it globally.
            I get the value from an object-node (the rotating object) which gives me the current rotation (normally even when it is or should be colliding).

            I hope this is what you needed?

            Greetings,
            Casimir

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

              On 13/01/2015 at 10:14, xxxxxxxx wrote:

              what I wanted to know is:how does it rotate?
              depending on time? or mouse rotation action? or dynamics? specify whatever thing is rotating it.

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

                On 13/01/2015 at 10:28, xxxxxxxx wrote:

                Oh yeah, sorry for that!
                I rotate it manually with my mouse, for animation.
                In this example it are just two static objects, but in my bigger file even those two objects move depending on other controls.

                Cheers,
                Casimir

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

                  On 13/01/2015 at 10:41, xxxxxxxx wrote:

                  so when you rotate with the mouse, it stops at a certain rotation "before the collision" and get stuck, correct?

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

                    On 13/01/2015 at 11:34, xxxxxxxx wrote:

                    Yes indeed, and that's kind of what I want, except that now it stops at random rotations.
                    E.g. sometimes it stops at Pitching 8.45° and sometimes at 9.37°, while it should always be 12°.

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

                      On 13/01/2015 at 12:04, xxxxxxxx wrote:

                      this code is not tested, test it and tell me if it works.

                        
                          
                          
                          import c4d  
                          #Welcome to the world of Python  
                            
                          def main() :  
                              global isColliding  
                            global newRotation  
                            global lastRotationOutput  
                            global newRotationOutput  
                            
                            if isColliding == False:  
                                lastRotationOutput = newRotation  
                                newRotationOutput = newRotation  
                            else:  
                                newRotationOutput = lastRotationOutput + (2 * (lastRotationOutput - newRotation))
                          
                      
                      1 Reply Last reply Reply Quote 0
                      • H
                        Helper
                        last edited by

                        On 13/01/2015 at 12:07, xxxxxxxx wrote:

                        This may make the error smaller. But the principal error stays the same.
                        I'm sorry I need to stamp on the hopes.
                        Mohamed, did you read my explanation?

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

                          On 13/01/2015 at 12:31, xxxxxxxx wrote:

                          yea I totally understand where the problem lies, and I tested my code in a simple scene and it failed too "even worse".

                          I guess a python tag may do it "because you will control the refresh" , but in xpresso it is horrible to do such things

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

                            On 14/01/2015 at 06:01, xxxxxxxx wrote:

                            Yeah I'm looking into that.
                            But, my problem is, how should I calculate the collision? On that level I have no helper functions to use, so I guess I have to code it whole from nil.

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