btConeShape orientation
-
- Posts: 32
- Joined: Sun Jun 18, 2006 10:22 pm
btConeShape orientation
The constructor for btConeShape is documented as btConeShape::btConeShape ( btScalar radius, btScalar height) .
But when you try to match a btConeShape to a mesh, where the mesh is a cone standing on its base (i.e. height along y-axis), the collision shape does not match the geometry.
This is simply because the btConeShape is oriented along the z-axis initially, so the height param is really its length. Using cones in the CCDPhysicsDemo shows this, if you disable the sim and swing the camera round to the back of the stack.
This is not much of a problem really, it is just a matter of passing the correct dimension as the cone's length, and orienting the mesh correctly.
But perhaps it would be better to change the 'height' param to 'length', to avoid confusion?
But when you try to match a btConeShape to a mesh, where the mesh is a cone standing on its base (i.e. height along y-axis), the collision shape does not match the geometry.
This is simply because the btConeShape is oriented along the z-axis initially, so the height param is really its length. Using cones in the CCDPhysicsDemo shows this, if you disable the sim and swing the camera round to the back of the stack.
This is not much of a problem really, it is just a matter of passing the correct dimension as the cone's length, and orienting the mesh correctly.
But perhaps it would be better to change the 'height' param to 'length', to avoid confusion?
-
- Posts: 59
- Joined: Thu Aug 31, 2006 11:51 am
-
- Posts: 32
- Joined: Sun Jun 18, 2006 10:22 pm
btConeShape is aligned like this:
cone.jpg
(The 3 arrows showing the x,y,z axes 'meet' at the world origin)
Cone aligned to z-axis with center at (0,0,0). This is how the btConeShape is constructed. If your mesh is also like this, you should not have any problems. Just use the mesh length (from base to apex) in the btConeShape constructor, i.e. something like Works for me anyway. Apart from this, I have had no problems with cones.
cone.jpg
(The 3 arrows showing the x,y,z axes 'meet' at the world origin)
Cone aligned to z-axis with center at (0,0,0). This is how the btConeShape is constructed. If your mesh is also like this, you should not have any problems. Just use the mesh length (from base to apex) in the btConeShape constructor, i.e. something like
Code: Select all
m_CollisionShape = new btConeShape btConeShape(radius, length).
-
- Posts: 59
- Joined: Thu Aug 31, 2006 11:51 am
I've made a mesh like on your picture, but it is not working...nomad wrote:btConeShape is aligned like this:
cone.jpg
(The 3 arrows showing the x,y,z axes 'meet' at the world origin)
Cone aligned to z-axis with center at (0,0,0). This is how the btConeShape is constructed. If your mesh is also like this, you should not have any problems. Just use the mesh length (from base to apex) in the btConeShape constructor, i.e. something likeWorks for me anyway. Apart from this, I have had no problems with cones.Code: Select all
m_CollisionShape = new btConeShape btConeShape(radius, length).
-
- Posts: 32
- Joined: Sun Jun 18, 2006 10:22 pm
-
- Posts: 59
- Joined: Thu Aug 31, 2006 11:51 am
It is colliding with static plane, but it does not fit the mesh. It looks like apex is in (0,0,0). But I can not find correct mesh...Or maybe it does not collide correctly...nomad wrote:How exactly is it not working? Is the cone colliding with anything?Jack wrote:I've made a mesh like on your picture, but it is not working...
-
- Posts: 32
- Joined: Sun Jun 18, 2006 10:22 pm
-
- Posts: 59
- Joined: Thu Aug 31, 2006 11:51 am
FrameTransformMatrix is Identity. I am using this exporter:nomad wrote:If you are creating the mesh in a graphics program (like 3ds Max) then perhaps the mesh coordinates are not centered about the origin? I had a problem like this with Max, which exports a transformation matrix with the mesh.
http://www.andytather.co.uk/Panda/direc ... loads.aspx
I like it more then one included in DirectX SDK.
-
- Posts: 32
- Joined: Sun Jun 18, 2006 10:22 pm
Still sounds like an export issue, but maybe your problem is different to mine. If you can let me have your MAX file (I'm using MAX 7) then I could export it and see how your cone works in my game engine (I use .3ds and .X formats). Or you could try my cone: cone.max
-
- Posts: 59
- Joined: Thu Aug 31, 2006 11:51 am
I made it. I corrected btConeShape.cpp to:
Now it is working. In fact cone is vertical (Y) aligned. Its bottom is at zero level....
Code: Select all
#ifdef WIN32
//static int coneindices[3] = {1,2,0};
[b]static int coneindices[3] = {2,1,0};[/b]
#else
static int coneindices[3] = {2,1,0};
#endif
-
- Posts: 59
- Joined: Thu Aug 31, 2006 11:51 am
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
Some fixes have been made to the btConeShape. Unfortunately no scaling yet. You can apply scaling yourself, directly on the height/radius.Jack wrote:It also looks like scaling is not working for cone shape..
Some updates have been made in the Bullet User Manual:
http://www.continuousphysics.com/ftp/pu ... Manual.pdf
Thanks for the feedback!
Erwin
-
- Posts: 59
- Joined: Thu Aug 31, 2006 11:51 am
Is it hard to add scaling? Objects are scaled dynamically during game play...It would be very great to have scaling for cone.Erwin Coumans wrote:Some fixes have been made to the btConeShape. Unfortunately no scaling yet. You can apply scaling yourself, directly on the height/radius.Jack wrote:It also looks like scaling is not working for cone shape..
Some updates have been made in the Bullet User Manual:
http://www.continuousphysics.com/ftp/pu ... Manual.pdf
Thanks for the feedback!
Erwin
-
- Posts: 32
- Joined: Sun Jun 18, 2006 10:22 pm
Yep. Cone is now y-aligned, with center at (0,0,0). Much easier to work with.Jack wrote:I made it. I corrected btConeShape.cpp to:
Now it is working. In fact cone is vertical (Y) aligned. Its bottom is at zero level....Code: Select all
#ifdef WIN32 //static int coneindices[3] = {1,2,0}; [b]static int coneindices[3] = {2,1,0};[/b] #else static int coneindices[3] = {2,1,0}; #endif
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
It is easy to add one scale-factor for all directions, is that enough for a start? (Re)scaling with different scale factors for x,y and z is more work.Jack wrote:Is it hard to add scaling? Objects are scaled dynamically during game play...It would be very great to have scaling for cone.
Thanks,
Erwin