- 浏览: 314934 次
- 性别:
- 来自: 益阳
文章分类
最新评论
-
duckbit:
楼主是否能把共享layout的例子发给我,有点没明白 谢谢额! ...
Android换肤apk -
天涯海角262253:
...
Androidpn里的Xmpp的理解 -
lbstudy:
Activity之间的切换动画 -
dumbnesslys:
楼主可不可以给个源码 ,就build.xml的 772774 ...
Ant自动打包 -
finaljava:
build.xml 这么复杂,看看这个吧http://angr ...
Ant自动打包
In the last post I discussed how Replica Island uses line segments organized as a 2D regular grid of tiles as the basis for its background collision system. This time I will explain how dynamic collisions (collisions between moving objects) are detected and resolved.
In Replica Island I draw a distinction between collisions that occur with the background geometry (falling on the ground, sliding on a slope, hitting the Android's head on the ceiling) and collisions that occur between game objects (the Android depressing a button, or hitting an enemy, or collecting a coin). While both of those cases are forms of "collision detection," they represent very different types of tests and I have two (entirely separate--mostly) systems for dealing with them.
Moving objects vs the background
Since I alluded to how background collision detection works in the last post, I'll start with that system. If Android is falling through space and passes into the ground, I need to detect that intersection and then fix it so that he doesn't actually fall through the floor. This is actually a pretty tricky problem because the frame rate of any Android game (and really, any modern game on any platform) can fluctuate as the game is played. The Android moves through space in game units / second, but the game is displayed in frames per second, and depending on the current speed of the game there's no good way to predict how far he'll move in a single frame. So I need a method that can cover a range of space between the last frame and this one so that even a dramatic movement won't allow the player to pass through walls.The solution is to "sweep" the space in between the character's position at the last frame and his current position, and snap the character back if an intersection is detected. I use rays to do this: rays are cast from a character's previous position to his current position, and the first intersection along the ray (that is, the intersection that is closest to the ray's start point) is considered to be the spot at which the character hit a wall. I also filter my ray test by the normals of the surfaces I am considering; surfaces that do not oppose the direction of the ray can be ignored (that is, I only care about surfaces whose dot product against the direction of the ray is less that 0). Characters are not well described by a single, thin ray, however, so I do two tests: one filtered against horizontal surfaces and one filtered against vertical surfaces (angled surfaces fall into one bucket or the other depending on their slope). This is a nice method because it allows me to tune exactly how I test a volume against collision; often I want to allow a small amount of intersection: when the character is standing on a sloped surface, for example, I want to allow his bounding box to intersect with the slope slightly so that it looks like his feet are on the ground. With a couple of simple ray tests this method covers the space between the previous frame and the current frame pretty well without too much processor overhead. I briefly experimented with a final volume test pass to make sure that collisions were not being missed by the ray tests, but in the end such a test wasn't necessary (and actually, despite being more technically correct, the results were a lot less fun).
Sometimes I want game objects that act like background collision but are not part of the collision tile map. For example, a moving platform might act in every way like a background element except that it can move. In these cases, I allow entities to submit temporary line segments to the background collision system which will then be used along with all the rest of the background collision line segment data. This way characters in the world can be made to act exactly like solid objects without remaining static, and other characters can come along and react to them without any special code.
Moving objects vs each other
However, the more common case is when two game objects--a bullet and the player, an enemy and some spikes, etc--that are moving and non-solid come into contact. In this case we need to detect the intersection and then let code specific to each entity decide what to do about it. Still, we can generalize the system a little bit more: usually in such collisions we can name one of the entities as the "offender" and the other entity as the "victim." When a bullet hits the player, the bullet is the offender and the player is the victim. When a robot runs into some spikes, the spikes are the offender and the robot the victim. In fact, if we consider an animating character, we might want to mark some parts of a given frame of animation as "offensive" and other parts "vulnerable." In a game where a character can punch, we probably want the character's fist to deal damage to other characters but at the same time we'd expect other parts of the character, say his back and head, to be vulnerable to hits. So in order to detect collisions between game entities, I decided to give my entities multiple collision volumes, some associated with offensive areas and others associated with areas that are vulnerable to hits.Each animation frame in Replica Island can carry a list of "attack" volumes and "vulnerability" volumes. When detecting collisions, I stipulate that collisions can only occur between a single attack volume and a single vulnerability volume. Furthermore, volumes can be set to deal and receive specific types of hits, which allows me to filter the number of actual volume intersection tests I need to perform (for example, the coin is only vulnerable to a "collection" hit, so only collection-hit-dealing attack volumes will be tested against the coin.
Each time an animation frame changes a new set of attack and vulnerability volumes may become active. These volumes are unioned together into a sphere that is guaranteed to encompass them called the bounding sphere. The volumes, along with the bounding sphere, are then submitted to the runtime collision detection system. Each frame, the collision detection system sorts all of the bounding spheres that have been submitted and tests them for intersections. The sort is by the left-most point of the sphere, so objects end up sorted along the x-axis of the level. This is a type of sweep and prune algorithm, and it makes it easy to quickly find overlapping bounding spheres because potentially colliding sphere pairs are guaranteed to be grouped together in the sorted list. When a pair of bounding spheres that intersect is found, each of the related entities' attack and vulnerability volumes are tested for intersection. If an intersection between an attack volume and a vulnerability volume is found, we know that these two entities have hit each other and some other code needs to run in order to respond.
For a long time the Replica Island engine only supported sphere collision volumes for these kinds of dynamic tests. About half-way through development I added an axis-aligned box collision type as well, but otherwise no complicated collision volume tests have been necessary. I'm very happy with the way that this system turned out: it's reliable, fast, and easy to extend.
发表评论
-
Want to Change the Game Industry? Support the Xperia PLAY.
2011-12-07 21:05 0The problems with the console g ... -
Replica Island Updated
2011-12-07 21:04 0Yesterday I uploaded the first ... -
Hot Failure
2011-12-07 21:04 0An article I originally wrote f ... -
Building a Reflective Object System in C++
2011-12-07 21:03 0Every game engine I've worked w ... -
Leveraging Java and C++ for Hybrid Games
2011-12-07 21:02 0I've been thinking a lot lately ... -
Game Object Construction Rabbit Hole
2011-12-07 21:01 0Today I want to write a little ... -
Long Time, No See
2011-12-07 21:00 0I haven't written anything here ... -
Replica Island Passes a Million Installs
2011-12-07 20:59 0Holy crap!Replica Island passed ... -
Control Configuration and Abstraction
2011-12-07 20:58 0The #1 thing that I've learn ... -
Design Post-Mortem: Three Mistakes
2011-12-07 20:58 0While I'm pretty happy with Rep ... -
Replica Island: One Month On
2011-12-07 20:57 0As of today, Replica Island ... -
My New Favorite User Feedback
2011-12-07 20:56 0You can't write this stuff ... -
Replica Island User Comments Are Hilarious
2011-12-07 20:55 0Update: Blogger apparently isn' ... -
Design Post-Mortem: The Possession Orb
2011-12-07 20:55 0Rather than write a big lo ... -
Replica Island Released!
2011-12-07 20:54 0I released Replica Island almos ... -
Fragmentation? More like Fragmentawesome.
2011-12-07 20:53 0I'm lucky enough to have occasi ... -
The Elusive Perfect Platformer Camera
2011-12-07 20:52 0I've come to believe that platf ... -
Game Play Video
2011-12-07 20:51 0Here's some footage of an early ... -
Tuning With Metrics Redux
2011-12-07 20:50 0A while back I posted about the ... -
Some Screenshots
2011-12-07 20:49 0I've posted some screenshots of ...
相关推荐
【航天时序异常检测与LSTM技术】 随着航天技术的发展,航天器不断向地球发送海量遥测数据。这些数据包含了航天器的健康状态、运行状况等关键信息,但同时也带来了巨大的处理挑战。传统的异常检测系统通常只能处理...
Toward Automated Detecting Unanticipated Price Feed...论文分享PPT
3.7 Learn to Inspect Data: Variables and Expressions . . . . 29 3.8 A Debug Session on a Simple Example . . . . . . 30 4 Fixing Memory Problems . . . . . . . . . . . . 33 4.1 Memory Management in C/...
respond to imminent collisions. We employed the locusts’ vision mechanism to motion control of a mobile robot. The selected image processing method is implemented on a developed extension module ...
Moving on, you will add user-detecting classes and APIs such as gesture detection, touch screen listeners, and sensors to your app. You will also learn to adapt your app to run on tablets and other ...
### 检测音乐音频中的和声变化 #### 摘要 本文介绍了一种用于检测音乐音频信号中和声内容变化的新方法。该方法基于一个新颖的等温调音阶空间模型,将12-bin色度向量映射到一个6维多面体的内部空间;...
Collaborative Cyber Threat Intelligence 英文无水印pdf pdf所有页面使用FoxitReader和PDF-XChangeViewer测试都可以打开 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,...
在这个场景中,"Detecting collisions between polygons" 涉及到的技术主要是几何碰撞检测。 首先,我们需要了解多边形的基本概念。多边形是由一系列线段(边)连接而成的闭合图形,这些线段在二维空间中形成一个...
### 检测控制系统的仪器故障 #### 引言与背景 本文主要探讨了一种用于自动检测控制系统中反馈传感器(或仪器)潜在故障的方法。在许多工业自动化领域中,反馈传感器是确保系统稳定运行的关键部件。...
to computer forensics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 1.6.1 Basic communications on the Internet. . . . . . . . . . . . . . . . 32 1.6.2 Computer security and computer ...
This book is a wake-up call explaining how to detect and prevent the hacking of medical equipment at hospitals and healthcare facilities. The vulnerability of the medical equipment inside the hospital...
Start Nmap scanning, discover hosts, port scan, detecting operating systems, and detect service and application versions . Raise those Fingerprints Understand the mechanics of Nmap OS fingerprinting, ...
### 使用BLAST检测与分析文本重复 #### 摘要 本文主要介绍了一种通过利用BLAST(基本局部对齐搜索工具)来检测文本重复的新方法。该方法着重于改进传统算法,使其不仅适用于生物信息学领域中的DNA及蛋白质序列比对...
Dynamic branching prediction and branch prediction logic. The Pentium on-chip caches. Pentium compatibility. Extensions to the Pentium registers. Model-specific registers. Feature control ...
Given very few images containing a common object of interest under severe variations in appearance, we detect the common object and provide a compact visual representation of that object, depicted by ...
LFM算法(Detecting_the_overlapping_and_hierarchical...) 是一种用于复杂网络中社团结构检测的算法,该算法能够发现网络中的社团结构,特别是能够识别允许节点重叠的社团以及社团之间的层次结构。LFM算法由Andrea ...
tion algorithms, feature selection method and the number of top features in order to find the combination that yields the best performance in detecting new malware on Android. Empirical results ...
"Eye-location-and-face-detecting.zip"这个压缩包文件包含了相关的MATLAB代码和资源,旨在帮助研究者或开发者进行精确的眼部和面部检测。MATLAB是一种强大的编程环境,特别适合于数学计算和图像处理任务,因此它在...