Isotropix Forums

Getting polygons, vertices and normals

Clarisse Scripting related topics

Getting polygons, vertices and normals

Unread postby tsn » Wed May 27, 2020 1:45 pm

Hello,

Could someone here please help me with the following task: I want to get the polygons of an object and - in a second step - the correpsonding vertices of the polygons. Any assistance is much appreciated, so thanks in advance.
Last edited by tsn on Mon Jun 01, 2020 10:40 am, edited 1 time in total.
tsn
 
Posts: 28
Joined: Tue Mar 31, 2015 5:04 pm

Re: Getting polygons and vertices

Unread postby mdkai » Wed May 27, 2020 3:16 pm

Hi
You can not access any sub components inside Clarisse, other than a shading group !
If you need to get specific parts of the mesh, either seperate this or give it a custom attribute in houdini for example.
After export, use the extract property to get this data and use it inside Clarisse.

We may also ask, what it is you wish to do ?
Cheers
Kai
Join us at the Discord https://discord.gg/G5cJj9A
mdkai
 
Posts: 342
Joined: Tue Oct 07, 2014 7:24 pm

Re: Getting polygons and vertices

Unread postby tsn » Wed May 27, 2020 3:48 pm

Thank you very much Kai. Anyway, that's bad news.

What I want to do is to place a certain number of particles on polygons based on their surface area and a given particle radius. I was also hoping to be able to calculate intersections between particles and polygons and for this I need the polygons and their vertex positions. Unfortnately, adding custom properties and attributes via a 3rd party tool is not an option for me in this case.
tsn
 
Posts: 28
Joined: Tue Mar 31, 2015 5:04 pm

Re: Getting polygons, vertices and normals

Unread postby tsn » Mon Jun 01, 2020 10:37 am

I've been able to find a workaround for my task. Not 100% what I was looking for, but satisfying for my current needs.

The next question is about normals. I've searched the SDK for functions to get normals and found this one, which gives me the normal of a surface at a sampling point:

Code: Select all
ix.api.GeometrySample.get_geometric_normal


I know how to convert my object/geometry into points, loop through those points, and get the samples (see snippet below), but got stuck with the ix.api.GeometrySample.get_geometric_normal command. How do I use it correctly?

Code: Select all
geo = ix.get_item("project://scene/polygrid")
point_cloud = geo.get_module().get_geometry().get_point_cloud()
point_count = point_cloud.get_point_count()

for index in range(point_count):
    point_sample = ix.api.GeometryPointSample()
    point_cloud.get_sample(index, point_sample)
    # ---> ix.api.GeometrySample.get_geometric_normal ?#


TIA,
Thomas
tsn
 
Posts: 28
Joined: Tue Mar 31, 2015 5:04 pm

Re: Getting polygons, vertices and normals

Unread postby anemoff » Tue Jun 23, 2020 6:13 pm

Hi!

You were almost there. It's as simple as this:

python code

geo = ix.get_item("project://scene/polygrid")
point_cloud = geo.get_module().get_geometry().get_point_cloud()
point_count = point_cloud.get_point_count()

for index in range(point_count):
point_sample = ix.api.GeometryPointSample()
point_cloud.get_sample(index, point_sample)
print(point_sample.normal)


Check GeometryPointSample doc here: https://www.clarissewiki.com/4.0/sdk/st ... ample.html

Cheers,
Anthony Nemoff
Isotropix
R&D Engineer
User avatar
anemoff
 
Posts: 330
Joined: Wed Jan 13, 2016 10:10 am

Re: Getting polygons, vertices and normals

Unread postby tsn » Thu Jun 25, 2020 11:26 am

Big thanks Anthony. That was really close :D
tsn
 
Posts: 28
Joined: Tue Mar 31, 2015 5:04 pm


Return to Scripting