Sunday, June 19, 2022

good C++ logic in collision detect and math library

    Developer ToolBox

  1. 3D Math Code
  2. It's just some base library for 3D-Math, but I think, it's not bad. Give it a try. It's not *fully* tested, because I hacked the last files together this morning... but I think, it's very easy to use.

  3. Math Library
  4. Here's my hat in the ring for math libraries. It's the math system for the engine I'm currently developing. I'm posting it in the hopes that someone else may find it usefull, but because I also want people to nitpick about it, any errors I may have missed, and ways to improve it. I am still working on the classes and adding to it, so any help is, of course, appreciated. The engine also works standalone, the project included compiles as a static library, which can easily be linked into a project. The include files are all linked through the GEKXMath.h file, so you only have to include it. The source is also commented (decently), compatible with (and a project file for) DoXygen source commentor. So far, it sports quite a few features:

    1. 2D/3D/4D vectors (seperate classes, I opted to seperate them instead of templating them so that I didn't have to specialize anything). I have overloaded basic operators for conveniance (like plus, minus, multiple, divide. I didn't want to overload actuall functions (like dot or cross product), because I felt it gets confusing to overload these, everyone has a different spin on what symbols to use.
    2. A quaternion class, with everything I've found that I've needed (so far at least).
    3. A 4x4 matrix class (and conversions between quaternions and matrices in the classes), with rotations, scaling, etc (everything a matrix should be able to do).
    4. A plane class, simple so far, I've just starting adding interesection between containment objects.
    5. A bounding sphere, and an axis aligned bounding box class, with intersections tests against themselves and each other.
    6. A 6 plane view frustum class, and a function to generate the planes from a projection matrix, and visibility checks against points, bounding spheres, and axis aligned bounding boxes.

    Featured Articles

  5. 3D Pong Collision & Response
  6. Here is an example / inspiration on how to handle a 3D pong / breakout game. It handles AABBox / Sphere collision tests, and perform some simple collision physics, based on an extended 'velocity reflection' model (does friction / restitution and handles difference in object mass). Thanks to the physics, Objects don't get squashed on walls, and react pretty well to multiple simultaneous collision. The code is unoptimised, but should be already quite fast already. SInce the collision detection routines work on overlaps, you have to be careful with the velocity of the objects, and their relative size (relative to their velocity). Swept tests would solve the problem of both accuracy and stability on thin&fast moving objects, but that's for another COTD.... Other goodies are,

  7. Source Documentation with Doxygen
  8. I used to maintain that good code is self-documenting. While I still believe that to a certain extent, such thinking makes a lot of assumptions about the person(s) who may be reading the code. As your project grows larger and additional programmers of varying skill levels (and areas of expertise) come on board, the need for good commenting and documentation becomes pretty clear.

  9. Plane Class
  10. This is a simple plane class that allows you to calculate the equation of a plane given three points, determine a points orientation to the plane and determine if a line from point1 to point2 intersects the plane

  11. A Small, Portable 3D Engine
  12. For the last few years at school, I�ve been using a TI-85 Graphing calculator. About a year and half ago, I tried to write a simple orthographic display, but it never got anywhere. Last month, I was extremely bored in math class, so I decided to see what I could program. I suddenly came up with a great idea for a perspective projection and implemented it. Various enhancements and optimizations have led to the 3D engine I use today. This article will describe the evolution of my engine from a sample program to a full library of portable software rendering functions, and document this library, called pGL (portable GL). The library interface is based on OpenGL (as much as a set of TI-85 programs can be based on C), because it is very simple and easy to use, and I also don�t need to replicate the long initialization and error-checking routines of DirectX.

  13. Basic Collision Detection
  14. I've seen a few tutorials on basic collision detection around the net, but most of them I've read are either pretty confusing or somewhat incomplete. I've attempted here to write a tutorial that anyone with a basic understanding of 3D concepts and linear algebra should be able to pick up on quickly. If you're already familiar with collision detection, there's no real reason to read further. I'm not presenting anything new here, just stating the basics and suggesting a few possibly "better" ways to do a step or two.

  15. 3D Geometry Primer: Chapter 1 by Bram de Greve
  16. Chapter 1 and chapter 2 are good.

No comments:

Post a Comment