资源简介
椭球的碰撞检测 纯算法实现 你可以仔细想、阅读代码 虽然有些难懂 但成果会很大 坚持
代码片段和文件信息
//-----------------------------------------------------------------------------
// Name: ogl_basic_collision.cpp
// Author: Kevin Harris
// Last Modified: 02/01/05
// Description: As you may or may not know truly accurate collision
// detection between two 3D objects can only be done by
// performing an intersection test on every triangle in the
// first object against every triangle of the other object.
// Obviously it‘s too wasteful to just go around blindly
// performing this costly procedure on every object in the
// scene against every other object. To save us considerable
// CPU cycles we‘ll calculate and assign a bounding sphere
// for each of our 3D objects so we can perform a quick check
// to see whether or not the two objects are even close to one
// another and require further testing. In short if the two
// bounding spheres of our objects overlap then there exists
// a possible collision and we need investigate further by
// checking triangles. If the two spheres don‘t overlap a
// collision is not possible and we can move on.
//
// Note: Most of the math used in this sample is based on a small paper
// written by Gary Simmons which is one of the instructors at
// www.gameinstitute.com. I‘ve included the paper with the sample for reference.
// Please see it for further details.
//
// Control Keys: F1 - Toggle bounding sphere visibility
// F2 - Toggle triangle motion
//
// Up - View moves forward
// Down - View moves backward
// Left - View strafes left
// Right - View strafes Right
// Left Mouse - Perform looking
// Mouse - Look about the scene
//-----------------------------------------------------------------------------
#define STRICT
#define WIN32_LEAN_AND_MEAN
#include
#include
#include
#include
#include
using namespace std;
#include
#include
#include “resource.h“
#include “geometry.h“
#include “matrix4x4f.h“
#include “vector3f.h“
//-----------------------------------------------------------------------------
// SYMBOLIC CONSTANTS
//-----------------------------------------------------------------------------
enum Collision
{
COLLISION_NO
COLLISION_YES
COLLISION_NOT_CHECKED
};
//-----------------------------------------------------------------------------
// STRUCTS
//-----------------------------------------------------------------------------
struct triangle
{
vector3f v0;
vector3f v1;
vector3f v2;
vector3f vNormal;
// Bounding sphere
vector3f vCenter
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 7406 2003-10-07 09:50 ogl_basic_collision\codesampler.ico
文件 84480 2001-04-16 09:16 ogl_basic_collision\dot_product.doc
文件 51885 2005-01-27 18:19 ogl_basic_collision\geometry.h
文件 8993 2005-02-01 16:59 ogl_basic_collision\matrix4x4f.h
文件 29990 2005-10-04 22:20 ogl_basic_collision\ogl_basic_collision.cpp
文件 4612 2005-02-01 11:08 ogl_basic_collision\ogl_basic_collision.dsp
文件 110592 2005-10-12 23:25 ogl_basic_collision\ogl_basic_collision.exe
文件 3058 2003-10-07 10:46 ogl_basic_collision\ogl_basic_collision.rc
文件 5261 2005-02-01 12:32 ogl_basic_collision\ogl_basic_collision.vcproj
文件 1000 2002-05-02 22:30 ogl_basic_collision\resource.h
文件 4746 2005-03-24 21:34 ogl_basic_collision\vector3f.h
目录 0 2009-04-20 12:44 ogl_basic_collision
----------- --------- ---------- ----- ----
312023 12
- 上一篇:2010破解版.rar
- 下一篇:WebSocket测试小程序
评论
共有 条评论