Jump to content

Getting Objects to spawn on the Normal location


RustyMac2020

Recommended Posts

Hi all

I am starting to get a small handle of things regarding procedural modelling, and once again I have hit the cliffs during my journey; I am having trouble with trying to spawn these small Air-con units along a cube's normal's this is in order to get them more straight, and as a bonus I am trying to get the Air-con units to just specifically spawn on the normal's in a specific direction either X,Y,Z axis will do so long as I have control of the Axis myself that would be great : )

I have attached a screen shot of what I mean.

I have tried to personally use the N attribute to get them to latch on the normal's, however it does not seem to work and I am out of ideas as to what could have possibly gone wrong

I have also attached an image of a previous element I rigged up to this same system with Lampposts and they have spawned in the centre of the primitive.

How would I go about fixing this please.

Kind Regards

Ahmet.B

Aircon_Unit_To_Be_Mounted_OnBuilding_Wall.png

Lamppost_Feasability_Test_02_Odforum_Posting.png

Link to comment
Share on other sites

Primitive normals don't actually exist... they're the normalized average of all associated point or vertex normals that comprise the primitive, drawn from the primitive's barycenter. If you want to create points at those locations, one way to do it with minimal scripting is to facet your polygons to unique the points, then compute point normals, then use a Primitive SOP to scale down the primitives to 0 so they each become a single point (make sure that you remove N from "Vector Attributes to Transform"), then Fuse the points to average the normals.

If you're okay with scripting, you could also use

addpoint(0, @primnum);

in a Primitive Wrangle to a point for each primitive. Then set i@sourceprim on each new point to be the primitive number, and v@sourceprimuv to be (0.5, 0.5, 0.5), which for any quad will be the barycenter of the primitive. Then use Attribute Interpolate to compute the normal for each of these new points.

  • Like 1
Link to comment
Share on other sites

11 minutes ago, toadstorm said:

Primitive normals don't actually exist... they're the normalized average of all associated point or vertex normals that comprise the primitive, drawn from the primitive's barycenter. If you want to create points at those locations, one way to do it with minimal scripting is to facet your polygons to unique the points, then compute point normals, then use a Primitive SOP to scale down the primitives to 0 so they each become a single point (make sure that you remove N from "Vector Attributes to Transform"), then Fuse the points to average the normals.

If you're okay with scripting, you could also use


addpoint(0, @primnum);

in a Primitive Wrangle to a point for each primitive. Then set i@sourceprim on each new point to be the primitive number, and v@sourceprimuv to be (0.5, 0.5, 0.5), which for any quad will be the barycenter of the primitive. Then use Attribute Interpolate to compute the normal for each of these new points.

you can also... cause I do this alot:

Use this in a primwrangle:

///Add Center Point

addpoint(0, @P);

///Remove Prim
removeprim(0, @primnum, 1);

 

 

 

Edited by jonidunno
  • Like 1
Link to comment
Share on other sites

4 minutes ago, jonidunno said:

you can also... cause I do this alot:

Use this in a primwrangle:

///Add Center Point

addpoint(0, @P);

///Remove Prim
removeprim(0, @primnum, 1);

 

 

 

This works great for positioning the points, but it won't actually inherit attributes like N from the primitives' points... that's why Attribute Interpolate might be a better way to go, since it'll automatically interpolate vector attributes from the original points that make up each primitive.

  • Like 1
Link to comment
Share on other sites

Hi Ahmet,

just to confuse you a little bit more, here is the definite answer ; ) use addpoint(), prim_normal(), setpointattrib() and removeprim() in a primitive wrangle:

int pt = addpoint(0, v@P);
vector nml = prim_normal(0, i@primnum, vector(0.0));
setpointattrib(0, 'N', pt, nml, 'set');

removeprim(0, i@primnum, 1);

Out of curiosity: Hasn't this already been solved in your old threads? 

Another thing: You keep posting in the wrong forum section: 'Education' is for posting tutorials and learning resources. Your questions belong to 'Modeling'.

  • Like 3
Link to comment
Share on other sites

18 hours ago, konstantin magnus said:

Hi Ahmet,

just to confuse you a little bit more, here is the definite answer ; ) use addpoint(), prim_normal(), setpointattrib() and removeprim() in a primitive wrangle:


int pt = addpoint(0, v@P);
vector nml = prim_normal(0, i@primnum, vector(0.0));
setpointattrib(0, 'N', pt, nml, 'set');

removeprim(0, i@primnum, 1);

Out of curiosity: Hasn't this already been solved in your old threads? 

Another thing: You keep posting in the wrong forum section: 'Education' is for posting tutorials and learning resources. Your questions belong to 'Modeling'.

Hello, oh sorry I had no idea, I will post for help on the Modelling forums next time I need to start a new topic in regards to this, and that piece of code you sent really worked, I will need to experiment more with the VEX code you have sent me, you have been really helpful and I cannot thank you enough for your time.

I forgot I can access the VOP node, I'm so silly >_< I was missing a few of the connection we did in my previous post, my apologies.

Kind Regards

Ahmet.B

Konstantine_Code_Helped_01.png

Edited by RustyMac2020
Double checked something within Houdini only to realise I was going in circles
Link to comment
Share on other sites

23 hours ago, ThomasPara said:

Impossible to know what happens inside your delete-node and vop-node. And since its all merged, the screen doesnt realy help either.

Hello, yes sorry that is true I did not, I have attached a screen shot of what I have inside my VOP node, however I managed to get a reply from the user "constantine magnus" who had previously helped me with the VOP node connections, I was silly and had forgot I could enter my VOP node to apply the same connections "constantine magnus" posted to me in VEX form. I have also attached a screen shot of my delete node I have a code inside it that again was help from "constantine" which basically takes the position of the main building block and deletes the points based on targeted components positions and translation coordinates. 

Kind Regards

Ahmet.B  

VOP_Node_01.png

Delete_Node_01.png

Edited by RustyMac2020
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...