auts: add transform to have flexible positions
This commit is contained in:
parent
a7c7c3d51a
commit
0adc284a9d
5
main.v
5
main.v
|
@ -48,6 +48,11 @@ fn main() {
|
|||
ob.dim_z = 2
|
||||
ob.elem = e4
|
||||
|
||||
// Position
|
||||
ob.transform.pos_x = 10.0
|
||||
ob.transform.pos_y = 10.0
|
||||
ob.transform.rot_z = 45.0
|
||||
|
||||
println("ob: ${ob}")
|
||||
|
||||
//
|
||||
|
|
13
object.v
13
object.v
|
@ -9,12 +9,17 @@ mut:
|
|||
elem &Elem // XXX use id/enum
|
||||
|
||||
// Position in the world
|
||||
pos_x int
|
||||
pos_y int
|
||||
pos_z int
|
||||
//pos_x int
|
||||
//pos_y int
|
||||
//pos_z int
|
||||
|
||||
// Flixible position in the world
|
||||
transform &Transform
|
||||
}
|
||||
|
||||
fn new_object() &Object {
|
||||
o := &Object{}
|
||||
o := &Object{
|
||||
transform: new_transform(),
|
||||
}
|
||||
return o
|
||||
}
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
module main
|
||||
|
||||
struct Transform {
|
||||
mut:
|
||||
pos_x f32
|
||||
pos_y f32
|
||||
pos_z f32
|
||||
rot_x f32
|
||||
rot_y f32
|
||||
rot_z f32
|
||||
}
|
||||
|
||||
fn new_transform() &Transform {
|
||||
t := &Transform{}
|
||||
return t
|
||||
}
|
Loading…
Reference in New Issue