PDA

View Full Version : nodeLocalBoundingBox


PEN
07-27-2011, 05:47 PM
Any one use this before. Looks to me like it is still returning a world bounding box and the values are backwards, ie;[max,min]

Can any one confirm this or has used it and found the same issues. This test was in 2011.

PEN
07-27-2011, 05:51 PM
I should mention that nodeGetBoundingBox and passing the needed matrix works.

Furball89
07-27-2011, 06:52 PM
hey!
its been long time since i played with nodegetboundingbox but afaik nodelocalboundingbox returns the transformed (oriented) bounding box the one you can see in the viewport ('j' to toggle it) where as nodegetbounding box returns a box that encloses the rotated object.

PEN
07-27-2011, 08:25 PM
I know what it is supposed to do but it is not doing that here, did you test it?

nodeGetBoundingBox obj obj.transform returns the correct bounding box for the local that it seen in the viewport.

lo
07-27-2011, 09:10 PM
I can confirm it is not working for me in max 2009.

denisT
07-27-2011, 10:16 PM
hmm... it always worked and still works for me. i used it in many places...
here is the correspondence between nodeLocalBoundingBox and nodeGetBoundingBox:
pseudo

(nodeLocalBoundingBox <node>) == (nodeGetBoundingBox <node> <node>.transform)*<node>.transform
(nodeLocalBoundingBox <node>)*(inverse <node>.transform) == (nodeGetBoundingBox <node> <node>.transform)


nodeLocalBoundingBox is very usefull:

(
b = box()
rotate b (angleaxis 32 [0,1,0])
rotate b (angleaxis 48 [1,0,0])
move b [10,0,0]
bb = nodeLocalBoundingBox b
p1 = point pos:bb[1]
p2 = point pos:bb[2]
)

PEN
07-28-2011, 02:30 PM
That is basiclly the test code from the help and it wasn't working. I will test again after I have this rig out the door and see what was going on.

denisT
07-28-2011, 04:21 PM
That is basiclly the test code from the help
oops... i swear i didn't look in the help when i was writing the post :)

what is not working? is it not working with the coordsys context?

PEN
07-28-2011, 04:51 PM
It isn't returning a local bounding box the way that it is shown in the help. Rotate the object and it produces different values when it should always give the same ones relative to the objects pivot.

denisT
07-28-2011, 06:56 PM
It isn't returning a local bounding box the way that it is shown in the help. Rotate the object and it produces different values when it should always give the same ones relative to the objects pivot.

the function works correct but has a confusing name. the function returns local bounding box corners transformed in world space coordinate system. to get really local values you have to multiply it on inverse object's transform. it always worked this way.
i can't name the function correct... something like - worldspaceLocalBoundingBox :)

Ruramuq
07-28-2011, 07:48 PM
resuming:
nodeLocalBoundingBox == relative to identity matrix
nodeGetBoundingBox == relative to specified matrix

in coordsys local nodeLocalBoundingBox $ == nodeGetBoundingBox $ $.transform

PEN
07-29-2011, 02:45 PM
I think that is why it does not appear to work correctly, I'm not quite sure when I would need what it does by default. Thanks for the help. I have it working the way that I first outlined so I will stick with that. I'll play more with it when I have time to see what I can get out of the local bounding method.

Kickflipkid687
12-02-2011, 10:23 PM
This thread helped me get the proper bounds size when the pivot point is rotated oddly, which is good :)

But now.... I'm not sure how I can get the local bounds rotation?
I can create my own matrix, but this time its a bit more complex than in the past.

I know I can create a Y Vector from 2 points, but I can't use the Max/Min from the Bounds, since it wouldn't be in a straight line. I'd have to get an offset position from the lower bounds to the top of the bounds box for the proper line.

But even with that, I'd have to use something for a Normal Direction (Z), but I'm not sure what. I can't use the objects normal Transform, because it could be any direction.... :shrug:

denisT
12-02-2011, 10:49 PM
But now.... I'm not sure how I can get the local bounds rotation?

probably you or me are missing something. local object rotation if its <obj>.objectoffsetrot

Kickflipkid687
12-02-2011, 10:57 PM
Ok, I will try to explain better :)


Normally calculating Bounds Box isn't that bad, but lets say you rotate the object a certain way, which again, isn't bad.

But, what if you rotate an object, but then also use Affect Pivot Only, and rotate the pivot in the opposite direction of the bounds box direction.

This is what I'm trying to figure out. However max is calculating the bounds box of the mesh, according the geo, and not according to the actual transform matrix, this is what I want.

I cannot rely on the standard bounds box it seems, or the nodes transform by default...

denisT
12-02-2011, 11:15 PM
However max is calculating the bounds box of the mesh, according the geo, and not according to the actual transform matrix...

how does it calculate the bounding of a camera?

Kickflipkid687
12-02-2011, 11:21 PM
I'm not sure I get what you mean?

Are you hinting at using the viewport transform to get the bounds transform somehow?

denisT
12-02-2011, 11:34 PM
I'm not sure I get what you mean?

Are you hinting at using the viewport transform to get the bounds transform somehow?
i want to say that max doesn't loop through all mesh verts to get its bbox.
max itself doesn't calculate node's bbox, it asks the node about its size. using SDK i can write a node that can return any bbox size...

Kickflipkid687
12-03-2011, 12:39 AM
That makes sense. Although , u find the size, but in doing that
Could u get the direction then? I suppose building a matrix from
the points somehow?

This isn't a make or break thing. My current method works fine
Until the pivot rotation is changed, but I would like to account for
It if possible.

Kickflipkid687
12-03-2011, 01:46 PM
So this code gets me almost there. The only issue is the rotation is facing the Local Rotation direction now, which makes sense for how I'm doing this. Since I'm using the transform.

c = snapshot $
bounds = in coordsys local nodeLocalBoundingBox c
bb = bounds[2] - bounds[1]--c.max - c.min

b = box()

b.width = bb[1]
b.length = bb[2]
b.height = bb[3]
CenterPivot b

delete c

b.transform = $.transform
b.pos = $.center
b.pivot = $.pivot


Edit: By the local rotation, I mean if you rotate the Pivot Only in a direction not aligned to the bounds box.

Kickflipkid687
12-03-2011, 02:11 PM
Here's what I mean. The box is the right size, but now I just need to align it the same somehow...


http://dl.dropbox.com/u/6895456/boundsIssue.jpg

miauu
12-03-2011, 07:33 PM
Download the video and watch it. VIDEO
(http://dl.dropbox.com/u/35093423/2011-12-03_2230.swf)
This is my Visual Pivot Placer script. There is a button "localBBox" which align orange cage to local bbox. But when the pivot is rotated my code don't work properly. The only one solution that I know is to reset pivot and then press "localbbox". So, my advice is:
- store the pivot transformation
- reset pivot
- align your box
- restore pivot transformation

Kickflipkid687
12-03-2011, 08:42 PM
It's funny you responded, I just downloaded your script, as you may know and tried it out :P

I was hoping/wondering if you had it solved, hehe

miauu
12-03-2011, 08:46 PM
;)
Is this not work:

- store the pivot transformation
- reset pivot
- align your box
- restore pivot transformation

Kickflipkid687
12-03-2011, 09:00 PM
Yeah, I saw that :) I am trying to remember/figure out how to get the pivot rotation.

I'll do some searching and get back :)

Kickflipkid687
12-03-2011, 09:09 PM
Actually, I just figured out an easier way to do it, and it seems to work perfect :D

bounds
if (isGroupMember selection[1] == true) then ( bounds= in coordsys local nodeLocalBoundingBox selection[1].parent) else (bounds= in coordsys local nodeLocalBoundingBox selection[1] )

b = box()

bb = bounds[2] - bounds[1]--c.max - c.min
b.width = bb[1]
b.length = bb[2]
b.height = bb[3]
CenterPivot b
--delete c

obj = selection[1]

if (isGroupMember selection[1] == true) then obj = selection[1].parent else obj = selection[1]

tm = obj.objecttransform

if (isGroupMember obj == true) then
(
b.transform = tm
b.pos = obj.parent.center
b.pivot = obj.parent.pivot
)
else
(
b.transform = tm
b.pos = obj.center
b.pivot = obj.pivot
)

Kickflipkid687
12-03-2011, 09:19 PM
Although... this method seems to be very slow when trying to use realtime...

Something to do when using objecttransform


Edit: Nevermind, perf wasnt caused by any of that.

Now the only issue is, when using this in mouseTrack, while moving, the box created moves/twitches rapidly aligned/unaligned for some reason.

Kickflipkid687
12-03-2011, 09:42 PM
Sorry for all the spam.

I got that last issue solved, it was because my ray was hitting/using the object I didn't want it to, so it kept moving/updating. Now it doesn't flicker and works fine :D

CGTalk Moderation
12-03-2011, 09:42 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.