Correct Angle of Trees on a Sphere

Hi everyone!

I know this is too easy for most of you guys, but i’ve been trying to wrap my head on this for almost a week now and i don’t seem to get it. :-[

So here’s my (probably trivial) problem: how do I orient the .3ds tree models i’ve exported so that they are in the proper angle on the sphere. I’m using ofx3dModelLoader to load the 3d tree model and “plant” trees on a sphere. Attached is the picture and the .zip file containing the misoriented code and a Tree.3ds model.

Thanks a lot in advance everyone…

[Trees on Sphere.zip](http://forum.openframeworks.cc/uploads/default/1710/Trees on Sphere.zip)

One way is to use the normal at the position on the sphere you are placing the tree. In other words get your desired direction and your actual (y as i see in the picture) vectors and find the rotation axis by cross product. Get the angle of rotation between curent and desired direction vectors and from this information you can construct a quaternion or a matrix to transform each tree. Be warned that paralell vectors will bring problems like the one os the poles.

tnx a lot, i’ll try implementing your suggestion.
btw, there’s an attached zip file containing the source. if anyone could take a look, modify, then repost the codes, i’ll be extremely delighted! ;D

hi everyone. uhm, :-[ i know it’s quite embarrassing, but I really don’t seem to be able to display the trees properly. I’d really appreciate it a lot if anyone could at least post an example based on the code I posted above using the ofx3dmodelloader addon to load and display the 3d trees on the sphere. Tnx so much in advance…