#vfx #bevy #serialization #texture #ron #define #magic

bevy_magic_fx

在序列化文件中定义基于网格的VFX

25个版本 (4个破坏性版本)

0.14.3 2024年8月6日
0.14.1 2024年7月15日
0.2.9 2024年3月13日

游戏开发 中排名第255

Download history 13/week @ 2024-04-28 161/week @ 2024-05-05 16/week @ 2024-05-12 13/week @ 2024-05-19 263/week @ 2024-05-26 514/week @ 2024-06-02 274/week @ 2024-06-09 14/week @ 2024-06-16 5/week @ 2024-06-30 30/week @ 2024-07-07 136/week @ 2024-07-14 77/week @ 2024-07-28 263/week @ 2024-08-04 21/week @ 2024-08-11

每月下载量366

MIT许可

3MB
854

Bevy Magic Fx

在RON文件中定义基于网格的VFX并将其加载到bevy中

2024-03-13 18-33-39

beam_fx

magic_fx_sample_1

more_vfx

如何使用

cargo run --example waterfall

如何安装

  1. 将此插件添加到您的bevy应用程序中
app .add_plugins( MagicFxPlugin )
  1. 从文件加载并注册您的着色器变体
 		let shadvar_name = & shader_variant_manifest.name;

                    let shader_material_handle = animated_materials.add( build_animated_material(
                        shader_variant_manifest, // the ron file parsed 
                        &texture_handles_map
                        ).unwrap()
                    ); 
                    
                    asset_loading_resource.animated_material_map.insert( 
                        shadvar_name .clone(), 
                        shader_material_handle );
   
  1. 从文件加载并注册您的魔法fx变体

 let magic_fx_variant_manifest: &MagicFxVariantManifest = fx_variant_assets
                        .get(&asset_handles_resource.magic_fx_variant_manifest_handle)
                        .unwrap();

                     let mesh_handles_map = &asset_loading_resource.mesh_handles_map;

                    let animated_materials_map = &asset_loading_resource.animated_material_map;
  
                    let magic_fx = MagicFxVariant::from_manifest(
                        magic_fx_variant_manifest, // the ron file parsed 
                      
                        &mesh_handles_map,
                      
                        &animated_materials_map,
                     
                        
                    ).unwrap();

			//save the variant for later spawning ..
 		asset_loading_resource.loaded_magic_fx_variants.insert( 
                        magic_fx.name.clone(), 
                        magic_fx );
      

  1. 随时创建您的魔法fx变体
             let _magic_fx_root = commands
                        .spawn(SpatialBundle::default())
                        .insert(MagicFxVariantComponent {
                            magic_fx,  //this is what you saved in a resource in step 3
                            start_time: time.elapsed(),
                        })
                        .id();

示例VFX定义文件(RON)


(
    
    name: "magic",    
       
    magic_fx_instances: [( 

     shader_variant_name: "shader_variants/purple.shadvar.ron",
	  mesh_name:  "meshes/projectile.obj", 
		  start_time_offset: 0.0,
		  end_time_offset: 3.0,
		  start_transform: (translation: (3.0,2.0,0.0), rotation:(0.0,0.0,0.0),scale:(1.0,1.0,1.0)),
		  end_transform: (translation: (4.0,0.0,0.0), rotation:(2.0,0.0,0.0),scale:(1.0,1.0,1.0)),

    )] ,  

    max_time: 5.0


)

示例着色器变体定义文件(RON)

(
    
    name: "purple",
    texture: "textures/fire_01.png",
    animation_speed: (0.5,0.1), // Assuming animation_speed is a string for some reason; otherwise, consider using a float or int
    distortion_speed: (0.02,0.01),
    scroll_repeats: ( 3.0,3.0),
    distortion_amount: 0.02 , 

    color: Rgba(
        red: 5,
        green: 5,
        blue: 255,
        alpha: 255 // Assuming your Color struct has rgba fields; adjust according to your actual Color struct
    ),
     emissive:  (
        5.0,20.0,5.0
    )
      
)


牌面

要在网格上使用牌面,您必须在相机中插入一个MagicFxBillboardTarget组件。

依赖项

~34–71MB
~1M SLoC