//!Collision-detection function collection /*! * Collision-detection function collection * Provides intersection tests for several common cases */ /* * Copyright (C) 2006-2010 Alejandro Valenzuela Roca, * * This file is part of MotorJ, a free framework for videogame development. * * * * MotorJ is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * MotorJ 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with MotorJ. If not, see . * * * Real-Time Rendering by Tomas Akenine-Möller and Eric Haines was used as * a reference to implement some of the algorithms. * */ /* * "Pixel por Pixel, polígono por polígono" * - Colisión por el bien de todos * */ #ifndef COLLISIONS_H #define COLLISIONS_H #include #ifndef NINTENDO_DS #ifndef NINTENDO_WII #ifdef VISUAL_STUDIO #include #endif #include #include "lanjobot.h" #endif #else #include #endif #include "support.h" #define AACIL_TOL 0.1 #define COLR_NOCOLLISION 0 #define COLR_OUTSIDE 0 #define COLR_OVERLAP 1 #define COLR_EXACT 1 // col_ray_tr return values: #define COLR_OVER 2 #define COLR_UNDER 3 //! Axis-aligned box vs Axis-aligned box collision test short col_aabb_aabb(vector3 & a_min, vector3 & a_max, vector3 & b_min, vector3 & b_max); //! Axis-aligned box vs point collision test short col_aabb_pt(vector3 & a_min, vector3 & a_max, vector3 & pt); //! Oriented bounding box vs oriented bounding box collision test short col_obb_obb(obb & a, obb & b); //! Sphere-on-sphere collision test short col_sph_sph(vector3 sphcen0, float r0, vector3 sphcen1, float r1, vector3 * sph0_sph1); //! Ray vs triangle collision test short col_ray_tr(vector3 & ray_origin, vector3 * ray_dir, triangle & tr, vector3 * correction); //! Point vs axis-aligned cylinder collision test short col_pt_aacyl(vector3 & point, vector3 & cyl_base, float cyl_height, float cyl_radius, vector3 * correction); //! Ray vs sphere collision test short col_ray_sph(vector3 & ray_origin, vector3 & ray_dir, vector3 sphcen, float r, vector3* correctionArray); short col_tr_aabb( triangle & tr, vector3 & a_min, vector3 & a_max); #endif