btConeShape orientation

nomad
Posts: 32
Joined: Sun Jun 18, 2006 10:22 pm

btConeShape orientation

Post by nomad »

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?
Jack
Posts: 59
Joined: Thu Aug 31, 2006 11:51 am

Post by Jack »

I have a troubles with ConeMesh too. How does it orientated? Where is zero point?
nomad
Posts: 32
Joined: Sun Jun 18, 2006 10:22 pm

Post by nomad »

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

Code: Select all

m_CollisionShape = new btConeShape btConeShape(radius, length).
Works for me anyway. :wink: Apart from this, I have had no problems with cones.
Jack
Posts: 59
Joined: Thu Aug 31, 2006 11:51 am

Post by Jack »

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 like

Code: Select all

m_CollisionShape = new btConeShape btConeShape(radius, length).
Works for me anyway. :wink: Apart from this, I have had no problems with cones.
I've made a mesh like on your picture, but it is not working... :(
nomad
Posts: 32
Joined: Sun Jun 18, 2006 10:22 pm

Post by nomad »

Jack wrote:I've made a mesh like on your picture, but it is not working... :(
How exactly is it not working? Is the cone colliding with anything?
Jack
Posts: 59
Joined: Thu Aug 31, 2006 11:51 am

Post by Jack »

nomad wrote:
Jack wrote:I've made a mesh like on your picture, but it is not working... :(
How exactly is it not working? Is the cone colliding with anything?
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
Posts: 32
Joined: Sun Jun 18, 2006 10:22 pm

Post by nomad »

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.
Jack
Posts: 59
Joined: Thu Aug 31, 2006 11:51 am

Post by Jack »

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.
FrameTransformMatrix is Identity. I am using this exporter:
http://www.andytather.co.uk/Panda/direc ... loads.aspx
I like it more then one included in DirectX SDK.
nomad
Posts: 32
Joined: Sun Jun 18, 2006 10:22 pm

Post by nomad »

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
Jack
Posts: 59
Joined: Thu Aug 31, 2006 11:51 am

Post by Jack »

I made it. I corrected btConeShape.cpp to:

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
Now it is working. In fact cone is vertical (Y) aligned. Its bottom is at zero level....
Jack
Posts: 59
Joined: Thu Aug 31, 2006 11:51 am

Post by Jack »

It also looks like scaling is not working for cone shape.. :(
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Post by Erwin Coumans »

Jack wrote:It also looks like scaling is not working for cone shape.. :(
Some fixes have been made to the btConeShape. Unfortunately no scaling yet. You can apply scaling yourself, directly on the height/radius.

Some updates have been made in the Bullet User Manual:
http://www.continuousphysics.com/ftp/pu ... Manual.pdf

Thanks for the feedback!
Erwin
Jack
Posts: 59
Joined: Thu Aug 31, 2006 11:51 am

Post by Jack »

Erwin Coumans wrote:
Jack wrote:It also looks like scaling is not working for cone shape.. :(
Some fixes have been made to the btConeShape. Unfortunately no scaling yet. You can apply scaling yourself, directly on the height/radius.

Some updates have been made in the Bullet User Manual:
http://www.continuousphysics.com/ftp/pu ... Manual.pdf

Thanks for the feedback!
Erwin
Is it hard to add scaling? Objects are scaled dynamically during game play...It would be very great to have scaling for cone.
nomad
Posts: 32
Joined: Sun Jun 18, 2006 10:22 pm

Post by nomad »

Jack wrote:I made it. I corrected btConeShape.cpp to:

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
Now it is working. In fact cone is vertical (Y) aligned. Its bottom is at zero level....
Yep. Cone is now y-aligned, with center at (0,0,0). Much easier to work with. :D
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Post by Erwin Coumans »

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.
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.

Thanks,
Erwin