Jump to content

no cross ?


CinnamonMetal

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
Link to comment
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.

Link to comment
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 :) 

Link to comment
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

Link to comment
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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...