src/ascension/transform.h

changeset 45
18de2af03531
parent 32
86468a71dd73
     1.1 --- a/src/ascension/transform.h	Tue Mar 26 20:37:21 2024 +0100
     1.2 +++ b/src/ascension/transform.h	Thu Mar 28 23:30:21 2024 +0100
     1.3 @@ -57,42 +57,41 @@
     1.4  
     1.5  ASC_TRANFORM_FUNC void asc_transform_translate(
     1.6          asc_transform transform,
     1.7 -        float x, float y, float z
     1.8 +        asc_vec3f vec
     1.9  ) {
    1.10 -    transform[asc_mat4_index(3, 0)] += x;
    1.11 -    transform[asc_mat4_index(3, 1)] += y;
    1.12 -    transform[asc_mat4_index(3, 2)] += z;
    1.13 -}
    1.14 -
    1.15 -ASC_TRANFORM_FUNC void asc_transform_translate2i(
    1.16 -        asc_transform transform,
    1.17 -        asc_vec2i position
    1.18 -) {
    1.19 -    asc_transform_translate(
    1.20 -            transform,
    1.21 -            (float) position.x, (float) position.y, 0
    1.22 -    );
    1.23 +    transform[asc_mat4_index(3, 0)] += vec.x;
    1.24 +    transform[asc_mat4_index(3, 1)] += vec.y;
    1.25 +    transform[asc_mat4_index(3, 2)] += vec.z;
    1.26  }
    1.27  
    1.28  ASC_TRANFORM_FUNC void asc_transform_scale(
    1.29          asc_transform transform,
    1.30 -        float x, float y, float z
    1.31 +        asc_vec3f vec
    1.32  ) {
    1.33      for (unsigned i = 0 ; i < 3 ; i++) {
    1.34 -        transform[asc_mat4_index(0, i)] *= x;
    1.35 -        transform[asc_mat4_index(1, i)] *= y;
    1.36 -        transform[asc_mat4_index(2, i)] *= z;
    1.37 +        transform[asc_mat4_index(0, i)] *= vec.width;
    1.38 +        transform[asc_mat4_index(1, i)] *= vec.height;
    1.39 +        transform[asc_mat4_index(2, i)] *= vec.depth;
    1.40      }
    1.41  }
    1.42  
    1.43 -ASC_TRANFORM_FUNC void asc_transform_scale2i(
    1.44 +ASC_TRANFORM_FUNC void asc_transform_rotate(
    1.45          asc_transform transform,
    1.46 -        asc_vec2i dimensions
    1.47 +        asc_vec3f vec
    1.48  ) {
    1.49 -    asc_transform_scale(
    1.50 -            transform,
    1.51 -            (float) dimensions.width, (float) dimensions.height, 0
    1.52 -    );
    1.53 +    // TODO: implement
    1.54 +}
    1.55 +
    1.56 +ASC_TRANFORM_FUNC void asc_transform_from_parts(
    1.57 +        asc_transform transform,
    1.58 +        asc_vec3f position,
    1.59 +        asc_vec3f scale,
    1.60 +        asc_vec3f rotation
    1.61 +) {
    1.62 +    asc_transform_identity(transform);
    1.63 +    asc_transform_scale(transform, scale);
    1.64 +    asc_transform_translate(transform, position);
    1.65 +    asc_transform_rotate(transform, rotation);
    1.66  }
    1.67  
    1.68  #endif //ASCENSION_TRANSFORM_H

mercurial