About Store Forum Documentation Contact
Donations:
327$/mo



Post Reply 
Mesh Bounding Box
Author Message
mokh Offline
Member

Post: #1
Mesh Bounding Box
Hi there,

How can I get the correct bounding box of a mesh, when an animation has been applied to it ?
Mesh::box always gives the bounding box of the mesh when the animations have been not applied to it.
(This post was last modified: 06-08-2011 02:55 PM by mokh.)
06-08-2011 02:39 PM
Find all posts by this user Quote this message in a reply
Driklyn Offline
Member

Post: #2
RE: Mesh Bounding Box
Try:

Code:
Box box;
mesh().getBox(box);
06-08-2011 06:37 PM
Find all posts by this user Quote this message in a reply
mokh Offline
Member

Post: #3
RE: Mesh Bounding Box
thank you for your reply,
unfortunately it returns the exact same dimensions of Mesh::box.
I'm thinking that maybe the engine handles the animations in GPU, if I'm correct then I don't think if there would be a way to get that. at least at the moment. correct me if I'm wrong.

What I'm trying to do is to calculate the the position of the vertex which has the least Y value at each frame of the animation. If there is another possible solution to this, I would be very happy to hear it.
Thanks in advance
(This post was last modified: 06-08-2011 08:39 PM by mokh.)
06-08-2011 08:37 PM
Find all posts by this user Quote this message in a reply
Driklyn Offline
Member

Post: #4
RE: Mesh Bounding Box
Try:

Code:
mesh().setBase();
// animate

Box box;
mesh().getBox(box);

mesh().setRender();

Couldn't tell yah if that will work or not, but Mesh::setBase() enables software rendering (CPU). Calling Mesh::setRender() afterwards re-enables hardware rendering (GPU).

If not, try loading in your own MeshBase, animating that, and then get the box.
06-08-2011 08:58 PM
Find all posts by this user Quote this message in a reply
mokh Offline
Member

Post: #5
RE: Mesh Bounding Box
Thanks again Driklyn,

We have some sort of problems here, there is no function called setBase, only setRender is available but even if it was available I don't think if your solution could solve this because in the engine animation is always being applied to the skeleton and you can not explicitly apply that skeleton on the mesh ( I'm not sure about it though ), when you want to draw the mesh you can provide the function either a matrix or the skeleton to draw that mesh based on the supplied argument.
06-09-2011 04:59 AM
Find all posts by this user Quote this message in a reply
Driklyn Offline
Member

Post: #6
RE: Mesh Bounding Box
Use Header Browser tool. There is indeed a setBase method.

MeshBase allows you to animate a mesh using a skeleton (this is likely what Mesh::draw() is calling). MeshBase::getBox header comments says "get box encapsulating the MeshBase, this method iterates through all vertexes". Seems like if you were to animate a MeshBase, getBox would return a valid box around the animated mesh.

Are you using the PC or Mac version?
06-09-2011 05:24 AM
Find all posts by this user Quote this message in a reply
mokh Offline
Member

Post: #7
RE: Mesh Bounding Box
PC Version, and I just saw the Mesh class header files and there wasn't a setBase method. and when you call the Mesh::draw it draw the animated mesh, it doesn't change the mesh, and it seems like that even if I could use the setBase method, I think the skeleton animation is applied in the vertex shader and it's applied in the draw method when you want to display it. I mean that it doesn't even change the original vertex, and only transforms the input vertex base upon the binded bones.
06-09-2011 06:23 AM
Find all posts by this user Quote this message in a reply
Driklyn Offline
Member

Post: #8
RE: Mesh Bounding Box
(06-09-2011 06:23 AM)mokh Wrote:  I mean that it doesn't even change the original vertex, and only transforms the input vertex base upon the binded bones.

Perhaps when you're using skeletons. I'm not sure, but wouldn't that mean you couldn't animate a character when using software rendering? Seems like it should work with both software and hardware rendering.

Try:

Code:
// animate, update matrix
mesh().setBox();

This recalculates the bounding box.

----------

EDIT: Btw, if you're using Visual Studio, replace all those mesh(). with mesh()-> if you haven't figured that out by now. I use Code Editor and forgot to change the syntax.
(This post was last modified: 06-09-2011 07:02 AM by Driklyn.)
06-09-2011 06:53 AM
Find all posts by this user Quote this message in a reply
mokh Offline
Member

Post: #9
RE: Mesh Bounding Box
Thanks for your information about the setBox method but sadly as I have expected, The mesh doesn't change when you draw it with an animated skeleton. It transforms the vertices on fly I think the setBox and getBox methods can be used when you change the mesh, like adding new faces or removing ones or explicitly move vertices.

Code:
mesh.draw(some_animated_skeleton);

// and then if I

mesh.draw(some_matrix);

// the second one will exactly look like the one in the mesh editor

I was wondering if there was a method that applies the skeleton to the mesh without drawing it.

And by the way, you can only animate objects by skeletons in esenthel. Even a single cube will have a .skel file when you convert it from an animated 3d model file, but the skel will have 1 bone and that bone will have weight 1.0 assigned to all the vertices.
(This post was last modified: 06-09-2011 07:41 AM by mokh.)
06-09-2011 07:03 AM
Find all posts by this user Quote this message in a reply
Driklyn Offline
Member

Post: #10
RE: Mesh Bounding Box
I figured it out. You must use MeshBase class.

Code:
MeshBase mb;

Bool Player::update()
{
    mb.create(mesh()->setBase()); // must recreate every frame to reset vertices
    mb.animate(cskel);
}

I couldn't figure out a way to reset the vertices without recreating the MeshBase every frame. There might be a better way.

(06-09-2011 07:03 AM)mokh Wrote:  And by the way, you can only animate objects by skeletons in esenthel.

Unless you're hardcore and animate the vertexes manually using MeshBase pfft
06-09-2011 07:56 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #11
RE: Mesh Bounding Box
Mesh.box * skel.matrix() = approximate box
06-09-2011 10:33 AM
Find all posts by this user Quote this message in a reply
Post Reply