Re: [script] output triangle count

Date : Wed, 28 Nov 2007 14:13:17 +0100
To : XSI(at)Softimage.COM
From : Vladimir Jankijevic <vladimir.jankijevic(at)frame-eleven.com>
Subject : Re: [script] output triangle count
maybe something like this??
it's in python and I'm learning it right now so don't blame me for strange code...

script:

oObj = Application.Selection(0)
count = 0
subdivision  = [0,1,4,16,32,64,128,256,512,1024]

# getting the render subdivision level
for p in oObj.Properties:
        if p.type == 'geomapprox':
            render_level = p.Parameters("gapproxmordrsl").Value
           
# the math :)       
if render_level > 0:
    for poly in oObj.ActivePrimitive.Geometry.Polygons:
        count += poly.Points.Count
       
    count *= subdivision[render_level] *2
   
else:
   
    count = oObj.ActivePrimitive.Geometry.Triangles.count

# output
LogMessage("object \"" + oObj.name + "\" has " + str(count) + " triangles at render time")
   



Bernard Lebel wrote:
All right, thank a lot.


I agree about the speed. Unfortunately my knowledge in c++ is very
limited, the time it would require me to write such a command is
unavailable right now :-(


Cheers
Bernard



On Nov 27, 2007 11:24 AM, Andy Nicholas <andy(at)andynicholas.com> wrote:
  
It's basically going to be like this for each polygon inside that 1D array
of polygons:

[N, i1, i2, i3, i4, i5...]

where N gives the number of indices for that polygon. It'd then be
followed by more definitions until you reach the end of the array.

But looking at it, it does seem slightly tricky to use as you'll have to
go through every single polygon skipping the indices to total up how many
triangles each polygon uses (based on numtriangles = numindices-2).

I'd advise you to write a C++ command to get the information because a)
using a script to do this willalmost certainly be pretty slow, and b)
there's a GetTriangleCount() method in the C++ CGeometryAccessor class
which does exactly what you want already.

Cheers

Andy



    
Thanks Guillaume and Andy.

Sorry for being obtuse, but I don't quite understand what the doc says
about the polygon data returned by the call:

2) polygon data: ordered array of polygon definitions,
each polygon is defined by a list of elements,
the first element of a polygon definition must be set with the number
of indices for that polygon.
The ordering of vertices must respect a ccw ordering to get out going
normals (right-hand rule).
E.g. array of polygons with 4 indices each e.g. {4,0,1,4,3,4,1,2,5,4... }

Sorry but this is almost chinese for me. I mean heck, I just want to
know how many polygons there are in the object. An unsubdivided sphere
gives me an array length of 304, where it has 96 quads and 16
triangles......


Thanks
Bernard





On Nov 27, 2007 10:25 AM, Guillaume Laforge <guillaume(at)alamaison.fr>
wrote:
      
Hi Bernard,

The GetApproximatedMesh  method gives you the description of the
sudivided mesh. Maybe you can find triangles count from there ?

My non subdived 1/2


Guillaume Laforge | La Maison



Bernard Lebel a écrit :

        
Hello,

Is there a way to find out, in scripting, the "output" triangle count?
For instance, when I run something like

logmessage( selection(0).activeprimitive.geometry.triangles.count );

no matter how high the geoapprox setting is, it's always returning the
same value. I'd like to know how many triangles there are *after* the
geometry approximation.


Thanks
Bernard
---
Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in
          
body:
        
unsubscribe xsi

          
---
Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in
body:
unsubscribe xsi

        
---
Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body:
unsubscribe xsi

      

---
Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body:
unsubscribe xsi

    

---
Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body:
unsubscribe xsi

  

-- 
Vladimir Jankijevic
3D / Animation

frame eleven ag
Schiffbaustrasse 10
8005 Zurich

tel  +41-1-444 34 44
fax  +41-1-444 34 45

vladimir.jankijevic(at)frame-eleven.com

www.frame-eleven.com
--- Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body: unsubscribe xsi

Search the XSI List archives here or use the advanced search form to search across mailing lists. Searching help is available.
This site supposedly brought to you by Benjamin Grosser and the Imaging Technology Group.