Archived
1
Fork 0
This repository has been archived on 2025-04-12. You can view files and clone it, but cannot push or open issues or pull requests.
prism/engine/core/include/components.hpp

112 lines
2 KiB
C++
Raw Normal View History

2020-08-11 12:07:21 -04:00
#pragma once
2020-09-20 23:31:03 -04:00
#include <vector>
2020-08-11 12:07:21 -04:00
#include "assetptr.hpp"
2020-08-19 22:09:14 -04:00
#include "object.hpp"
#include "quaternion.hpp"
#include "matrix.hpp"
2020-08-11 12:07:21 -04:00
class btCollisionShape;
class btRigidBody;
class Scene;
class Mesh;
class Material;
struct Collision {
enum class Type {
Cube,
Capsule
} type = Type::Cube;
2021-05-12 09:56:44 -04:00
prism::float3 size;
2020-08-11 12:07:21 -04:00
bool is_trigger = false;
std::string trigger_id;
bool exclude_from_raycast = false;
bool trigger_entered = false;
btCollisionShape* shape = nullptr;
};
struct Rigidbody {
enum class Type {
Dynamic,
Kinematic
} type = Type::Dynamic;
int mass = 0;
float friction = 0.5f;
bool enable_deactivation = true;
bool enable_rotation = true;
2021-05-12 09:56:44 -04:00
void add_force(const prism::float3 force) {
2020-08-11 12:07:21 -04:00
stored_force += force;
}
btRigidBody* body = nullptr;
2021-05-12 09:56:44 -04:00
prism::float3 stored_force;
2020-08-11 12:07:21 -04:00
};
struct Data {
std::string name, prefab_path;
prism::Object parent = prism::NullObject;
2020-08-11 12:07:21 -04:00
bool editor_object = false;
};
struct Transform {
2021-05-12 09:56:44 -04:00
prism::float3 position, scale = prism::float3(1);
2020-08-11 12:07:21 -04:00
Quaternion rotation;
Matrix4x4 model;
2022-02-21 00:14:47 -05:00
[[nodiscard]] prism::float3 get_world_position() const {
2020-08-11 12:07:21 -04:00
return {
model[3][0],
model[3][1],
model[3][2]
};
}
};
struct Renderable {
AssetPtr<Mesh> mesh;
std::vector<AssetPtr<Material>> materials;
std::vector<Matrix4x4> temp_bone_data;
2020-08-11 12:07:21 -04:00
};
struct Light {
enum class Type : int{
Point = 0,
Spot = 1,
Sun = 2
} type = Type::Point;
2021-05-12 09:56:44 -04:00
prism::float3 color = prism::float3(1);
2020-08-11 12:07:21 -04:00
float power = 10.0f;
float size = 1.0f;
float spot_size = 40.0f;
bool enable_shadows = true;
bool use_dynamic_shadows = false;
};
struct Camera {
float fov = 75.0f;
2020-08-13 07:48:50 -04:00
float near = 1.0f;
float exposure = 1.0f;
2020-08-11 12:07:21 -04:00
Matrix4x4 view, perspective;
};
struct EnvironmentProbe {
bool is_sized = true;
2021-05-12 09:56:44 -04:00
prism::float3 size = prism::float3(10);
2020-08-11 12:07:21 -04:00
float intensity = 1.0;
};