Closed Zelyutin closed 5 years ago
It depends on the version of BulletSharp, but it's usually a class called Matrix.
Your IDE should suggest the right type when you type in:
colMapObject = new CompoundShape()
colMapObject.AddChildShape(
Yeah, I know that the Matrix should be passed as an argument. I use bullet sharp 3 and VS2017. But I didn't found a method in Matrix that will create it from Quaternion and Vector3 as in original btTransform. That's why I asked it.
I mean it depends on whether it's the generic version or a version that uses types from a graphics library like OpenTK/SharpDX/etc.
The generic version has no special Matrix constructors, but you can always multiply a rotation matrix and a translation matrix.
Matrix rotation = Matrix.RotationQuaternion(new Quaternion(0, 0, 0, 1));
Matrix translation = Matrix.Translation(x, y, z);
Matrix transform = rotation * translation;
colMapObject.AddChildShape(transform, sphere);
See here about multiplying matrices: https://docs.microsoft.com/en-us/windows/desktop/direct3d9/transforms#concatenating-matrices With a Matrix class from some other framework, you can do the same, except if the matrix layout is different (like in OpenTK), you may have to reverse the multiplication order to translation * rotation.
In this particular case, since (0, 0, 0, 1) is an identity quaternion that specifies no rotation, you could just use the translation matrix: colMapObject.AddChildShape(Matrix.Translation(x, y, z), sphere);
The generic version of BulletSharp has math classes based on SlimDX: https://slimdx.org/docs/#T_SlimDX_Matrix However, the Matrix.Transformation constructor that takes a rotation quaternion and a translation vector has been removed since it depends on DirectX.
Thank you very much for you rapid and detailed answer! It helped!
Hi!
I'm trying to port some C++ code using BulletPhysics to C# using BulletSharp.
For btCompoundShape I use CompoundShape class, similarly for Quaterion and Vector3. But what's need to be used for btTransform?