MCPcopy Create free account
hub / github.com/axmolengine/axmol / shootBox

Method shootBox

tests/cpp-tests/Source/Physics3DTest/Physics3DTest.cpp:194–222  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

192Physics3DTestDemo::~Physics3DTestDemo() {}
193
194void 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
224std::string BasicPhysics3DDemo::subtitle() const
225{

Callers

nothing calls this directly

Calls 15

createFunction · 0.85
getPhysicsObjMethod · 0.80
setCcdMotionThresholdMethod · 0.80
Vec3Function · 0.50
getPosition3DMethod · 0.45
normalizeMethod · 0.45
translateMethod · 0.45
setTextureMethod · 0.45
setLinearFactorMethod · 0.45
setLinearVelocityMethod · 0.45
setAngularVelocityMethod · 0.45

Tested by

no test coverage detected