Setting Object global posirion ObjectData
-
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
-
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();
-
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.