PxActor* World::createRigidBody(const PxGeometry& geometry, float mass, const ofVec3f& pos, const ofQuaternion& rot, float density) { assert(inited); PxTransform transform; toPx(pos, transform.p); toPx(rot, transform.q); PxActor *actor; if (mass > 0) { PxRigidDynamic* rigid = PxCreateDynamic(*physics, transform, geometry, *defaultMaterial, density); rigid->setMass(mass); rigid->setLinearDamping(0.25); rigid->setAngularDamping(0.25); actor = rigid; } else { PxRigidStatic *rigid = PxCreateStatic(*physics, transform, geometry, *defaultMaterial); actor = rigid; } scene->addActor(*actor); return actor; }
bool HTMLElementImp::evalPx(HTMLElementImp* element, const std::u16string& attr, const std::u16string& prop) { Nullable<std::u16string> value = element->getAttribute(attr); if (value.hasValue()) { std::u16string length = value.value(); if (toPx(length)) { css::CSSStyleDeclaration style = element->getStyle(); style.setProperty(prop, length, u"non-css"); return true; } } return false; }
bool HTMLElementImp::evalVspace(HTMLElementImp* element, const std::u16string& prop) { Nullable<std::u16string> value = element->getAttribute(prop); if (value.hasValue()) { std::u16string px = value.value(); if (toPx(px)) { css::CSSStyleDeclaration style = element->getStyle(); style.setProperty(u"margin-top", px, u"non-css"); style.setProperty(u"margin-bottom", px, u"non-css"); return true; } } return false; }
bool HTMLElementImp::evalBorder(HTMLElementImp* element) { Nullable<std::u16string> value = element->getAttribute(u"border"); if (value.hasValue()) { std::u16string px = value.value(); if (toPx(px)) { css::CSSStyleDeclaration style = element->getStyle(); style.setProperty(u"border-width", px, u"non-css"); style.setProperty(u"border-style", u"solid", u"non-css"); return true; } } return false; }
void World::setGravity(ofVec3f gravity) { assert(inited); scene->setGravity(toPx(gravity)); }
PxActor* World::addBox(const ofVec3f& size, const ofVec3f& pos, const ofQuaternion& rot, float mass) { assert(inited); return createRigidBody(PxBoxGeometry(toPx(size)), mass, pos, rot); }