Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-07-25 13:09:46 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-07-25 13:09:46 +0400
commitd71455d4c1534a1949f6fb0e6ab0fcb1ceb7c2f8 (patch)
tree1ab3c49dd272c80edf473f5fa4ffd8250ec848bc
parent48c9da843c40ff8a97b462d8539185b662ba1567 (diff)
switch vector multiplication order & some style changes.
-rw-r--r--io_import_scene_dxf.py102
-rw-r--r--io_import_scene_unreal_psk.py90
-rw-r--r--io_mesh_ply/__init__.py37
3 files changed, 165 insertions, 64 deletions
diff --git a/io_import_scene_dxf.py b/io_import_scene_dxf.py
index 6aab7122..0c7abd20 100644
--- a/io_import_scene_dxf.py
+++ b/io_import_scene_dxf.py
@@ -311,7 +311,7 @@ class CArc(CEntity):
ma = getOCS(self.normal)
if ma:
#ma.invert()
- points = [v * ma for v in points]
+ points = [ma * v for v in points]
#print ('arc vn=', vn)
#print ('faces=', len(faces))
return ((points, edges, faces, vn))
@@ -520,7 +520,7 @@ class CCircle(CEntity):
ma = getOCS(self.normal)
if ma:
#ma.invert()
- points = [v * ma for v in points]
+ points = [ma * v for v in points]
#print ('cir vn=', vn)
#print ('faces=',len(faces))
return( (points, edges, faces, vn) )
@@ -626,7 +626,7 @@ class CEllipse(CEntity):
ma = getOCS(self.normal)
if ma:
#ma.invert()
- points = [v * ma for v in points]
+ points = [ma * v for v in points]
return ((points, edges, faces, vn))
#
@@ -810,7 +810,7 @@ class CLWPolyLine(CEntity):
ma = getOCS(self.normal)
if ma:
#ma.invert()
- verts = [v * ma for v in verts]
+ verts = [ma * v for v in verts]
return (verts, edges, [], vn-1)
#
@@ -1018,7 +1018,7 @@ class CPolyLine(CEntity):
if self.normal!=Vector((0,0,1)):
ma = getOCS(self.normal)
if ma:
- verts = [v * ma for v in verts]
+ verts = [ma * v for v in verts]
return((verts, lines, [], vn-1))
#
@@ -1182,7 +1182,7 @@ class CSolid(CEntity):
if self.normal!=Vector((0,0,1)):
ma = getOCS(self.normal)
if ma:
- points = [v * ma for v in points]
+ points = [ma * v for v in points]
return((points, edges, faces, vn))
#
@@ -1315,7 +1315,7 @@ class CTrace(CEntity):
if self.normal!=Vector((0,0,1)):
ma = getOCS(self.normal)
if ma:
- points = [v * ma for v in points]
+ points = [ma * v for v in points]
return ((points, edges, faces, vn))
#
@@ -1425,7 +1425,7 @@ def transform(normal, rotation, obj): #----------------------------------------
if ma_new:
ma = ma_new
ma.resize_4x4()
- o = o * ma
+ o = ma * o
if rotation != 0:
g = radians(-rotation)
@@ -2425,24 +2425,76 @@ class IMPORT_OT_autocad_dxf(bpy.types.Operator):
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
- filepath = StringProperty(name="File Path", description="Filepath used for importing the DXF file", maxlen= 1024, default= "", subtype='FILE_PATH')
-
- new_scene = BoolProperty(name="Replace scene", description="Replace scene", default=toggle&T_NewScene)
- #new_scene = BoolProperty(name="New scene", description="Create new scene", default=toggle&T_NewScene)
- curves = BoolProperty(name="Draw curves", description="Draw entities as curves", default=toggle&T_Curves)
- thic_on = BoolProperty(name="Thic ON", description="Support THICKNESS", default=toggle&T_ThicON)
-
- merge = BoolProperty(name="Remove doubles", description="Merge coincident vertices", default=toggle&T_Merge)
- mergeLimit = FloatProperty(name="Limit", description="Merge limit", default = theMergeLimit*1e4,min=1.0, soft_min=1.0, max=100.0, soft_max=100.0)
-
- draw_one = BoolProperty(name="Merge all", description="Draw all into one mesh-object", default=toggle&T_DrawOne)
- circleResolution = IntProperty(name="Circle resolution", description="Circle/Arc are aproximated will this factor", default = theCircleRes,
- min=4, soft_min=4, max=360, soft_max=360)
+ filepath = StringProperty(
+ name="File Path",
+ description="Filepath used for importing the DXF file",
+ maxlen=1024,
+ subtype='FILE_PATH',
+ )
+ new_scene = BoolProperty(
+ name="Replace scene",
+ description="Replace scene",
+ default=toggle & T_NewScene,
+ )
+ #~ new_scene = BoolProperty(
+ #~ name="New scene",
+ #~ description="Create new scene",
+ #~ default=toggle & T_NewScene,
+ #~ )
+ curves = BoolProperty(
+ name="Draw curves",
+ description="Draw entities as curves",
+ default=toggle & T_Curves,
+ )
+ thic_on = BoolProperty(
+ name="Thic ON",
+ description="Support THICKNESS",
+ default=toggle & T_ThicON,
+ )
+ merge = BoolProperty(
+ name="Remove doubles",
+ description="Merge coincident vertices",
+ default=toggle & T_Merge,
+ )
+ mergeLimit = FloatProperty(
+ name="Limit",
+ description="Merge limit",
+ default=theMergeLimit * 1e4,
+ min=1.0,
+ soft_min=1.0,
+ max=100.0,
+ soft_max=100.0,
+ )
+ draw_one = BoolProperty(
+ name="Merge all",
+ description="Draw all into one mesh-object",
+ default=toggle & T_DrawOne,
+ )
+ circleResolution = IntProperty(
+ name="Circle resolution",
+ description="Circle/Arc are aproximated will this factor",
+ default=theCircleRes,
+ min=4,
+ soft_min=4,
+ max=360,
+ soft_max=360,
+ )
codecs = tripleList(['iso-8859-15', 'utf-8', 'ascii'])
- codec = EnumProperty(name="Codec", description="Codec", items=codecs, default = 'ascii')
-
- debug = BoolProperty(name="Debug", description="Unknown DXF-codes generate errors", default=toggle&T_Debug)
- verbose = BoolProperty(name="Verbose", description="Print debug info", default=toggle&T_Verbose)
+ codec = EnumProperty(name="Codec",
+ description="Codec",
+ items=codecs,
+ default='ascii',
+ )
+ debug = BoolProperty(
+ name="Debug",
+ description="Unknown DXF-codes generate errors",
+ default=toggle & T_Debug,
+ )
+ verbose = BoolProperty(
+ name="Verbose",
+ description="Print debug info",
+ default=toggle & T_Verbose,
+ )
##### DRAW #####
def draw(self, context):
diff --git a/io_import_scene_unreal_psk.py b/io_import_scene_unreal_psk.py
index edc7cd02..fe4b4e75 100644
--- a/io_import_scene_unreal_psk.py
+++ b/io_import_scene_unreal_psk.py
@@ -382,7 +382,7 @@ def pskimport(infile,importmesh,importbone,bDebugLogPSK,importmultiuvtextures):
bpy.context.scene.objects.active = ob_new
#set mode to able to edit the bone
bpy.ops.object.mode_set(mode='EDIT')
-
+
#newbone = ob_new.data.edit_bones.new('test')
#newbone.tail.y = 1
print("creating bone(s)")
@@ -391,8 +391,8 @@ def pskimport(infile,importmesh,importbone,bDebugLogPSK,importmultiuvtextures):
bpy.ops.object.mode_set(mode='EDIT')
newbone = ob_new.data.edit_bones.new(bone.name)
'''
-
-
+
+
armdata = bpy.data.armatures.new(objectname)
ob_new = bpy.data.objects.new(meshname, armdata)
#ob_new = bpy.data.objects.new(meshname, 'ARMATURE')
@@ -405,7 +405,7 @@ def pskimport(infile,importmesh,importbone,bDebugLogPSK,importmultiuvtextures):
bpy.context.scene.objects.active = ob_new
#set mode to able to edit the bone
bpy.ops.object.mode_set(mode='EDIT')
-
+
#newbone = ob_new.data.edit_bones.new('test')
#newbone.tail.y = 1
print("creating bone(s)")
@@ -420,7 +420,7 @@ def pskimport(infile,importmesh,importbone,bDebugLogPSK,importmultiuvtextures):
#note bone location is set in the real space or global not local
bonesize = bpy.types.Scene.unrealbonesize
if bone.name != bone.parent:
-
+
pos_x = bone.bindpos[0]
pos_y = bone.bindpos[1]
pos_z = bone.bindpos[2]
@@ -431,12 +431,12 @@ def pskimport(infile,importmesh,importbone,bDebugLogPSK,importmultiuvtextures):
rotmatrix = bone.bindmat.to_matrix().to_4x4().to_3x3() # XXX, redundant matrix conversion?
newbone.transform(bone.bindmat.to_matrix().to_4x4(),True,True)
- #parent_head = parentbone.head * parentbone.matrix.to_quaternion().inverse()
- #parent_tail = parentbone.tail * parentbone.matrix.to_quaternion().inverse()
+ #parent_head = parentbone.matrix.to_quaternion().inverse() * parentbone.head
+ #parent_tail = parentbone.matrix.to_quaternion().inverse() * parentbone.tail
#location=Vector(pos_x,pos_y,pos_z)
#set_position = (parent_tail - parent_head) + location
#print("tmp head:",set_position)
-
+
#pos_x = set_position.x
#pos_y = set_position.y
#pos_z = set_position.z
@@ -462,7 +462,7 @@ def pskimport(infile,importmesh,importbone,bDebugLogPSK,importmultiuvtextures):
newbone.tail.y = bone.bindpos[1] + bonesize * rotmatrix[1][1]
newbone.tail.z = bone.bindpos[2] + bonesize * rotmatrix[1][2]
#newbone.roll = fixRoll(newbone)
- #print("no parent")
+ #print("no parent")
bpy.context.scene.update()
@@ -549,13 +549,13 @@ def pskimport(infile,importmesh,importbone,bDebugLogPSK,importmultiuvtextures):
me_ob.update_tag()
"""
- Material setup coding.
- First the mesh has to be create first to get the uv texture setup working.
- -Create material(s) list in the psk pack data from the list.(to do list)
- -Append the material to the from create the mesh object.
- -Create Texture(s)
- -fae loop for uv assign and assign material index
-
+ Material setup coding.
+ First the mesh has to be create first to get the uv texture setup working.
+ -Create material(s) list in the psk pack data from the list.(to do list)
+ -Append the material to the from create the mesh object.
+ -Create Texture(s)
+ -fae loop for uv assign and assign material index
+
"""
bpy.ops.object.mode_set(mode='OBJECT')
#===================================================================================================
@@ -566,7 +566,7 @@ def pskimport(infile,importmesh,importbone,bDebugLogPSK,importmultiuvtextures):
print ("-------------------------")
materialname = "pskmat"
materials = []
-
+
for matcount in range(materialcount):
#if texturedata != None:
matdata = bpy.data.materials.new(materialname + str(matcount))
@@ -582,7 +582,7 @@ def pskimport(infile,importmesh,importbone,bDebugLogPSK,importmultiuvtextures):
#matdata.texture_coords = 'UV'
#matdata.active_texture = texturedata
materials.append(matdata)
-
+
for material in materials:
#add material to the mesh list of materials
me_ob.materials.append(material)
@@ -622,7 +622,7 @@ def pskimport(infile,importmesh,importbone,bDebugLogPSK,importmultiuvtextures):
for countm in range(materialcount):
psktexname="psk" + str(countm)
me_ob.uv_textures.new(name=psktexname)
- #psktexname="psk" + str(countm)
+ #psktexname="psk" + str(countm)
#me_ob.uv_textures.new(name=psktexname)
for countm in range(len(me_ob.uv_textures)):
me_ob.update()
@@ -672,8 +672,8 @@ def pskimport(infile,importmesh,importbone,bDebugLogPSK,importmultiuvtextures):
#for face in me_ob.faces:
#print(dir(face))
-
-
+
+
'''
matdata = bpy.data.materials.new(materialname)
#color is 0 - 1 not in 0 - 255
@@ -717,7 +717,7 @@ def pskimport(infile,importmesh,importbone,bDebugLogPSK,importmultiuvtextures):
#print(vgp)
#[vertex id],weight
vgroup.add([vgp[0]], vgp[2], 'ADD')
-
+
#check if there is a material to set to
if len(materials) > 0:
obmesh.active_material = materials[0] #material setup tmp
@@ -744,16 +744,46 @@ class IMPORT_OT_psk(bpy.types.Operator):
bl_label = "Import PSK"
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
-
+
# List of operator properties, the attributes will be assigned
# to the class instance from the operator settings before calling.
- filepath = StringProperty(name="File Path", description="Filepath used for importing the psk file", maxlen= 1024, subtype='FILE_PATH')
- filter_glob = StringProperty(default="*.psk", options={'HIDDEN'})
- importmesh = BoolProperty(name="Mesh", description="Import mesh only. (not yet build.)", default=True)
- importbone = BoolProperty(name="Bones", description="Import bones only. Current not working yet.", default=True)
- importmultiuvtextures = BoolProperty(name="Single UV Texture(s)", description="Single or Multi uv textures.", default=True)
- bDebugLogPSK = BoolProperty(name="Debug Log.txt", description="Log the output of raw format. It will save in current file dir. Note this just for testing.", default=False)
- unrealbonesize = FloatProperty( name="Bone Length", description="Bone Length from head to tail distance.", default=1,min=0.001,max=1000)
+ filepath = StringProperty(
+ name="File Path",
+ description="Filepath used for importing the psk file",
+ maxlen= 1024,
+ subtype='FILE_PATH',
+ )
+ filter_glob = StringProperty(
+ default="*.psk",
+ options={'HIDDEN'},
+ )
+ importmesh = BoolProperty(
+ name="Mesh",
+ description="Import mesh only. (not yet build.)",
+ default=True,
+ )
+ importbone = BoolProperty(
+ name="Bones",
+ description="Import bones only. Current not working yet.",
+ default=True,
+ )
+ importmultiuvtextures = BoolProperty(
+ name="Single UV Texture(s)",
+ description="Single or Multi uv textures.",
+ default=True,
+ )
+ bDebugLogPSK = BoolProperty(
+ name="Debug Log.txt",
+ description="Log the output of raw format. It will save in current file dir. Note this just for testing.",
+ default=False,
+ )
+ unrealbonesize = FloatProperty(
+ name="Bone Length",
+ description="Bone Length from head to tail distance.",
+ default=1,
+ min=0.001,
+ max=1000,
+ )
def execute(self, context):
bpy.types.Scene.unrealbonesize = self.unrealbonesize
diff --git a/io_mesh_ply/__init__.py b/io_mesh_ply/__init__.py
index e8384923..50edb885 100644
--- a/io_mesh_ply/__init__.py
+++ b/io_mesh_ply/__init__.py
@@ -16,7 +16,7 @@
#
# ##### END GPL LICENSE BLOCK #####
-# <pep8 compliant>
+# <pep8-80 compliant>
bl_info = {
"name": "Stanford PLY format",
@@ -32,7 +32,8 @@ bl_info = {
"support": 'OFFICIAL',
"category": "Import-Export"}
-# To support reload properly, try to access a package var, if it's there, reload everything
+# To support reload properly, try to access a package var,
+# if it's there, reload everything
if "bpy" in locals():
import imp
if "export_ply" in locals():
@@ -63,7 +64,8 @@ class ImportPLY(bpy.types.Operator, ImportHelper):
filter_glob = StringProperty(default="*.ply", options={'HIDDEN'})
def execute(self, context):
- paths = [os.path.join(self.directory, name.name) for name in self.files]
+ paths = [os.path.join(self.directory, name.name)
+ for name in self.files]
if not paths:
paths.append(self.filepath)
@@ -76,17 +78,33 @@ class ImportPLY(bpy.types.Operator, ImportHelper):
class ExportPLY(bpy.types.Operator, ExportHelper):
- '''Export a single object as a stanford PLY with normals, colours and texture coordinates.'''
+ '''Export a single object as a stanford PLY with normals, ''' \
+ '''colours and texture coordinates.'''
bl_idname = "export_mesh.ply"
bl_label = "Export PLY"
filename_ext = ".ply"
filter_glob = StringProperty(default="*.ply", options={'HIDDEN'})
- use_modifiers = BoolProperty(name="Apply Modifiers", description="Apply Modifiers to the exported mesh", default=True)
- use_normals = BoolProperty(name="Normals", description="Export Normals for smooth and hard shaded faces", default=True)
- use_uv_coords = BoolProperty(name="UVs", description="Exort the active UV layer", default=True)
- use_colors = BoolProperty(name="Vertex Colors", description="Exort the active vertex color layer", default=True)
+ use_modifiers = BoolProperty(
+ name="Apply Modifiers",
+ description="Apply Modifiers to the exported mesh",
+ default=True,
+ )
+ use_normals = BoolProperty(
+ name="Normals",
+ description="Export Normals for smooth and hard shaded faces",
+ default=True,
+ )
+ use_uv_coords = BoolProperty(
+ name="UVs",
+ description="Export the active UV layer",
+ default=True,
+ )
+ use_colors = BoolProperty(
+ name="Vertex Colors",
+ description="Exort the active vertex color layer",
+ default=True)
@classmethod
def poll(cls, context):
@@ -96,7 +114,8 @@ class ExportPLY(bpy.types.Operator, ExportHelper):
filepath = self.filepath
filepath = bpy.path.ensure_ext(filepath, self.filename_ext)
from . import export_ply
- return export_ply.save(self, context, **self.as_keywords(ignore=("check_existing", "filter_glob")))
+ keywords = **self.as_keywords(ignore=("check_existing", "filter_glob"))
+ return export_ply.save(self, context, keywords)
def draw(self, context):
layout = self.layout