[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [21300] branches/soc-2009-aligorith: NLA SoC: Adding some files that seem to have been missed during some merges.
Joshua Leung
aligorith at gmail.com
Thu Jul 2 04:53:19 CEST 2009
Revision: 21300
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21300
Author: aligorith
Date: 2009-07-02 04:53:18 +0200 (Thu, 02 Jul 2009)
Log Message:
-----------
NLA SoC: Adding some files that seem to have been missed during some merges. Hopefully all of these should really be in the repositry...
Added Paths:
-----------
branches/soc-2009-aligorith/release/scripts/animation_clean.py
branches/soc-2009-aligorith/release/scripts/image_2d_cutout.py
branches/soc-2009-aligorith/release/scripts/object_active_to_other.py
branches/soc-2009-aligorith/release/scripts/scripttemplate_gamelogic_module.py
branches/soc-2009-aligorith/release/scripts/textplugin_convert_ge.py
branches/soc-2009-aligorith/release/scripts/wizard_bolt_factory.py
branches/soc-2009-aligorith/release/scripts/wizard_landscape_ant.py
branches/soc-2009-aligorith/release/text/release_249.txt
branches/soc-2009-aligorith/release/ui/space_sequencer.py
branches/soc-2009-aligorith/source/gameengine/Converter/BL_ModifierDeformer.cpp
branches/soc-2009-aligorith/source/gameengine/Converter/BL_ModifierDeformer.h
branches/soc-2009-aligorith/source/gameengine/Ketsji/KX_PythonSeq.cpp
branches/soc-2009-aligorith/source/gameengine/Ketsji/KX_PythonSeq.h
branches/soc-2009-aligorith/source/gameengine/PyDoc/API_intro.py
branches/soc-2009-aligorith/source/gameengine/SceneGraph/SG_DList.h
branches/soc-2009-aligorith/source/gameengine/SceneGraph/SG_QList.h
Added: branches/soc-2009-aligorith/release/scripts/animation_clean.py
===================================================================
--- branches/soc-2009-aligorith/release/scripts/animation_clean.py (rev 0)
+++ branches/soc-2009-aligorith/release/scripts/animation_clean.py 2009-07-02 02:53:18 UTC (rev 21300)
@@ -0,0 +1,192 @@
+#!BPY
+
+"""
+Name: 'Clean Animation Curves'
+Blender: 249
+Group: 'Animation'
+Tooltip: 'Remove unused keyframes for ipo curves'
+"""
+
+# ***** BEGIN GPL LICENSE BLOCK *****
+#
+# Copyright (C) 2008-2009: Blender Foundation
+#
+# 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,
+# --------------------------------------------------------------------------
+
+import bpy
+from Blender import IpoCurve, Draw, Window
+
+def clean_ipos(ipos):
+ eul = 0.001
+
+ def isflat(vec):
+ prev_y = vec[0][1]
+ mid_y = vec[1][1]
+ next_y = vec[2][1]
+
+ # flat status for prev and next
+ return abs(mid_y-prev_y) < eul, abs(mid_y-next_y) < eul
+
+
+
+ X=0
+ Y=1
+ PREV=0
+ MID=1
+ NEXT=2
+
+ LEFT = 0
+ RIGHT = 1
+
+ TOT = 0
+ TOTBEZ = 0
+ # for ipo in bpy.data.ipos:
+ for ipo in ipos:
+ if ipo.lib:
+ continue
+ # print ipo
+ for icu in ipo:
+ interp = icu.interpolation
+ extend = icu.extend
+
+ bezierPoints = icu.bezierPoints
+ bezierVecs = [bez.vec for bez in bezierPoints]
+
+ l = len(bezierPoints)
+
+ TOTBEZ += l
+
+ # our aim is to simplify this ipo as much as possible!
+ if interp == IpoCurve.InterpTypes.BEZIER or interp == interp == IpoCurve.InterpTypes.LINEAR:
+ #print "Not yet supported"
+
+ if interp == IpoCurve.InterpTypes.BEZIER:
+ flats = [isflat(bez) for bez in bezierVecs]
+ else:
+ # A bit of a waste but fake the locations for these so they will always be flats
+ # IS better then too much duplicate code.
+ flats = [(True, True)] * l
+ for v in bezierVecs:
+ v[PREV][Y] = v[NEXT][Y] = v[MID][Y]
+
+
+ # remove middle points
+ if l>2:
+ done_nothing = False
+
+ while not done_nothing and len(bezierVecs) > 2:
+ done_nothing = True
+ i = l-2
+
+ while i > 0:
+ #print i
+ #print i, len(bezierVecs)
+ if flats[i]==(True,True) and flats[i-1][RIGHT] and flats[i+1][LEFT]:
+
+ if abs(bezierVecs[i][MID][Y] - bezierVecs[i-1][MID][Y]) < eul and abs(bezierVecs[i][MID][Y] - bezierVecs[i+1][MID][Y]) < eul:
+ done_nothing = False
+
+ del flats[i]
+ del bezierVecs[i]
+ icu.delBezier(i)
+ TOT += 1
+ l-=1
+ i-=1
+
+ # remove endpoints
+ if extend == IpoCurve.ExtendTypes.CONST and len(bezierVecs) > 1:
+ #print l, len(bezierVecs)
+ # start
+
+ while l > 2 and (flats[0][RIGHT] and flats[1][LEFT] and (abs(bezierVecs[0][MID][Y] - bezierVecs[1][MID][Y]) < eul)):
+ print "\tremoving 1 point from start of the curve"
+ del flats[0]
+ del bezierVecs[0]
+ icu.delBezier(0)
+ TOT += 1
+ l-=1
+
+
+ # End
+ while l > 2 and flats[-2][RIGHT] and flats[-1][LEFT] and (abs(bezierVecs[-2][MID][Y] - bezierVecs[-1][MID][Y]) < eul):
+ print "\tremoving 1 point from end of the curve", l
+ del flats[l-1]
+ del bezierVecs[l-1]
+ icu.delBezier(l-1)
+ TOT += 1
+ l-=1
+
+
+
+ if l==2:
+ if isflat( bezierVecs[0] )[RIGHT] and isflat( bezierVecs[1] )[LEFT] and abs(bezierVecs[0][MID][Y] - bezierVecs[1][MID][Y]) < eul:
+ # remove the second point
+ print "\tremoving 1 point from 2 point bez curve"
+ # remove the second point
+ del flats[1]
+ del bezierVecs[1]
+ icu.delBezier(1)
+ TOT+=1
+ l-=1
+
+ # Change to linear for faster evaluation
+ '''
+ if l==1:
+ print 'Linear'
+ icu.interpolation = IpoCurve.InterpTypes.LINEAR
+ '''
+
+
+
+
+ if interp== IpoCurve.InterpTypes.CONST:
+ print "Not yet supported"
+
+ print 'total', TOT, TOTBEZ
+ return TOT, TOTBEZ
+
+def main():
+ ret = Draw.PupMenu('Clean Selected Objects Ipos%t|Object IPO%x1|Object Action%x2|%l|All IPOs (be careful!)%x3')
+
+ sce = bpy.data.scenes.active
+ ipos = []
+
+ if ret == 3:
+ ipos.extend(list(bpy.data.ipos))
+ else:
+ for ob in sce.objects.context:
+ if ret == 1:
+ ipo = ob.ipo
+ if ipo:
+ ipos.append(ipo)
+
+ elif ret == 2:
+ action = ob.action
+ if action:
+ ipos.extend([ipo for ipo in action.getAllChannelIpos().values() if ipo])
+
+
+
+ if not ipos:
+ Draw.PupMenu('Error%t|No ipos found')
+ else:
+ total_removed, total = clean_ipos(ipos)
+ Draw.PupMenu('Done!%t|Removed ' + str(total_removed) + ' of ' + str(total) + ' points')
+
+ Window.RedrawAll()
+
+
+if __name__ == '__main__':
+ main()
Added: branches/soc-2009-aligorith/release/scripts/image_2d_cutout.py
===================================================================
--- branches/soc-2009-aligorith/release/scripts/image_2d_cutout.py (rev 0)
+++ branches/soc-2009-aligorith/release/scripts/image_2d_cutout.py 2009-07-02 02:53:18 UTC (rev 21300)
@@ -0,0 +1,559 @@
+#!BPY
+
+"""
+Name: '2D Cutout Image Importer'
+Blender: 249
+Group: 'Image'
+Tooltip: 'Batch UV Map images to Planes'
+"""
+
+__author__ = "Kevin Morgan (forTe)"
+__url__ = ("Home page, http://gamulabs.freepgs.com")
+__version__ = "1.2.1"
+__bpydoc__ = """\
+This Script will take an image and
+UV map it to a plane sharing the same width to height ratio as the image.
+Import options allow for the image to be a still or sequence type image
+<br><br>
+Imports can be single images or whole directories of images depending on the chosen
+option.
+"""
+
+####################################################
+#Copyright (C) 2008: Kevin Morgan
+####################################################
+#-------------GPL LICENSE BLOCK-------------
+#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 3 of the License, or
+#(at your option) any later version.
+#
+#This program is distributed in the hopes 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, see <http://www.gnu.org/licenses>.
+####################################################
+####################################################
+#V1.0
+#Basic Functionality
+#Published June 28, 2007
+####################################################
+#V1.1
+#Added Support for enabling viewport transparency
+#Added more options to the UI for materials
+#Added Proportionality code (Pixels per unit)
+#Added GPL License Block
+#Published June 29, 2007
+####################################################
+#V1.2
+#Added Support for Copying Existing Materials
+#Import Images as Sequences
+#Refreshed GUI - now with more clutter :(
+#Miscellaneous and Housekeeping
+#Published June 16, 2008
+####################################################
+#V1.2.1
+#Added Extend Texture Mode option at request of a user
+#Published September 24, 2008
+####################################################
+
+import Blender
+from Blender import BGL, Draw, Image, Mesh, Material, Texture, Window
+from Blender.Mathutils import *
+import bpy
+
+# Global Constants
+DIR = 0
+SINGLE = 1
+CUROFFS = 0
+
+# GUI CONSTANTS
+NO_EVT = 0
+SINGLE_IMG = 1
+DIRECTORY_IMG = 2
+CLR_PATH = 3
+CHG_EXT = 4
+EXIT = 5
+DO_SCRIPT = 6
+
+VERSIONSTRING = '1.2.1'
+
+# Note the two parameter dicts could be combined, I just, liked them seperate...
+# GUI Buttons Dict
+GUIPARAMS = {
+ 'Path': Draw.Create(''),
+ 'ImageExt': Draw.Create(''),
+ 'Seq': Draw.Create(0),
+ 'PackImage': Draw.Create(0),
+ 'PPU': Draw.Create(50),
+ 'VPTransp': Draw.Create(1),
+ 'XOff': Draw.Create(0.0),
+ 'YOff': Draw.Create(0.0),
+ 'ZOff': Draw.Create(0.0),
+ 'CopyMat': Draw.Create(0),
+ 'MatId': Draw.Create(0),
+ 'MatCol': Draw.Create(1.0, 0.0, 0.0),
+ 'Ref': Draw.Create(0.8),
+ 'Spec': Draw.Create(0.5),
+ 'Hard': Draw.Create(50),
+ 'Alpha': Draw.Create(1.0),
+ 'ZTransp': Draw.Create(1),
+ 'Shadeless': Draw.Create(0),
+ 'TexChan': Draw.Create(1),
+ 'MPTCol': Draw.Create(1),
+ 'MPTAlpha': Draw.Create(1),
+ 'UseAlpha': Draw.Create(1),
+ 'CalcAlpha': Draw.Create(0),
+ 'ExtendMode': Draw.Create(0),
+ 'AutoRefresh': Draw.Create(0),
+ 'Cyclic': Draw.Create(0),
+ 'Frames': Draw.Create(100),
+ 'Offs': Draw.Create(0),
+ 'StartFr': Draw.Create(1),
+ 'RedrawImp': Draw.Create(0)
+}
+
+# Script Execution Paramaters
+PARAMS = {
+ 'ImagePaths': [], # Path to images to import
+ 'ImportType': SINGLE, # Import a Directory or a Single Image?
+ 'ImageProp': Image.Sources.STILL, # What sources for the image, still or sequence
+ 'PackImage': 0, # Pack the Image(s)?
+ 'PPU': 20, # Pixels Per Blender Unit
+ 'MakeTransp': 1, # Make face transparent in viewport
+
+ 'NewMat': 1, # If true make a new material, otherwise duplicate an existing one, replacing appropriate attributes
+ 'MaterialId': 0, # ID to take from the Materials list upon copy
+ 'Materials': None, # Materials in Scene
+ 'MatProps': {'Col': [1.0, 0.0, 0.0], 'Shadeless': 1, 'Ref': 0.5, 'Spec': 0.5, 'Hard': 200, 'Alpha': 1.0, 'ZTransp': 1},
+
+ 'TexProps': {'UseAlpha': 1, 'CalcAlpha': 0, 'ExtendMode': 0}, # Texture Properties
+ 'TexChannel': 0, # Texture Channel
+ 'TexMapTo': {'Col': 1, 'Alpha': 1}, # Map to Col and/or Alpha
+ 'SeqProps': {'AutoRefresh': 0, 'Cyclic': 0, 'Frames': 100, 'Offs': 0, 'StartFr': 1},
+ 'ObOffset': Vector(1, 0, 0) # Offset by this vector upon creation for multifile import
+}
+
+# Get the Active Scene, of course
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list