Skip to content
Snippets Groups Projects
Commit cc9f663c authored by Bastien Montagne's avatar Bastien Montagne
Browse files

Small changes to images as planes:

*Use absolute as default size mode (dpi with BU is not that nice).
*Use default plane primitive instead of creating our own square (this way we can be sure things like verts order will always match those of default plane!), request from Christopher Barrett in tracker.
parent 79d1a85d
No related branches found
No related tags found
No related merge requests found
......@@ -19,7 +19,7 @@
bl_info = {
"name": "Import Images as Planes",
"author": "Florian Meyer (tstscr), mont29, matali",
"version": (1, 8),
"version": (1, 9),
"blender": (2, 66, 4),
"location": "File > Import > Images as Planes or Add > Mesh > Images as Planes",
"description": "Imports images and creates planes with the appropriate aspect ratio. "
......@@ -214,7 +214,7 @@ class IMPORT_OT_image_to_plane(Operator, AddObjectHelper):
('DPI', "Dpi", "Use definition of the image as dots per inch"),
('DPBU', "Dots/BU", "Use definition of the image as dots per Blender Unit"),
)
size_mode = EnumProperty(name="Size Mode", default='DPI', items=_size_modes,
size_mode = EnumProperty(name="Size Mode", default='ABSOLUTE', items=_size_modes,
description="How the size of the plane is computed")
height = FloatProperty(name="Height", description="Height of the created plane",
......@@ -369,29 +369,24 @@ class IMPORT_OT_image_to_plane(Operator, AddObjectHelper):
px = py = 1
if self.size_mode == 'ABSOLUTE':
y = self.height / 2
y = self.height
x = px / py * y
elif self.size_mode == 'DPI':
fact = 1 / self.factor / context.scene.unit_settings.scale_length * 0.0254 / 2
fact = 1 / self.factor / context.scene.unit_settings.scale_length * 0.0254
x = px * fact
y = py * fact
else: # elif self.size_mode == 'DPBU'
fact = 1 / self.factor / 2
fact = 1 / self.factor
x = px * fact
y = py * fact
verts = ((-x, -y, 0.0),
(+x, -y, 0.0),
(+x, +y, 0.0),
(-x, +y, 0.0),
)
faces = ((0, 1, 2, 3), )
mesh_data = bpy.data.meshes.new(img.name)
mesh_data.from_pydata(verts, [], faces)
mesh_data.update()
object_data_add(context, mesh_data, operator=self)
bpy.ops.mesh.primitive_plane_add('INVOKE_REGION_WIN')
plane = context.scene.objects.active
# Why does mesh.primitive_plane_add leave the object in edit mode???
if plane.mode is not 'OBJECT':
bpy.ops.object.mode_set(mode='OBJECT')
plane.dimensions = x, y, 0.0
bpy.ops.object.transform_apply(scale=True)
plane.data.uv_textures.new()
plane.data.materials.append(material)
plane.data.uv_textures[0].data[0].image = img
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment