[PATCH] Align to vector (now any axis can be aligned)

Hi, i have made another patch for the bge, it features the getLinearVelocity() improvement AND a new python function: alignToNormal(), that function is based on a script made by wiseman303, that aligns the object’s local z axis with a given normal (for example the face right under his feet), so games like sonic, f-zero or a snowboarding game can be done easily with alignToNormal() and a ray sensor.

OLD PATCH dl link (WARNING: this patch will not apply over the current SVN version!)

edit:
i have changed alignToNormal(normal) to alignAxisToVect(vect, axis) as suggested in the mailing list, so now you can align ANY axis with a given vector. also it’s a bit more “error safe”

here is the patch (i have uploaded example blendfiles!): https://projects.blender.org/tracker/index.php?func=detail&aid=11000

Examples:


vector = [0,0,1] # global z axis

own.alignAxisToVect(vector, 0) #this will align the local X axis with the global z axis



vector = [0,0,1] # global z axis

own.alignAxisToVect(vector, 1) #this will align the local Y axis with the global z axis



vector = [0,0,1] # global z axis

own.alignAxisToVect(vector, 2) #this will align the local Z axis with the global z axis

That will be handy for all sorts of things.

Your two new functions would help in a lot of cases.

Thanks for striving to improve the BGE, do note we are in feature freeze, and no new BGE features will be commited until after 2.46 release.

yea, but anyone can build the patched blender :wink:

Hi, cyborg_ar.

Thanks for your new features. Are you making it randomly, or do you have some to-do list?

sweet Cyborg_aaaar… what are you making next…?

cool. I’ve missed that one

i do patches as i need them.

:slight_smile: that sounds like a dream to me

Last I saw he’s working on a Sonic game, which can be a very damanding type of game. Expect at most plenty of patches from him as he starts doing more advanced movements, badniks, dangers, ect…

Oh, and someone in the mailing lists suggests the function can be expanded so it’s useful in even more cases.
http://lists.blender.org/pipermail/bf-committers/2008-May/020989.html

yes please.

ah, i’m trying to expand the function, it can be useful to aim arrows for example

as you make patches pls post script examples and demo’s of how the new functions can be used.

Cyborg_ar’s first patch has been comitted.
http://lists.blender.org/pipermail/bf-blender-cvs/2008-May/013925.html

Now just expand this function to maximize its usefullness and put it in the patch tracker.

O_o i can’t believe it, my first patch was approved! now i can look at blender code and say “hey! i wrote those 5 lines of code!” :smiley:

about the new function, i’m working on it, and now i have meld for making patches so it will be a bit easier.

i have changed alignToNormal(normal) to alignAxisToVect(vect, axis) as suggested in the mailing list, so now you can align ANY axis with a given vector. also it’s a bit more “error safe”

here is the patch (i have uploaded example blendfiles!): https://projects.blender.org/tracker/index.php?func=detail&aid=11000

To others: The thing is to try not to get too dependent on functions that are not officially in the BGE yet.

Though I think this will go in.

Axis specific alignment is just what I required! Thank you for your contribution cyborg_ar.

To others: The thing is to try not to get too dependent on functions that are not officially in the BGE yet.

lol, my patches are “to whom it my concern” if it’s useful to anyone and s/he is capable to apply the patch & build blender, nothing should stop him/her to use the new functionality! :slight_smile:

I’m not discouraging you, people can use it, your stuff will likely be commited, but some features by other developers may end up not going in the next official release like Wizard’s Tiles.

Still it can easily be used for large projects if people had an updated build with the feature.

lol ok, then “use it at your own risk”