Previous Thread  Next Thread

chat icon Faces shade smooth export

Ilya81

Posted: Wed Jun 06, 2012 1:20 pm
Joined: 06 Jun 2012
Posts: 2
The question isn't new but I've not succeeded to find an appropriate answer. I need to differ faces_shade_smooth when it's applied only to a faces group but groups aren't smoothed between them. I've succeded to find only use_smooth property and the built-in export script acts the same way (i. e. doesn't differ smooth groups).

I've found how to do it from UI but I don't know how can I export it in a script.

Tell me please how can I exactly get if a particular polygon that uses smooth does belong to some group or doesn't (i. e. if it should be smoothed with some other polygon or not).
Reply with quote


CoDEmanX

Posted: Wed Jun 06, 2012 9:22 pm
Joined: 05 Apr 2009
Posts: 684
by groups you mean vertex groups right?

hope this helps:

Code:
import bpy

o = bpy.context.object
m = o.data

print("Object:   %s" % o.name)
print("Mesh:     %s" % m.name)
print("Polygons: %i" % len(m.polygons))
print()

for poly in m.polygons:
   
    if not poly.select:
        continue
   
    print("Polygon %i smooth? %s" % (poly.index, poly.use_smooth))

    for vert_index in poly.vertices:
        vertex = m.vertices[vert_index]
       
        print("  Vertex %i" % vert_index)
        print("  Vertex groups: %i" % len(vertex.groups))
        for g in vertex.groups:
            print("    %s" % o.vertex_groups[g.group].name)
        print()

_________________
I'm sitting, waiting, wishing, building Blender in superstition...
Reply with quote


Ilya81

Posted: Thu Jun 07, 2012 8:24 am
Joined: 06 Jun 2012
Posts: 2
Unfortunantly that is not I'm looking for. I've already tried this way and found out that smooth groups don't match vertex groups (really I'm not sure if smooth groups are represented for vertices, edges or polygons). E. g. if I select a mesh, enter in edit mode, select some polygons, press W and select from popup menu "Shade smooth" I don't create a vertex group. I can see that in the object data tab the list of vertex groups is still empty.

The smooth groups effect is only that polygons are being smoothed only inside groups but not between them. Such feature was for a long time 3D Studio Max and appeared only in some latest versions of Blender. The problem is how to export it, standard scripts still are not modified for this new feature.
Reply with quote


CoDEmanX

Posted: Thu Jun 07, 2012 1:04 pm
Joined: 05 Apr 2009
Posts: 684
the operator exec function of bpy.ops.mesh.faces_shade_smooth call:

mesh_set_smooth_faces(em, 1);

which does:

Code:
   BMIter iter;
   BMFace *efa;

   if (em == NULL) return;
   
   BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
      if (BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
         BM_elem_flag_set(efa, BM_ELEM_SMOOTH, smooth);
      }
   }


in python it would be:

Code:
for efa in bm:
    if efa.select:
        efa.use_smooth = smooth # 0 or 1


so my above code is right, the information is stored in poly.use_smooth
_________________
I'm sitting, waiting, wishing, building Blender in superstition...
Reply with quote


 
Jump to:  
Powered by phpBB © 2001, 2005 phpBB Group