2012-07-25 24 views
0

我需要在Away3D中做一些简单的碰撞检测。我发现away3d.bounds.AxisAlignedBoundingBox类,但似乎我只能检查边界框和Vector之间的碰撞。检查Away3D中两个边界框之间的碰撞?

有什么办法来检查两个边界框之间的碰撞吗?

+0

检查这篇文章上的Away3D冲突检测,它是关于3.6版本,但它可能是好消息:HTTP ://www.packtpub.com/article/away-3d-detecting-collisions – danii 2012-07-25 08:30:28

回答

2

如果您使用的/可升级到4.4.x到, 直视Mesh.worldBounds ,特别是wordBounds.overlap(someOtherWorldBounds)。

例(Away3D中设置省略掉):

// setup objects and materials 
cubeMaterial:ColorMaterial; 
cube:Mesh; 

sphereMaterial:ColorMaterial; 
sphere:Mesh; 

collideMaterial:ColorMaterial; 

cubeMaterial = new ColorMaterial(0x3333FF); 
cube = new Mesh(new CubeGeometry(), cubeMaterial); 
cube.x = -100; 
cube.showBounds = true; 

sphereMaterial = new ColorMaterial(0xFF3333); 
sphere = new Mesh(new SphereGeometry(), sphereMaterial); 
sphere.x = 100; 
sphere.showBounds = true; 

collideMaterial = new ColorMaterial(0x33FF33); 
在enterFrame事件处理程序

// process your object movement here 
if (cube.worldBounds.overlaps(sphere.worldBounds) cube.material = collideMaterial; 
else cube.material = cubeMaterial; 
view.render();