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

    Setting Object global posirion ObjectData

    SDK Help
    0
    3
    284
    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

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

      On 21/08/2004 at 13:21, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   8.206 
      Platform:      
      Language(s) :     C++  ;

      ---------
      Hi,

      I have an object data plugin that creates new objects. The new objects need to be at specific locations in world space. But I can only make the objects be created relative to the ObjectData plugin.

      Im using:

        
      BaseObject* MyObjectPlugin::GetVirtualObjects(PluginObject *op, HierarchyHelp *hh)  
      {  
             
           BaseObject *oMain = BaseObject::Alloc(Osphere);  
           if(!oMain) return NULL;  
           Matrix m = oMain->GetMg();  
           m.off = Vector(0,0,200);  
           oMain->SetMg(m);  
        
           return oMain;  
      }  
      

      Im trying to move the sphere at Vector(0,0,200) in world space, but because the sphere object becomes a child of my ObjectData object, the sphere positions itself locally.

      Any help is apprieciated

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

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

        On 22/08/2004 at 02:43, xxxxxxxx wrote:

        Solved

        I had to multiply the vector by the inverted global matrix of the plugin object

          
        m.off = Vector(0,0,200) * !op->GetMg();  
        
        1 Reply Last reply Reply Quote 0
        • H
          Helper
          last edited by

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

          On 22/08/2004 at 11:21, xxxxxxxx wrote:

          The reason is that you have to SetMg() considering previous transformations. If the object was already at a position and you want to move it more, you have to add them together (or do what you're doing with inverse matrix).

          In other words, when you SetMg(), it doesn't retain the old global matrix, it is replaced by the new one. Keep that in mind.

          Matrix m = oMain->GetMg();
          m.off += Vector(0,0,200);
          oMain->SetMg(m);

          would delta translate from its current position.

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