Hi,
I'm asking myself how to properly use the local scale method on collision shapes. The way I understand it, you need one instance of a given shape for every scale that is used in the scene. So if you have two rigid bodies of the same size, they can share the same collision shape.
So where does the local scale come into play?
How to use local scale on collision shapes
-
Flix
- Posts: 456
- Joined: Tue Dec 25, 2007 1:06 pm
Re: How to use local scale on collision shapes
As far as I know you are right.B_old wrote:The way I understand it, you need one instance of a given shape for every scale that is used in the scene. So if you have two rigid bodies of the same size, they can share the same collision shape.
I think you can reuse the same base collision shape with different scaling only if you wrap it inside an additional "uniform scaling shape" or "bvh scaled shape", but this approach has nothing to do with the "local scale method" you are referring to...
In my experience this method is very useful (at least) in a pair of cases:B_old wrote:So where does the local scale come into play?
1) When using a btMultiSphereShape, it's the only way to scale it in a non uniform way; this can be used to create a (non uniformly) scaled sphere or some other shapes (like the wheel shape here:http://bulletphysics.org/Bullet/phpBB3/ ... ape#p17238).
2) When I want to create convex hull shapes and I want to scale them. Although I can store all the vertices and scale them each time for each new shape, it's more confortable to recreate the same shape and apply different local scaling. For example you may build a segmented cylinder or cone convex hull shape as a base, and then "cloning" it multiple times with different local scaling to create non uniformly scaled cyliners or cones (that was not possible with the base Bullet cylinder or cone shapes).
Of course this is just my experience, others might find it useful to use the local scaling method on other shapes too.
-
B_old
- Posts: 79
- Joined: Tue Sep 26, 2006 1:10 pm
Re: How to use local scale on collision shapes
Thanks for the reply, Flix. That gives me a few things to consider.
However, I don't understand the thing about the wheel shape.
However, I don't understand the thing about the wheel shape.
-
Flix
- Posts: 456
- Joined: Tue Dec 25, 2007 1:06 pm
Re: How to use local scale on collision shapes
The wheel shape internally is a btMultiSphereShape with a local scaling applied to it.B_old wrote:However, I don't understand the thing about the wheel shape.
P.S. The btMultiSphereShape is (as far as I know it) like a convex hull shape in which each vertex has a sphere associated to it (every point in this sphere is somehow "added" to the convex hull). Each "vertex sphere" can have a different radius and the whole shape can be scaled in a non-uniform way through the local scaling method. All this makes it a powerful shape type...
-
B_old
- Posts: 79
- Joined: Tue Sep 26, 2006 1:10 pm
Re: How to use local scale on collision shapes
Thanks for the explanation. That makes it a perfect choice for simulating blackberries, I suppose.
This is getting off-topic, but why didn't you use a cylinder for the wheel?
This is getting off-topic, but why didn't you use a cylinder for the wheel?
-
Flix
- Posts: 456
- Joined: Tue Dec 25, 2007 1:06 pm
Re: How to use local scale on collision shapes
Actually I used it (in the downloadable source code you can choose between various kind of wheel shapes, including cylinders).B_old wrote:why didn't you use a cylinder for the wheel
But the point is that I enjoy building collision shapes (there are a lot of possibilities with the Bullet base set).
Regarding the difference between a cylinder and a "wheel" shape: well, it probably depends on the wheel size, on the terrain (flat terrain should shrink the difference) and the vehicle itself (probably wheel shapes work better when they can "bend"). I haven't fully tested the wheel shape yet...
But I introduced it just as an example: with the btMultiSphereShape other useful shapes can be built (fully scalable capsule shapes, capsule shapes with different radii, boxes with smooth angles and so on...), and the local scaling method gives it more "flexibility".