3DSTATEfor Visual basic.Net开发
注:转载请说明来源处!
三、Collision Detection碰撞检测
碰撞检测主要的函数就是STATE_engine_is_movement_possible
当然,含有其他的一些函数
STATE_engine_is_movement_possible_camera_space
STATE_object_is_movement_possible
STATE_camera_move_with_collision_detection
STATE_object_drop_down
STATE_object_drop_down_fast
1、设置不碰撞对象
如飞机穿梭云中,就不参与碰撞。如:
STATE_object_make_non_collisional( CloudHandle )
设置对象是否碰撞,用如下函数:
STATE_object_make_collisional()
STATE_object_is_collisional()
2、计算A点和B点
A点和B点主要用于计算它们是否碰撞。
首先获取第一个碰撞对象的位置:
STATE_object_get_location1( CarHandle, CarLocation)
然后获取它的方向:
STATE_object_get_direction1( CarHandle, CarDirection)
注意: CarLocation和CarDirection都是矢量,为一个数组。
ahead_of_car(0)= dblCarLocation(0)+ speed * dblCarDirection(0)
ahead_of_car(1)= dblCarLocation(1)+ speed * dblCarDirection(1)
ahead_of_car(2)= dblCarLocation(2)+ speed * dblCarDirection(2)
现在检测碰撞
If STATE_object_is_movement_possible(CarHandle, CarLocation, ahead_of_car, _
intersecting_polygon, intersection_point, intersecting_object) == YES Then
//Nothing is blocking the path, it's ok to move
STATE_object_move( CarHandle, OBJECT_SPACE, -speed, 0, 0)
else
//Something must be in the way...
End If