calculate instead of follow_path

This commit is contained in:
jrkb 2024-07-01 14:39:07 +02:00
parent d081d1d42d
commit 62e6c63a61
3 changed files with 82 additions and 16 deletions

View file

@ -435,7 +435,9 @@ class FONT3D_OT_TestFont(bpy.types.Operator):
ob = bpy.data.objects.new(f"{glyph_id}", glyph.data)
if selected.type == "CURVE":
distribution_type = 'CALCULATE'
if selected.type == "CURVE" and distribution_type == 'FOLLOW_PATH':
distribution_type = "FOLLOW_PATH"
curve_length = butils.get_curve_length(selected)
@ -446,9 +448,25 @@ class FONT3D_OT_TestFont(bpy.types.Operator):
ob.constraints["Follow Path"].use_curve_follow = True
ob.constraints["Follow Path"].forward_axis = "FORWARD_X"
ob.constraints["Follow Path"].up_axis = "UP_Y"
# samplecurve = nodes.new(type="GeometryNodeSampleCurve")
# butils.ShowMessageBox("WHAT","INFO","I don't really know what you mean, lsaidry")
elif selected.type == "CURVE" and distribution_type == 'CALCULATE':
location, tangent = butils.calc_point_on_bezier_curve(selected, advance, True)
ob.location = selected.matrix_world @ location
mask = [0]
input_rotations = [mathutils.Vector((0.0, 0.0, 0.0))]
vectors = [tangent]
factors = [1.0]
local_main_axis = mathutils.Vector((1.0, 0.0, 0.0))
motor = butils.align_rotations_auto_pivot(mask,
input_rotations,
vectors,
factors,
local_main_axis)
ob.rotation_quaternion = (selected.matrix_world @ motor[0]).to_quaternion()
print("what")
else:
offset.x = advance
ob.location = selected.location + offset
@ -553,7 +571,7 @@ class FONT3D_OT_SaveFontToFile(bpy.types.Operator):
# get save data
selected_font = font3d_data.available_fonts[font3d_data.active_font_index]
print(selected_font.font_name)
# print(selected_font.font_name)
self.report({'INFO'}, f"{bl_info['name']}: {selected_font.font_name}")
preferences = getPreferences(context)
print(f"assets folder: {preferences.assets_dir}")
@ -673,6 +691,35 @@ class FONT3D_OT_CreateFontFromObjects(bpy.types.Operator):
return {'FINISHED'}
class HelloWorldPanel(bpy.types.Panel):
"""Creates a Panel in the Object properties window"""
bl_label = "Hello World Panel"
bl_idname = "OBJECT_PT_hello"
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "object"
def draw(self, context):
layout = self.layout
scene = context.scene
font3d = scene.font3d
font3d_data = scene.font3d_data
obj = context.active_object
row = layout.row()
row.label(text="Hello world!", icon='WORLD_DATA')
row = layout.row()
row.label(text="Active object is: " + obj.name)
row = layout.row()
row.prop(obj, "location")
row = layout.row()
row.operator("mesh.primitive_cube_add")
classes = (
FONT3D_addonPreferences,
FONT3D_OT_Font3D,
@ -691,6 +738,7 @@ classes = (
FONT3D_OT_ToggleFont3DCollection,
FONT3D_OT_SaveFontToFile,
FONT3D_OT_CreateFontFromObjects,
HelloWorldPanel,
)
def register():