Jump to content

[SOLVED] Missing ShapePtr methods


photo

Recommended Posts

Posted

Hello guys I want to point out that ShapePtr is missing a getter/setter for the rotation!

There's the setPosition(Math::Vec3) but no setRotation() or getRotation()

Posted

TheLorizz

There is no rotation setters or getters due to the precision issue, which is critical for physics.

You can use setTransform to set the full transform matrix at once.

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Posted
5 hours ago, silent said:

TheLorizz

There is no rotation setters or getters due to the precision issue, which is critical for physics.

You can use setTransform to set the full transform matrix at once.

I tried using a code like:

Mat4 transform = Mat4(translate(0.8f, 1.25f, 0.15f) * rotate(0.0f, 90.0f, 0.0f))
myCollision->setTransform(transform);

But it looks like it's not translating/rotating, when I get home I'll try recoding that part

Posted (edited)

Ok so, what I did first is to create the shape in the editor first and check if it works, it does, those are the settings.

Then I recreated it from code, because it should be something made dynamically, this is the code:

ShapeCylinderPtr wheel_rf_col = ShapeCylinder::create();
wheel_rf_col->setRadius(0.30668f);
wheel_rf_col->setHeight(0.19606f);
wheel_rf_col->setPosition(Vec3(0.72f, 1.25f, 0.15f));
//Mat4 transMatrix = (Mat4)translate(Vec3(0.72f, 1.25f, 0.15f));
Mat4 rotMatrix = (Mat4)rotateY(90.0f);
Mat4 transform = rotMatrix * wheel_rf_col->getTransform();
wheel_rf_col->setTransform(transform);
mesh->getBodyRigid()->addShape(wheel_rf_col); // This is the base vehicle mesh

But when I compile and run, this happens! As you can see, the vehicle dances

Whenever I change radius and height, this happens, it seems it doesn't move nor rotate!

Edited by TheLorizz
Posted (edited)
6 hours ago, silent said:

Can you send us whole test scene (data and source directories should be enough)? Right now it's hard to tell what is going on.

Thanks!

I've sent a direct message with the link, thanks for helping!

Edited by TheLorizz
Posted

Hi TheLorizz,

Instead of this:

mesh->getBodyRigid()->addShape(wheel_rf_col);

Use this:

mesh->getBodyRigid()->addShape(wheel_rf_col, translate(0.72f, 1.25f, 0.15f) * rotateY(90.0f));

Because addShape() has signature: (const Ptr<Shape> &shape, const Math::mat4 &transform = mat4_identity);
When you call the addShape() function without "transform" argument you reset shape's transform to zero.
 

Best regards,
Alexander

Posted
On 8/10/2020 at 1:51 PM, alexander said:

Hi TheLorizz,

Instead of this:


mesh->getBodyRigid()->addShape(wheel_rf_col);

Use this:


mesh->getBodyRigid()->addShape(wheel_rf_col, translate(0.72f, 1.25f, 0.15f) * rotateY(90.0f));

Because addShape() has signature: (const Ptr<Shape> &shape, const Math::mat4 &transform = mat4_identity);
When you call the addShape() function without "transform" argument you reset shape's transform to zero.
 

Best regards,
Alexander

Thanks, it works! Didn't see that transform reference

  • silent changed the title to [SOLVED] Missing ShapePtr methods
×
×
  • Create New...