vera/transform.rs
1/// The evolution of a transformation or colorization.
2#[derive(Copy, Clone)]
3pub enum Evolution {
4 /// Constant speed from start to end.
5 Linear,
6 /// Fast at the beginning, slow at the end.
7 FastIn,
8 /// Fast at the beginning, slow at the end.
9 SlowOut,
10 /// Slow at the beginning, fast at the end.
11 FastOut,
12 /// Slow at the beginning, fast at the end.
13 SlowIn,
14 /// Slow at ends, fast in middle.
15 FastMiddle,
16 /// Slow at ends, fast in middle.
17 SlowInOut,
18 /// Fast at ends, slow in middle.
19 FastInOut,
20 /// Fast at ends, slow in middle.
21 SlowMiddle,
22}
23
24// -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
25
26/// Data for the transformation of a single vertex or shape.
27/// You can have several transformations happening simultaneously, but the order of the transformations is likely important.
28pub struct Tf {
29 /// The type & value of the transformation.
30 pub t: Transformation,
31 /// The speed evolution of the transformation.
32 pub e: Evolution,
33 /// The start time of the transformation.
34 pub start: f32,
35 /// The duration of the transformation.
36 pub end: f32,
37}
38
39/// The available transformations
40/// Their doc is prefixed with their general use case: Vertex/Model, View, Projection.
41#[derive(Clone, Copy)]
42pub enum Transformation {
43 /// Vertex/Model: A scale operation with the provided X, Y and Z scaling.
44 Scale(f32, f32, f32),
45 /// Vertex/Model: A translate operation with the provided X, Y and Z scaling.
46 Translate(f32, f32, f32),
47 /// Vertex/Model: A rotate operation around the X axis with the provided counter-clockwise angle, in radians.
48 RotateX(f32),
49 /// Vertex/Model: A rotate operation around the Y axis with the provided counter-clockwise angle, in radians.
50 RotateY(f32),
51 /// Vertex/Model: A rotate operation around the Z axis with the provided counter-clockwise angle, in radians.
52 RotateZ(f32),
53
54 /// View:
55 Lookat(f32, f32, f32, f32, f32, f32, f32, f32, f32),
56 /// View:
57 Move(f32, f32, f32),
58 /// View:
59 Pitch(f32),
60 /// View:
61 Yaw(f32),
62 /// View:
63 Roll(f32),
64
65 /// Projection:
66 Orthographic(f32, f32, f32, f32, f32, f32),
67 /// Projection:
68 Perspective(f32, f32, f32, f32, f32, f32),
69}
70
71// -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
72
73/// Data for the transformation of a single vertex or shape.
74/// You can have several transformations happening simultaneously, but the order of the transformations is likely important.
75pub struct Cl {
76 /// The type & value of the transformation.
77 pub c: Colorization,
78 /// The speed evolution of the transformation.
79 pub e: Evolution,
80 /// The start time of the transformation.
81 pub start: f32,
82 /// The duration of the transformation.
83 pub end: f32,
84}
85
86/// The available transformations
87/// Their doc is prefixed with their general use case: Vertex/Model, View, Projection.
88#[derive(Clone, Copy)]
89pub enum Colorization {
90 /// Changes the current color to this new rgba color.
91 ToColor(f32, f32, f32, f32),
92}