Added basic triangle raycasting.
This commit is contained in:
@ -18,8 +18,10 @@ void RayTester3D::onStart() {
|
||||
|
||||
void RayTester3D::onUpdate() {
|
||||
prefab->transform.setLocalPosition(glm::vec3(0, 0, 0));
|
||||
box.max = glm::vec3( 0.5f, 0.5f, 0.5f);
|
||||
box.min = glm::vec3(-0.5f, -0.5f, -0.5f);
|
||||
|
||||
triangle.v0 = glm::vec3(-0.5f, -0.5f, 0);
|
||||
triangle.v1 = glm::vec3(0.5f, -0.5f, 0);
|
||||
triangle.v2 = glm::vec3(0, 0.5f, 0);
|
||||
|
||||
auto mouse = this->getGame()->inputManager.getAxis2D(INPUT_BIND_MOUSE_X, INPUT_BIND_MOUSE_Y);
|
||||
mouse *= 2.0f;
|
||||
@ -32,7 +34,7 @@ void RayTester3D::onUpdate() {
|
||||
// prefab->transform.setLocalPosition(pos);
|
||||
// ray.origin = glm::vec3(0, 0, 5);
|
||||
|
||||
bool_t x = raytestAABB(ray, box, &hit, &normal, &distance);
|
||||
bool_t x = raytestTriangle(ray, triangle, &hit, &normal, &distance);
|
||||
|
||||
if(x) {
|
||||
prefab->material->color = COLOR_RED;
|
||||
|
@ -14,7 +14,7 @@ namespace Dawn {
|
||||
public:
|
||||
SimpleSpinningCubePrefab *prefab;
|
||||
Camera *camera;
|
||||
struct AABB3D box;
|
||||
struct PhysicsTriangle triangle;
|
||||
struct Ray3D ray;
|
||||
glm::vec3 hit;
|
||||
glm::vec3 normal;
|
||||
|
@ -9,8 +9,4 @@ using namespace Dawn;
|
||||
|
||||
CubeCollider::CubeCollider(SceneItem *item) : Collider3D(item) {
|
||||
|
||||
}
|
||||
|
||||
bool_t CubeCollider::raycast(struct Ray3D ray, struct Collider3DRayResult *out){
|
||||
return false;
|
||||
}
|
@ -5,6 +5,7 @@
|
||||
|
||||
#pragma once
|
||||
#include "Collider3D.hpp"
|
||||
#include "physics/3d/Ray3D.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
class CubeCollider : public Collider3D {
|
||||
@ -13,7 +14,5 @@ namespace Dawn {
|
||||
glm::vec3 size = glm::vec3(1, 1, 1);
|
||||
|
||||
CubeCollider(SceneItem *item);
|
||||
|
||||
bool_t raycast(struct Ray3D ray, struct Collider3DRayResult *out)override;
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user