Author Topic: Bounding Box  (Read 11665 times)

Offline cyberkilla

  • float
  • ****
  • Posts: 413
    • View Profile
    • http://futurerp.net
Bounding Box
« on: January 11, 2007, 04:15:15 am »
Hey:)

Does the bounding box( which tells me not to call it too much ), change values
as a sequence of key frame animation is played out?

I would assume so, because my "dirty rectangle" clipping doesn't cover the avatar when he lifts his arms:).

If this is so, how can I make sure I have the right bounding box, without a major speed slowdown? I would appreciate any help on this;).
http://futurerp.net - Text Based MMORPG
http://beta.rpwar.com - 3D Isometric MMORPG

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Bounding Box
« Reply #1 on: January 11, 2007, 10:55:34 am »
Yes, it changes when doing a keyframe animation. In fact it's interpolated like the rest of the mesh is. I'll have a look if i can add a kind of getDirtyBoundingBox() to get the actual bounding box without recalculating it. For now, just stick with getBoundingBox(). The calculation isn't THAT heavy. It should not matter performance wise unless the mesh is quite big and/or you are doing it on hundreds of meshes.

Offline cyberkilla

  • float
  • ****
  • Posts: 413
    • View Profile
    • http://futurerp.net
Bounding Box
« Reply #2 on: January 11, 2007, 03:01:15 pm »
Ah thats good:) Ill try it.

It is clearly done in another game, similar to mine, so it must be possible.

The meshes are less than 500 vertexes, I think. And im expecting around 6 models on the screen at the same time.
http://futurerp.net - Text Based MMORPG
http://beta.rpwar.com - 3D Isometric MMORPG

Offline cyberkilla

  • float
  • ****
  • Posts: 413
    • View Profile
    • http://futurerp.net
Bounding Box
« Reply #3 on: January 12, 2007, 05:03:25 am »
Yup, works perfectly, and I don't notice any significant speed decrease:).

However, I have only tested with one model on the screen, so I may still have to work out some manual, and rather costly guessed bounding box.
One that I found to encapsulate the whole model, whatever it may be doing.

At least its an option:)

As I said, Im not expecting a huge number of models onscreen simultaneously,
so I have my fingers crossed that its not a problem:)
http://futurerp.net - Text Based MMORPG
http://beta.rpwar.com - 3D Isometric MMORPG

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Bounding Box
« Reply #4 on: January 12, 2007, 08:55:41 am »
I've looked into it and now i know, why i'm calculating the box each time you are calling this method... :wink: It's not that easy to return the actual bounding box without recalculating it, so i'll skip this as long as it's not a problem. It shouldn't be one IMHO.

Offline cyberkilla

  • float
  • ****
  • Posts: 413
    • View Profile
    • http://futurerp.net
Bounding Box
« Reply #5 on: January 12, 2007, 03:09:51 pm »
Yes indeed:)

I fully understand why it must be done.
http://futurerp.net - Text Based MMORPG
http://beta.rpwar.com - 3D Isometric MMORPG

Offline cyberkilla

  • float
  • ****
  • Posts: 413
    • View Profile
    • http://futurerp.net
Bounding Box
« Reply #6 on: January 12, 2007, 09:55:28 pm »
Does the bounding box encapsulate the child objects too?
http://futurerp.net - Text Based MMORPG
http://beta.rpwar.com - 3D Isometric MMORPG

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Bounding Box
« Reply #7 on: January 12, 2007, 10:58:21 pm »
No, they have a box of their own.

Offline cyberkilla

  • float
  • ****
  • Posts: 413
    • View Profile
    • http://futurerp.net
Bounding Box
« Reply #8 on: January 12, 2007, 11:11:59 pm »
Okay:) Thanks:)

Ah, I guess ill have to work this into my equations also:)
http://futurerp.net - Text Based MMORPG
http://beta.rpwar.com - 3D Isometric MMORPG

Offline cyberkilla

  • float
  • ****
  • Posts: 413
    • View Profile
    • http://futurerp.net
Bounding Box
« Reply #9 on: January 12, 2007, 11:41:40 pm »
Ah, one more little thing:)...

How is object space worked out? Is the calculated center of the mesh (0,0)?
http://futurerp.net - Text Based MMORPG
http://beta.rpwar.com - 3D Isometric MMORPG

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Bounding Box
« Reply #10 on: January 13, 2007, 12:06:08 am »
No, object space remains unchanged. It's the space the object was saved in the modeler.

Offline cyberkilla

  • float
  • ****
  • Posts: 413
    • View Profile
    • http://futurerp.net
Bounding Box
« Reply #11 on: January 13, 2007, 03:36:38 am »
Excellent:)

Im making a small utility with a slider control, to manually set the base y:)

Ill have a screenshot on my project thread soon.

It works Egon, and so far, it seems more than fast enough.
http://futurerp.net - Text Based MMORPG
http://beta.rpwar.com - 3D Isometric MMORPG

Offline cyberkilla

  • float
  • ****
  • Posts: 413
    • View Profile
    • http://futurerp.net
Bounding Box
« Reply #12 on: January 18, 2007, 11:12:32 pm »
This is strange! When I try to use a model with UV Mapping(1 texture),
the object space seems to be destroyed:(.

I have 2 models without UV Mapping, and they work fine.
I also have another model WITH UV Mapping, and its object space appears in the center of the model.
Before trying to use a texture, it worked fine too:(.


You know I spoke to you about getting the base of the models?
Well, in blender, you can put the mesh above the origin point, so the feet are just above it. In the game, I always use this point to keep the models on the ground.

No doubt other games do this too, because I see a lot of the models ive downloaded do the same.

Have you any idea what is happening Egon? Sorry for the extra problems:)

EDIT:
Just to clarify, the origin point of the model, which is supposed to be just below its feet, is in the center of the model instead.
It only happens with models with UV maps/texture.
http://futurerp.net - Text Based MMORPG
http://beta.rpwar.com - 3D Isometric MMORPG

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Bounding Box
« Reply #13 on: January 18, 2007, 11:48:50 pm »
There is no difference between loading a model with or without u/v as far as i can see. Can you provide me with a test case? Ideally two models and some code that shows the problem.

Offline cyberkilla

  • float
  • ****
  • Posts: 413
    • View Profile
    • http://futurerp.net
Bounding Box
« Reply #14 on: January 19, 2007, 12:34:36 am »
Yes, I will try to get something together. Thanks again!

This is strange. Perhaps there is another reason, but, I know for certain that the only thing modified on the model is the uv map, and a texture.

The result is that the origin point appears to move into the center of the models mesh, instead of where it was placed on the modeler.

I was inaccurate when I said it destroyed the object space:).


You see, I position the camera so this origin point(which I use for base of model),
is near the bottom of the camera view. This position does not change, even when it is broken.

The model, however, is no longer standing above this point, but is centered to it.


EDIT: This has grew even more complicated Egon. I fear it might be my fault now;).
I really hate it when you spend 3 hours trying to find out what is causing "x" problem, when you look again from another angle, and it turns out its not even the same problem:)
http://futurerp.net - Text Based MMORPG
http://beta.rpwar.com - 3D Isometric MMORPG