Blender like body transformation

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Blender like body transformation

Post by serengeor »

I'm creating my own world editor and I would like to get my bodies transform like in blender when using those arrows to transform them.
Blender somehow makes it so when you look from side of the body:
Image
If you would try to grab the 'arrow' on x axis and move mouse only on Y axis the body wouldn't move.

But if you would rotate cam a bit like this:
Image
And try to grab the 'arrow' on x axis and move mouse on Y axis the body would move.

I would like to achieve this in my editor as this is more comfortable way to move body than lets say moving body according only to mouse delta X position.

Anyone could give me a hand on maths behind this?
Working on game: Marrbles (Currently stopped).
agnas
Posts: 20
Joined: Tue Mar 27, 2007 6:16 pm
Location: Venezuela
Contact:

Re: Blender like body transformation

Post by agnas »

I'm creating my own world editor
Now you have a big problem. Please don´t do that, there are plenty of world editors to fit your needs or you can adapt to one. If you need help with the "maths behind this" you have a very rocky road ahead so most probable you can´t create "your own" editor. Just my friendly 2 cents.
/\+++/\
< agnas >
\/+++\/
micronosis.com
Radikalizm
Posts: 1215
Joined: Tue Jan 09, 2007 7:03 pm
Location: Leuven, Belgium

Re: Blender like body transformation

Post by Radikalizm »

agnas wrote:
I'm creating my own world editor
Now you have a big problem. Please don´t do that, there are plenty of world editors to fit your needs or you can adapt to one. If you need help with the "maths behind this" you have a very rocky road ahead so most probable you can´t create "your own" editor. Just my friendly 2 cents.
A lot of people on here make their own editors, heck I would even recommend people to make their own editors which suit their own needs since every game and every engine is different ;)
Serengeor did not ask for help regarding math, he asked a question regarding viewport functionality and limitations of body transformations based on the state of a viewport

What you're basically saying is that if you can't figure out something immediately you should stop what you're doing and do something else, which is pretty horrible advise to give someone IMO

@serengeor: I'll check out blender's behaviour later today to see if I can give you an answer, haven't used blender in a while so can't say how it's done atm
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Re: Blender like body transformation

Post by serengeor »

agnas wrote:
I'm creating my own world editor
Now you have a big problem. Please don´t do that, there are plenty of world editors to fit your needs or you can adapt to one
I'm pretty sure that I would have so much more trouble adapting any other editor to my framework than building one myself. The basics are pretty much done, I don't need any sort of mesh manipulation, as the level editor is only going to be used for placing assets premade in blender.
Radikalizm wrote:@serengeor: I'll check out blender's behaviour later today to see if I can give you an answer, haven't used blender in a while so can't say how it's done atm
I tried looking at the source, but I couldn't really read out much from it(c-style code?).

Don't worry too much if you can't find anything. I've got some other troubles at the moment (need to rewrite some stuff). And maybe I'll find some help at #blendercoders irc channel.
Working on game: Marrbles (Currently stopped).
Radikalizm
Posts: 1215
Joined: Tue Jan 09, 2007 7:03 pm
Location: Leuven, Belgium

Re: Blender like body transformation

Post by Radikalizm »

Still haven't had time to check this out myself, but I believe I found a rather simple solution

This is just a matter of camera orientation in relation to your scene's axes which will prevent movement in a single direction based on a selected direction, so the only thing you should check for is your camera's orientation

You can do this by taking a dot product with your normalized view vector and each of your unit axes each time your editor camera moves
If the dot product results in 1 (which is cos 0 or cos pi) you immediately know your view vector is aligned with the axis you're testing for

When you know this you can change the behaviour of your translation gizmo

It might be a good idea to add a small epsilon value as an error margin when doing your dot product check
Post Reply