0

I am working on a project in OpenGL 2.0. I load objects from a file, that file contains information about object names, its position, scale and rotation.

I got all these information in code, now I want to calculate the boundaries of all the objects loaded so I can start working on collision.

Project is the scale value is like 0.1 i.e it is multiplied with a dimension vector to get the actual boundary dimension.

e.g Object 1: scale x: -0.1, y: 0.05, z: 0.1 Object 2: scale x: 0.1, y: 0.1, z: 0.1

Object 1: pos x: 5, y: 21.7269, z: 0 Object 2: pos x -58.0646 y: -6.68359, z: 0

Object 1: rot x: 0, y: 0, z: 0 Object 2: rot x:0, y:90, z:0

My question is, I want to calculate the dimensions i.e boundary of each object, how can achieve this target?

Fahad Rauf
  • 705
  • 2
  • 8
  • 17
  • And what are the objects themselves? Scale is meaningless if you don't know the objects' sizes to begin with. Also, where is rotation? – riv May 30 '13 at 08:26
  • I added rotation in my question, object size is the thing that i don't know as it is loaded once object name is read from a file, that object is loaded from another directory – Fahad Rauf May 30 '13 at 08:32
  • Well, the bounding box obviously depends on the shape of the object, so you need to find that first. – riv May 30 '13 at 08:36
  • thanks, I got it, I am looking into finding the object size – Fahad Rauf May 30 '13 at 08:49

1 Answers1

1

Depends what you mean by "boundary". If you mean an AABB (axis-aligned bounding box), for each individual object, it's simply a matter of

  1. finding all your vertices
  2. multiplying the components by the scale
  3. transforming using rotation (either with a rotation matrix or by standard trigonometry)
  4. finding the extremes on the axes
  5. Translating by the position vectors

Many of these can be done in a different order.

You may be best off starting with some good theory. Real Time Collision Detection is very self-explanatory, and has always been one of my favorite books on the subject, and a wonderful place for any person with interest to get started.

Starting with lower-dimensional physics would also be a good idea until the concepts are more firmly rooted (ie. don't use the z dimension).

Taywee
  • 1,313
  • 11
  • 17
  • thanks for sharing the info, but I wanted to get boundary i.e the vertices but for that i need shapes size as riv pointed out, I am looking into it, thanks again for helping – Fahad Rauf May 30 '13 at 08:48