VEX: reading normals

   2541   6   1
User Avatar
Member
237 posts
Joined: June 2006
Offline
Hi,
found an intersting (for me) thing (a really simple one but I'm stuck.
Reading the point normals via
@N; // dont know if the normals are anyhow, anywhere basically existent. Neccessary?
vector normal1 = point(0,"N", @ptnum);
v@normal;

shoudnt be normal1 the same as N? I get normal1 = {0,0,0} in the spreadsheet.
And no, I can not use @normal1 = @N.
Edited by Follyx - May 16, 2021 14:22:18
User Avatar
Member
236 posts
Joined: March 2013
Offline
Using @N will create normals.
You only need to go, v@normal1 = @N;

You can't use @normal1 because there are a few "known" types that VEX wrangles auto sign for you.
The @N, @Cd for example. The reason it fails for you, is you are not declaring the type.
The default for undeclared is float I think, but anywho. You need to DECLARE! v@normal1 is your friend.
Edited by lewis_T - May 16, 2021 21:03:25
I'm not lying, I'm writing fiction with my mouth.
User Avatar
Member
7759 posts
Joined: Sept. 2011
Offline
Follyx
Hi,
found an intersting (for me) thing (a really simple one but I'm stuck.
Reading the point normals via

What are you trying to do? The code is nonsense.
User Avatar
Member
555 posts
Joined: Feb. 2017
Offline
Follyx
Hi,
found an intersting (for me) thing (a really simple one but I'm stuck.
Reading the point normals via
@N; // dont know if the normals are anyhow, anywhere basically existent. Neccessary?
vector normal1 = point(0,"N", @ptnum);
v@normal;

shoudnt be normal1 the same as N? I get normal1 = {0,0,0} in the spreadsheet.
And no, I can not use @normal1 = @N.

when you declare vector normal1 = blah;
that is a temporary variable (in some sort of wrangle?). That's not creating an attribute for use throughout your network.

so I can declare

vector tempdir = blah;

so I can do something with this in my wrangle, maybe to work out some facing direction...once you exit the wrangle...tempdir no longer exist.
User Avatar
Member
237 posts
Joined: June 2006
Offline
@jsmack: there are no stupid questions, just answers ;-)
Anyway I want to read the normals via a point attribute and assign it to an vector attribute. Easy I thought. And sorry for the typo: last line I should write v@normal1.

Background: existing object with changing normals wich I have to use for further coding
User Avatar
Member
7759 posts
Joined: Sept. 2011
Offline
Follyx
Anyway I want to read the normals via a point attribute and assign it to an vector attribute. Easy I thought. And sorry for the typo: last line I should write v@normal1.

It's easy, but complicated by the fact that geometry may or may not have explicit normals as an attribute, and if they do the attribute can be either per point(shared normal) or per vertex (split normal).

If it's an existing point attribute, then the attribute swap is the best way to duplicate an existing attribute.

A wrangle tries to always have normals be bound to '@N' but this means it will compute them if they don't exist which may produce unexpected results.

An example wrangle for assigning the normal to a new float attribute called "normal1":

v@normal1 = @N;

This will have the additional effect of creating an attribute "N" if it didn't already exist. The new attribute "normal1" also isn't tracked as a normal, and won't transform as one. To tag the attribute as a normal, either use an attrib create sop before the wrangle, or use setattribtypeinfo in the wrangle.
User Avatar
Member
237 posts
Joined: June 2006
Offline
That helped me out. Thanks jsmack
  • Quick Links