View Full Version : Put object into global position
dirtyharry 08-21-2010, 10:28 PM i have a problem with a script i put together from pieces of other scripts.
i want to set the position of the active object to the surface/position the mouse points.
works fine when the object is not under a parent.....else its positioned relativ
maybe some of u know how to achive this
thx
|
|
tcastudios
08-22-2010, 12:14 AM
Now, where have I seen that before...... :)
See if the following makes sense..
Cheers
Lennart
// Place At Pivot Position tcastudios.com 2010
// Create a Shortcut to make this work
// Select object to place
// Place your mouse pointer
// Run the Shortcut (not clicking the mouse)
var cam = doc->GetRenderBaseDraw()#BASEDRAW_DATA_CAMERA; // get the active view
var cambc = cam->GetContainer(); // Store current settings of view
var op = object(); // First active object
if(!op || op == cam) return; // No selection or view itself
CallCommand(1021420); // Set Camera Pivot Point
var pivp = cam#CAMERAOBJECT_PIVOT_POSITION; // Get the new (temp)pivot point
var opm = op->GetMg(); // Get objects matrix
opm->SetV0(pivp); // Set the global position into matrix
op->SetMg(opm); // Load the matrix back into object
// placing it at the new pivot point
cam->SetContainer(cambc); // Optionally restore the view settings
dirtyharry
08-22-2010, 10:53 AM
thanxs again lennart, my hero as always....
i wonder if it would be posible also rotate the object to the face-normal it is sitting on?
i guess this would be a few more words of code...
tcastudios
08-22-2010, 03:44 PM
Just add a constraint tag to the object set to Clamp, Surface and Phong Normal.
Cheers
Lennart
CGTalk Moderation
08-22-2010, 03:44 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.