/
Zamar_Terrier
/
TigorEngineWeb
Обзор
Документация
Войти
/
Zamar_Terrier
/
TigorEngineWeb
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
main
src/e_transform.c
209 строк
4 KB
Ilia Zamaruev
hard fix
28 окт 2025, 17:11
28 окт 2025, 17:11
8d866bd
Код
Авторство
О чём код?
#include "e_transform.h" #include "e_math.h" #include "gameObject2D.h" #include "gameObject3D.h" extern TEngine engine; void Transform2DInit(Transform2D* transform){ memset(transform, 0, sizeof(Transform2D)); transform->scale.x = engine.width / 10; transform->scale.y = engine.height / 10; transform->img.scale.x = 1; transform->img.scale.y = 1; transform->scaleOrig.x = engine.width; transform->scaleOrig.y = engine.height; } void Transform3DInit(Transform3D* transform){ memset(transform, 0, sizeof(Transform3D)); transform->scale.x = 1; transform->scale.y = 1; transform->scale.z = 1; transform->img.scale.x = 1; transform->img.scale.y = 1; } //2D Transforms void Transform2DSetPosition(GameObject2D *go, float x, float y) { GameObject2D *temp = (GameObject2D *)go; temp->transform.positionOrig.x = x; temp->transform.positionOrig.y = y; temp->transform.position.x = x; temp->transform.position.y = y; } void Transform2DReposition(GameObject2D *go) { GameObject2D *temp = (GameObject2D *)go; temp->transform.position.x = temp->transform.positionOrig.x; temp->transform.position.y = temp->transform.positionOrig.y; } vec2 Transform2DGetPosition(GameObject2D *go) { GameObject2D *temp = (GameObject2D *)go; return temp->transform.position; } void Transform2DSetImageOffset(GameObject2D *go, float x, float y) { GameObject2D *temp = (GameObject2D *)go; temp->transform.img.offset.x = x; temp->transform.img.offset.y = y; } vec2 Transform2DGetImageOffset(GameObject2D *go) { GameObject2D *temp = (GameObject2D *)go; vec2 offset; offset.x = temp->transform.img.offset.x; offset.y = temp->transform.img.offset.y; return offset; } void Transform2DSetScale(GameObject2D *go, float x, float y) { GameObject2D *temp = (GameObject2D *)go; temp->transform.scaleOrig.x = x; temp->transform.scaleOrig.y = y; temp->transform.scale.x = x; temp->transform.scale.y = y; } void Transform2DRescale(GameObject2D *go) { GameObject2D *temp = (GameObject2D *)go; temp->transform.scale.x = temp->transform.scaleOrig.x; temp->transform.scale.y = temp->transform.scaleOrig.y; } vec2 Transform2DGetScale(GameObject2D *go) { GameObject2D *temp = (GameObject2D *)go; vec2 size; size.x = temp->transform.scale.x; size.y = temp->transform.scale.y; return size; } void Transform2DSetRotation(GameObject2D *go, float angle){ GameObject2D *temp = (GameObject2D *)go; while(angle > 360) angle -= 360; while(angle < -360) angle += 360; temp->transform.rotation = angle; } float Transform2DGetRotation(GameObject2D *go){ GameObject2D *temp = (GameObject2D *)go; return temp->transform.rotation; } //3D Transforms void Transform3DSetPositionT(Transform3D* transform, float x, float y, float z) { transform->position.x = x; transform->position.y = y; transform->position.z = z; } void Transform3DSetPosition(GameObject3D *go, float x, float y, float z) { GameObject3D *temp = (GameObject3D *)go; temp->transform.position.x = x; temp->transform.position.y = y; temp->transform.position.z = z; } vec3 Transform3DGetPosition(GameObject3D *go) { GameObject3D *temp = (GameObject3D *)go; return temp->transform.position; } void Transform3DSetScaleT(Transform3D* transform, float x, float y, float z) { transform->scale.x = x; transform->scale.y = y; transform->scale.z = z; } void Transform3DSetScale(GameObject3D *go, float x, float y, float z) { GameObject3D *temp = (GameObject3D *)go; temp->transform.scale.x = x; temp->transform.scale.y = y; temp->transform.scale.z = z; } vec3 Transform3DGetScale(GameObject3D *go) { GameObject3D *temp = (GameObject3D *)go; return temp->transform.scale; } void Transform3DSetRotationT(Transform3D* transform, float x, float y, float z) { transform->rotation.x = x; transform->rotation.y = y; transform->rotation.z = z; } void Transform3DSetRotation(GameObject3D *go, float x, float y, float z){ GameObject3D *temp = (GameObject3D *)go; x = x > 360 ? 0 : x; x = x < -360 ? 0 : x; y = y > 360 ? 0 : y; y = y < -360 ? 0 : y; z = z > 360 ? 0 : z; z = z < -360 ? 0 : z; temp->transform.rotation.x = x; temp->transform.rotation.y = y; temp->transform.rotation.z = z; } vec3 Transform3DGetRotation(GameObject3D *go){ GameObject3D *temp = (GameObject3D *)go; return temp->transform.rotation; }