Revision: 21039
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21039
Author:   kazanbas
Date:     2009-06-20 18:48:58 +0200 (Sat, 20 Jun 2009)

Log Message:
-----------
Merge from 2.5 r20991 through r21037

Modified Paths:
--------------
    branches/soc-2009-kazanbas/release/datafiles/blenderbuttons
    branches/soc-2009-kazanbas/release/ui/buttons_data_bone.py
    branches/soc-2009-kazanbas/release/ui/buttons_data_modifier.py
    branches/soc-2009-kazanbas/release/ui/buttons_objects.py
    branches/soc-2009-kazanbas/source/blender/blenfont/intern/blf_font.c
    branches/soc-2009-kazanbas/source/blender/blenkernel/BKE_action.h
    branches/soc-2009-kazanbas/source/blender/blenkernel/BKE_context.h
    branches/soc-2009-kazanbas/source/blender/blenkernel/BKE_depsgraph.h
    branches/soc-2009-kazanbas/source/blender/blenkernel/depsgraph_private.h
    branches/soc-2009-kazanbas/source/blender/blenkernel/intern/action.c
    branches/soc-2009-kazanbas/source/blender/blenkernel/intern/context.c
    branches/soc-2009-kazanbas/source/blender/blenkernel/intern/depsgraph.c
    branches/soc-2009-kazanbas/source/blender/blenkernel/intern/ipo.c
    branches/soc-2009-kazanbas/source/blender/blenlib/intern/BLI_dynstr.c
    
branches/soc-2009-kazanbas/source/blender/editors/interface/interface_panel.c
    
branches/soc-2009-kazanbas/source/blender/editors/interface/interface_widgets.c
    branches/soc-2009-kazanbas/source/blender/editors/screen/screen_context.c
    branches/soc-2009-kazanbas/source/blender/editors/sculpt_paint/sculpt.c
    
branches/soc-2009-kazanbas/source/blender/editors/space_buttons/buttons_context.c
    branches/soc-2009-kazanbas/source/blender/editors/space_image/space_image.c
    branches/soc-2009-kazanbas/source/blender/editors/space_node/space_node.c
    branches/soc-2009-kazanbas/source/blender/editors/space_text/space_text.c
    
branches/soc-2009-kazanbas/source/blender/editors/space_view3d/space_view3d.c
    branches/soc-2009-kazanbas/source/blender/makesrna/RNA_access.h
    branches/soc-2009-kazanbas/source/blender/makesrna/RNA_define.h
    branches/soc-2009-kazanbas/source/blender/makesrna/intern/makesrna.c
    branches/soc-2009-kazanbas/source/blender/makesrna/intern/rna_ID.c
    branches/soc-2009-kazanbas/source/blender/makesrna/intern/rna_access.c
    branches/soc-2009-kazanbas/source/blender/makesrna/intern/rna_armature.c
    branches/soc-2009-kazanbas/source/blender/makesrna/intern/rna_define.c
    branches/soc-2009-kazanbas/source/blender/makesrna/intern/rna_internal.h
    
branches/soc-2009-kazanbas/source/blender/makesrna/intern/rna_internal_types.h
    branches/soc-2009-kazanbas/source/blender/makesrna/intern/rna_mesh.c
    branches/soc-2009-kazanbas/source/blender/makesrna/intern/rna_object.c
    branches/soc-2009-kazanbas/source/blender/makesrna/intern/rna_rna.c
    branches/soc-2009-kazanbas/source/blender/makesrna/intern/rna_space.c
    branches/soc-2009-kazanbas/source/blender/python/generic/Mathutils.c
    branches/soc-2009-kazanbas/source/blender/python/generic/Mathutils.h
    branches/soc-2009-kazanbas/source/blender/python/generic/euler.c
    branches/soc-2009-kazanbas/source/blender/python/generic/euler.h
    branches/soc-2009-kazanbas/source/blender/python/generic/matrix.c
    branches/soc-2009-kazanbas/source/blender/python/generic/matrix.h
    branches/soc-2009-kazanbas/source/blender/python/generic/quat.c
    branches/soc-2009-kazanbas/source/blender/python/generic/quat.h
    branches/soc-2009-kazanbas/source/blender/python/generic/vector.c
    branches/soc-2009-kazanbas/source/blender/python/generic/vector.h
    branches/soc-2009-kazanbas/source/blender/python/intern/bpy_rna.c
    branches/soc-2009-kazanbas/source/blender/python/intern/bpy_ui.c
    branches/soc-2009-kazanbas/source/creator/creator.c
    branches/soc-2009-kazanbas/source/gameengine/Converter/BL_ActionActuator.cpp
    
branches/soc-2009-kazanbas/source/gameengine/Converter/KX_BlenderScalarInterpolator.cpp
    branches/soc-2009-kazanbas/source/gameengine/Expressions/ListValue.cpp
    branches/soc-2009-kazanbas/source/gameengine/Expressions/SConscript
    branches/soc-2009-kazanbas/source/gameengine/GamePlayer/ghost/CMakeLists.txt
    branches/soc-2009-kazanbas/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp
    branches/soc-2009-kazanbas/source/gameengine/GamePlayer/ghost/Makefile
    branches/soc-2009-kazanbas/source/gameengine/GamePlayer/ghost/SConscript

Added Paths:
-----------
    branches/soc-2009-kazanbas/release/io/export_ply.py
    branches/soc-2009-kazanbas/release/ui/space_logic.py

Removed Paths:
-------------
    branches/soc-2009-kazanbas/release/scripts/ply_export.py

Modified: branches/soc-2009-kazanbas/release/datafiles/blenderbuttons
===================================================================
(Binary files differ)

Copied: branches/soc-2009-kazanbas/release/io/export_ply.py (from rev 21037, 
branches/blender2.5/blender/release/io/export_ply.py)
===================================================================
--- branches/soc-2009-kazanbas/release/io/export_ply.py                         
(rev 0)
+++ branches/soc-2009-kazanbas/release/io/export_ply.py 2009-06-20 16:48:58 UTC 
(rev 21039)
@@ -0,0 +1,286 @@
+import bpy
+
+__author__ = "Bruce Merry"
+__version__ = "0.93"
+__bpydoc__ = """\
+This script exports Stanford PLY files from Blender. It supports normals, 
+colours, and texture coordinates per face or per vertex.
+Only one mesh can be exported at a time.
+"""
+
+# Copyright (C) 2004, 2005: Bruce Merry, [email protected]
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+# Vector rounding se we can use as keys
+#
+# Updated on Aug 11, 2008 by Campbell Barton
+#    - added 'comment' prefix to comments - Needed to comply with the PLY spec.
+#
+# Updated on Jan 1, 2007 by Gabe Ghearing
+#    - fixed normals so they are correctly smooth/flat
+#    - fixed crash when the model doesn't have uv coords or vertex colors
+#    - fixed crash when the model has vertex colors but doesn't have uv coords
+#    - changed float32 to float and uint8 to uchar for compatibility
+# Errata/Notes as of Jan 1, 2007
+#    - script exports texture coords if they exist even if TexFace isn't 
selected (not a big deal to me)
+#    - ST(R) should probably be renamed UV(T) like in most PLY files (importer 
needs to be updated to take either)
+#
+# Updated on Jan 3, 2007 by Gabe Ghearing
+#    - fixed "sticky" vertex UV exporting
+#    - added pupmenu to enable/disable exporting normals, uv coords, and colors
+# Errata/Notes as of Jan 3, 2007
+#    - ST(R) coords should probably be renamed UV(T) like in most PLY files 
(importer needs to be updated to take either)
+#    - edges should be exported since PLY files support them
+#    - code is getting spaghettish, it should be refactored...
+#
+
+
+def rvec3d(v): return round(v[0], 6), round(v[1], 6), round(v[2], 6)
+def rvec2d(v): return round(v[0], 6), round(v[1], 6)
+
+def write(filename, scene, ob, \
+               EXPORT_APPLY_MODIFIERS= True,\
+               EXPORT_NORMALS= True,\
+               EXPORT_UV= True,\
+               EXPORT_COLORS= True\
+       ):
+       
+       if not filename.lower().endswith('.ply'):
+               filename += '.ply'
+       
+       if not ob:
+               raise Exception("Error, Select 1 active object")
+               return
+       
+       file = open(filename, 'wb')
+       
+       
+       #EXPORT_EDGES = Draw.Create(0)
+       """
+       is_editmode = Blender.Window.EditMode()
+       if is_editmode:
+               Blender.Window.EditMode(0, '', 0)
+       
+       Window.WaitCursor(1)
+       """
+       
+       #mesh = BPyMesh.getMeshFromObject(ob, None, EXPORT_APPLY_MODIFIERS, 
False, scn) # XXX
+       if EXPORT_APPLY_MODIFIERS:
+               mesh = ob.create_render_mesh(scene)
+       else:
+               mesh = ob.data
+       
+       if not mesh:
+               raise ("Error, could not get mesh data from active object")
+               return
+       
+       # mesh.transform(ob.matrixWorld) # XXX
+       
+       faceUV = len(mesh.uv_layers) > 0
+       vertexUV = len(mesh.sticky) > 0
+       vertexColors = len(mesh.vcol_layers) > 0
+       
+       if (not faceUV) and (not vertexUV):     EXPORT_UV = False
+       if not vertexColors:                                    EXPORT_COLORS = 
False
+       
+       if not EXPORT_UV:                                               faceUV 
= vertexUV = False
+       if not EXPORT_COLORS:                                   vertexColors = 
False
+               
+       if faceUV:
+               active_uv_layer = None
+               for lay in mesh.uv_layers:
+                       if lay.active:
+                               active_uv_layer= lay.data
+                               break
+               if not active_uv_layer:
+                       EXPORT_UV = False
+                       faceUV = None
+       
+       if vertexColors:
+               active_col_layer = None
+               for lay in mesh.vcol_layers:
+                       if lay.active:
+                               active_col_layer= lay.data
+               if not active_col_layer:
+                       EXPORT_COLORS = False
+                       vertexColors = None
+       
+       # incase
+       color = uvcoord = uvcoord_key = normal = normal_key = None
+       
+       mesh_verts = mesh.verts # save a lookup
+       ply_verts = [] # list of dictionaries
+       # vdict = {} # (index, normal, uv) -> new index
+       vdict = [{} for i in xrange(len(mesh_verts))]
+       ply_faces = [[] for f in xrange(len(mesh.faces))]
+       vert_count = 0
+       for i, f in enumerate(mesh.faces):
+               
+               
+               smooth = f.smooth
+               # XXX need face normals
+               """
+               if not smooth:
+                       normal = tuple(f.no)
+                       normal_key = rvec3d(normal)
+               """
+               if faceUV:
+                       uv = active_uv_layer[i]
+                       uv = uv.uv1, uv.uv2, uv.uv3, uv.uv4 # XXX - crufty :/
+               if vertexColors:
+                       col = active_col_layer[i]
+                       col = col.color1, col.color2, col.color3, col.color4
+               
+               f_verts= list(f.verts)
+               if not f_verts[3]: f_verts.pop() # XXX face length should be 
3/4, not always 4
+               
+               pf= ply_faces[i]
+               for j, vidx in enumerate(f_verts):
+                       v = mesh_verts[vidx]
+                       """
+                       if smooth:
+                               normal=         tuple(v.no)
+                               normal_key = rvec3d(normal)
+                       """
+                       normal_key = None # XXX
+                       
+                       if faceUV:
+                               uvcoord=        uv[j][0], 1.0-uv[j][1]
+                               uvcoord_key = rvec2d(uvcoord)
+                       elif vertexUV:
+                               uvcoord=        v.uvco[0], 1.0-v.uvco[1]
+                               uvcoord_key = rvec2d(uvcoord)
+                       
+                       if vertexColors:
+                               color=          col[j]
+                               color= int(color[0]*255.0), 
int(color[1]*255.0), int(color[2]*255.0)
+                       
+                       
+                       key = normal_key, uvcoord_key, color
+                       
+                       vdict_local = vdict[vidx]
+                       pf_vidx = vdict_local.get(key) # Will be None initially
+                       
+                       if pf_vidx == None: # same as vdict_local.has_key(key)
+                               pf_vidx = vdict_local[key] = vert_count;
+                               ply_verts.append((vidx, normal, uvcoord, color))
+                               vert_count += 1
+                       
+                       pf.append(pf_vidx)
+       
+       file.write('ply\n')
+       file.write('format ascii 1.0\n')
+       version = "2.5" # Blender.Get('version')
+       file.write('comment Created by Blender3D %s - www.blender.org, source 
file: %s\n' % (version, bpy.data.filename.split('/')[-1].split('\\')[-1] ))
+       
+       file.write('element vertex %d\n' % len(ply_verts))
+       
+       file.write('property float x\n')
+       file.write('property float y\n')
+       file.write('property float z\n')
+       
+       # XXX 
+       """
+       if EXPORT_NORMALS:
+               file.write('property float nx\n')
+               file.write('property float ny\n')
+               file.write('property float nz\n')
+       """
+       if EXPORT_UV:
+               file.write('property float s\n')
+               file.write('property float t\n')
+       if EXPORT_COLORS:
+               file.write('property uchar red\n')
+               file.write('property uchar green\n')
+               file.write('property uchar blue\n')
+       
+       file.write('element face %d\n' % len(mesh.faces))
+       file.write('property list uchar uint vertex_indices\n')
+       file.write('end_header\n')
+
+       for i, v in enumerate(ply_verts):
+               file.write('%.6f %.6f %.6f ' % tuple(mesh_verts[v[0]].co)) # co
+               """
+               if EXPORT_NORMALS:
+                       file.write('%.6f %.6f %.6f ' % v[1]) # no
+               """
+               if EXPORT_UV:                   file.write('%.6f %.6f ' % v[2]) 
# uv
+               if EXPORT_COLORS:               file.write('%u %u %u' % v[3]) # 
col
+               file.write('\n')
+       
+       for pf in ply_faces:
+               if len(pf)==3:          file.write('3 %d %d %d\n' % tuple(pf))
+               else:                           file.write('4 %d %d %d %d\n' % 
tuple(pf))
+       
+       file.close()
+       print("writing", filename, "done")
+       
+       if EXPORT_APPLY_MODIFIERS:
+               bpy.data.remove_mesh(mesh)
+       
+       # XXX
+       """
+       if is_editmode:
+               Blender.Window.EditMode(1, '', 0)
+       """
+
+class EXPORT_OT_ply(bpy.types.Operator):
+       '''
+       Operator documentatuon text, will be used for the operator tooltip and 
python docs.
+       '''
+       __label__ = "Export PLY"
+       
+       # List of operator properties, the attributes will be assigned
+       # to the class instance from the operator settings before calling.
+       
+       __props__ = [
+               bpy.props.StringProperty(attr="filename", name="File Name", 
description="File name used for exporting the PLY file", maxlen= 1024, default= 
""),
+               bpy.props.BoolProperty(attr="use_modifiers", name="Apply 
Modifiers", description="Apply Modifiers to the exported mesh", default= True),
+               bpy.props.BoolProperty(attr="use_normals", name="Export 
Normals", description="Export Normals for smooth and hard shaded faces", 
default= True),
+               bpy.props.BoolProperty(attr="use_uvs", name="Export UVs", 
description="Exort the active UV layer", default= True),
+               bpy.props.BoolProperty(attr="use_colors", name="Export Vertex 
Colors", description="Exort the active vertex color layer", default= True)
+       ]
+       
+       def poll(self, context):
+               print("Poll")
+               return context.active_object != None
+       
+       def execute(self, context):
+               # print("Selected: " + context.active_object.name)
+
+               if not self.filename:
+                       raise Exception("filename not set")
+                       
+               write(self.filename, context.scene, context.active_object,\
+                       EXPORT_APPLY_MODIFIERS = self.use_modifiers,
+                       EXPORT_NORMALS = self.use_normals,
+                       EXPORT_UV = self.use_uvs,
+                       EXPORT_COLORS = self.use_colors,
+               )
+
+               return ('FINISHED',)
+       
+       def invoke(self, context, event):       
+               wm = context.manager
+               wm.add_fileselect(self.__operator__)
+               return ('RUNNING_MODAL',)
+
+
+bpy.ops.add(EXPORT_OT_ply)
+
+if __name__ == "__main__":
+       bpy.ops.EXPORT_OT_ply(filename="/tmp/test.ply")
+
+

Deleted: branches/soc-2009-kazanbas/release/scripts/ply_export.py
===================================================================
--- branches/soc-2009-kazanbas/release/scripts/ply_export.py    2009-06-20 
16:32:52 UTC (rev 21038)
+++ branches/soc-2009-kazanbas/release/scripts/ply_export.py    2009-06-20 
16:48:58 UTC (rev 21039)
@@ -1,228 +0,0 @@
-#!BPY
-
-"""
-Name: 'Stanford PLY (*.ply)...'
-Blender: 241
-Group: 'Export'
-Tooltip: 'Export active object to Stanford PLY format'
-"""
-
-import bpy
-import Blender
-from Blender import Mesh, Scene, Window, sys, Image, Draw
-import BPyMesh
-
-__author__ = "Bruce Merry"
-__version__ = "0.93"
-__bpydoc__ = """\
-This script exports Stanford PLY files from Blender. It supports normals, 
-colours, and texture coordinates per face or per vertex.
-Only one mesh can be exported at a time.
-"""
-
-# Copyright (C) 2004, 2005: Bruce Merry, [email protected]
-#
-# This program is free software; you can redistribute it and/or

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to