Revision: 20876
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=20876
Author:   yukishiro
Date:     2009-06-14 16:54:46 +0200 (Sun, 14 Jun 2009)

Log Message:
-----------
merge from 20828 to 20874

Modified Paths:
--------------
    branches/soc-2009-yukishiro/config/win32-vc-config.py
    branches/soc-2009-yukishiro/release/scripts/export_obj.py
    branches/soc-2009-yukishiro/release/scripts/flt_properties.py
    branches/soc-2009-yukishiro/release/scripts/import_obj.py
    branches/soc-2009-yukishiro/release/scripts/textplugin_convert_ge.py
    branches/soc-2009-yukishiro/release/scripts/wizard_bolt_factory.py
    branches/soc-2009-yukishiro/release/ui/buttons_data_armature.py
    branches/soc-2009-yukishiro/release/ui/buttons_data_bone.py
    branches/soc-2009-yukishiro/release/ui/buttons_data_camera.py
    branches/soc-2009-yukishiro/release/ui/buttons_data_curve.py
    branches/soc-2009-yukishiro/release/ui/buttons_data_empty.py
    branches/soc-2009-yukishiro/release/ui/buttons_data_lamp.py
    branches/soc-2009-yukishiro/release/ui/buttons_data_lattice.py
    branches/soc-2009-yukishiro/release/ui/buttons_data_mesh.py
    branches/soc-2009-yukishiro/release/ui/buttons_data_modifier.py
    branches/soc-2009-yukishiro/release/ui/buttons_data_text.py
    branches/soc-2009-yukishiro/release/ui/buttons_material.py
    branches/soc-2009-yukishiro/release/ui/buttons_objects.py
    branches/soc-2009-yukishiro/release/ui/buttons_physic_cloth.py
    branches/soc-2009-yukishiro/release/ui/buttons_scene.py
    branches/soc-2009-yukishiro/release/ui/buttons_texture.py
    branches/soc-2009-yukishiro/release/ui/buttons_world.py
    branches/soc-2009-yukishiro/release/ui/space_text.py
    branches/soc-2009-yukishiro/release/windows/extra/python26.zip
    branches/soc-2009-yukishiro/source/blender/blenfont/BLF_api.h
    branches/soc-2009-yukishiro/source/blender/blenfont/intern/blf.c
    branches/soc-2009-yukishiro/source/blender/blenfont/intern/blf_font.c
    
branches/soc-2009-yukishiro/source/blender/blenfont/intern/blf_internal_types.h
    branches/soc-2009-yukishiro/source/blender/blenkernel/BKE_displist.h
    branches/soc-2009-yukishiro/source/blender/blenkernel/intern/booleanops.c
    branches/soc-2009-yukishiro/source/blender/blenkernel/intern/displist.c
    branches/soc-2009-yukishiro/source/blender/blenkernel/intern/modifier.c
    
branches/soc-2009-yukishiro/source/blender/blenkernel/intern/particle_system.c
    branches/soc-2009-yukishiro/source/blender/blenlib/intern/freetypefont.c
    branches/soc-2009-yukishiro/source/blender/editors/include/UI_interface.h
    branches/soc-2009-yukishiro/source/blender/editors/interface/interface.c
    branches/soc-2009-yukishiro/source/blender/editors/interface/interface_api.c
    
branches/soc-2009-yukishiro/source/blender/editors/interface/interface_handlers.c
    
branches/soc-2009-yukishiro/source/blender/editors/interface/interface_intern.h
    
branches/soc-2009-yukishiro/source/blender/editors/interface/interface_regions.c
    
branches/soc-2009-yukishiro/source/blender/editors/interface/interface_style.c
    
branches/soc-2009-yukishiro/source/blender/editors/interface/interface_templates.c
    
branches/soc-2009-yukishiro/source/blender/editors/interface/interface_widgets.c
    branches/soc-2009-yukishiro/source/blender/editors/preview/previewrender.c
    
branches/soc-2009-yukishiro/source/blender/editors/space_script/script_edit.c
    branches/soc-2009-yukishiro/source/blender/editors/space_text/text_ops.c
    branches/soc-2009-yukishiro/source/blender/editors/space_view3d/SConscript
    
branches/soc-2009-yukishiro/source/blender/editors/space_view3d/view3d_intern.h
    branches/soc-2009-yukishiro/source/blender/editors/space_view3d/view3d_ops.c
    
branches/soc-2009-yukishiro/source/blender/editors/space_view3d/view3d_view.c
    branches/soc-2009-yukishiro/source/blender/makesdna/DNA_sequence_types.h
    branches/soc-2009-yukishiro/source/blender/makesdna/DNA_space_types.h
    branches/soc-2009-yukishiro/source/blender/makesdna/DNA_userdef_types.h
    branches/soc-2009-yukishiro/source/blender/makesrna/intern/rna_armature.c
    branches/soc-2009-yukishiro/source/blender/makesrna/intern/rna_material.c
    branches/soc-2009-yukishiro/source/blender/makesrna/intern/rna_sequence.c
    branches/soc-2009-yukishiro/source/blender/makesrna/intern/rna_space.c
    branches/soc-2009-yukishiro/source/blender/makesrna/intern/rna_userdef.c
    branches/soc-2009-yukishiro/source/blender/python/BPY_extern.h
    branches/soc-2009-yukishiro/source/blender/python/intern/bpy_interface.c
    branches/soc-2009-yukishiro/source/blender/python/intern/bpy_operator_wrap.c
    branches/soc-2009-yukishiro/source/blender/python/intern/bpy_rna.c
    branches/soc-2009-yukishiro/source/blender/python/intern/bpy_util.c
    branches/soc-2009-yukishiro/source/blender/python/intern/bpy_util.h
    
branches/soc-2009-yukishiro/source/blender/render/intern/source/convertblender.c
    
branches/soc-2009-yukishiro/source/blender/windowmanager/intern/wm_event_system.c
    branches/soc-2009-yukishiro/source/blender/windowmanager/intern/wm_window.c
    branches/soc-2009-yukishiro/source/blender/windowmanager/wm_event_system.h
    branches/soc-2009-yukishiro/source/blender/windowmanager/wm_window.h
    branches/soc-2009-yukishiro/source/creator/creator.c
    
branches/soc-2009-yukishiro/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
    
branches/soc-2009-yukishiro/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp
    
branches/soc-2009-yukishiro/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h
    
branches/soc-2009-yukishiro/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp
    branches/soc-2009-yukishiro/source/gameengine/BlenderRoutines/KX_BlenderGL.h
    
branches/soc-2009-yukishiro/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp
    
branches/soc-2009-yukishiro/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
    
branches/soc-2009-yukishiro/source/gameengine/Converter/KX_BlenderSceneConverter.h
    branches/soc-2009-yukishiro/source/gameengine/Expressions/ListValue.cpp
    branches/soc-2009-yukishiro/source/gameengine/Expressions/PyObjectPlus.h
    
branches/soc-2009-yukishiro/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp
    
branches/soc-2009-yukishiro/source/gameengine/GamePlayer/ActiveX/BlenderPlayerCtl.cpp
    
branches/soc-2009-yukishiro/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp
    
branches/soc-2009-yukishiro/source/gameengine/GamePlayer/ghost/GPG_Application.cpp
    
branches/soc-2009-yukishiro/source/gameengine/GamePlayer/netscape/src/ketsji/KXH_ketsji_hooks.cpp
    branches/soc-2009-yukishiro/source/gameengine/Ketsji/KX_Camera.cpp
    branches/soc-2009-yukishiro/source/gameengine/Ketsji/KX_GameObject.cpp
    branches/soc-2009-yukishiro/source/gameengine/Ketsji/KX_GameObject.h
    branches/soc-2009-yukishiro/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
    branches/soc-2009-yukishiro/source/gameengine/Ketsji/KX_KetsjiEngine.h
    branches/soc-2009-yukishiro/source/gameengine/Ketsji/KX_Light.cpp
    branches/soc-2009-yukishiro/source/gameengine/Ketsji/KX_Light.h
    branches/soc-2009-yukishiro/source/gameengine/Ketsji/KX_PythonInit.cpp
    branches/soc-2009-yukishiro/source/gameengine/Ketsji/KX_PythonSeq.cpp
    branches/soc-2009-yukishiro/source/gameengine/Ketsji/KX_SoundActuator.cpp
    
branches/soc-2009-yukishiro/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
    branches/soc-2009-yukishiro/source/gameengine/Rasterizer/RAS_LightObject.h
    branches/soc-2009-yukishiro/tools/Blender.py
    branches/soc-2009-yukishiro/tools/btools.py

Modified: branches/soc-2009-yukishiro/config/win32-vc-config.py
===================================================================
--- branches/soc-2009-yukishiro/config/win32-vc-config.py       2009-06-14 
14:45:06 UTC (rev 20875)
+++ branches/soc-2009-yukishiro/config/win32-vc-config.py       2009-06-14 
14:54:46 UTC (rev 20876)
@@ -9,10 +9,10 @@
 BF_FFMPEG_LIB = 'avformat-52.lib avcodec-52.lib avdevice-52.lib avutil-50.lib 
swscale-0.lib'
 
 BF_PYTHON = LIBDIR + '/python'
-BF_PYTHON_VERSION = '2.5'
+BF_PYTHON_VERSION = '2.6'
 BF_PYTHON_INC = '${BF_PYTHON}/include/python${BF_PYTHON_VERSION}'
 BF_PYTHON_BINARY = 'python'
-BF_PYTHON_LIB = 'python25'
+BF_PYTHON_LIB = 'python26'
 BF_PYTHON_LIBPATH = '${BF_PYTHON}/lib'
 
 WITH_BF_OPENAL = True

Modified: branches/soc-2009-yukishiro/release/scripts/export_obj.py
===================================================================
--- branches/soc-2009-yukishiro/release/scripts/export_obj.py   2009-06-14 
14:45:06 UTC (rev 20875)
+++ branches/soc-2009-yukishiro/release/scripts/export_obj.py   2009-06-14 
14:54:46 UTC (rev 20876)
@@ -181,12 +181,89 @@
                                copyCount+=1
        print '\tCopied %d images' % copyCount
 
+
+def test_nurbs_compat(ob):
+       if ob.type != 'Curve':
+               return False
+       
+       for nu in ob.data:
+               if (not nu.knotsV) and nu.type != 1: # not a surface and not 
bezier
+                       return True
+       
+       return False
+
+def write_nurb(file, ob, ob_mat):
+       tot_verts = 0
+       cu = ob.data
+       
+       # use negative indices
+       Vector = Blender.Mathutils.Vector
+       for nu in cu:
+               
+               if nu.type==0:          DEG_ORDER_U = 1
+               else:                           DEG_ORDER_U = nu.orderU-1  # 
Tested to be correct
+               
+               if nu.type==1:
+                       print "\tWarning, bezier curve:", ob.name, "only poly 
and nurbs curves supported"
+                       continue
+               
+               if nu.knotsV:
+                       print "\tWarning, surface:", ob.name, "only poly and 
nurbs curves supported"
+                       continue
+               
+               if len(nu) <= DEG_ORDER_U:
+                       print "\tWarning, orderU is lower then vert count, 
skipping:", ob.name
+                       continue
+               
+               pt_num = 0
+               do_closed = (nu.flagU & 1)
+               do_endpoints = (do_closed==0) and (nu.flagU & 2)
+               
+               for pt in nu:
+                       pt = Vector(pt[0], pt[1], pt[2]) * ob_mat
+                       file.write('v %.6f %.6f %.6f\n' % (pt[0], pt[1], pt[2]))
+                       pt_num += 1
+               tot_verts += pt_num
+               
+               file.write('g %s\n' % (fixName(ob.name))) # 
fixName(ob.getData(1)) could use the data name too
+               file.write('cstype bspline\n') # not ideal, hard coded
+               file.write('deg %d\n' % DEG_ORDER_U) # not used for curves but 
most files have it still
+               
+               curve_ls = [-(i+1) for i in xrange(pt_num)]
+               
+               # 'curv' keyword
+               if do_closed:
+                       if DEG_ORDER_U == 1:
+                               pt_num += 1
+                               curve_ls.append(-1)
+                       else:
+                               pt_num += DEG_ORDER_U
+                               curve_ls = curve_ls + curve_ls[0:DEG_ORDER_U]
+               
+               file.write('curv 0.0 1.0 %s\n' % (' '.join( [str(i) for i in 
curve_ls] ))) # Blender has no U and V values for the curve
+               
+               # 'parm' keyword
+               tot_parm = (DEG_ORDER_U + 1) + pt_num
+               tot_parm_div = float(tot_parm-1)
+               parm_ls = [(i/tot_parm_div) for i in xrange(tot_parm)]
+               
+               if do_endpoints: # end points, force param
+                       for i in xrange(DEG_ORDER_U+1):
+                               parm_ls[i] = 0.0
+                               parm_ls[-(1+i)] = 1.0
+               
+               file.write('parm u %s\n' % ' '.join( [str(i) for i in parm_ls] 
))
+
+               file.write('end\n')
+       
+       return tot_verts
+
 def write(filename, objects,\
 EXPORT_TRI=False,  EXPORT_EDGES=False,  EXPORT_NORMALS=False,  
EXPORT_NORMALS_HQ=False,\
 EXPORT_UV=True,  EXPORT_MTL=True,  EXPORT_COPY_IMAGES=False,\
 EXPORT_APPLY_MODIFIERS=True, EXPORT_ROTX90=True, EXPORT_BLEN_OBS=True,\
 EXPORT_GROUP_BY_OB=False,  EXPORT_GROUP_BY_MAT=False, 
EXPORT_KEEP_VERT_ORDER=False,\
-EXPORT_POLYGROUPS=False):
+EXPORT_POLYGROUPS=False, EXPORT_CURVE_AS_NURBS=True):
        '''
        Basic write function. The context and options must be alredy set
        This can be accessed externaly
@@ -266,6 +343,17 @@
        # Get all meshes
        for ob_main in objects:
                for ob, ob_mat in BPyObject.getDerivedObjects(ob_main):
+                       
+                       # Nurbs curve support
+                       if EXPORT_CURVE_AS_NURBS and test_nurbs_compat(ob):
+                               if EXPORT_ROTX90:
+                                       ob_mat = ob_mat * mat_xrot90
+                               
+                               totverts += write_nurb(file, ob, ob_mat)
+                               
+                               continue
+                       # end nurbs
+                       
                        # Will work for non meshes now! :)
                        # getMeshFromObject(ob, container_mesh=None, 
apply_modifiers=True, vgroups=True, scn=None)
                        me= BPyMesh.getMeshFromObject(ob, containerMesh, 
EXPORT_APPLY_MODIFIERS, EXPORT_POLYGROUPS, scn)
@@ -585,7 +673,7 @@
                EXPORT_MTL, EXPORT_SEL_ONLY, EXPORT_ALL_SCENES,\
                EXPORT_ANIMATION, EXPORT_COPY_IMAGES, EXPORT_BLEN_OBS,\
                EXPORT_GROUP_BY_OB, EXPORT_GROUP_BY_MAT, 
EXPORT_KEEP_VERT_ORDER,\
-               EXPORT_POLYGROUPS
+               EXPORT_POLYGROUPS, EXPORT_CURVE_AS_NURBS
        
        EXPORT_APPLY_MODIFIERS = Draw.Create(0)
        EXPORT_ROTX90 = Draw.Create(1)
@@ -604,6 +692,7 @@
        EXPORT_GROUP_BY_MAT = Draw.Create(0)
        EXPORT_KEEP_VERT_ORDER = Draw.Create(1)
        EXPORT_POLYGROUPS = Draw.Create(0)
+       EXPORT_CURVE_AS_NURBS = Draw.Create(1)
        
        
        # Old UI
@@ -693,7 +782,7 @@
                                EXPORT_MTL, EXPORT_SEL_ONLY, EXPORT_ALL_SCENES,\
                                EXPORT_ANIMATION, EXPORT_COPY_IMAGES, 
EXPORT_BLEN_OBS,\
                                EXPORT_GROUP_BY_OB, EXPORT_GROUP_BY_MAT, 
EXPORT_KEEP_VERT_ORDER,\
-                               EXPORT_POLYGROUPS
+                               EXPORT_POLYGROUPS, EXPORT_CURVE_AS_NURBS
 
                        Draw.Label('Context...', ui_x+9, ui_y+239, 220, 20)
                        Draw.BeginAlign()
@@ -726,7 +815,9 @@
                        Draw.EndAlign()
                        EXPORT_POLYGROUPS = Draw.Toggle('Polygroups', 
EVENT_REDRAW, ui_x+9, ui_y+95, 120, 20, EXPORT_POLYGROUPS.val, 'Export vertex 
groups as OBJ groups (one group per face approximation).')
                        
+                       EXPORT_CURVE_AS_NURBS = Draw.Toggle('Nurbs', 
EVENT_NONE, ui_x+139, ui_y+95, 100, 20, EXPORT_CURVE_AS_NURBS.val, 'Export 3D 
nurbs curves and polylines as OBJ curves, (bezier not supported).')
                        
+                       
                        Draw.Label('Blender Objects as OBJ:', ui_x+9, ui_y+59, 
220, 20)
                        Draw.BeginAlign()
                        EXPORT_BLEN_OBS = Draw.Toggle('Objects', EVENT_REDRAW, 
ui_x+9, ui_y+39, 60, 20, EXPORT_BLEN_OBS.val, 'Export blender objects as "OBJ 
objects".', do_split)
@@ -779,6 +870,7 @@
        EXPORT_GROUP_BY_MAT = EXPORT_GROUP_BY_MAT.val
        EXPORT_KEEP_VERT_ORDER = EXPORT_KEEP_VERT_ORDER.val
        EXPORT_POLYGROUPS = EXPORT_POLYGROUPS.val
+       EXPORT_CURVE_AS_NURBS = EXPORT_CURVE_AS_NURBS.val
        
        
        base_name, ext = splitExt(filename)
@@ -828,7 +920,7 @@
                        EXPORT_COPY_IMAGES, EXPORT_APPLY_MODIFIERS,\
                        EXPORT_ROTX90, EXPORT_BLEN_OBS,\
                        EXPORT_GROUP_BY_OB, EXPORT_GROUP_BY_MAT, 
EXPORT_KEEP_VERT_ORDER,\
-                       EXPORT_POLYGROUPS)
+                       EXPORT_POLYGROUPS, EXPORT_CURVE_AS_NURBS)
                
                Blender.Set('curframe', orig_frame)
        

Modified: branches/soc-2009-yukishiro/release/scripts/flt_properties.py
===================================================================
--- branches/soc-2009-yukishiro/release/scripts/flt_properties.py       
2009-06-14 14:45:06 UTC (rev 20875)
+++ branches/soc-2009-yukishiro/release/scripts/flt_properties.py       
2009-06-14 14:54:46 UTC (rev 20876)
@@ -1,4 +1,3 @@
-#!BPY
 # flt_properties.py. For setting default OpenFLight ID property types
 # Copyright (C) 2007 Blender Foundation
 #

Modified: branches/soc-2009-yukishiro/release/scripts/import_obj.py
===================================================================
--- branches/soc-2009-yukishiro/release/scripts/import_obj.py   2009-06-14 
14:45:06 UTC (rev 20875)
+++ branches/soc-2009-yukishiro/release/scripts/import_obj.py   2009-06-14 
14:54:46 UTC (rev 20876)
@@ -2,7 +2,7 @@
  
 """
 Name: 'Wavefront (.obj)...'
-Blender: 248
+Blender: 249
 Group: 'Import'
 Tooltip: 'Load a Wavefront OBJ File, Shift: batch import all dir.'
 """
@@ -40,7 +40,7 @@
 # ***** END GPL LICENCE BLOCK *****
 # --------------------------------------------------------------------------
 
-from Blender import *
+from Blender import Mesh, Draw, Window, Texture, Material, sys
 import bpy
 import BPyMesh
 import BPyImage
@@ -166,12 +166,13 @@
        del temp_mtl
        
        #Create new materials
-       for name in unique_materials.iterkeys():
-               unique_materials[name]= bpy.data.materials.new(name)
+       for name in unique_materials: # .keys()
+               if name != None:
+                       unique_materials[name]= bpy.data.materials.new(name)
+                       unique_material_images[name]= None, False # assign None 
to all material images to start with, add to later.
                
-               unique_material_images[name]= None, False # assign None to all 
material images to start with, add to later.
-               
        unique_materials[None]= None
+       unique_material_images[None]= None, False
        
        for libname in material_libs:
                mtlpath= DIR + libname
@@ -536,6 +537,98 @@
                me.addVertGroup(group_name)
                me.assignVertsToGroup(group_name, group_indicies,1.00, 
Mesh.AssignModes.REPLACE)
 
+
+def create_nurbs(scn, context_nurbs, vert_loc, new_objects):
+       '''
+       Add nurbs object to blender, only support one type at the moment
+       '''
+       deg = context_nurbs.get('deg', (3,))
+       curv_range = context_nurbs.get('curv_range', None)
+       curv_idx = context_nurbs.get('curv_idx', [])
+       parm_u = context_nurbs.get('parm_u', [])
+       parm_v = context_nurbs.get('parm_v', [])
+       name = context_nurbs.get('name', 'ObjNurb')
+       cstype = context_nurbs.get('cstype', None)
+       
+       if cstype == None:
+               print '\tWarning, cstype not found'
+               return
+       if cstype != 'bspline':
+               print '\tWarning, cstype is not supported (only bspline)'
+               return
+       if not curv_idx:
+               print '\tWarning, curv argument empty or not set'
+               return
+       if len(deg) > 1 or parm_v:
+               print '\tWarning, surfaces not supported'
+               return
+       
+       cu = bpy.data.curves.new(name, 'Curve')
+       cu.flag |= 1 # 3D curve
+       
+       nu = None
+       for pt in curv_idx:
+               
+               pt = vert_loc[pt]
+               pt = (pt[0], pt[1], pt[2], 1.0)
+               
+               if nu == None:
+                       nu = cu.appendNurb(pt)
+               else:
+                       nu.append(pt)
+       
+       nu.orderU = deg[0]+1
+       
+       # get for endpoint flag from the weighting
+       if curv_range and len(parm_u) > deg[0]+1:
+               do_endpoints = True
+               for i in xrange(deg[0]+1):
+                       
+                       if abs(parm_u[i]-curv_range[0]) > 0.0001:
+                               do_endpoints = False
+                               break
+                       
+                       if abs(parm_u[-(i+1)]-curv_range[1]) > 0.0001:
+                               do_endpoints = False
+                               break
+                       
+       else:
+               do_endpoints = False
+       
+       if do_endpoints:
+               nu.flagU |= 2
+       
+       
+       # close
+       '''
+       do_closed = False
+       if len(parm_u) > deg[0]+1:
+               for i in xrange(deg[0]+1):
+                       #print curv_idx[i], curv_idx[-(i+1)]
+                       
+                       if curv_idx[i]==curv_idx[-(i+1)]:
+                               do_closed = True
+                               break
+       
+       if do_closed:
+               nu.flagU |= 1
+       '''
+       
+       ob = scn.objects.new(cu)
+       new_objects.append(ob)
+
+
+def strip_slash(line_split):
+       if line_split[-1][-1]== '\\':
+               if len(line_split[-1])==1:
+                       line_split.pop() # remove the \ item
+               else:

@@ 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