Collision Detection of 3D game programming masters

Source: Internet
Author: User

Preface

I am very honored to write the preface to this important task. On the basis of this, I will teach programmers the necessary skills to create the next generation of 3D video games. There aren't many books that teach you how to create a real-time 3D engine. At the beginning, pixels are drawn. From the original game of Atari to the present, technology has developed so far. We were really pushing the state of the art then, but they really seem lame now.

Recalling the past, early games were simply not computer games in technical scenarios. Their imagination and status are based on simple or non-logic, but they lack the ability to integrate multiple media sets. You may remember that my first computer Space War was created in 1970, four years ago on Intel 4004, six years ago on 8080, I just want a microprocessor to create them. However, for real-time computing, the clock frequency at that time was too slow. This game is limited to an minor planet, and many of its processing is completed around hardware through a program, because the microprocessor capabilities are limited, and everything needs to be implemented by software. (Note: currently, gpu ppu sound cards can save CPU usage, while CPU is busy with logical operations)

Today, we are moving forward to creating a magical image (even if we cannot do that ). creating images fly to bring joy. In fact, creating any world, environment, or role requires the extraordinary Control of software and hardware by game developers. Through the color palette, we shorten the time and enrich it, making it possible for general projects.

Andre Lamothe not only closely understands these technologies, but also has a very special understanding of games. I have found many art-savvy players in gaming practitioners, but lack the feeling of creating exciting and entertaining games. Other thoughtful players, but lack ordinary programmers. Andre is a real player and software master. Each of his books shows his successful experience.

The recent project we worked with impressed me not only with its rich artistic knowledge reserves, but also with the rich experience of dark theme games left over from history. It took 19 days to write about all the games, and he was easy to remember, but the knowledge of other things was about Stinker (yes, Atari DIA a few that were really bad ). but we have made more, more classic, you know.

I hope you like this book and use it to create some great games that will make me happy to play in the future.

Nolan Bushnell founder of Atari, Inc

1568 page 3D Collision Detection

Collision Detection-Collision Detection

Although I want to spend a whole chapter on collision detection, it is important that I spend a lot of pages describing graphics algorithms and rendering, especially this book. In the case of the least, collision detection will exceed the geometric processing, and there are a lot of interesting problems waiting to be solved, whether it is intersection or collision. I encourage you to keep it simple. In 99% of the time, simple balls, cube ranges, and good work will become complicated in real algorithms, So let's review some concepts.

Bounding spheres and cylinders sphere range and cylinder

The initial collision detection method was to use a sphere or a cylinder to enclose each object or test collision within a certain range. Let's assume that we have two objects a and B, 15.19.

Each object is surrounded by a sphere with a radius of RA and Rb, Which is detected by the radius of RA and Rb. We can simply check whether the distance between them is smaller than RA + RB or

If (Dist (PZ + Pb) <(RA + RB) {// collsion has occurred} // end if

Dist calculates the full distance between Pa and Pb. Of course, if the object is naturally not spherical, such as a pipe and a wood, the range ball won't work too well. In my experience, you can use a tight range ball for quick writing. In this way, you can narrow the range to the original 50-70%.

In addition, you can use other range balls such as a cylinder and longitude ry. As long as the cylinders are oriented the same way, then the test for collision is similar. See figure 15.20 as an example.

In the figure, we can see that the radius of the two objecta and B are Ra and Rb respectively. However, to test the collision, we need to test two things: the intersection of the Y axis and the ring rad II. Test here: calculate the distance between two points (PA) and Pb in the 2D X-zplane.

Of course, you can continue to use a variety of range volumes to help you better solve the appropriate problems, such as the axis or object axis-aligned volume boxes. Collision Tests are similar. You need to calculate objects overlap with a battery of geometric tests.

Note: Some classic books include computing image ry and ry tools, good graphics and classical series of game programming.

Use data structures to accelerate Collision Detection

Finally, I would like to introduce some optimization issues of collision detection. Collision Detection Technology is like a formula. We all know that there are many books to show it, and everyone uses the same mathematics. Not necessarily the speed of real-time gaming and theoretically collision detection.

For example, suppose you have 1000 objects in the game world (object, bullet, etc.)-it is very easy to think of first-person and space games. Now suppose you want to complete the collision detection of 1000 obejcts: 1000x1000 = 1000000. Now it is assumed that all the objects are emitted, the particles are flying, and each object increases by 1000. Now you can calculate 10000x10000 = 100000000. Obviously the fastest line division or range won't help you. At this point, you have to think about collision from different perspectives and use space division.

We will discuss special segmentation. When we talk about BSP trees and octrees, I upgraded the data structure, which is not only useful for graphics, but best for collision. You can see why. Using these data structures, we can separate our objects into units or areas and into internal areas. This may be only a few hundred or fewer pieces of data. The calculation amount is reduced.

For example, if we use 10000 objects, we will talk about sector, octree or BSP. In the gaming world, we will find about 50 objects for each unit. So we have to process 10000/50 units, and we will process 50x50 of the calculations, all of which are 200X2500 = 500000.

This is much better than 100000000! In addition, the smart use of separation, we solve the problem so that 100000000 to 500000 computing to 5% of the work.

When you need to use collision detection, You need to jump out of the box. do not focus on the testing range box or polygon of low-level algorithms to start universal Collision Detection Algorithms and work.

Terrain-following Technology

Finally, I want to discuss more questions. When you write about the game's terrain, you must go on to the tanks of the terrain, the game role or whatever. In most terrain demos behind this book, we have used a very simple (but effective) Physical Model to scan the polygon mesh and find the patch for top height, raise or put down the model, clear or change from the current location to the new location.

It seems so good. It feels good. It consists of 10 lines of code. However, the problem is that the object is still under the terrain. Here, if we see that the object does not feel good, for example, it is appropriate to promote or put down the model, but it will not follow the terrain. Let's fix it.

Comment: it seems that even the 3D game programming masters have not provided substantial code in collision detection.

Sorry!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.