AA 碰撞体 就是将所有的物体设置为矩形框进行碰撞计算。下面是代码
/*
* Copyright (C) 2010 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.replica.replicaisland;
/**
* An Axis-Aligned rectangular collision volume. This code treats other volumes as if they are
* also rectangles when calculating intersections. Therefore certain types of intersections, such
* as sphere vs rectangle, may not be absolutely precise (in the case of a sphere vs a rectangle,
* for example, a new rectangle that fits the sphere is used to perform the intersection test, so
* there is some potential for false-positives at the corners). However, for our purposes absolute
* precision isn't necessary, so this simple implementation is sufficient.
*/
public class AABoxCollisionVolume extends CollisionVolume {
private Vector2 mWidthHeight;
private Vector2 mBottomLeft;
public AABoxCollisionVolume(float offsetX, float offsetY, float width, float height) {
super();
mBottomLeft = new Vector2(offsetX, offsetY);
mWidthHeight = new Vector2(width, height);
}
public AABoxCollisionVolume(float offsetX, float offsetY, float width, float height,
int hit) {
super(hit);
mBottomLeft = new Vector2(offsetX, offsetY);
mWidthHeight = new Vector2(width, height);
}
@Override
public final float getMaxX() {
return mBottomLeft.x + mWidthHeight.x;
}
@Override
public final float getMinX() {
return mBottomLeft.x;
}
@Override
public final float getMaxY() {
return mBottomLeft.y + mWidthHeight.y;
}
@Override
public final float getMinY() {
return mBottomLeft.y;
}
/**
* Calculates the intersection of this volume and another, and returns true if the
* volumes intersect. This test treats the other volume as an AABox.
* @param position The world position of this volume.
* @param other The volume to test for intersections.
* @param otherPosition The world position of the other volume.
* @return true if the volumes overlap, false otherwise.
*/
@Override
public boolean intersects(Vector2 position, FlipInfo flip, CollisionVolume other,
Vector2 otherPosition, FlipInfo otherFlip) {
final float left = getMinXPosition(flip) + position.x;
final float right = getMaxXPosition(flip) + position.x;
final float bottom = getMinYPosition(flip) + position.y;
final float top = getMaxYPosition(flip) + position.y;
final float otherLeft = other.getMinXPosition(otherFlip) + otherPosition.x;
final float otherRight = other.getMaxXPosition(otherFlip) + otherPosition.x;
final float otherBottom = other.getMinYPosition(otherFlip) + otherPosition.y;
final float otherTop = other.getMaxYPosition(otherFlip) + otherPosition.y;
final boolean result = boxIntersect(left, right, top, bottom,
otherLeft, otherRight, otherTop, otherBottom)
|| boxIntersect(otherLeft, otherRight, otherTop, otherBottom,
left, right, top, bottom);
return result;
}
/** Tests two axis-aligned boxes for overlap. */
private boolean boxIntersect(float left1, float right1, float top1, float bottom1,
float left2, float right2, float top2, float bottom2) {
final boolean horizontalIntersection = left1 < right2 && left2 < right1;
final boolean verticalIntersection = top1 > bottom2 && top2 > bottom1;
final boolean intersecting = horizontalIntersection && verticalIntersection;
return intersecting;
}
/** Increases the size of this volume as necessary to fit the passed volume. */
public void growBy(CollisionVolume other) {
final float maxX;
final float minX;
final float maxY;
final float minY;
if (mWidthHeight.length2() > 0) {
maxX = Math.max(getMaxX(), other.getMaxX());
minX = Math.max(getMinX(), other.getMinX());
maxY = Math.max(getMaxY(), other.getMaxY());
minY = Math.max(getMinY(), other.getMinY());
} else {
maxX = other.getMaxX();
minX = other.getMinX();
maxY = other.getMaxY();
minY = other.getMinY();
}
final float horizontalDelta = maxX - minX;
final float verticalDelta = maxY - minY;
mBottomLeft.set(minX, minY);
mWidthHeight.set(horizontalDelta, verticalDelta);
}
}
分享到:
相关推荐
在LHC的s = 2.76 TeV和s = 5.02 TeV时,在外围Pb-Pb碰撞中研究了重矢量介子ψ和Y的唯一光产生。 为了评估先前在超外围条件下测试过的圆锥形偶极子形式主义的鲁棒性,计算了三个中心度类别的速度分布和核修饰因子(RA...
aard2-android, Android的Aard2,一个简单的字典应用程序 用于Android的 Aard 2Android 2的Aard是 Android的 Aard字典的继承者。 它带有重新设计的用户界面,书签,历史和更好的字典存储格式。下载用于Android的 Aa...
我们研究了pA和AA碰撞中C偶数介子的中央排他性生产截面的速度依赖性,其中A是重离子。 我们观察到由$$ \γ$$γ-Odderon和Pomeron-Pomeron融合机制引起的贡献在质量上有不同的行为。 这可用于从仅在前向区域产生的$$ ...
Android--AA记账助手 Android--Hide-Music-Player Android-3D卡片效果 android个人中心页面效果源码 Android仿微博、微信、qq 点击缩略图TransferImage Android例子源码IOS风格的uitableview列表 Android例子源码IOS...
Android项目开发实验报告,可以作为一个基础模板参考,对app的介绍十分详细。主要是一个AA结算的app
AA制消费信息管理系统 AA制消费信息管理系统
2.3 系统的主要功能 2 3.设计方案 3 3.1系统需求分析(给出程序的功能模块图,对各个功能作出详细介绍) 3 3.2系统界面设计(给出界面截图及其主要类的属性设置) 3 3.3系统程序设计(功能模块给出详细的程序代码,重点...
AA制消费系统,基于C++平台开发,功能强大,界面华丽!
在本文中,我们对LHC能量下pp,pA和AA碰撞中光子-光子,光子-pomeron和pomeron-pomeron相互作用产生的双喷产生进行了详细的比较。 使用前向物理蒙特卡洛(FPMC)在LHC能量下计算横截面的横向动量,伪快速度和角度...
javaee框架技术aa
Android_8.9.55_BBPJ_64_808277f8aa36e3494dae1b190c2aece.apk
5.02 $$ s = 5.02和13 TeV的pp碰撞中,涵盖了运动范围$$ | \ η| <0> 0 $$> 0),给出了结果。 报告了覆盖多个伪快速区域的两个多样性估计量的$$ p_mathrm {T} $$ pT谱。 标准化为INEL $$ \,> 0 $$> 0的$$ p _ {\ ...
asp源码—GetAA拼客系统asp版 v2.2.zip asp源码—GetAA拼客系统asp版 v2.2.zip asp源码—GetAA拼客系统asp版 v2.2.zip asp源码—GetAA拼客系统asp版 v2.2.zip asp源码—GetAA拼客系统asp版 v2.2.zip asp源码—GetAA...
Android手机另类刷机方法之
AA制就餐系统,C++编写。用于餐厅管理客户就餐费用系统
小米盒子3,MDZ-16-AA,系统镜像文件1.4.16d.full.img
在核-核(AA)碰撞中,对高pT颗粒产生的中等影响通常由核修饰因子(RAA)... 我们对外围RAA数据的解释将统一对较轻的碰撞系统或较低能量的观察结果,尽管没有强烈的射流淬火,但在这些观察中,椭圆形流动值仍然很高。
AA系统是一个财务系统,致力于小组的费用均摊,它适用于在一起居住,并且乐于均摊消费的人们。 该系统采用ASP.NET 2.0的XSD数据集来进行数据访问;使用AspNetPager进行分页;使用WebChart生成报表。 解压密码:...
接口设计是缔造系统整合架构之美的基础。例如,Android框架里常呈现 Template Method与Abstract Factory模式联合运用的结构,其中有两个重要的接口,搭配得似乎完美了。不过,Adapter模式将进一步隐藏...