GIMPACT Handbook

Francisco León

0.0.1

Abstract

GIMPACT Geometric tools for VR.


Table of Contents

1. Introduction
1. Features
2. Geometry basics
1. Coordinate System
2. Trimeshes
3. Memory Basics
3.1. Buffers
3.2. Dynamic Arrays
4. Creating Trimeshes
4.1. Trimesh components
4.2. Building a Trimesh
5. Modifying Trimeshes
5.1. Modifying Vertices
5.2. Linear Transformations
3. Collision Detection
1. Finding Collision Pairs
1.1. Rectangular Boxes :AABB
1.2. Finding Interferences on a Room
2. Finding contacts between trimeshes
3. Finding contacts between a trimesh and a sphere
4. Finding contacts between a trimesh and a capsule
5. Finding contacts between a trimesh and a OBB
6. Finding contacts between a trimesh and a cylinder
7. Finding contacts between a trimesh and a convex polyhedron
4. Integration of GIMPACT with other packages
1. Integration with Open Dynamics Engine
2. Integration with Gammaleon
5. Building GIMPACT from sources
1. Using CODE::BLOCKS
6. Recomendations
1. TODO
2. Bugs
7. References
1. Links

List of Figures

2.1. Right Hand Coordinate System
2.2. Trimesh.
2.3. Linear Transformation.
3.1. Shape interference.
3.2. AABB.
3.3. Object Interferences.
4.1. ODE physics with GIMPACT trimesh collision.
4.2. Gammaleon Physics collision.

Chapter 1. Introduction

Table of Contents

1. Features

GIMPACT is a software library written in C language, which consists on a set of geometric tools focused designed for support projects based on Virtual Reality.

In this release it gives tools for contact surface determination for physics objects. This is important in Virtual Reality simulation and games, because bodies interact between them reacting to applied forces resulting from collisions.

GIMPACT collision functions can be used in other physics libraries, take as example Open Dynamics Engine. In this case was necessary to drop out OPCODE system in favor of GIMPACT. As consecuence of this, ODE improves its trimesh collision functionallity with a very superior performance; the buggy trimesh behavior was fixed definitively.

Another advantage of GIMPACT is that it doesn't have hierarchy structures (trees), unlike OPCODE. It gives to GIMPACT the capability of managing dynamic trimeshes like deformable bodies and cloth.

See how GIMPACT allows to implement trimesh collisions successfully in section Integration of GIMPACT with other packages.

GIMPACT collision routines were implemented optimally: it consumes very litle processor resources thanks of its simple design and it takes advantage of precalculated results in cache.

1. Features

  • Collisioin between trimesh shapes, concave or convex.
  • Trimesh dynamic structures allow managing deformable bodies.
  • Supports Vertex Buffers e Index Buffers.
  • Low memory requirements. It DOESN'T USE TREES and It DOESN'T USE HASH TABLES.

Chapter 2. Geometry basics

1. Coordinate System

GIMPACT uses the Right Hand Coordinate System:

Figure 2.1. Right Hand Coordinate System

Right Hand Coordinate System

2. Trimeshes

Object surfaces are often represented as discrete aproximations which consists on a set of vertices and triangular faces.

A trimesh has the following attributes:

  • A set of vertices. (With 3 coordinates)
  • A set of triplets which corresponds to each triangle indices.

Take the following trimesh example:

Figure 2.2. Trimesh.

Trimesh.

Notice that:

  • Triangular faces share common vertices.
  • Vertices v1,v2,...v7 have the following indices: [0,1,...,6].
  • Vertices from a triangular face should be enumerated in inverse clock order, because the rule of cross product for the Right Hand Coordinate System.
  • Indices of triangular faces must be : [0,2,1;2,3,1;2,4,3;4,5,3;4,6,5 ]

3. Memory Basics

GIMPACT design was developed in mind for taking advantage of multi-processing capabilities of modern computers and also for distributed architechture enviroment (GRID Processing).

For that reason GIMPACT implements a memory management system which allows getting access to data wich would comes from many memory sources (System memory, GPU video memory etc.) althougt it protects the memory access on concurrent processes. For example , in a modern PC we will found the following memory sources:

  • System memory.( Managed by the C memory functions nativelly, like malloc does)
  • Vertex Memory from GPU or Vertex buffers.
  • Fragment Memory from GPU or PBuffers .( Used for image and geometry processing.)

But at this moment, GIMPACT only suports system memory access. In next releases it will support paralele processing and SIMD instructions.

GIMPACT have these memory management systems: Buffers and Dynamic arrays.

3.1. Buffers

A buffer refers to a memory resource which belongs to a Memory Manager. At this moment there are these avaliable memory managers :

  • G_BUFFER_MANAGER_SYSTEM : Corresponds to allocated data in system memory by the malloc() function. It should be destroyed by GIMPACT when the program terminates.
  • G_BUFFER_MANAGER_SHARED : Corresponds to data allocated in user application, like a pointer to another array. Shared use. It must be managed, initialized and released by the user.

GIMPACT requires to initialize its internal structures before using its memory routines.

[Important]Important

Before using GIMPACT, call this function gimpact_init() for initializing its internal structures.

[Important]Important

At end call gimpact_terminate() for releasing memory resources.

For creating memory buffers you would use the following methods:

For accessing buffers like accessing to an array, use BUFFER ARRAYS. There is an example in BUFFER ARRAYS Details

3.2. Dynamic Arrays

Dynamic arrays are data structures for general purpose collections. They are created on system memory, and have the hability of change their size, adding and removing their elements.

See how to use them on :DYNAMIC ARRAYS

4. Creating Trimeshes

4.1. Trimesh components

  • Vertices: A BUFFER ARRAY of vectors.
  • Indices: A BUFFER ARRAY of triplets which contain the triangle indices.
  • AABB set: A GIM_AABB_SET structure which consist on a set of Axis Aligned Boxes which correnspond to the rectangular volume occupied by each triangle.

4.2.  Building a Trimesh

Use this function: gim_trimesh_create_from_data, it will create a trimesh from application native data.

If you want to create a trimesh from buffers (F.E. from video hardware memory) use gim_trimesh_create_from_arrays.

Trimeshes use buffers strongly, for supporting concurrent access and multi-processing, see Buffers.

Is recommended to see trimesh reference at: TRIMESH.

5. Modifying Trimeshes

GIMPACT supports collisions between moving trimeshes and deformable bodies. On each interval simulations could modify the state of the trimesh, applying a linear transformation or changing their vertices directly. Then Trimeshes will update their structures quickly in a execution time near to O(log(n)) .

5.1. Modifying Vertices

GIMPACT trimeshes have their vertices contained in a GBUFFER_ARRAY. See Buffers and BUFFER ARRAYS

See how to modify trimesh vertices at: TRIMESH.

5.2. Linear Transformations

GIMPACT have matrix transformations with these types:mat2f,mat3f y mat4f. Matrices are row oriented:

Figure 2.3. Linear Transformation.

Linear Transformation.

Para saber como aplicar transformaciones lineales a los vertices de una superficie triángular, vease TRIMESH.

Chapter 3. Collision Detection

1. Finding Collision Pairs

For accelerating the collision process it is necessary to avoid expensive calculations detecting which pairs of objects won't intersect.

So it is necessary to approximate objects geometry to simple shapes like spheres or rectangular boxes:

Figure 3.1. Shape interference.

Shape interference.

1.1. Rectangular Boxes :AABB

AABB means Axis Aligned Bounding Box, which is used for approximating the space ocupied by a solid object:

Figure 3.2. AABB.

AABB.

1.2.  Finding Interferences on a Room

One of the most common collision problems is finding which pairs of objects are near to intersect. This stage of process is known as Broad Phase, which consists of verify very quickly which objects could intersect, by evaluating AABB collisions. With this previus verification is posible to avoid expensive calculations implied on detailed collisions per triangle based.

See how is posible to avoid executing collision commands when objects won't intersect, independently of their geometric shape.

Figure 3.3. Object Interferences.

Object Interferences.

For avoid executing NxN compairisons, GIMPACT uses a sweep based technique which orders AABB corners, reducing the complexity to O(log(N)); In many cases we have a linear complexity of O(N). This technique is known as Box Prunning.

See how to find collision pairs on gim_aabbset_self_intersections(). Also visit BOX_PRUNNING

2. Finding contacts between trimeshes

See gim_trimesh_trimesh_collision().

3. Finding contacts between a trimesh and a sphere

See gim_trimesh_sphere_collision().

4. Finding contacts between a trimesh and a capsule

See gim_trimesh_capsule_collision().

5. Finding contacts between a trimesh and a OBB

Will be implemented in next releases of GIMPACT.

6. Finding contacts between a trimesh and a cylinder

Will be implemented in next releases of GIMPACT.

7. Finding contacts between a trimesh and a convex polyhedron

May be implemented in next releases of GIMPACT, but since trimeshes can be convex polyhedrons it won't be strictly necessary.

Chapter 4. Integration of GIMPACT with other packages

1. Integration with Open Dynamics Engine

Integrating GIMPACT with ODE has had successfully results. Now is possible to make physical collisions between moving trimeshes correctly:

Figure 4.1. ODE physics with GIMPACT trimesh collision.

ODE physics with GIMPACT trimesh collision.

Download the new version of ODE with GIMPACT at: ode-gimpact.zip.

[Important]Important

CODE::BLOCKS IDE with MingW compiler are highly recommended for building ODE-GIMPACT sources.

[Important]Important

Some additional commands must be called for supporting the new changes to ODE.

  • At the beginning of the application, dInitODE() must be called.
  • At the end, dCloseODE() must be called.

2. Integration with Gammaleon

Gammaleon is a 3D engine which integrates physics on its simulations. Organizes the worlds in Rooms and Sectors.

Figure 4.2. Gammaleon Physics collision.

Gammaleon Physics collision.

Gammaleon uses ODE and GIMPACT for implement complex physics simulations. Its most outstanding features are:

  • Robust collisions at high velocities, without interpenetration problems.
  • Concurrent physical simulations on multiple rooms.

Download Gammaleon at: gammaleon.zip.

[Important]Important

CODE::BLOCKS IDE with MingW compiler are highly recommended for building Gammaleon sources.

Chapter 5. Building GIMPACT from sources

Table of Contents

1. Using CODE::BLOCKS

1. Using CODE::BLOCKS

CODE::BLOCKS has been the most successfull Free IDE for C/C++ programming. It is highly recommended for building GIMPACT sources, although Mingw compiler is strongly used:

Chapter 6. Recomendations

Table of Contents

1. TODO
2. Bugs

1. TODO

Documentation in process.

2. Bugs

Documentation in process.

Chapter 7. References

Table of Contents

1. Links

1. Links