forum.boolean.name

forum.boolean.name (http://forum.boolean.name/index.php)
-   Программирование (http://forum.boolean.name/forumdisplay.php?f=54)
-   -   Коллизия - столкновение обектов в 3Д мире (http://forum.boolean.name/showthread.php?t=8629)

beZ_probleM 08.07.2009 02:52

Коллизия - столкновение обектов в 3Д мире
 
подскажыте плиз как организовать столкновение(пересичение(?)) обектов в 3Д мире?
у меня есть два обекта
один обект двигается по "горбатой" поверхности(холмы и впадины)
и он не должен проваливатся сквоь неё...
какими методами можно такое организовать?

кто хоть чтото знает отписуйте пожалуйста

beZ_probleM 08.07.2009 02:59

Ответ: Коллизия - столкновение обектов в 3Д мире
 
нашол вот такое...
Цитата:

The simplest form of collision-detection I know of uses bounding circles. I'm assuming you're doing a 2-Dimensional game but the same procedure works just as well in 3D (except then they're called bounding spheres, not circles!).

Let's say every moving piece of your game is represented by a GameObject class, which has an x and a y co-ordinate, plus a radius that describes a circle big enough to completely surround the GameObject. You keep all your GameObjects in an array:

GameObject[] objects;

Collision Detection can be computationally expensive if you have a lot of moving objects because in the exhaustive case you have to compare every object with every other object.

int i,j,dx,dy,r1s;
GameObject g1, g2;
for ( i = 0 ; i < objects.length-1 ; i ++ ) {
g1 = objects[i];
// calculate the radius squared
r1s = g1.radius * g1.radius;
for ( j = i+1 ; j < objects.length ; j ++ ) {
g2 = objects[j];
// calculate the distance between the 2 objects
dx = g1.x - g2.x;
dy = g1.y - g2.y;
// if the distance squared is less than both of
// the radii squared, the circles overlap (collision!)
if ( ( (dx * dx) + (dy * dy) ) < ( r1s + (g2.radius * g2.radius) ) ) {
doCollision( g1, g2 );
}
}
}

This is the easiest way to do things, but of course it only works well with objects that are perfectly round ( PacMan ! ). What you should do if you need more accurate Collision Detection is use this method first to see if any of the bounding spheres overlap. If they do, use a more precise (and more computationally intensive) C.D. method like line or polygon intersection.
если я правильно перевожу, то здесь пишется что ето для круглых обектов тоесть центром столкновения есть точка(не полигоны)?
меня впринцыпе ето устраивает... ещёбы ктото обяснил как ето использовать в програме))

pax 30.06.2010 01:27

Ответ: Коллизия - столкновение обектов в 3Д мире
 
Столкновение объекта с ландшафтом в простейшем случае организуется на основе карты высот. Определяется позиция объекта на карте высот, рассчитывается высота "земли" под ногами, положение объекта над землей корректируется в соотвествии с полученной высотой.

Другой вариант - проверять пересечение луча, пущеного из точки объекта вниз с каждым треугольником ландшафта. Здесь более сложная математика.

Ой я нечайно тему поднял ))

nil0q 05.01.2011 22:00

Ответ: Коллизия - столкновение обектов в 3Д мире
 
-> http://forum.boolean.name/showpost.p...24&postcount=2


Часовой пояс GMT +4, время: 12:07.

vBulletin® Version 3.6.5.
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Перевод: zCarot