applyPosition vs movePivot

8 views
Skip to first unread message

Jensa

unread,
Nov 20, 2008, 5:07:19 AM11/20/08
to away3d.dev
I've read some threads here and it seems that applyPosition and
movePivot does much of the same.

The former does however take some rotation into account, but the tests
I've done shows me that applyPosition really just moves things around
rather than changing the pivot point?

The comment in the applyPosition-code says "Apply the given position
to the geometry without altering the appearance of the mesh". I really
wouldn't expect that changing the position would change the appearance
of the mesh at all, so I think I don't get this. movePivot does just
what it says, but could someone give be a better definition as to what
exactly applyPosition does other than moving an object?

J

Fabrice

unread,
Nov 20, 2008, 6:02:54 AM11/20/08
to away3...@googlegroups.com
On screen, it looks like they're doing the same...

The movePivot is not affecting the mesh information
It allows you to offset the model without altering its geometry.

In past versions, the movePivot was adding offsets to all vertexes,
this is now applyPosition();

ApplyPosition is extremly handy for modeling or correction purposes or
for instance when an object needs to be duplicated,
and then showed with different offsets using movePivot...

Same principle for rotations, you can say object.rotationX and also
can say applyRotations

Fabrice

Jensa

unread,
Nov 20, 2008, 9:22:47 AM11/20/08
to away3d.dev
Ah. ok. And how does this differ from object.position then?

J

Jensa

unread,
Nov 20, 2008, 9:26:38 AM11/20/08
to away3d.dev
... and how does object.position = new Number3D(x,y,z) differ from
object.moveTo(x,y,z)? The two look really similar in the source code
other than an extra check in the moveTo method?

J

Fabrice

unread,
Nov 20, 2008, 9:47:33 AM11/20/08
to away3...@googlegroups.com
all 3 display same thing on screen, thats where it looks confusing.
the pivot is there for instance to allow a rotation from a given
point. same could be done with applyPosition
In case of an export to obj format for instance, it would reveal a
totally fucked up model in many apps
if the vertexes would not be offsetted. Or for instance, if you want
to make some geometry and recenter it.
like line 385 in PathExtrude

if(_recenter) {
applyPosition( (this.minX+this.maxX)*.5, (this.minY+this.maxY)*.5,
(this.minZ+this.maxZ)*.5);

the moveTo, is there to avoid certain cases where you would need to
generate an extra Number3D
and acts indeed as method like the property position.

Fabrice

Rob Bateman

unread,
Nov 22, 2008, 8:41:06 PM11/22/08
to away3...@googlegroups.com
... and how does object.position = new Number3D(x,y,z) differ from
object.moveTo(x,y,z)? The two look really similar in the source code
other than an extra check in the moveTo method?

position uses a number3d to set the translation of the 3d object. moveTo uses three number agruments. The difference is preferred way of working - sometimes you will want to set position with number3d, other times you don't want to have to create a number3d object just to set the position.

Ideally position should be read-only, as setting a number3d for the position before adjusting xyz values will not update position. But this was tried and broke backwars compatibility, therefore both are now present.

Rob
 
--
Rob Bateman
Flash Development & Consultancy

rob.b...@gmail.com
www.infiniteturtles.co.uk
www.away3d.com
Reply all
Reply to author
Forward
0 new messages