Jump to content

Recommended Posts

int chngePrim = detail(1,"iteration",0);
if(chngePrim%2==0){
    v@Vector_Pt_AC = prim(0,"Vector_Pt_AB",chngePrim) - prim(0,"Vector_Pt_AC",chngePrim)/1;
    setprimattrib(geoself(),"Vector_Pt_AB",chngePrim,@Vector_Pt_AC,"set");    
    v@crossPro = cross(prim(0,"Vector_Pt_AC",chngePrim),(0,1,0));
}

Why is my cross product attribute not being created ?

Edited by CinnamonMetal

Share this post


Link to post
Share on other sites

Hi, try to define the up vector like this:

set(0,1,0)

or

{0,1,0}

 

Share this post


Link to post
Share on other sites

are you sure the attribute is being created in the place you think it's being created? looks like you're running a detail wrangle, but you're trying to create that cross attribute per-primitive, and that won't work. you'd have to create the cross attribute as a prim attribute ahead of time, then use setprimattrib() to set it.

Share this post


Link to post
Share on other sites

If I create the cross attribute ahead of time, otherwise in a primitive wrangler before the detail wrangler; there are variables in the cross attribute that are not available until the detail wrangler which comes after the primitive wrangler for which the cross attribute was created ?

If I use the cross attribute within the primitive wrangler (the wrangler before the detail wrangler) the cross function doesn't accept variables :( other wise I would be able to set the cross attribute, you know what wrangler I'm referring too ;) If not it's the wrangler before the detail wrangler :) 

Share this post


Link to post
Share on other sites
On 5/22/2018 at 1:39 AM, CinnamonMetal said:

int chngePrim = detail(1, "iteration" ,0);
if(chngePrim%2 == 0){
    v@Vector_Pt_AC = vector(prim(0, "Vector_Pt_AB", chngePrim)) - vector(prim(0, "Vector_Pt_AC" ,chngePrim))/1;
    setprimattrib(0, "Vector_Pt_AB", chngePrim, v@Vector_Pt_AC);    
    v@crossPro = cross(vector(prim(0,"Vector_Pt_AC",chngePrim)), set(0,1,0));
}

Why is my cross product attribute not being created ?

if you are doing more than one operation per line, always hard cast your variables, otherwise they will be considered as a float in some cases.
This is especially true for functions that accept multiple data types.

side topic, the {0,1,0} notation does not accept variables, so use set(0, x, 0) instead if you need to

Share this post


Link to post
Share on other sites

it seems like your running in a for-each loop, is it a per-primitive operation?

If so your primnum will allways be 0 inside the loop. 

I would also break this line up into:

v@Vector_Pt_AC = vector(prim(0, "Vector_Pt_AB", chngePrim)) - vector(prim(0, "Vector_Pt_AC" ,chngePrim))/1;

I will ignore the /1, because im not sure what that is doing here.
 

vector AB = prim(0,"Vector_Pt_AB",0);
vector AC = prim(0,"Vector_Pt_AC",0);
v@Vector_Pt_AC = AB-AC;

This will only work if your v@Vector_Pt_AC exist from before, or else you would only have an empty vector.

 

It would be easier to understand your solution if we know what your goal is, because i think this can be done in a mutch more efficient and easier fashion

 

  • Thanks 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×