Skip to content

Commit

Permalink
fixed off-by one error, finalized for version 0.4 release
Browse files Browse the repository at this point in the history
  • Loading branch information
BlendingJake committed Mar 25, 2016
1 parent e1201ec commit 72ec8de
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions cubester.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def materialFrameHandler(scene):
if type == "vertex":
colors = object["frames"]

if frame % skip_frames == 0 and frame < max * skip_frames:
if frame % skip_frames == 0 and frame < (max - 1) * skip_frames and frame >= 0:
use_frame = int(frame / skip_frames)
color = colors[use_frame]

Expand All @@ -245,8 +245,8 @@ def materialFrameHandler(scene):
bpy.types.Scene.cubester_load_type = EnumProperty(name = "Input Type", items = (("single", "Single Image", ""), ("multiple", "Image Sequence", "")))
bpy.types.Scene.cubester_image = StringProperty(default = "", name = "")
bpy.types.Scene.cubester_load_image = StringProperty(default = "", name = "Load Image", subtype = "FILE_PATH", update = adjustSelectedImage)
bpy.types.Scene.cubester_skip_images = IntProperty(name = "Skip # Images", min = 0, max = 30, default = 0, description = "Skip this number of images before using one")
bpy.types.Scene.cubester_max_images = IntProperty(name = "Max Number Of Images", min = 2, max = 100, default = 10, description = "Maximum number of images to be used")
bpy.types.Scene.cubester_skip_images = IntProperty(name = "Image Step", min = 1, max = 30, default = 1, description = "Step from image to image by this number")
bpy.types.Scene.cubester_max_images = IntProperty(name = "Max Number Of Images", min = 2, max = 1000, default = 10, description = "Maximum number of images to be used")
bpy.types.Scene.cubester_frame_step = IntProperty(name = "Frame Step Size", min = 1, max = 10, default = 4, description = "The number of frames each picture is used")
#look adjustments
bpy.types.Scene.cubester_invert = BoolProperty(name = "Invert Height?", default = False)
Expand Down Expand Up @@ -352,7 +352,7 @@ def draw(self, context):
time = rows * columns * slope + intercept #approximate time count for mesh
else:
points = rows * columns
time = points * slope + intercept + points * image_mesh_slope + images_found * image_count_slope
time = (points * slope) + intercept + (points * image_mesh_slope )+ ((images_found / (scene.cubester_skip_images + 1)) * image_count_slope)

time_mod = "s"
if time > 60: #convert to minutes if needed
Expand Down Expand Up @@ -520,14 +520,13 @@ def execute(self, context):

frames_vert_colors = []

if len(images[0]) >= scene.cubester_max_images:
max = scene.cubester_max_images
if len(images[0]) > scene.cubester_max_images:
max = scene.cubester_max_images + 1
else:
max = len(images[0])
max *= scene.cubester_skip_images + 1
max = len(images[0])

#goes through and for each image for each block finds new height
for image_index in range(0, max, scene.cubester_skip_images + 1):
for image_index in range(0, max, scene.cubester_skip_images):
filepath = images[0][image_index]
name = images[1][image_index]
picture = fetchImage(name, filepath)
Expand All @@ -542,6 +541,7 @@ def execute(self, context):
h = findPointHeight(r, g, b, a, scene)

if h != -1:

frame_heights.append(h)
if scene.cubester_mesh_style == "blocks":
frame_colors += [(r, g, b) for i in range(24)]
Expand All @@ -553,9 +553,9 @@ def execute(self, context):

frames.append(frame_heights)
frames_vert_colors.append(frame_colors)

#determine what data to use
if scene.cubester_materials == "vertex":
if scene.cubester_materials == "vertex":
scene.cubester_vertex_colors[ob.name] = {"type" : "vertex", "frames" : frames_vert_colors,
"frame_skip" : scene.cubester_frame_step, "total_images" : max}
else:
Expand Down Expand Up @@ -588,7 +588,7 @@ def execute(self, context):
#loop through to get the four vertices that compose the face
for frame_vert in range(frame_start_vert, end_point):
fcurves = [action.fcurves.new(data_path % vert_index, i) for i in range(3)] #fcurves for x, y, z
frame_counter = 1 #go through each frame and add position
frame_counter = 0 #go through each frame and add position
temp_v = mesh.vertices[vert_index].co

#loop through frames
Expand All @@ -598,7 +598,7 @@ def execute(self, context):
fcurves[i].keyframe_points.insert(frame_counter, vals[i], {'FAST'})

frame_counter += scene.cubester_frame_step #skip frames for smoother animation

vert_index += 1

#only skip vertices if made of blocks
Expand Down

0 comments on commit 72ec8de

Please sign in to comment.