Skip to content

A Bevy Engine plugin for making 2D paths, smooth animations with Bezier curves

License

Notifications You must be signed in to change notification settings

eliotbo/bevy_pen_tool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bevy_pen_tool

A Bevy Engine plugin for making 2D paths, smooth animations, meshes and roads with Bezier curves.

bevy_pen_tool

Controls

Icon Keys Description
scale_up Left Control + Mousescroll up Scale UI and curves up
scale_down Left Control + Mousescroll down Scale UI and curves down
spawn_curve Left Shift + Click Spawn curve
select Left Crtl + Drag Select curves
group Left Control + G Group selected curves
latch Left Shift + Left Control + Drag Latch a curve to another curve by dragging a free anchor close to another free anchor
unlatch Space + Drag Unlatch anchors that were latched together.
hide_anchors H Hide anchors and control points
save Left Control + S Save set of existing individual curves (does not currently preserve groups or latches)
load Left Control + L Load set of saved curves (does not currently preserve groups or latches)
hide_ctrls Left Control + Left Shift + H Hide the control points
lut Left Shift + T Compute look-up table (linearizes animations)
sound None Toggle sound
bin Select curves or group + Delete Delete curves or group
road None Spawn road on curve group
mesh None Spawn mesh inside curve group
heli None Spawn animated helicopter on curve group

Setup

Clone the repo, copy and paste the crate called "bevy_pen_tool_plugin" from the "crates" folder in the repo to the directory for your project, and add "bevy_pen_tool_plugin" as a local dependency in Cargo.toml. Refer to main.rs and Cargo.toml for futher details.

How to

A typical sequence of actions using the plugin would be as follows:

  1. Spawn curves
  2. Latch them together
  3. Group the latched curves (cannot be ungrouped)
  4. Move anchors and control points to desired position
  5. Compute the look-up table
  6. Save

A user can save and load the data structure for a group of Bezier curves -- called Group in the code -- in JSON format. The default directory for saving groups is "./saved/groups/", and the file extension is a custom one: ".group". Meshes can be saved in well-known ".obj" format, and their default save directory is "./saved/meshes". The one save button prompts a file dialog window for each data structure that can be saved in the current session.

There are two important parameters to tweak and they are both located in a Resource called "Globals"

  1. group_lut_num_points: the number of elements in the generated look-up table (more yields smoother animations/meshes)
  2. road_width: the width of the road meshes. Refer to main.rs to see how to modify these parameters.

When the control points, shown as arrow tips, are hidden, the plugin places them almost exactly on top of the anchors. In this mode of operation, one can draw an arbitrary polygon and generate the corresponding mesh.

Notes

bevy_pen_tool, in its current form,

  • attemps to follow Bevy's latest release
  • does not work with a Perspective Camera (only Orthographic)
  • cannot save multiple groups at once, only a single one
  • deletes everything on the canvas before loading a group of Bezier curves

TODO

  • ability to move whole group
  • select and delete mesh
  • saving multiple groups
  • ruler tool
  • no guarantees, but maybe a 3D version

About

A Bevy Engine plugin for making 2D paths, smooth animations with Bezier curves

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages