| 192 | Physics3DTestDemo::~Physics3DTestDemo() {} |
| 193 | |
| 194 | void Physics3DTestDemo::shootBox(const ax::Vec3& des) |
| 195 | { |
| 196 | Physics3DRigidBodyDes rbDes; |
| 197 | Vec3 linearVel = des - _camera->getPosition3D(); |
| 198 | linearVel.normalize(); |
| 199 | linearVel *= 100.0f; |
| 200 | rbDes.originalTransform.translate(_camera->getPosition3D()); |
| 201 | rbDes.mass = 1.f; |
| 202 | rbDes.shape = Physics3DShape::createBox(Vec3(0.5f, 0.5f, 0.5f)); |
| 203 | auto mesh = PhysicsMeshRenderer::create("MeshRendererTest/box.c3t", &rbDes); |
| 204 | mesh->setTexture("Images/Icon.png"); |
| 205 | |
| 206 | auto rigidBody = static_cast<Physics3DRigidBody*>(mesh->getPhysicsObj()); |
| 207 | rigidBody->setLinearFactor(Vec3::ONE); |
| 208 | rigidBody->setLinearVelocity(linearVel); |
| 209 | rigidBody->setAngularVelocity(Vec3::ZERO); |
| 210 | rigidBody->setCcdMotionThreshold(0.5f); |
| 211 | rigidBody->setCcdSweptSphereRadius(0.4f); |
| 212 | |
| 213 | this->addChild(mesh); |
| 214 | mesh->setPosition3D(_camera->getPosition3D()); |
| 215 | mesh->setScale(0.5f); |
| 216 | mesh->syncNodeToPhysics(); |
| 217 | |
| 218 | // optimize, only sync node to physics |
| 219 | mesh->setSyncFlag(Physics3DComponent::PhysicsSyncFlag::PHYSICS_TO_NODE); // sync node to physics |
| 220 | |
| 221 | mesh->setCameraMask((unsigned short)CameraFlag::USER1); |
| 222 | } |
| 223 | |
| 224 | std::string BasicPhysics3DDemo::subtitle() const |
| 225 | { |
nothing calls this directly
no test coverage detected