[Bf-committers] [Bf-blender-cvs] SVN commit: /data/svn/bf-blender [13999] trunk/blender/release/scripts/ flt_toolbar.py: -> DOF from active tool

Joe Eagar joeedh at gmail.com
Sun Mar 9 00:38:57 CET 2008


Eh I thought 1 blender unit was supposed to be 1 meter?

Joe

Geoffrey Bantle wrote:
> Revision: 13999
>           http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=13999
> Author:   briggs
> Date:     2008-03-07 08:23:55 +0100 (Fri, 07 Mar 2008)
>
> Log Message:
> -----------
> -> DOF from active tool
>
> Creates (or modifies) a DOF node based upon the active object.
> Requires two selected objects, the non-active one will get its
> DOF coordinate system from the active selected object. This assumes
> that 1 Blender unit == 10 meters
>
> Modified Paths:
> --------------
>     trunk/blender/release/scripts/flt_toolbar.py
>
> Modified: trunk/blender/release/scripts/flt_toolbar.py
> ===================================================================
> --- trunk/blender/release/scripts/flt_toolbar.py	2008-03-07 03:24:23 UTC (rev 13998)
> +++ trunk/blender/release/scripts/flt_toolbar.py	2008-03-07 07:23:55 UTC (rev 13999)
> @@ -1,606 +1,654 @@
> -#!BPY
> -
> -"""
> -Name: 'FLT Toolbar'
> -Blender: 240
> -Group: 'Misc'
> -Tooltip: 'Tools for working with FLT databases'
> -"""
> -
> -__author__ = "Geoffrey Bantle"
> -__version__ = "1.0 11/21/07"
> -__email__ = ('scripts', 'Author, ')
> -__url__ = ('blender', 'elysiun')
> -
> -__bpydoc__ ="""\
> -This script provides tools for working with OpenFlight databases in Blender. OpenFlight is a
> -registered trademark of MultiGen-Paradigm, Inc.
> -
> -Feature overview and more availible at:
> -http://wiki.blender.org/index.php/Scripts/Manual/FLTools
> -"""
> -
> -# --------------------------------------------------------------------------
> -# flt_palettemanager.py version 0.1 2005/04/08
> -# --------------------------------------------------------------------------
> -# ***** BEGIN GPL LICENSE BLOCK *****
> -#
> -# Copyright (C) 2007: 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,
> -# Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
> -#
> -# ***** END GPL LICENCE BLOCK *****
> -# --------------------------------------------------------------------------
> -
> -import Blender.Draw as Draw
> -from Blender.BGL import *
> -import Blender
> -import flt_properties
> -reload(flt_properties)
> -from flt_properties import *
> -
> -xrefprefix = ""
> -xrefstack = list()
> -vofsstack = list()
> -vquatstack = list()
> -prop_w = 256
> -prop_h = 256
> -
> -
> -#event codes
> -evcode = {
> -	"XREF_MAKE" : 100,
> -	"XREF_EDIT" : 101,
> -	"XREF_FILE" : 102,
> -	"XREF_PICK" : 103,
> -	"XREF_SELECT" : 104,
> -        "XREF_POP" : 105,
> -        "XREF_PREFIX" : 106,
> -	"FACE_NAME" : 200,
> -	"FACE_MAKESUB" : 201,
> -	"FACE_KILLSUB" : 202,
> -	"FACE_SELSUB" : 203,
> -	"SCENE_UPDATE" : 303,
> -	"IDPROP_COPY" : 501,
> -	"IDPROP_KILL" : 502,
> -	"CLIGHT_MAKE" : 700
> -}
> -
> -XREF_PREFIX = None
> -XREF_MAKE = None
> -XREF_EDIT = None
> -XREF_SELECT = None
> -XREF_POP = None
> -FACE_MAKESUB = None
> -FACE_SELSUB = None
> -FACE_KILLSUB = None
> -IDPROP_KILL = None
> -IDPROP_COPY = None
> -SCENE_UPDATE = None
> -CLIGHT_MAKE = None
> -
> -def update_state():
> -	state = dict()
> -	state["activeScene"] = Blender.Scene.getCurrent()
> -	state["activeObject"] = state["activeScene"].getActiveObject()
> -	if state["activeObject"] and not state["activeObject"].sel:
> -		state["activeObject"] = None
> -	state["activeMesh"] = None
> -	if state["activeObject"] and state["activeObject"].type == 'Mesh':
> -		state["activeMesh"] = state["activeObject"].getData(mesh=True)
> -	
> -	state["activeFace"] = None
> -	if state["activeMesh"]:
> -		if state["activeMesh"].faceUV and state["activeMesh"].activeFace != None:
> -			state["activeFace"] = state["activeMesh"].faces[state["activeMesh"].activeFace]
> -		
> -	#update editmode
> -	state["editmode"]	= Blender.Window.EditMode()
> -
> -	return state
> -def pack_face_index(index, intensity):
> -	return ((127*intensity)+(128*index))
> -def unpack_face_index(face_index):
> -	index = face_index / 128
> -	intensity = float(face_index - 128.0 * index) / 127.0
> -	return(index,intensity)
> -	
> -def idprops_append(object, typecode, props):
> -	object.properties["FLT"] = dict()
> -	object.properties["FLT"]['type'] = typecode 
> -	for prop in props:
> -		object.properties["FLT"][prop] = props[prop]
> -	object.properties["FLT"]['3t8!id'] = object.name
> -
> -def idprops_kill(object):
> -	state = update_state()
> -	if object and object.properties.has_key('FLT'):
> -		object.properties.pop('FLT')
> -
> -def idprops_copy(source):
> -	state = update_state()
> -	if source.properties.has_key('FLT'):
> -		for object in state["activeScene"].objects:
> -			if object.sel and object != source and (state["activeScene"].Layers & object.Layers):
> -				idprops_kill(object)
> -				object.properties['FLT'] = dict()
> -				for key in source.properties['FLT']:
> -					object.properties['FLT'][key] = source.properties['FLT'][key]
> -
> -def update_all():
> -	state = update_state()
> -	#update the baked FLT colors for all meshes.
> -	for object in state["activeScene"].objects:
> -		if object.type == "Mesh":
> -			mesh = object.getData(mesh=True)
> -			if 'FLT_COL' in mesh.faces.properties:
> -				mesh.activeColorLayer = "FLT_Fcol"
> -				for face in mesh.faces:
> -					(index,intensity) = unpack_face_index(face.getProperty('FLT_COL'))
> -					color = struct.unpack('>BBBB',struct.pack('>I',state["colors"][index]))
> -					#update the vertex colors for this face
> -					for col in face.col:
> -						col.r = int(color[0] * intensity)
> -						col.g = int(color[1] * intensity)
> -						col.b = int(color[2] * intensity)
> -						col.a = 255
> -
> -
> -#Change this to find the deep parent
> -def xref_create():
> -	global xrefprefix
> -	global xrefstack
> -	global vofsstack
> -	global vquatstack
> -	global prop_w
> -	global prop_h
> -	
> -	state = update_state()
> -	
> -	def findchildren(object):
> -		children = list()
> -		for candidate in state["activeScene"].objects:
> -			if candidate.parent == object:
> -				children.append(candidate)
> -		retlist = list(children)
> -		for child in children:
> -			retlist = retlist + findchildren(child)
> -		return retlist
> -		
> -	actObject = state["activeObject"]
> -        if actObject and xrefprefix:
> -                scenenames = list()
> -                for scene in Blender.Scene.Get():
> -                        scenenames.append(scene.name)
> -
> -                if xrefprefix in scenenames:
> -                        #build a unique name for the xref...
> -                        suffix = 1
> -                        found = False
> -                        while not found:
> -                                candidate = xrefprefix + str(suffix)
> -                                if not candidate in scenenames:
> -                                        xrefname = candidate
> -                                        found = True
> -                                suffix+=1
> -                else:
> -                        xrefname = xrefprefix
> -                #create our XRef node
> -                xnode = state["activeScene"].objects.new('Empty')
> -                xnode.name = 'X:' + xrefname
> -                xnode.properties['FLT'] = dict()
> -                for prop in FLTXRef:
> -                        xnode.properties['FLT'][prop] = FLTXRef[prop]
> -                xnode.properties['FLT']['3t200!filename'] = xrefname + '.flt'
> -		xnode.properties['FLT']['type'] = 63
> -		xnode.enableDupGroup = True
> -		xnode.DupGroup = Blender.Group.New(xrefname) #this is dangerous... be careful!
> -
> -                #copy rot and loc of actObject
> -                xnode.setLocation(actObject.getLocation())
> -                xnode.setEuler(actObject.getEuler())         
> -                
> -                #build the new scene
> -		xrefscene = Blender.Scene.New(xrefname)
> -		xrefscene.properties['FLT'] = dict()
> -		xrefscene.properties['FLT']['Filename'] = xrefname
> -		xrefscene.properties['FLT']['Main'] = 0
> -
> -                #find the children of actObject so that we can add them to the group
> -		linkobjects = findchildren(actObject)
> -                linkobjects.append(actObject)
> -		for object in linkobjects:
> -                        xrefscene.objects.link(object)
> -                        state["activeScene"].objects.unlink(object)
> -                        xnode.DupGroup.objects.link(object)
> -                #clear rotation of actObject and location
> -                actObject.setLocation(0.0,0.0,0.0)
> -                actObject.setEuler(0.0,0.0,0.0)
> -
> -                xrefscene.update(1)
> -                state["activeScene"].update(1)
> -
> -def xref_select():
> -	state = update_state()
> -	candidates = list()
> -	scenelist = [scene.name for scene in Blender.Scene.Get()]
> -	for object in state["activeScene"].objects:
> -		if object.type == 'Empty' and object.enableDupGroup == True and object.DupGroup:
> -			candidates.append(object)
> -		
> -	for object in candidates:
> -		if object.DupGroup.name in scenelist:
> -			object.sel = 1
> -
> -def xref_edit():
> -	global xrefprefix
> -	global xrefstack
> -	global vofsstack
> -	global vquatstack
> -	global prop_w
> -	global prop_h
> -	
> -	state = update_state()
> -
> -	actObject = state["activeObject"]
> -
> -	if actObject and actObject.type == 'Empty' and actObject.DupGroup:
> -#		if actObject.properties.has_key('FLT') and actObject.properties['FLT']['type'] == 63:
> -		for FLTscene in Blender.Scene.Get():
> -			if FLTscene.properties.has_key('FLT') and FLTscene.name == actObject.DupGroup.name:
> -				actObject.sel = 0
> -				xrefstack.append(state["activeScene"])
> -				vofsstack.append(Blender.Window.GetViewOffset())
> -				vquatstack.append(Blender.Window.GetViewQuat())
> -				FLTscene.makeCurrent()
> -				Blender.Window.SetViewOffset(0.0,0.0,0.0)
> -
> -def xref_finish():
> -	global xrefprefix
> -	global xrefstack
> -	global vofsstack
> -	global vquatstack
> -	global prop_w
> -	global prop_h
> -	
> -	state = update_state() 
> -        if xrefstack:
> -                scene = xrefstack.pop()
> -                Blender.Window.SetViewQuat(vquatstack.pop())
> -                Blender.Window.SetViewOffset(vofsstack.pop())
> -                scene.makeCurrent()
> -                
> -
> -def sortSub(a,b):
> -	aindex = a.getProperty("FLT_ORIGINDEX")
> -	bindex = b.getProperty("FLT_ORIGINDEX")
> -	
> -	if aindex > bindex:
> -		return 1
> -	elif aindex < bindex:
> -		return -1
> -	return 0
> -
> -def subface_make():
> -	global xrefprefix
> -	global xrefstack
> -	global vofsstack
> -	global vquatstack
> -	global prop_w
> -	global prop_h
> -	
> -	editmode = 0
> -	if Blender.Window.EditMode():
> -		Blender.Window.EditMode(0)
> -		editmode = 1
> -
> -	state = update_state()
> -	
> -	actmesh = state["activeMesh"]
> -	activeFace = state["activeFace"]
> -	if actmesh:
> -		if not "FLT_ORIGINDEX" in actmesh.faces.properties:
> -			actmesh.faces.addPropertyLayer("FLT_ORIGINDEX",Blender.Mesh.PropertyTypes["INT"])
> -			for i, face in enumerate(actmesh.faces):
> -				face.setProperty("FLT_ORIGINDEX",i)
> -		if not "FLT_SFLEVEL" in actmesh.faces.properties:
> -			actmesh.faces.addPropertyLayer("FLT_SFLEVEL",Blender.Mesh.PropertyTypes["INT"])
>
> @@ Diff output truncated at 10240 characters. @@
>
> _______________________________________________
> Bf-blender-cvs mailing list
> Bf-blender-cvs at blender.org
> http://lists.blender.org/mailman/listinfo/bf-blender-cvs
>
>   



More information about the Bf-committers mailing list