make objects pivot look at an object ...

hello ... i was wondering if it is possible to make a bunch of ( 500 and more) objects pivots look at a node or something without affecting the original object .. u can look at the attachment the will give the idea ...
thanks in advance

AttachmentSize
1.jpg53.05 KB
2.jpg56.26 KB

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
JokerMartini's picture

Here it is explained

Scene Setup: All the teapots are animated going from left to right as seen in image one.
There is a Geosphere in the origin 0,0,0

Run the script. The result makes all the animated teapots aligned towards the geosphere which is what we want. Results of image 2.

The problem is that when i delete the look-at constraints the teapots return back to there original states found in image 1.

I want to somehow figure out a way to keep that offset and rotation created by the lookatConstraint and but delete the look at constraints.

AttachmentSize
step1.png 171.02 KB
step2.png 165.61 KB

John Martini
Digital Artist
http://www.JokerMartini.com (new site)

Garp's picture

Now it's animated?

This is quite different from what we've been doing so far.
I can't open the file (still using old max 9). You'll have to describe the scene: what is animated (objects? target?), what is looking at what, how many targets?
From the script it seems that you link to a dummy and then give it a lookAt. If you want to animate either the dummy or the target, of course you don't delete the dummy!

Garp's picture

(...!)

(
    local dum = dummy()
    local theTarget = $Geosphere01  -- the target
    local theLookAt = lookAt_constraint()
    theLookAt.appendTarget theTarget 100
    dum.rotation.controller = theLookAt
    for obj in selection do
    (
        dum.pos = obj.pos
        obj.transform = dum.transform
    )
    delete dum
)

I'm curious to see where this is going :)

JokerMartini's picture

Bug

Alright this is where I'm going with it Garp.
I'm having an issue when I delete the Dummy with the Look At Constraint. Now do you know of any where I could get around that and somehow delete it which keeping its offset?

Directions:Open the max file and run the attached script but ONLY on the green wirecolored objects and the scrub the time line. You'll notice all the objects animate inward which is what I want.

If you do that same process but delete the dummy it doesnt react the same.

Thanks
John

AttachmentSize
objlookat.max 248 KB
alignobjecttoobject-v2.ms 363 bytes

John Martini
Digital Artist
http://www.JokerMartini.com (new site)

Garp's picture

(...)

(
    local dum = dummy()
    local theTarget = $Geosphere01  -- the target
    local theLookAt = lookAt_constraint()
    theLookAt.appendTarget theTarget 100
    dum.rotation.controller = theLookAt
    for obj in selection do
    (
        dum.pos = obj.pos
        local oldTM = obj.transform
        local newTM = dum.transform
        obj.transform = newTM
        obj.objectOffsetRot = oldTM * inverse newTM
    )
    delete dum
)
JokerMartini's picture

Nice

Great stuff Garp.

Now this script seems to change the objects pivot to point at the targeted object which is great and what I asked for. Thanks a ton.

Now is there a way to not only change the objects pivot but rotation align it to point at the target objects pivot.
For example. You had a geosphere at 0,0,0 and then you created a handful of teapots.
You now want to rotate align the teapots so not only their pivots but also the spout on all of them are pointing towards to targeted object (geosphere)

John Martini
Digital Artist
http://www.JokerMartini.com (new site)

JokerMartini's picture

Is

Is there a way to do this without using a controller?

Is there a way to run the script and it makes the objects pivots rotate to look at an object? It doesn't have to be a permanent thing like the look at controller. I'd like it to just rotate once to match.

John Martini
Digital Artist
http://www.JokerMartini.com (new site)

Garp's picture

Working version:

(
    local theTarget = $Geosphere01  -- the target
    local theLookAt = lookAt_constraint()
    theLookAt.appendTarget theTarget 100
    for obj in selection do
    (
        local oldTM = obj.transform
        obj.rotation.controller = theLookAt
        obj.objectOffsetRot = oldTM * inverse obj.transform
    )
)
JokerMartini's picture

Hey Guys

Hey guys did this one ever get figured out and working?
I was messing around with it today and it does not seem to be working properly?
Any final scripts or conclusion on this one?

John Martini
Digital Artist
http://www.JokerMartini.com (new site)

ttm1st's picture

u mean : for o in $ do

u mean :
for o in $ do o.objectOffsetRot *= o.rotation
i tried that but the objects didnt get back to thier original state ...

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.