How to create a sphere with specified radius, in VEX?

   1169   2   0
User Avatar
Member
14 posts
Joined: April 2011
Offline
Greetings.

I'm learning VEX, what I'm trying to do is to create a sphere in a Point Wrangle (Detail) with specified radius using VEX.

I can create the sphere prim, but I can't seem to change its radius, and it's always created with the default value of 1.

For example:

int pt = addpoint(0, 0);
setpointattrib(0, 'P', pt, set(0, 5, 0));
setpointattrib(0, 'pscale', pt, 3.0);
int prim = addprim(0, 'sphere', pt);

I was under the impression that by changing the point's attribute 'pscale', it would affect the sphere's radius, with the following rational:

1) The sphere's position was affected by the point's position attribute 'P' (so why not 'pscale');
2) The sphere's radius *would* be affected if I use a copy_to_point SOP node instead (but I want to learn the VEX way).

Much appreciated for any advice/insights on how to do this.

Thank you.
User Avatar
Member
2658 posts
Joined: June 2008
Offline
You could try something like this...
int pt = addpoint(0, 0);
int prim = addprim(0, 'sphere', pt);
matrix3 transform_value = {{1, 0, 0}, {0, 2, 0}, {0, 0, 1}};
setprimintrinsic(0, "transform", prim, transform_value, "set");

Attachments:
Untitled-1.jpg (247.3 KB)

Using Houdini Indie 20.5
Windows 11 64GB Ryzen 16 core.
nVidia 3060RTX 12BG RAM.
User Avatar
Member
14 posts
Joined: April 2011
Offline
Thank you, Enivob, for your feedback on the 'setprimintrinsic' command.

It worked, and I was able to make the syntax a bit shorter for my use case:

int pt = addpoint(0, 0);
int prim = addprim(0, 'sphere', pt);
matrix3 mat3 = ident() * 3.0;
setprimintrinsic(0, 'transform', prim, mat3, 'set');

Much appreciated for your help.
  • Quick Links