Missing Node3D functionality

May 10, 2013 at 4:13 AM
Edited May 10, 2013 at 4:15 AM
I often use functions for converting the node3D spaces in world or from world in the spezified local space or from one local space to another local space.

Is it possible that you can implement the three helper methods inside the Node3D class? I think they are very handy.
Vector3f Node3D::LocalToGlobal(Vector3f point) {
    Vector4f result = WorldMatrix() * Vector4f(point, 1.0f);

    return Vector3f(result.x, result.y, result.z);
Vector3f Node3D::GlobalToLocal(Vector3f point) {
    Vector4f result = WorldMatrix().Inverse() * Vector4f(point, 1.0f);

    return Vector3f(result.x, result.y, result.z);
Vector3f Node3D::LocalToLocal(Vector3f point, Node3D* node3D) {
    Vector3f result = LocalToGlobal(point);

    return node3D->GlobalToLocal(result);
May 10, 2013 at 11:29 AM
Sure, I can add these. It is also possible to do this directly with the transform matrices too, but I can understand the convenience functions. Most likely I will add these to the Entity3D class, that way they will be available to both Entity3D and Node3D. Also, I added several helper methods to the Vector4f class a little while ago that may help here too, such as Vector4f::xyz() that perform similar functionality as a swizzle operator in HLSL.
May 10, 2013 at 5:10 PM
Dont think that matrices can have this functionality. It would be odd to see them there.

Oh yes it have to be the Entity3D class. Everytime i think Entity3D is a Node3D but thats wrong Node3D is an Entity3D :S.
May 11, 2013 at 2:59 PM
One thing that comes to mind as I am implementing these methods is how to make the distinction between points and vectors for the transformations. In you example code, we always assume the caller is passing in a point (where w=1.0), but there are equally valid use cases where they would be passing a vector (where w=0.0). Since the input and output types are the same in either case, I think there has to be some distinction...

I would hate to have to add two methods - one for points and one for vectors, since it would be easy for a newbie to mix the two up. Do any solutions come to mind with this?
May 11, 2013 at 3:57 PM
Edited May 11, 2013 at 3:58 PM
Something like
Vector3f LocalToGlobal(Vector3f value, bool point = true);
Vector3f Node3D::LocalToGlobal(Vector3f point, bool point) {
    Vector4f result = WorldMatrix() * Vector4f(point, (float)point);

    return Vector3f(result.x, result.y, result.z);

Never used such a method for a vector. I hope i didnt misunderstood you.
May 14, 2013 at 2:42 AM
That should work, but I think I'll try something other than casting bool value. For some reason, casting has been causing me some pain lately, so I'll try to avoid it whenever possible... These will definitely be in the next commit, which shouldn't be too long from now. I'll be sure to post again once it is up and available. Thanks again for the suggestion.