本文整理汇总了C++中VRTransformPtr::getPhysics方法的典型用法代码示例。如果您正苦于以下问题:C++ VRTransformPtr::getPhysics方法的具体用法?C++ VRTransformPtr::getPhysics怎么用?C++ VRTransformPtr::getPhysics使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VRTransformPtr
的用法示例。
在下文中一共展示了VRTransformPtr::getPhysics方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: attachTransform
void virtuose::attachTransform(VRTransformPtr trans)
{
if(vc == 0) return;
isAttached = true;
attached = trans;
VRPhysics* o = trans->getPhysics();
btMatrix3x3 t = o->getInertiaTensor();
float inertia[9] {0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0};
Matrix3ToArray(t,inertia);
cout<<"\n "<<"\n "<<inertia[0] << " " <<inertia[1] << " " <<inertia[2] << "\n "<<inertia[3] << " " <<inertia[4] << " " <<inertia[5] << "\n "<<inertia[6] << " " <<inertia[7] <<" " << inertia[8]<<"\n ";
CHECK(virtAttachVO(vc, o->getMass(), inertia));
}
示例2: apply
// called from VRTransform::apply_constraints
void VRConstraint::apply(VRTransformPtr obj, VRObjectPtr parent, bool force) {
if (!active || obj->getPhysics()->isPhysicalized()) return;
auto now = VRGlobals::CURRENT_FRAME;
if (apply_time_stamp == now && !force) return;
apply_time_stamp = now;
if (local) parent = obj->getParent(true);
if (auto r = Referential.lock()) parent = r;
Matrix4d J;
if (parent) J = parent->getMatrixTo(obj);
else J = obj->getWorldMatrix();
J.mult(refMatrixB);
J.multLeft(refMatrixAI);
for (int i=0; i<3; i++) { // translation
if (min[i] > max[i]) continue; // free
if (min[i] > J[3][i]) J[3][i] = min[i]; // lower bound
if (max[i] < J[3][i]) J[3][i] = max[i]; // upper bound
}
Vec3d angles = VRTransform::computeEulerAngles(J);
auto sign = [](float a) {
return a<0?-1:1;
};
// TODO: this is not correct, for example [180, 20, 180], corresponds to [0, 160, 0], and not [0, 20, 0] !!
// this tries to fix it somewhat, but its not clean!
if ( abs(angles[0]) > Pi*0.5 && abs(angles[2]) > Pi*0.5) {
angles[0] -= sign(angles[0])*Pi;
angles[2] -= sign(angles[2])*Pi;
angles[1] = Pi - angles[1];
}
Vec3d angleDiff;
for (int i=3; i<6; i++) { // rotation
if (min[i] > max[i]) continue; // free
float a = angles[i-3];
float d1 = min[i]-a; while(d1 > Pi) d1 -= 2*Pi; while(d1 < -Pi) d1 += 2*Pi;
float d2 = max[i]-a; while(d2 > Pi) d2 -= 2*Pi; while(d2 < -Pi) d2 += 2*Pi;
if (d1 > 0 && abs(d1) <= abs(d2)) angleDiff[i-3] = d1; // lower bound
if (d2 < 0 && abs(d2) <= abs(d1)) angleDiff[i-3] = d2; // upper bound
}
VRTransform::applyEulerAngles(J, angles + angleDiff);
J.multLeft(refMatrixA);
J.mult(refMatrixBI);
obj->setMatrixTo(J, parent);
}
示例3: attachTransform
void virtuose::attachTransform(VRTransformPtr trans) {
//if(!connected()) return;
isAttached = true;
attached = trans;
VRPhysics* o = trans->getPhysics();
btMatrix3x3 t = o->getInertiaTensor();
Vec9 inertia;
Matrix3ToArray(t,inertia.data);
print(inertia, 9);
//cout<<"\n virtuose::attachTransform:\n " << inertia[0] << " " <<inertia[1] << " " <<inertia[2] << "\n "<<inertia[3] << " " <<inertia[4] << " " <<inertia[5] << "\n "<<inertia[6] << " " <<inertia[7] <<" " << inertia[8]<<"\n ";
cout<<"\n virtuose::attachTransform:\n ";
interface.setObject<Vec9>("inertia", inertia);
interface.setObject<float>("mass", o->getMass());
interface.setObject<bool>("doAttach", true);
//CHECK(virtAttachVO(vc, o->getMass(), inertia));
}
示例4: unphysicalize
void VRPhysicsManager::unphysicalize(VRTransformPtr obj) {
if (!obj) return;
btCollisionObject* bdy = obj->getPhysics()->getCollisionObject();
if (!bdy) return;
if (OSGobjs.count(bdy)) OSGobjs.erase(bdy);
}
示例5: physicalize
void VRPhysicsManager::physicalize(VRTransformPtr obj) {
if (!obj) return;
btCollisionObject* bdy = obj->getPhysics()->getCollisionObject();
if (!bdy) return;
OSGobjs[bdy] = obj;
}