ぬの部屋(仮)
nu-no-he-ya
  • 1234567
    891011121314
    15161718192021
    22232425262728
    2930     
           
        123
    45678910
    11121314151617
    18192021222324
    25262728293031
           
       1234
    567891011
    12131415161718
    19202122232425
    26272829   
           
    1234567
    891011121314
    15161718192021
    22232425262728
    293031    
           
        123
    45678910
    11121314151617
    18192021222324
    25262728293031
           
      12345
    6789101112
    13141516171819
    20212223242526
    27282930   
           
          1
    2345678
    9101112131415
    16171819202122
    23242526272829
    3031     
        123
    45678910
    11121314151617
    18192021222324
    252627282930 
           
     123456
    78910111213
    14151617181920
    21222324252627
    28293031   
           
         12
    3456789
    10111213141516
    17181920212223
    24252627282930
    31      
       1234
    567891011
    12131415161718
    19202122232425
    2627282930  
           
    1234567
    891011121314
    15161718192021
    22232425262728
    293031    
           
         12
    3456789
    10111213141516
    17181920212223
    24252627282930
           
      12345
    6789101112
    13141516171819
    20212223242526
    2728293031  
           
      12345
    6789101112
    13141516171819
    20212223242526
    2728     
           
          1
    2345678
    9101112131415
    16171819202122
    23242526272829
    3031     
       1234
    567891011
    12131415161718
    19202122232425
    262728293031 
           
     123456
    78910111213
    14151617181920
    21222324252627
    282930    
           
         12
    3456789
    10111213141516
    17181920212223
    24252627282930
    31      
       1234
    567891011
    12131415161718
    19202122232425
    2627282930  
           
    1234567
    891011121314
    15161718192021
    22232425262728
    293031    
           
        123
    45678910
    11121314151617
    18192021222324
    25262728293031
           
      12345
    6789101112
    13141516171819
    20212223242526
    27282930   
           
          1
    2345678
    9101112131415
    16171819202122
    23242526272829
    3031     
        123
    45678910
    11121314151617
    18192021222324
    252627282930 
           
     123456
    78910111213
    14151617181920
    21222324252627
    28293031   
           
     123456
    78910111213
    14151617181920
    21222324252627
    28      
           
         12
    3456789
    10111213141516
    17181920212223
    24252627282930
    31      
      12345
    6789101112
    13141516171819
    20212223242526
    2728293031  
           
    1234567
    891011121314
    15161718192021
    22232425262728
    2930     
           
        123
    45678910
    11121314151617
    18192021222324
    25262728293031
           
      12345
    6789101112
    13141516171819
    20212223242526
    27282930   
           
          1
    2345678
    9101112131415
    16171819202122
    23242526272829
    3031     
       1234
    567891011
    12131415161718
    19202122232425
    262728293031 
           
     123456
    78910111213
    14151617181920
    21222324252627
    282930    
           
         12
    3456789
    10111213141516
    17181920212223
    24252627282930
    31      
       1234
    567891011
    12131415161718
    19202122232425
    2627282930  
           
    1234567
    891011121314
    15161718192021
    22232425262728
    293031    
           
    1234567
    891011121314
    15161718192021
    22232425262728
           
           
        123
    45678910
    11121314151617
    18192021222324
    25262728293031
           
     123456
    78910111213
    14151617181920
    21222324252627
    28293031   
           
          1
    2345678
    9101112131415
    16171819202122
    23242526272829
    30      
       1234
    567891011
    12131415161718
    19202122232425
    262728293031 
           
     123456
    78910111213
    14151617181920
    21222324252627
    282930    
           
         12
    3456789
    10111213141516
    17181920212223
    24252627282930
    31      
      12345
    6789101112
    13141516171819
    20212223242526
    2728293031  
           
    1234567
    891011121314
    15161718192021
    22232425262728
    2930     
           
        123
    45678910
    11121314151617
    18192021222324
    25262728293031
           
      12345
    6789101112
    13141516171819
    20212223242526
    27282930   
           
          1
    2345678
    9101112131415
    16171819202122
    23242526272829
    3031     
         12
    3456789
    10111213141516
    17181920212223
    242526272829 
           
      12345
    6789101112
    13141516171819
    20212223242526
    2728293031  
           
          1
    2345678
    9101112131415
    16171819202122
    23242526272829
    3031     
        123
    45678910
    11121314151617
    18192021222324
    252627282930 
           
     123456
    78910111213
    14151617181920
    21222324252627
    28293031   
           
          1
    2345678
    9101112131415
    16171819202122
    23242526272829
    30      
       1234
    567891011
    12131415161718
    19202122232425
    262728293031 
           
    1234567
    891011121314
    15161718192021
    22232425262728
    293031    
           
         12
    3456789
    10111213141516
    17181920212223
    24252627282930
           
      12345
    6789101112
    13141516171819
    20212223242526
    2728293031  
           
    1234567
    891011121314
    15161718192021
    22232425262728
    2930     
           
        123
    45678910
    11121314151617
    18192021222324
    25262728293031
           
        123
    45678910
    11121314151617
    18192021222324
    25262728   
           
     123456
    78910111213
    14151617181920
    21222324252627
    28293031   
           
         12
    3456789
    10111213141516
    17181920212223
    24252627282930
    31      
       1234
    567891011
    12131415161718
    19202122232425
    2627282930  
           
    1234567
    15161718192021
    293031    
           
         12
    3456789
    10111213141516
           
      12345
    6789101112
    13141516171819
    20212223242526
    2728293031  
           
          1
    2345678
    9101112131415
    16171819202122
    23242526272829
    3031     
        123
    45678910
    11121314151617
    18192021222324
    252627282930 
           
     123456
    78910111213
    14151617181920
    21222324252627
    28293031   
           
          1
    2345678
    9101112131415
    16171819202122
    23242526272829
    30      
       1234
    567891011
    12131415161718
    19202122232425
    262728293031 
           
    1234567
    891011121314
    15161718192021
    22232425262728
    293031    
           
        123
    45678910
    11121314151617
    18192021222324
    25262728293031
           
      12345
    6789101112
    13141516171819
    20212223242526
    27282930   
           
        123
    45678910
    11121314151617
    18192021222324
    252627282930 
           
     123456
    78910111213
    14151617181920
    21222324252627
    28293031   
           
       1234
    567891011
    12131415161718
    19202122232425
    2627282930  
           
    1234567
    891011121314
    15161718192021
    22232425262728
    293031    
           
         12
    3456789
    10111213141516
    17181920212223
    24252627282930
           
      12345
    6789101112
    13141516171819
    20212223242526
    2728293031  
           
      12345
    6789101112
    13141516171819
    20212223242526
    2728     
           
          1
    2345678
    9101112131415
    16171819202122
    23242526272829
    3031     
     123456
    78910111213
    14151617181920
    21222324252627
    282930    
           
         12
    3456789
    10111213141516
    17181920212223
    24252627282930
    31      
    1234567
    891011121314
    15161718192021
    22232425262728
    293031    
           
        123
    45678910
    11121314151617
    18192021222324
    252627282930 
           
     123456
    78910111213
    14151617181920
    21222324252627
    28293031   
           
     123456
    78910111213
    14151617181920
    21222324252627
    28293031   
           
       1234
    567891011
    12131415161718
    19202122232425
    262728293031 
           
     123456
    78910111213
    14151617181920
    21222324252627
    282930    
           
         12
    3456789
    10111213141516
    17181920212223
    24252627282930
    31      
      12345
    6789101112
    13141516171819
    20212223242526
    2728293031  
           
    1234567
    891011121314
    15161718192021
    22232425262728
    2930     
           
        123
    45678910
    11121314151617
    18192021222324
    25262728293031
           
      12345
    6789101112
    13141516171819
    20212223242526
    27282930   
           
          1
    2345678
    9101112131415
    16171819202122
    23242526272829
    3031     
          1
    2345678
    9101112131415
    16171819202122
    232425262728 
           
       1234
    567891011
    12131415161718
    19202122232425
    262728293031 
           
    1234567
    891011121314
    15161718192021
    22232425262728
    293031    
           
         12
    3456789
    10111213141516
    17181920212223
    24252627282930
           
      12345
    6789101112
    13141516171819
    20212223242526
    2728293031  
           
    1234567
    891011121314
    15161718192021
    22232425262728
    2930     
           
        123
    45678910
    11121314151617
    18192021222324
    25262728293031
           
  • オブジェクトの頂点に行列を適用するプログラムにUIを付けてアドオン風にする

    import bpy
    import mathutils
    
    
    # 行列をモデルに適用するボタン
    class execButton(bpy.types.Operator):
      bl_idname = "szl.multmatrixbutton"
      bl_label = "multi matrix"
      
      def execute(self, context):
          
          M11 = context.scene.myinputs.m11
          M12 = context.scene.myinputs.m12
          M13 = context.scene.myinputs.m13
          M14 = context.scene.myinputs.m14
          #######################################
          M21 = context.scene.myinputs.m21
          M22 = context.scene.myinputs.m22
          M23 = context.scene.myinputs.m23
          M24 = context.scene.myinputs.m24
          #######################################
          M31 = context.scene.myinputs.m31
          M32 = context.scene.myinputs.m32
          M33 = context.scene.myinputs.m33
          M34 = context.scene.myinputs.m34
          #######################################
          M41 = context.scene.myinputs.m41
          M42 = context.scene.myinputs.m42
          M43 = context.scene.myinputs.m43
          M44 = context.scene.myinputs.m44
          
          #######################################
          #apply matrix
          matrix = mathutils.Matrix((
          (M11  ,M12  ,M13  ,M14),
          (M21  ,M22  ,M23  ,M24),
          (M31  ,M32  ,M33  ,M34),
          (M41  ,M42  ,M43  ,M44)))
          
          msh = bpy.context.active_object
          for vt in msh.data.vertices:
            
              src = mathutils.Vector((vt.co[0],vt.co[1],vt.co[2],1))
            
              dst = matrix @ src
            
              vt.co[0] = dst[0]
              vt.co[1] = dst[1]
              vt.co[2] = dst[2]      
              
          return{'FINISHED'}
    # 行列を単位行列にする
    class execButtonLoadIdentity(bpy.types.Operator):
      bl_idname = "szl.loadidentitybutton"
      bl_label = "load identity"
      
      def execute(self, context):
        context.scene.myinputs.m11 =1.0
        context.scene.myinputs.m12 =0.0
        context.scene.myinputs.m13 =0.0
        context.scene.myinputs.m14 =0.0
        #######################################
        context.scene.myinputs.m21 =0.0
        context.scene.myinputs.m22 =1.0
        context.scene.myinputs.m23 =0.0
        context.scene.myinputs.m24 =0.0
        #######################################
        context.scene.myinputs.m31 =0.0
        context.scene.myinputs.m32 =0.0
        context.scene.myinputs.m33 =1.0
        context.scene.myinputs.m34 =0.0
        #######################################
        context.scene.myinputs.m41 =0.0
        context.scene.myinputs.m42 =0.0
        context.scene.myinputs.m43 =0.0
        context.scene.myinputs.m44 =1.0
    
        return{'FINISHED'}
    #テキストボックスを定義
    class myCInputs(bpy.types.PropertyGroup):
    
        m11: bpy.props.FloatProperty(name="m11")
        m12: bpy.props.FloatProperty(name="m12")
        m13: bpy.props.FloatProperty(name="m13")
        m14: bpy.props.FloatProperty(name="m14")
        #######################################
        m21: bpy.props.FloatProperty(name="m21")
        m22: bpy.props.FloatProperty(name="m22")
        m23: bpy.props.FloatProperty(name="m23")
        m24: bpy.props.FloatProperty(name="m24")
        #######################################
        m31: bpy.props.FloatProperty(name="m31")
        m32: bpy.props.FloatProperty(name="m32")
        m33: bpy.props.FloatProperty(name="m33")
        m34: bpy.props.FloatProperty(name="m34")
        #######################################
        m41: bpy.props.FloatProperty(name="m41")
        m42: bpy.props.FloatProperty(name="m42")
        m43: bpy.props.FloatProperty(name="m43")
        m44: bpy.props.FloatProperty(name="m44")
    class myCTool_PT_panel(bpy.types.Panel):
        bl_label = "行列適用"
        bl_category = "行列適用"
        bl_space_type = "VIEW_3D"
        bl_region_type = "UI"
    
        def draw(self, context):
            layout = self.layout
    
            column = layout.column(align=True)
    
            # テキストボックスを並べる
            row = column.row(align=True)
            row.prop(context.scene.myinputs, "m11", text="")
            row.prop(context.scene.myinputs, "m12", text="")
            row.prop(context.scene.myinputs, "m13", text="")
            row.prop(context.scene.myinputs, "m14", text="")
            row = column.row(align=True)
            row.prop(context.scene.myinputs, "m21", text="")
            row.prop(context.scene.myinputs, "m22", text="")
            row.prop(context.scene.myinputs, "m23", text="")
            row.prop(context.scene.myinputs, "m24", text="")
            row = column.row(align=True)
            row.prop(context.scene.myinputs, "m31", text="")
            row.prop(context.scene.myinputs, "m32", text="")
            row.prop(context.scene.myinputs, "m33", text="")
            row.prop(context.scene.myinputs, "m34", text="")
            row = column.row(align=True)
            row.prop(context.scene.myinputs, "m41", text="")
            row.prop(context.scene.myinputs, "m42", text="")
            row.prop(context.scene.myinputs, "m43", text="")
            row.prop(context.scene.myinputs, "m44", text="")
            
            # ボタンを配置
            layout.operator("szl.loadidentitybutton")
            layout.operator("szl.multmatrixbutton")
    classes = (
        myCInputs,
        execButton,
        execButtonLoadIdentity,
        myCTool_PT_panel
    )
    
    
    def register():
        for cls in classes:
            bpy.utils.register_class(cls)
    
        bpy.types.Scene.myinputs = bpy.props.PointerProperty(type=myCInputs)
    
    def unregister():
        for cls in classes:
            bpy.utils.unregister_class(cls)
        del bpy.types.Scene.myinputs
    
    if __name__ == "__main__":
        register()