gwenael

Spaces (world, parent, pivot, local)

64 posts in this topic

Deltakosh, is it faster to compute all the matrices or do some tests and compute only the matrices which need to be updated? I can modify the code as requested by neoRiley if that won't impact on performance.

Share this post


Link to post
Share on other sites

Trying to understand something... 

Lets say I have a sphere which is located at (10,0,0). 

Now, when I rotate it about WORLD Y axis, shouldn't it move around? I mean, the WORLD Y axis is located at 0,0,0 so when I do the following

sphere.rotate(BABYLON.Axis.Y , Math.PI/2, BABYLON.Space.WORLD);

shouldn't the sphere be moving around the world axis y like a moon around the earth? I'm asking because it rotates about the LOCAL y axis.

Share this post


Link to post
Share on other sites
The Local space = to the direction X or Z of your objects rotated.

The World space = to the direction X or Z from the scene.

 

If your object and move on the X axis of the space of the world, he'll go right or left regardless of its rotation. but in the Local space, it will go in the X direction of the objects following its rotation.  But on the Y axis, it is the same thing. Regardless of the rotation, the models can always move from high to low only compare it to the X and Z axis.

The World space is not a pivot point but a direction

Share this post


Link to post
Share on other sites

Sorry, dad72, but it seems that this time the translator wasn't good enough  :) Didn't understand what do you mean  :(

Share this post


Link to post
Share on other sites
I'll try to do better

 

If your object is placed on the X axis of world space, it will go to the left or right regardless of its rotation.

But in the local space, it will go in the direction X of the object following its rotation. But on the Y axis, irrespective of the rotation, the model can still move up and down compared to the axes X and Z.

The global space is not a pivot point but one direction.

 

Ilustration :

 

local_global_axes.gif

 

Paradine and Wingnut like this

Share this post


Link to post
Share on other sites

Trying to understand something... 

Lets say I have a sphere which is located at (10,0,0). 

Now, when I rotate it about WORLD Y axis, shouldn't it move around? I mean, the WORLD Y axis is located at 0,0,0 so when I do the following

sphere.rotate(BABYLON.Axis.Y , Math.PI/2, BABYLON.Space.WORLD);

shouldn't the sphere be moving around the world axis y like a moon around the earth? I'm asking because it rotates about the LOCAL y axis.

 

@Binyan - the way I dealt with this was to parent the sphere to an empty 3D object.  When I say empty, I mean, it doesn't have a mesh/geometry, but has it's own transform.  Then I set it out on it's x axis, and then rotate the parent on the Y axis.  You could do it with math of course, but it helps to describe it in a visual way.  

 

The Y axis is in "world" space just means it's purely "up" but it's origin is where ever the object's position is.  So, putting it out 10 on the X axis and rotating on Y in WORLD space just means it'll rotate perfectly on Y, but 10 clicks out on X

Share this post


Link to post
Share on other sites

@neoRiley, 

Thank you, I think I can use that approach for my needs.

@dad72,

Thanks for thoroughness. Let me see if I understood well... So when I'm rotating the mesh in the world space, it just rotates the model and there is nothing to do with movement right? And when I'm rotating the mesh in local space, it rotates the model both with its local axes. For example, if I'm rotating it 45 degrees right, then the local Z axis points to the previous -X direction, and X axis points to the previous Z direction. Is this right?

In general there is no visual difference between local and world rotation, the only difference is whether to move the local axes or no?

Share this post


Link to post
Share on other sites
Yes it is. This is how I always understood. Try Unity or 3ds max which offers World and Local axes transformation. The object visually moves differently according to chosen axis.
 
But in babylon, the local and world axis is that for rotations and not transformation. This could be interesting as additional feature. What do you think Deltakosh ?
 
Otherwise I use the same method as neoRiley. a pivot point is 0, 0, 0 I actually turn on the X axis :
 
EmptyPivot = new BABYLON.Mesh("pivos", scene);Moon.parent = EmptyPivot;

 

Share this post


Link to post
Share on other sites

Hi binyan,

 

I think this has been explained well thus far, however I might suggest a broader way of looking at Global Axis vs. Local Axis.  As a developer of visual software in more early days, We were dealing with calculations between Euler and Quaternion math.  As it's visually easier to work with Quaternion transforms (translation, rotation,scale), most graphic UIs mathematically process an objects transforms using Euler angles and convert these to Quaternion angles for the graphic user as this is what most graphic artists work with today.  However, it is valuable for everyone to understand that most applications calculate Pitch, Roll, and Yaw for every object(Euler angles) - which will assist everyone who understands this conversion process in understanding transforms in scripting and in graphic UIs - especially when calculating Rotation in three dimensional space.

 

For those who TRULY want to understand Euler transforms:

http://www.chrobotics.com/library/understanding-euler-angles

 

But to put this into perspective; for Euler angles to work mathematically, there has to be an Inertial Frame set.  Remember, the application and/or API you're using most likely calculates angles and transform deltas in Euler space.  The Inertial Frame set is equivalent to the World Axis you're working with in the WebGL Javascipt API - which as you're working in Quaternion space, is a static X,Y,Z axis at (0,0,0) world transforms - the same as a scene in Blender, Maya, 3DSMax, etc.  

 

And each object (or parent of an object) you transform will transform using its own X,Y,Z (local) axis.  But as we find in Euler space, we require a world axis as a static reference in order to calculate any objects local axis transform (translation, rotation,scale) - this is calculated as a delta in transforms between the object's local transform and the static world axis.  Without a Static World axis, there is no way to reference any one object, let alone multiple objects in 3 dimensional space.  One huge benefit of graphic 3D UIs is they can simply switch from transforming any object using either the world axis or the local axis - usually with a single button click.

 

I hope I explained this in a reasonably comprehensive way, as it's essential to understand when working in three dimensions.  I believe if anyone really wants to understand how most 3D software applications and APIs calculate transforms(based on angles), they should have a firm grasp of Euler angles.  Don't let the math scare you; it's simple once you understand Euler space, and will broaden your development skills dramatically.

 

(If you already understand euler angles, please excuse my consummate uttering.)

 

Cheers,

 

David B. ;)

Deltakosh and binyan like this

Share this post


Link to post
Share on other sites

I just recently added a couple of links and more concise info on 12/19 in the am, so please re-read if this topic is of interest to you.  :rolleyes: 

 

Hello,

 

I swore not to expand further on my general explanation above - which briefly outlines basic methods in calculating transform deltas.  However, this week I found myself with a serious problem in solving transforms in one application, and exporting these transforms to a separate application.  I shot mocap data and solved the data to a skeleton using Motion Analysis EVaRT software.  My skeletons were performing correctly in EVaRT, however, when I exported from EVaRT and into MAYA, the skeleton's leg joints in Maya were rotating (spinning) around their Z axis wildly like a high speed drill bit - not really what I wanted.

 

Fortunately, I'd run into this before, as there were several factors working together to produce the undesired animation.  They all directly relate back to my previous post.  First, the axis orientation for each skeleton joint in EVaRT is what's considered to be an "earth fixed" orientation - where the z axis runs the length of each skeleton joint (Z axis up.)  This should be similar to bones in most 3D software, although in most applications, the world axis is Y axis up. However, EVaRT world space is typically set to 'earth fixed' orientation (world axis Z up.)  This is important to note as "earth fixed" axis' are standard in many applications and devices, as the earth follows longitude, latitude, and altitude.  Many modern applications and devices use this "earth fixed" axis' orientation for calculating transforms.  I find this is the case for many of the motion capture platforms, and certainly in magnetic mocap systems, and other magnetic devices since these must calculate earth's force of gravity when initialized and set this as a constant (z) force in order to calculate an object's transforms.  I know there are many who might think they'll never use such devices, however, as most manufacturers are beginning to incorporate inertial and other sensors into their mobile and other devices, many people will need to work in spaces other than Quaternion.  And if anyone wants to work on film sets or in other disciplines, you'll need to use Euler calculations in order to work with scanners, surveyors, motion control cameras, etc.  So I've learned to 'never say never.'  I also recently found this as an issue in developing scenes using Unreal Engine 4 - in which my team spent 4 days troubleshooting a problem before they came to ask if I might know what the problem was.  They had a flying craft (a UE4 pawn) controlled by a standard game controller, and the 'pawn' was spinning endlessly over itself.  I had discovered similar behaviors developing in other software (due to the differences between euler values and quaternion values), and was able to correct the controls for Pitch, Roll, and Yaw (euler) in short time.

 

So, for the exported mocap skeleton i mentioned previously, once I imported the skeleton and mesh into MAYA and rendered the scene, I observed an undesired performance that needed to be corrected.  Correcting this problem takes us a bit further into some of the issues typically observed when working in different applications - and often with code others have written.  The two main problems I run into when using 3D applications such as Maya, Max, XSI, Blender, etc. is that even though these software applications provide a nice graphic UI and generally use a quaternion world space (X,Y,Z) to work in, gimbal lock is often a problem.  This is because much of what we observe is a facade - most 3D software is most likely calculating the majority of object transforms in euler values, and converting these calculations to quaternion coordinates (X,Y,Z transforms) to work with.  And if one doesn't understand this and how to correct the difference in world space axis', it's easy to spend countless hours troubleshooting without resolve.

 

In addition, most 3D software applications provide multiple layers of transform matrices - not just one, but up to seven - as in the case of Maya.  And depending on how the software is used, changing a transform value might be affecting a separate (often hidden) matrix than where your perceived problem might lie.  Prior to animating an object and/or binding any vertices to more than one bone or skeleton object, I often 'freeze" object transforms to represent a value of zero in all matrices as a precaution - since I've found that these matrices often become changed from their initial value of zero - and this is often done inadvertently by others working on the same scene. So in resetting the values of the matrices to zero, this ensures identical start transforms (a reliable baseline) when exporting/importing animation transforms between different software.  Otherwise, it can be very difficult to troubleshoot animation between software.

 

One other primary consideration I believe is necessary to understand is the order of rotation for an object, and specifically bone objects - as the threshold for bone objects reaching gimbal lock is inherently greater than for most other objects - due to the constrained behavior of these skeleton components. Every object has a specific order of rotation, and the objects order of rotation determines its behavior.  So my advice is to absolutely know an object's order of rotation prior to animating any attribute of an object's transforms - and also to change the order of rotation for an object when necessary to generate the desired behavior when animating.  The user can individually define the rotation order for an object's matrix (axis) in most 3D applications - and typically in scripting - and once you're aware of this, animating object transforms becomes much easier.  Depending on a skeleton's desired performance (orientation transforms), you can usually solve gimbal lock on a joint's axis by redefining (changing) the order of rotation for that bone.  Keep in mind that this isn't conditional, but generally set one time globally for an object - so make certain to review your entire animation prior to committing to a change in the rotation order for an object's axis.  

 

For more information on how the rotation order affects behavior, please follow this link:

http://softimage.wiki.softimage.com/xsidocs/transforms_RotatingObjects.htm

 

This is a reference for Softimage, however, it applies to most 3D graphic UIs.  this doc covers several aspects of orientation transforms, but for a general explanation on rotation order, specifically read the sections labelled 'Setting the Rotation Order' and 'Animation and Rotation'. The latter discusses manipulating object transforms using Euler values - so if this is not familiar, I recommend working with function curves using Euler values, as these fcurves are quite different to read and manipulate behaviors - and they offer a very different level of control for animating objects.

 

OK - that's more than I've said to my Wife in all of 2014 - so enough.  I know this stuff can be a bit boring, but hopefully somewhere down the road, someone might think back on this tirade and possibly save time troubleshooting transform problems.  Wow - it's 5am now - cool. <_<

 

David B.

binyan and Deltakosh like this

Share this post


Link to post
Share on other sites

In my last two posts, I'm certain I assumed either too little or too much; depending on the reader/developer.  There are several mathematical disciplines that can represent and explain 2 dimensional and 3 dimensional space, however in my opinion, Linear Algebra is the foundation for how we calculate vectors in graphic display.  If you do not have a basic grasp of Linear Algebra, it is my opinion there is little foundation for understanding how 3 dimensional space is represented mathematically (what we do :blink: ), as well as calculated and manipulated.

 

So for those of you who do not have the foundation of LA (linear algebra), you'll most likely not be able to really understand what graphic developers are coding.  Don't be afraid of LA; it only appears daunting.  However, I can tell you from my personal experience that LA is fairly simple in structure - especially when calculating 2D and 3D space(s) - which in LA can be represented by R2 and R3 respectively (please excuse my non-math keyboard  :)  And once LA is basically grasped, it's fairly simple to explain how 2D and 3D vectors in math directly relate to the (x,y) axis' and (x,y,z) axis' respectively.  And if developers don't have this foundation, I doubt they have the knowledge to create, use, and manipulate matrices' effectively (or at all). I'm certain no one reading this wants me to continue with a lesson in LA, but I believe most everyone developing using WebGL should spend a couple of afternoons (4 hours or so) to grasp this specific discipline of math.

 

If I'm stepping too far out of the original post, please let me know!    ;)

 

David B.

binyan likes this

Share this post


Link to post
Share on other sites

Fantastic, dbawel!  I love listening to you type.  I started a thread called The Wingnut Chronicles (over a year ago) and you can type anything you want about any subject (within reason)... there... anytime you wish. 

 

Or maybe start your own "The Dbawel Papers" or similar.  MoCap is just going to grow and grow, and it sounds to me like you have a ton of experience with such, and related subjects.  I think you have knowledge and experience far beyond mocap and transformations.  We will need to extract all of that, somehow.  :)

 

I am drawn to make a wiki tutorial out of your last three posts, and that tells me two things.  Your information seems highly valuable, and you explain it nicely.  PLEASE keep hanging out with us, and PLEASE find a comfortable thread to keep on typing... about anything that you feel might apply to our community and to its tech.  Good stuff!  Thanks!

Share this post


Link to post
Share on other sites

Hi Wingnut,

 

Thank you for your kind words. :) This post is the most valuable resource I have to produce content.  I appreciate all of the help this community has provided in such a short time, and will continue to roam this board and offer any experience I can - provided I don't underestimate the the amount of brain power found here.

 

Cheers,

 

David B.

Share this post


Link to post
Share on other sites

Hello,

 

I've asked jerome to post on this thread, which I hope he does.  He has touched upon a key tool in both mathematically manipulating vectors (matrices')  and understanding animation in GUI space.  Please find his post below. 

 

http://www.html5gamedevs.com/topic/11580-b%C3%A9zier-curves/

 

We should try and keep this  Spaces (world, parent, pivot, local) post pinned, and I know many of you can add to this - so please do.  :)

 

Cheers,

 

Dbawel

Share this post


Link to post
Share on other sites

Hi,

 

I won't assume the average user of this forum doesn't yet understand the basics of Cartesian Space (3D coordinates (x,y,z,) in most graphic applications); but if you might be reading this thread and want to further understand how mathematical vector and vector deltas are represented in math, please read the following links:

 

In this order -

 

1. http://www.intmath.com/vectors/7-vectors-in-3d-space.php

2. http://tutorial.math.lamar.edu/Classes/CalcIII/3DCoords.aspx

 

And the following is a bare bones explanation of the math used in manipulating vectors (matrices'.)

 

http://www.intmath.com/vectors/7-vectors-in-3d-space.php

 

Cheers

 

Dbawel

jerome and Deltakosh like this

Share this post


Link to post
Share on other sites

It appears that 2 of the links in the above post decided to stop loading over the last 12 hours.  As it's about 2am here in CA, I'll take a look at this in the morning, try and find out why and fix these two rebel links - bastards! :ph34r: .

 

Cheers,

 

DBawel

Share this post


Link to post
Share on other sites

These links load now - but 20 minutes prior, 2 of the links would consistently and repeatedly time out.  But as long as they are back up, move forward I say!

 

If anyone reviews these links and find they've learned something from these - please let me know.  Here they are again - in order:

 

In this order -

 

1. http://www.intmath.c...in-3d-space.php

2. http://tutorial.math...I/3DCoords.aspx

 

And the following link is a bare bones explanation of the math used in manipulating vectors (matrices'.)

 

http://www.intmath.c...in-3d-space.php

 

I hope there is value here for those who initially requested, and we'll continue to provide more info and materials in which to help provide insight into how various objects behave and are animated in the different dimensional matrices', and lay out the syntax and considerations for working in different vector space using Euler Angles, Quaternion math in 3 dimensions, and how to plot these both on a grid(s) as a function curve.  If all goes well, then perhaps we'll revisit sine, cosine, and other math functions to help drive logical animation and particle phyics, as well as create interesting spiral geometry,

 

Cheers,

 

DBawel

Wingnut likes this

Share this post


Link to post
Share on other sites

Hi DK,

 

Sorry I've been offline for a little while - am working on implimenting a node.js server for our company.  

 

I'm certain I would enjoy contributing to the documentation pages and info.  I've written published documentation and curriculum for software and applications previously; from both a technical and artistic perspective, and would love to provide more methodical materials.

 

My approach would most likely be to catagorize different aspects of dimentional math, GUIs, and more specifics of how this all works within the BabylonJS framework as of now.  It appears that if I simply register on the site, I can contribute.  However, please let me know if there's any specific permissions reqired to to create and edit a new page in the documentation topics, and/or if there's a pre-defined format the community has adopted.  Also, if you can provide info on what duties and time commitments are required to participate as a curator, I would be happy to offer this as well.

 

Cheers,

 

DBawel

Share this post


Link to post
Share on other sites

I'm in.  Please send a message to provide any info I might need.  If you need to contact me directly, I sent you a message today with my personal email.  -Thanks, DBawel

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.