2021-03-09 02:39:41 +00:00
|
|
|
/*
|
2021-07-24 05:19:52 +00:00
|
|
|
transform.h
|
2021-03-09 02:39:41 +00:00
|
|
|
|
2021-07-24 05:19:52 +00:00
|
|
|
Transform management
|
2021-03-09 02:39:41 +00:00
|
|
|
|
|
|
|
Copyright (C) 2021 Bill Currie <bill@taniwha.org>
|
|
|
|
|
|
|
|
Author: Bill Currie <bill@taniwha.org>
|
|
|
|
Date: 2021/02/26
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2021-07-24 05:19:52 +00:00
|
|
|
#ifndef __QF_scene_transform_h
|
|
|
|
#define __QF_scene_transform_h
|
2021-03-09 02:39:41 +00:00
|
|
|
|
|
|
|
#include "QF/darray.h"
|
2021-07-24 05:19:52 +00:00
|
|
|
#include "QF/qtypes.h"
|
2021-03-09 02:39:41 +00:00
|
|
|
#include "QF/simd/vec4f.h"
|
|
|
|
#include "QF/simd/mat4f.h"
|
|
|
|
|
2021-07-24 05:19:52 +00:00
|
|
|
/** \defgroup transform Transform management
|
2021-03-09 02:39:41 +00:00
|
|
|
\ingroup utils
|
|
|
|
*/
|
|
|
|
///@{
|
|
|
|
|
|
|
|
typedef struct transform_s {
|
2021-07-24 05:19:52 +00:00
|
|
|
struct hierarchy_s *hierarchy;
|
2022-02-14 07:41:38 +00:00
|
|
|
uint32_t index; ///< index in hierarchy
|
|
|
|
int32_t id; ///< scene id
|
2021-03-09 02:39:41 +00:00
|
|
|
} transform_t;
|
|
|
|
|
|
|
|
transform_t *Transform_New (transform_t *parent);
|
2022-02-14 07:41:38 +00:00
|
|
|
/* Deletes all child transforms, and transform names */
|
2021-03-09 02:39:41 +00:00
|
|
|
void Transform_Delete (transform_t *transform);
|
|
|
|
transform_t *Transform_NewNamed (transform_t *parent, const char *name);
|
|
|
|
uint32_t Transform_ChildCount (const transform_t *transform) __attribute__((pure));
|
|
|
|
transform_t *Transform_GetChild (const transform_t *transform,
|
|
|
|
uint32_t childIndex) __attribute__((pure));
|
|
|
|
void Transform_SetParent (transform_t *transform, transform_t *parent);
|
|
|
|
transform_t *Transform_GetParent (const transform_t *transform) __attribute__((pure));
|
|
|
|
void Transform_SetName (transform_t *transform, const char *name);
|
|
|
|
const char *Transform_GetName (const transform_t *transform) __attribute__((pure));
|
|
|
|
void Transform_SetTag (transform_t *transform, uint32_t tag);
|
|
|
|
uint32_t Transform_GetTag (const transform_t *transform) __attribute__((pure));
|
|
|
|
void Transform_GetLocalMatrix (const transform_t *transform, mat4f_t mat);
|
|
|
|
void Transform_GetLocalInverse (const transform_t *transform, mat4f_t mat);
|
|
|
|
void Transform_GetWorldMatrix (const transform_t *transform, mat4f_t mat);
|
2021-12-17 07:42:31 +00:00
|
|
|
// XXX the pointer may be invalidated by hierarchy updates
|
|
|
|
const vec4f_t *Transform_GetWorldMatrixPtr (const transform_t *transform) __attribute__((pure));
|
2021-03-09 02:39:41 +00:00
|
|
|
void Transform_GetWorldInverse (const transform_t *transform, mat4f_t mat);
|
|
|
|
vec4f_t Transform_GetLocalPosition (const transform_t *transform) __attribute__((pure));
|
2021-03-09 14:52:40 +00:00
|
|
|
void Transform_SetLocalPosition (transform_t *transform, vec4f_t position);
|
2021-03-09 02:39:41 +00:00
|
|
|
vec4f_t Transform_GetLocalRotation (const transform_t *transform) __attribute__((pure));
|
2021-03-09 14:52:40 +00:00
|
|
|
void Transform_SetLocalRotation (transform_t *transform, vec4f_t rotation);
|
2021-03-09 02:39:41 +00:00
|
|
|
vec4f_t Transform_GetLocalScale (const transform_t *transform) __attribute__((pure));
|
2021-03-09 14:52:40 +00:00
|
|
|
void Transform_SetLocalScale (transform_t *transform, vec4f_t scale);
|
2021-03-09 02:39:41 +00:00
|
|
|
vec4f_t Transform_GetWorldPosition (const transform_t *transform) __attribute__((pure));
|
2021-03-09 14:52:40 +00:00
|
|
|
void Transform_SetWorldPosition (transform_t *transform, vec4f_t position);
|
2021-03-09 02:39:41 +00:00
|
|
|
vec4f_t Transform_GetWorldRotation (const transform_t *transform) __attribute__((pure));
|
2021-03-09 14:52:40 +00:00
|
|
|
void Transform_SetWorldRotation (transform_t *transform, vec4f_t rotation);
|
2021-03-09 02:39:41 +00:00
|
|
|
vec4f_t Transform_GetWorldScale (const transform_t *transform) __attribute__((pure));
|
2021-03-09 14:52:40 +00:00
|
|
|
void Transform_SetLocalTransform (transform_t *transform, vec4f_t scale,
|
|
|
|
vec4f_t rotation, vec4f_t position);
|
2021-03-09 02:39:41 +00:00
|
|
|
// NOTE: these use X: right, Y: forward, Z:up
|
|
|
|
// aslo, not guaranteed to be normalized or even orthogonal
|
|
|
|
vec4f_t Transform_Forward (const transform_t *transform) __attribute__((pure));
|
|
|
|
vec4f_t Transform_Right (const transform_t *transform) __attribute__((pure));
|
|
|
|
vec4f_t Transform_Up (const transform_t *transform) __attribute__((pure));
|
|
|
|
// no SetWorldScale because after rotations, non uniform scale becomes shear
|
|
|
|
|
|
|
|
///@}
|
|
|
|
|
2021-07-24 05:19:52 +00:00
|
|
|
#endif//__QF_scene_transform_h
|