Skip to content
Snippets Groups Projects
Commit aff35474 authored by Campbell Barton's avatar Campbell Barton
Browse files

various style edits, no functional changes

parent 77774b1f
No related branches found
No related tags found
No related merge requests found
...@@ -25,19 +25,19 @@ bl_info = { ...@@ -25,19 +25,19 @@ bl_info = {
"location": "File > Import > GIMP Image to Scene(.xcf/.xjt)", "location": "File > Import > GIMP Image to Scene(.xcf/.xjt)",
"description": "Imports GIMP multilayer image files as a series of multiple planes", "description": "Imports GIMP multilayer image files as a series of multiple planes",
"warning": "XCF import requires xcftools installed", "warning": "XCF import requires xcftools installed",
"wiki_url": "http://wiki.blender.org/index.php/Extensions:2.5/Py/"\ "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.5/Py/"
"Scripts/Import-Export/GIMPImageToScene", "Scripts/Import-Export/GIMPImageToScene",
"tracker_url": "http://projects.blender.org/tracker/index.php?"\ "tracker_url": "http://projects.blender.org/tracker/index.php?"
"func=detail&aid=25136", "func=detail&aid=25136",
"category": "Import-Export"} "category": "Import-Export"}
""" """
This script imports GIMP layered image files into 3D Scenes (.xcf, .xjt) This script imports GIMP layered image files into 3D Scenes (.xcf, .xjt)
""" """
def main(File, Path, LayerViewers, MixerViewers, LayerOffset,\ def main(File, Path, LayerViewers, MixerViewers, LayerOffset,
LayerScale, OpacityMode, PremulAlpha, ShadelessMats,\ LayerScale, OpacityMode, PremulAlpha, ShadelessMats,
SetCamera, SetupCompo, GroupUntagged, Ext): SetCamera, SetupCompo, GroupUntagged, Ext):
#------------------------------------------------- #-------------------------------------------------
...@@ -147,8 +147,8 @@ def main(File, Path, LayerViewers, MixerViewers, LayerOffset,\ ...@@ -147,8 +147,8 @@ def main(File, Path, LayerViewers, MixerViewers, LayerOffset,\
os.rename(PathSaveRaw+imageFile, PathSaveRaw+NameShort+'.jpg') os.rename(PathSaveRaw+imageFile, PathSaveRaw+NameShort+'.jpg')
if HasAlpha: os.rename(PathSaveRaw+imageFileAlpha, PathSaveRaw+NameShort+'_A'+'.jpg') if HasAlpha: os.rename(PathSaveRaw+imageFileAlpha, PathSaveRaw+NameShort+'_A'+'.jpg')
IMGs.append({'LayerMode':md, 'LayerOpacity':op,\ IMGs.append({'LayerMode':md, 'LayerOpacity':op,
'LayerName':n, 'LayerNameShort':NameShort,\ 'LayerName':n, 'LayerNameShort':NameShort,
'RenderLayer':RenderLayer, 'LayerCoords':[ow, oh, ox, oy], 'HasAlpha':HasAlpha}) 'RenderLayer':RenderLayer, 'LayerCoords':[ow, oh, ox, oy], 'HasAlpha':HasAlpha})
else: # Ext == '.xcf': else: # Ext == '.xcf':
...@@ -194,14 +194,14 @@ def main(File, Path, LayerViewers, MixerViewers, LayerOffset,\ ...@@ -194,14 +194,14 @@ def main(File, Path, LayerViewers, MixerViewers, LayerOffset,\
Mode = LineThree[:Slash] Mode = LineThree[:Slash]
Opacity = float(LineThree[Slash+1:LineThree.find('%')])*.01 Opacity = float(LineThree[Slash+1:LineThree.find('%')])*.01
IMGs.append ({\ IMGs.append ({
'LayerMode':Mode,\ 'LayerMode': Mode,
'LayerOpacity':Opacity,\ 'LayerOpacity': Opacity,
'LayerName':Line[4].rstrip(),\ 'LayerName': Line[4].rstrip(),
'LayerNameShort':NameShort,\ 'LayerNameShort': NameShort,
'LayerCoords':list(map(int, Line[1].replace('x', ' ').replace('+', ' +').replace('-', ' -').split())),\ 'LayerCoords': list(map(int, Line[1].replace('x', ' ').replace('+', ' +').replace('-', ' -').split())),
'RenderLayer':RenderLayer,\ 'RenderLayer': RenderLayer,
'HasAlpha':True,\ 'HasAlpha': True,
}) })
elif Line.startswith('Version'): elif Line.startswith('Version'):
ResX, ResY = map (int, Line.split()[2].split('x')) ResX, ResY = map (int, Line.split()[2].split('x'))
...@@ -213,8 +213,8 @@ def main(File, Path, LayerViewers, MixerViewers, LayerOffset,\ ...@@ -213,8 +213,8 @@ def main(File, Path, LayerViewers, MixerViewers, LayerOffset,\
else: else:
Opacity = ' --percent 100' Opacity = ' --percent 100'
for Layer in IMGs: for Layer in IMGs:
CMD = '%s -C %s%s -o %s%s.png "%s"%s' %\ CMD = ('%s -C %s%s -o %s%s.png "%s"%s' %
(XCF2PNG, Path, File, PathSave, Layer['LayerName'].replace(' ', '_'), Layer['LayerName'], Opacity) (XCF2PNG, Path, File, PathSave, Layer['LayerName'].replace(' ', '_'), Layer['LayerName'], Opacity))
os.system(CMD) os.system(CMD)
#------------------------------------------------- #-------------------------------------------------
...@@ -286,13 +286,12 @@ def main(File, Path, LayerViewers, MixerViewers, LayerOffset,\ ...@@ -286,13 +286,12 @@ def main(File, Path, LayerViewers, MixerViewers, LayerOffset,\
LayerList.append([RenderLayer, LayerMode, LayerOpacity]) LayerList.append([RenderLayer, LayerMode, LayerOpacity])
LayerNum += 1 LayerNum += 1
# Object # Object
bpy.ops.mesh.primitive_plane_add(\ bpy.ops.mesh.primitive_plane_add(view_align=False,
view_align=False,\ enter_editmode=False,
enter_editmode=False,\ rotation=(0, 0, pi))
rotation=(0, 0, pi))
bpy.ops.object.transform_apply(location=False, rotation=True, scale=False) bpy.ops.object.transform_apply(location=False, rotation=True, scale=False)
...@@ -301,8 +300,8 @@ def main(File, Path, LayerViewers, MixerViewers, LayerOffset,\ ...@@ -301,8 +300,8 @@ def main(File, Path, LayerViewers, MixerViewers, LayerOffset,\
if SetupCompo: if SetupCompo:
Active.layers = LayerFlags[RenderLayer] Active.layers = LayerFlags[RenderLayer]
Active.location = (\ Active.location = (
(float(Coords[2])-(ResX*0.5))*LayerScale,\ (float(Coords[2])-(ResX*0.5))*LayerScale,
(-float(Coords[3])+(ResY*0.5))*LayerScale, Z) (-float(Coords[3])+(ResY*0.5))*LayerScale, Z)
for Vert in Active.data.vertices: for Vert in Active.data.vertices:
...@@ -420,16 +419,15 @@ def main(File, Path, LayerViewers, MixerViewers, LayerOffset,\ ...@@ -420,16 +419,15 @@ def main(File, Path, LayerViewers, MixerViewers, LayerOffset,\
LayerList = [] LayerList = []
for Layer in IMGs: for Layer in IMGs:
Make3DLayer(\ Make3DLayer(Layer['LayerName'].replace(' ', '_'),
Layer['LayerName'].replace(' ', '_'),\ Layer['LayerNameShort'].replace(' ', '_'),
Layer['LayerNameShort'].replace(' ', '_'),\ Z,
Z,\ Layer['LayerCoords'],
Layer['LayerCoords'],\ Layer['RenderLayer'],
Layer['RenderLayer'],\ Layer['LayerMode'],
Layer['LayerMode'],\ Layer['LayerOpacity'],
Layer['LayerOpacity'],\ Layer['HasAlpha'],
Layer['HasAlpha'],\ )
)
Z -= LayerOffset Z -= LayerOffset
...@@ -647,9 +645,9 @@ class GIMPImageToScene(bpy.types.Operator): ...@@ -647,9 +645,9 @@ class GIMPImageToScene(bpy.types.Operator):
# Call Main Function # Call Main Function
if Ext: if Ext:
main(filename, directory, LayerViewers, MixerViewers, LayerOffset,\ main(filename, directory, LayerViewers, MixerViewers, LayerOffset,
LayerScale, OpacityMode, PremulAlpha, ShadelessMats,\ LayerScale, OpacityMode, PremulAlpha, ShadelessMats,
SetCamera, SetupCompo, GroupUntagged, Ext) SetCamera, SetupCompo, GroupUntagged, Ext)
else: else:
self.report({'ERROR'},"Selected file wasn't valid, try .xcf or .xjt") self.report({'ERROR'},"Selected file wasn't valid, try .xcf or .xjt")
......
...@@ -23,17 +23,25 @@ bl_info = { ...@@ -23,17 +23,25 @@ bl_info = {
"blender": (2, 5, 7), "blender": (2, 5, 7),
"api": 35622, "api": 35622,
"location": "File > Import > Images as Planes", "location": "File > Import > Images as Planes",
"description": "Imports images and creates planes with the appropriate aspect ratio. "\ "description": "Imports images and creates planes with the appropriate "
"The images are mapped to the planes.", "aspect ratio. The images are mapped to the planes.",
"warning": "", "warning": "",
"wiki_url": "http://wiki.blender.org/index.php/Extensions:2.5/Py/"\ "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.5/Py/"
"Scripts/Add_Mesh/Planes_from_Images", "Scripts/Add_Mesh/Planes_from_Images",
"tracker_url": "https://projects.blender.org/tracker/index.php?"\ "tracker_url": "https://projects.blender.org/tracker/index.php?"
"func=detail&aid=21751", "func=detail&aid=21751",
"category": "Import-Export"} "category": "Import-Export"}
import bpy, os, mathutils import bpy
from bpy.props import * import mathutils
import os
from bpy.props import (BoolProperty,
EnumProperty,
IntProperty,
FloatProperty,
)
from add_utils import * from add_utils import *
from bpy_extras.io_utils import ImportHelper from bpy_extras.io_utils import ImportHelper
from bpy_extras.image_utils import load_image from bpy_extras.image_utils import load_image
...@@ -54,7 +62,7 @@ EXT_LIST = { ...@@ -54,7 +62,7 @@ EXT_LIST = {
'cin': ['cin'], 'cin': ['cin'],
'dpx': ['dpx'], 'dpx': ['dpx'],
'psd': ['psd']} 'psd': ['psd']}
EXT_VALS = [val for val in EXT_LIST.values()] EXT_VALS = list(EXT_LIST.values())
EXTENSIONS = [] EXTENSIONS = []
for i in EXT_VALS: for i in EXT_VALS:
EXTENSIONS.extend(i) EXTENSIONS.extend(i)
...@@ -189,12 +197,12 @@ def align_planes(self, planes): ...@@ -189,12 +197,12 @@ def align_planes(self, planes):
gap = self.align_offset gap = self.align_offset
offset = 0 offset = 0
for i, plane in enumerate(planes): for i, plane in enumerate(planes):
offset += (plane.dimensions.x / 2) + gap offset += (plane.dimensions.x / 2.0) + gap
if i == 0: continue if i == 0: continue
move_local = mathutils.Vector((offset, 0, 0)) move_local = mathutils.Vector((offset, 0, 0))
move_world = plane.location + move_local * plane.matrix_world.inverted() move_world = plane.location + move_local * plane.matrix_world.inverted()
plane.location += move_world plane.location += move_world
offset += (plane.dimensions.x / 2) offset += (plane.dimensions.x / 2.0)
##### MAIN ##### ##### MAIN #####
def import_images(self, context): def import_images(self, context):
...@@ -363,7 +371,9 @@ class IMPORT_OT_image_to_plane(bpy.types.Operator, ImportHelper, AddObjectHelper ...@@ -363,7 +371,9 @@ class IMPORT_OT_image_to_plane(bpy.types.Operator, ImportHelper, AddObjectHelper
##### REGISTER ##### ##### REGISTER #####
def import_images_button(self, context): def import_images_button(self, context):
self.layout.operator(IMPORT_OT_image_to_plane.bl_idname, text="Images as Planes", icon='PLUGIN') self.layout.operator(IMPORT_OT_image_to_plane.bl_idname,
text="Images as Planes",
icon='PLUGIN')
def register(): def register():
bpy.utils.register_module(__name__) bpy.utils.register_module(__name__)
......
...@@ -26,12 +26,15 @@ bl_info = { ...@@ -26,12 +26,15 @@ bl_info = {
"location": "File > Import-Export", "location": "File > Import-Export",
"description": "Import-Export PLY mesh data withs UV's and vertex colors", "description": "Import-Export PLY mesh data withs UV's and vertex colors",
"warning": "", "warning": "",
"wiki_url": "http://wiki.blender.org/index.php/Extensions:2.5/Py/"\ "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.5/Py/"
"Scripts/Import-Export/Stanford_PLY", "Scripts/Import-Export/Stanford_PLY",
"tracker_url": "", "tracker_url": "",
"support": 'OFFICIAL', "support": 'OFFICIAL',
"category": "Import-Export"} "category": "Import-Export"}
# Copyright (C) 2004, 2005: Bruce Merry, bmerry@cs.uct.ac.za
# Contributors: Bruce Merry, Campbell Barton
# To support reload properly, try to access a package var, # To support reload properly, try to access a package var,
# if it's there, reload everything # if it's there, reload everything
if "bpy" in locals(): if "bpy" in locals():
......
...@@ -18,9 +18,6 @@ ...@@ -18,9 +18,6 @@
# <pep8-80 compliant> # <pep8-80 compliant>
# Copyright (C) 2004, 2005: Bruce Merry, bmerry@cs.uct.ac.za
# Contributors: Bruce Merry, Campbell Barton
""" """
This script exports Stanford PLY files from Blender. It supports normals, This script exports Stanford PLY files from Blender. It supports normals,
colours, and texture coordinates per face or per vertex. colours, and texture coordinates per face or per vertex.
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
# #
# ##### END GPL LICENSE BLOCK ##### # ##### END GPL LICENSE BLOCK #####
# <pep8 compliant> # <pep8-80 compliant>
bl_info = { bl_info = {
...@@ -28,10 +28,10 @@ bl_info = { ...@@ -28,10 +28,10 @@ bl_info = {
"location": "File > Import-Export > Raw Faces (.raw) ", "location": "File > Import-Export > Raw Faces (.raw) ",
"description": "Import-Export Raw Faces", "description": "Import-Export Raw Faces",
"warning": "", "warning": "",
"wiki_url": "http://wiki.blender.org/index.php/Extensions:2.5/Py/"\ "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.5/Py/"
"Scripts/Import-Export/Raw_Mesh_IO", "Scripts/Import-Export/Raw_Mesh_IO",
"tracker_url": "https://projects.blender.org/tracker/index.php?"\ "tracker_url": "https://projects.blender.org/tracker/index.php?"
"func=detail&aid=25692", "func=detail&aid=25692",
"category": "Import-Export"} "category": "Import-Export"}
if "bpy" in locals(): if "bpy" in locals():
......
...@@ -16,11 +16,9 @@ ...@@ -16,11 +16,9 @@
# #
# ##### END GPL LICENSE BLOCK ##### # ##### END GPL LICENSE BLOCK #####
# <pep8 compliant> # <pep8-80 compliant>
__author__ = ["Aurel Wildfellner"] """
__version__ = '0.2'
__bpydoc__ = """\
This script exports a Mesh to a RAW triangle format file. This script exports a Mesh to a RAW triangle format file.
The raw triangle format is very simple; it has no verts or faces lists. The raw triangle format is very simple; it has no verts or faces lists.
...@@ -40,7 +38,7 @@ import bpy ...@@ -40,7 +38,7 @@ import bpy
def faceToTriangles(face): def faceToTriangles(face):
triangles = [] triangles = []
if (len(face) == 4): if len(face) == 4:
triangles.append([face[0], face[1], face[2]]) triangles.append([face[0], face[1], face[2]])
triangles.append([face[2], face[3], face[0]]) triangles.append([face[2], face[3], face[0]])
else: else:
......
...@@ -16,11 +16,9 @@ ...@@ -16,11 +16,9 @@
# #
# ##### END GPL LICENSE BLOCK ##### # ##### END GPL LICENSE BLOCK #####
# <pep8 compliant> # <pep8-80 compliant>
__author__ = ["Anthony D'Agostino (Scorpius)", "Aurel Wildfellner"] """
__version__ = '0.2'
__bpydoc__ = """\
This script imports Raw Triangle File format files to Blender. This script imports Raw Triangle File format files to Blender.
The raw triangle format is very simple; it has no verts or faces lists. The raw triangle format is very simple; it has no verts or faces lists.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment