1
$\begingroup$

I have a billboard tree in Blender made up of a single triangle. I applied an Array and Curve modifier to it to instance itself on the curve. I collapsed the trees and separated them by loose parts. Now I have hundreds of trees whose local origins are aligned to the global axis, which is not what I need.

In Unity, I have a billboarding script that automatically aligns the trees to the face the camera. However, this script does not work if the tree's origins (or pivot points as they're called in Unity), are not aligned to the normal of the tree's front face (or back face, it doesn't really matter because I can just negate the script's LookAt function).

Does anyone know if there's a script available for this or would be willing to write a script that can move all the origins of selected objects to each of the objects' individual face normals?

Thanks.

In the mean time, I'm going to look into Python and see if I can figure something out, but I don't have a lot of time and have an intermediate level C# background.

Edit 01 - Added image of what I'm looking for. The yellow arrow shows the re-alignment I'm seeking:

enter image description here

Edit 02 - I cannot reply due to the 50+ comment restriction. @X-27, I followed your instructions, but was met with the following strange tilt after parenting and enabling Face Duplication (not to mention the duplicates stabbing the parents):

enter image description here

The only way to mitigate the tilting is to re-orientate the child tree into some weird angle in order to get the duplicated trees to be standing up, but their rotations are still messed up. Judging by your screenshots, you also have the same problem with the duplicated blue trees being angled in an awkward manner. This is not what I need.

Regardless, I appreciate your suggestion, but I no longer need this solution and do not have time to learn Python and the Blender API to make a script myself.

@yhoyo, I think you may have misunderstood my question. I already know of the Properties Shelf rotation and the script you posted simply zeroes out the Z rotation, which is not what I needed.

$\endgroup$
1
$\begingroup$

First off, you are way over complicating this. There is no need to use a script to correct the origin's rotation at all.

Starting with the tree with the array and curve modifier before it is applied (GCF green in images), instead of separating each tree along the curve, create a second tree (X-27 blue in images) and parent it to the tree with the modifiers.

Parent

Then set the the first tree's Duplication to Faces to add new trees with the location and rotation of each of the existing trees along the curve.

Duplicate faces

Then Make Duplicates Real by pressing Ctrl+Shift+A to make the second set of trees separate objects. Now all of the new trees have there own origins in the correct places.

Separate objects

If you want to, you can delete the curve and the first tree. Also, any tree you now select will also have the correct local rotation.

Without the first trees

$\endgroup$
1
$\begingroup$

hi the easy way is change the rotation in properties panel

change rotation

also you can select all the objects and run this script:

import bpy

obs = bpy.context.selected_objects

for ob in obs:
    ob.rotation_euler[2] = 0

best

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.