Physics3D: How to place the the Sprite inside the rigidBody? (3.11.1) [solved]

Hi,

I tried it with Physics3DRigidBodyDes::originalTransform.translate, but it doesn’t seem to have any effect. No matter what translation I use, I always end up with the rigidbody centered in the middle of the sprite. How can it move the rigid body to another position relative to the sprite?

Here’s the code in charge:

cocos2d::PhysicsSprite3D* SpaceScene::createShip( const cocos2d::Vec3 &pos) {

    char* model = "models/orc.c3b";

    // just to get OBB
    auto sprite = Sprite3D::create(model);
    cocos2d::OBB _obb(sprite->getAABB());

    Physics3DRigidBodyDes rbDes;

    // next line has no effect at all
    // no matter where I want to translate
    rbDes.originalTransform.translate(Vec3(-100.0f, 0.0f, 0.0f));

    rbDes.mass = 5.0f;
    rbDes.shape = Physics3DShape::createBox(_obb._extents);
    auto ship = PhysicsSprite3D::create(model, &rbDes);

    auto rigidBody = static_cast<Physics3DRigidBody*>(ship->getPhysicsObj());
    
    rigidBody->setLinearFactor(Vec3::ONE);
    rigidBody->setLinearVelocity(Vec3::ZERO);
    rigidBody->setAngularVelocity(Vec3::ZERO);
    rigidBody->setCcdMotionThreshold(0.05f);
    rigidBody->setCcdSweptSphereRadius(0.4f);
    rigidBody->setDamping(0.9f, 0.9f);    

    ship->setPosition3D(pos );

    ship->syncNodeToPhysics();
    ship->setSyncFlag(Physics3DComponent::PhysicsSyncFlag::PHYSICS_TO_NODE);
    ship->setCameraMask((unsigned short)CameraFlag::USER1);

    return ship;
}

No matter what arguments I give to rbDes.originalTransform.translate, the output is always the same:

From my understandig of the code, the green box should be translated 100.0 on the x side, but nothing happens.

I have no clue what I’m doing wrong and would gladly appreciate any help on this.

Flo

btw: also tried it in the shootBox()-function from the Physics3DTests, commenting out or changing the
Physics3DRigidBodyDes::originalTransform.translate() had no effect at all (was set to camera->getPosition3D()).

What’s the secret behind originalTransform.translate()? What is it used for? and more important:
How can I place RigidBody relative to it’s Sprite3D or vice versa?

greetings,

flo

Found it out, just had to use this create-function:

static PhysicsSprite3D* create(const std::string &modelPath, Physics3DRigidBodyDes* rigidDes, const cocos2d::Vec3& translateInPhysics = cocos2d::Vec3::ZERO, const cocos2d::Quaternion& rotInPhsyics = cocos2d::Quaternion::ZERO);

Still don’T know what originalTransform in the rigid body description is, guess it isn’t used anymore…