Point all vectors to same direction

Discussions about SOFTIMAGEs© Interactive Creative Environment©
Splin
Posts: 14
Joined: 07 Jul 2009, 09:17

Point all vectors to same direction

Post by Splin » 13 Oct 2011, 13:36

Hello,

if rotating vectors on a single plane it is easy to get them pointing in to the same direction, lets say X +45.
As I am trying to scatter barbs to a fir branch I would like them all to be under certain angle. But when adding to vector X +45 on a cylinder, other sides vector is pointing alltogether backwards. Since it would need X -45 to make it point into the same direction than the other side of mesh. It is alltogether behaving correctly but I can not figure out how to make it behave as I need it.
On the left is what happens. On the right is what I would like to see.
Image

Am I approaching this whole thing wrong? In the end I would like to use modified point vectors to align scattered barbs on a branch correctly.

Thank you!

Pancho
Posts: 659
Joined: 19 Sep 2010, 09:28

Re: Point all vectors to same direction

Post by Pancho » 13 Oct 2011, 17:39

I'd say the normal vector at the given point doesn't know what's up or down. That's your problem. You need to establish a rotation axis (horizontal?) first and then rotate the vectors towards an "up" position. Up position could be a vector position above your vector (vector position + y).

User avatar
Hirazi Blue
Administrator
Posts: 5113
Joined: 04 Jun 2009, 10:15

Re: Point all vectors to same direction

Post by Hirazi Blue » 13 Oct 2011, 20:14

Wrong answer (that's why I removed the screenshots):
Isn't this "simply" a case of feeding the y-scalar of every vector the same value?
(see Pancho's remark below)
Stay safe, sane & healthy!

User avatar
TwinSnakes007
Posts: 316
Joined: 06 Jun 2011, 14:00

Re: Point all vectors to same direction

Post by TwinSnakes007 » 13 Oct 2011, 21:04

The more I see from this app, the more it impresses me. It's the best app in the suite.

-TS-

Pancho
Posts: 659
Joined: 19 Sep 2010, 09:28

Re: Point all vectors to same direction

Post by Pancho » 13 Oct 2011, 21:59

Nice, if it is that simple, but will it also work on a branch with a diagonal direction? On your example with all polygons in the same y direction it works for sure!

User avatar
Hirazi Blue
Administrator
Posts: 5113
Joined: 04 Jun 2009, 10:15

Re: Point all vectors to same direction

Post by Hirazi Blue » 14 Oct 2011, 07:49

I'm afraid you're right. It doesn't work as I naively thought it would, I just checked... :ymblushing:
Sorry, I was in a hurry yesterday...
Stay safe, sane & healthy!

Splin
Posts: 14
Joined: 07 Jul 2009, 09:17

Re: Point all vectors to same direction

Post by Splin » 14 Oct 2011, 08:29

Yes, thats a tip I could not think up. I need to establish first rotation axis for vectors.

But the issue still remains since as brought up it does not work diagonally.
What would be solution? To compensate with original polygon vectors somehow?

Pancho
Posts: 659
Joined: 19 Sep 2010, 09:28

Re: Point all vectors to same direction

Post by Pancho » 14 Oct 2011, 08:37

I'd say you need to establish an up position first. The surface normal doesn't bring this information with itself a.f.a.i.k. Then rotate the vector towards the other vector.

But even with this method it'll be difficult. Imagine a branch growing downwards at a certain position. Your "up" position would actually need to be a down position. So for the proper combing the growth direction would be the way to go.

Splin
Posts: 14
Joined: 07 Jul 2009, 09:17

Re: Point all vectors to same direction

Post by Splin » 14 Oct 2011, 09:32

Trying idea what Pancho proposed...need to do some figuring out first how to apply it :)

In the mean time, posted a branch pic and branch itself for everyone to play around:
Download OBJ
Image

Pancho
Posts: 659
Joined: 19 Sep 2010, 09:28

Re: Point all vectors to same direction

Post by Pancho » 14 Oct 2011, 13:00

If you'd grow the tree dynamically, there might be a way to figure out the growth direction. If you got an already existing model, I don't know whether you can find a way to follow each branch to its end and save direction vectors for the points on the tree.

If you have a dynamically spreading weight map on the tree, starting on the trunk, probably the difference in the weight values between point neighbours could be use to figure out a flowing direction. something like filling the tree with a liquid in zero gravity. The areas which get "wet" first are closer to the trunk then those who get later touched by the liquid. The liquid would arrive latest in the tiny branches up in the tree crown.

Just an idea.

Pancho
Posts: 659
Joined: 19 Sep 2010, 09:28

Re: Point all vectors to same direction

Post by Pancho » 14 Oct 2011, 13:02

P.S.:

Problem with a weight map is that it grows on a per point basis. For the effect I have in mind it would need to grow on a per distance one.

nautilus
Posts: 29
Joined: 08 Mar 2011, 21:32

Re: Point all vectors to same direction

Post by nautilus » 14 Oct 2011, 13:18

another idea (i don´t know if it suits your needs in this case) would be:
duplicate your tree object, scale it, move it "up" a little (in the direction in which the pointvectors should direct). use that as your helper object.
now that you have a (invisible helper) copy of all your point ID´s, tell your origonal pointvectors to point in the helper-point-direction (simple array of your IDs).

maybe this helps. i didn´t try it myself, just a thought.

Splin
Posts: 14
Joined: 07 Jul 2009, 09:17

Re: Point all vectors to same direction

Post by Splin » 17 Oct 2011, 14:11

I came to the other solution what worked out. I rotated the instance shape's center under the angle I needed.
As I align them to normals now, for some reason not all instanse shapes are pointing in the direction they must. Some are pointing backwards :/
Image

Pancho
Posts: 659
Joined: 19 Sep 2010, 09:28

Re: Point all vectors to same direction

Post by Pancho » 17 Oct 2011, 15:00

The idea from Nautilus hardly works. It might in some cases, but is as good as a null at the root of the tree which can be used as a reference for the direction the leaves should grow.

As I said, what you want is a growth direction as a guide for the rotation direction. How you can achieve this is a bit more complicated.