Dear All,
I use AABB for my mesh. But when I use setLocalScaling on the collisionshape, the AABB doesn't surround the actual mesh. Some parts of the mesh is left outside the AABB. I've read some topics related to previous versions of Bullet, tried using updateAabbs(). But result was the same. What might be the problem for the case? By the way I use Bullet 2.75
Regards,
Ugras
SetLocalScaling and AABB Help for Bullet 2.75
-
Erwin Coumans
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
Re: SetLocalScaling and AABB Help for Bullet 2.75
Can you use Bullet 2.76 (beta) and create a .bullet file of your world so we can have a look at the file?
It is really simple to create a .bullet file using Bullet 2.76:
Create your dynamics world and objects as usual, and then:
You can attach a zipped .bullet to this forum.
Thanks,
Erwin
It is really simple to create a .bullet file using Bullet 2.76:
Create your dynamics world and objects as usual, and then:
Code: Select all
//create a large enough buffer. There is no method to pre-calculate the buffer size yet.
int maxSerializeBufferSize = 1024*1024*5;
btDefaultSerializer* serializer = new btDefaultSerializer(maxSerializeBufferSize);
dynamicsWorld->serialize(serializer);
FILE* file = fopen("testFile.bullet","wb");
fwrite(serializer->getBufferPointer(),serializer->getCurrentBufferSize(),1, file);
fclose(file);
Thanks,
Erwin
-
Ugras
- Posts: 34
- Joined: Wed Dec 30, 2009 8:30 pm
Re: SetLocalScaling and AABB Help for Bullet 2.75
First of all, thanks for the rapid reply. I was out. I'm newly aware of 2.76. I'm currently downloading it and I will post the dynamics world as soon as possible. By the way, there was no problem with trimesh, but the problem occurs again when I use sphere collision shape for example.
Regards,
Ugras
Regards,
Ugras
-
Ugras
- Posts: 34
- Joined: Wed Dec 30, 2009 8:30 pm
Re: SetLocalScaling and AABB Help for Bullet 2.75
Dear Erwin Coumans,
I built v2.76 without any problem but haven't ported my app to it yet. I checked the AABB creation related codes at btboxshape.h line 81 (Bullet v2.75) and the rest of that file. I think my problem might be with the line 88 where:
As I guess, I get another vector after multiplying boxHalfExtents with m_localScaling and then translate it with margin (considering it 0.04).
1) What does m_implicitShapeDimensions correspond to?
2) One more question regarding AABB, (by the way feel free to criticise if this is a silly question, because I'm new to using physics engine):
Considering that scaling is not a rigid transform, isn't it possible to perform an affine transform on the AABB after scaling my rendering mesh and collision mesh (using setLocalScaling) at the same proportions? Consider that x0 is the origin (null element of the space bounded by AABB) before scaling. Then perform this x1 = Ax0, where A = [s1, 0, 0, 0, s2, 0, 0, 0, s3] where the s1, s2, s3 parameters represent the scaling along the coordinate axes.
After the transformation, x0 will stay at the coordinate where it was before the transformation. Then, let x2 = x1 + b, where b is some translation vector which represent the coordinate where I want to translate the origin inside the space of my rendering mesh. Overall affine transformation is x2 = Ax0 + b. How can I perform this addition of b vector to the origin of the AABB?
At least I have not been able to perform it yet.
Regards,
Ugras
I built v2.76 without any problem but haven't ported my app to it yet. I checked the AABB creation related codes at btboxshape.h line 81 (Bullet v2.75) and the rest of that file. I think my problem might be with the line 88 where:
Code: Select all
m_implicitShapeDimensions = (boxHalfExtents * m_localScaling) - margin;1) What does m_implicitShapeDimensions correspond to?
2) One more question regarding AABB, (by the way feel free to criticise if this is a silly question, because I'm new to using physics engine):
Considering that scaling is not a rigid transform, isn't it possible to perform an affine transform on the AABB after scaling my rendering mesh and collision mesh (using setLocalScaling) at the same proportions? Consider that x0 is the origin (null element of the space bounded by AABB) before scaling. Then perform this x1 = Ax0, where A = [s1, 0, 0, 0, s2, 0, 0, 0, s3] where the s1, s2, s3 parameters represent the scaling along the coordinate axes.
After the transformation, x0 will stay at the coordinate where it was before the transformation. Then, let x2 = x1 + b, where b is some translation vector which represent the coordinate where I want to translate the origin inside the space of my rendering mesh. Overall affine transformation is x2 = Ax0 + b. How can I perform this addition of b vector to the origin of the AABB?
At least I have not been able to perform it yet.
Regards,
Ugras
-
Ugras
- Posts: 34
- Joined: Wed Dec 30, 2009 8:30 pm
Re: SetLocalScaling and AABB Help for Bullet 2.75
Two more questions,
1) How is the origin of the AABB defined in Bullet? Ie, when I create a AABB for a mesh. The only input arg is the half extents.
2) When I import a mesh from 3DS Max or Blender to my rendering engine, is the origin of that mesh used for aabb creation? If so, how can I change that origin in Bullet?
Regards,
Ugras
1) How is the origin of the AABB defined in Bullet? Ie, when I create a AABB for a mesh. The only input arg is the half extents.
2) When I import a mesh from 3DS Max or Blender to my rendering engine, is the origin of that mesh used for aabb creation? If so, how can I change that origin in Bullet?
Regards,
Ugras
-
Erwin Coumans
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
Re: SetLocalScaling and AABB Help for Bullet 2.75
You are mixing up things and use wrong naming. There is no 'mesh' or 'AABB' in Bullet.
Bullet has a btBoxShape defined by half extents around its local origin, and together with the world transform of a btRigidBody it becomes an oriented bounding box (OBB). By default, the btBoxShape will be at the local center of that body. If you want to shift the center of the btBoxShape, relative to the btRigidBody, you can use a btCompoundShape.
Thanks,
Erwin
Bullet has a btBoxShape defined by half extents around its local origin, and together with the world transform of a btRigidBody it becomes an oriented bounding box (OBB). By default, the btBoxShape will be at the local center of that body. If you want to shift the center of the btBoxShape, relative to the btRigidBody, you can use a btCompoundShape.
Thanks,
Erwin
-
Ugras
- Posts: 34
- Joined: Wed Dec 30, 2009 8:30 pm
Re: SetLocalScaling and AABB Help for Bullet 2.75
Dear Erwin,
Thanks for the important and instructive answers. I applied your advice and it is OK now. As I'm novice at the collision detection subject, I'll check out real time collision detection books referenced, before proceeding,
Best regards,
Ugras
Thanks for the important and instructive answers. I applied your advice and it is OK now. As I'm novice at the collision detection subject, I'll check out real time collision detection books referenced, before proceeding,
Best regards,
Ugras