TheLorizz Posted August 6, 2020 Posted August 6, 2020 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()
silent Posted August 7, 2020 Posted August 7, 2020 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: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN
TheLorizz Posted August 7, 2020 Author Posted August 7, 2020 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
silent Posted August 7, 2020 Posted August 7, 2020 There is no method rotate() that will take 3 floats as input. Instead you can use rotate(quat(0.0f, 90.0f, 0.0f)) or rotateY(90.0f). Thanks! How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN
TheLorizz Posted August 7, 2020 Author Posted August 7, 2020 (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 August 7, 2020 by TheLorizz
silent Posted August 8, 2020 Posted August 8, 2020 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! How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN
TheLorizz Posted August 8, 2020 Author Posted August 8, 2020 (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 August 8, 2020 by TheLorizz
alexander Posted August 10, 2020 Posted August 10, 2020 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
TheLorizz Posted August 14, 2020 Author Posted August 14, 2020 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
Recommended Posts