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
    • Recent
    • Tags
    • Users
    • Login

    bd->WS

    Scheduled Pinned Locked Moved SDK Help
    12 Posts 0 Posters 932 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 17/07/2010 at 03:04, xxxxxxxx wrote:

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

      ---------
      Hello

      I am getting some strange values when trying to convert mouse position from world space to screen space in

      Bool MyObject::MoveHandle(PluginObject *op, PluginObject *undo, const Matrix &tm, LONG hit_id, LONG qualifier) {  
      ...  
      bd->WS(tm.off);  
      ...  
      }
      

      it all works well until the camera is in front of the world center (0,0,0), as soon as the camera goes trough center (so the center is behind camera) the return of WS skyrocket to very high numbers.

      Anyone know how to get pass this?

      Thanks

      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 19/07/2010 at 01:13, xxxxxxxx wrote:

        I suspect that tm is not in world space.
        Also tm.off might be an offset to the original position of the handle.

        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 19/07/2010 at 01:28, xxxxxxxx wrote:

          As Michael said tm is not in world space.

          cheers,
          Matthias

          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 19/07/2010 at 05:48, xxxxxxxx wrote:

            What is then the correct way to get screen coordinates in MoveHandle, basically I only need the movement and this is the code I use atm

            Bool MyObject::MoveHandle(PluginObject *op, PluginObject *undo, const Matrix &tm, LONG hit_id, LONG qualifier) {  
              BaseDocument *doc = GetActiveDocument();  
              BaseDraw *bd = doc->GetActiveBaseDraw();  
                
              if(mouseClick) { // save where you clicked in 2D  
                  storeTM = bd->WS(tm.off);  
                  mouseClick = FALSE;  
              }  
              Vector moveTM = bd->WS(tm.off); //move in 2D  
              Vector translate = moveTM - storeTM; //final move  
            ...
            

            The object is in center of the world anyway, so tm is in world space no?
            Or is it WS simply the wrong way to get this?

            Thanks

            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 19/07/2010 at 06:25, xxxxxxxx wrote:

              the documentation says:

              tm = The amount the handle has been moved by the user

              So tm is already the translation matrix (not sure in which space it is defined, might be the object space or world space, the docs don´t say anything about it. Rotate your object and check the result to find out). Simply use tm.off for your translate value and do something with it.

              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 19/07/2010 at 06:27, xxxxxxxx wrote:

                Well I need the translation in screen values not in 3D.

                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 19/07/2010 at 06:38, xxxxxxxx wrote:

                  If you know in which space the translation is defined and where your handle is then you can easily calculate the world space position and convert it.

                  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 19/07/2010 at 06:50, xxxxxxxx wrote:

                    Ok tested with rotating the object, so the translation matrix is in object space.

                    Since tm.off always starts from 0,0,0 and object is at 0,0,0 this basically is world space or isn't it.

                    The problem is still with WS and world center being behind the camera as far as I can see.

                    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 19/07/2010 at 07:37, xxxxxxxx wrote:

                      The translation matrix is in local space of the handle itself, so basically an offset.

                      cheers,
                      Matthias

                      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 19/07/2010 at 08:47, xxxxxxxx wrote:

                        so is bd->WS the right way to convert this offset to 2D screen coordinates?
                        or is there a simple alternative to get 2D screen coordinates of the mouse while moving a handle, since I am hitting a wall with this?

                        thanks.

                        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 19/07/2010 at 09:09, xxxxxxxx wrote:

                          WS( worldspace(handleposition + translation offset) )

                          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 19/07/2010 at 10:35, xxxxxxxx wrote:

                            Thanks for all the tips, it finally works with this code, and translating the matrix in front of camera at all times so it cant fail.

                            BaseDocument *doc = GetActiveDocument();  
                              BaseDraw *bd = doc->GetActiveBaseDraw();  
                              BaseObject* camera;   
                                
                              if(bd->GetSceneCamera(doc) != NULL)   
                                  camera = bd->GetSceneCamera(doc);  
                              else   
                                  camera = bd->GetEditorCamera();  
                                
                              Matrix camMg = camera->GetMg();  
                              Vector camZ = Vector(0,0,1000) * camMg;  
                                
                              if(mouseClick) {  
                                  storeTM = bd->WS(tm.off+camZ);  
                                  mouseClick = FALSE;  
                              }  
                              Vector moveTM = bd->WS(tm.off+camZ);  
                              Vector translate = (moveTM - storeTM);
                            

                            I doubt anyone will need something like this again, but here it is 🙂

                            Thanks again!

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