PhysicsWidget::PhysicsWidget(QWidget* parent /*= 0*/, Qt::WFlags flags /*= 0*/) : QWidget(parent, flags), m_updateRequested(false) { setupUi(this); connect(m_mass, SIGNAL(valueChanged(double)), this, SLOT(massChanged(double))); connect(m_mass, SIGNAL(valueChanged(double)), this, SLOT(updatePhysics())); connect(m_kinematic, SIGNAL(toggled(bool)), this, SLOT(kinematicChanged(bool))); connect(m_kinematic, SIGNAL(toggled(bool)), this, SLOT(updatePhysics())); connect(m_shape, SIGNAL(currentIndexChanged(int)), this, SLOT(shapeChanged(int))); connect(m_shape, SIGNAL(currentIndexChanged(int)), this, SLOT(updatePhysics())); connect(m_width, SIGNAL(valueChanged(double)), this, SLOT(updateBox())); connect(m_width, SIGNAL(valueChanged(double)), this, SLOT(updatePhysics())); connect(m_height, SIGNAL(valueChanged(double)), this, SLOT(updateBox())); connect(m_height, SIGNAL(valueChanged(double)), this, SLOT(updatePhysics())); connect(m_depth, SIGNAL(valueChanged(double)), this, SLOT(updateBox())); connect(m_depth, SIGNAL(valueChanged(double)), this, SLOT(updatePhysics())); connect(m_radius, SIGNAL(valueChanged(double)), this, SLOT(updateSphere(double))); connect(m_radius, SIGNAL(valueChanged(double)), this, SLOT(updatePhysics())); connect(m_cylRadius, SIGNAL(valueChanged(double)), this, SLOT(updateCylinder())); connect(m_cylRadius, SIGNAL(valueChanged(double)), this, SLOT(updatePhysics())); connect(m_cylHeight, SIGNAL(valueChanged(double)), this, SLOT(updateCylinder())); connect(m_cylHeight, SIGNAL(valueChanged(double)), this, SLOT(updatePhysics())); connect(m_restitution, SIGNAL(valueChanged(double)), this, SLOT(updateRestitution(double))); connect(m_restitution, SIGNAL(valueChanged(double)), this, SLOT(updatePhysics())); connect(m_friction, SIGNAL(valueChanged(double)), this, SLOT(updateFriction(double))); connect(m_rollingFriction, SIGNAL(valueChanged(double)), this, SLOT(updatePhysics())); connect(m_rollingFriction, SIGNAL(valueChanged(double)), this, SLOT(updateRollingFriction(double))); connect(m_friction, SIGNAL(valueChanged(double)), this, SLOT(updatePhysics())); connect(m_noContactResponse, SIGNAL(toggled(bool)), this, SLOT(noContactResponseChanged(bool))); connect(m_noContactResponse, SIGNAL(toggled(bool)), this, SLOT(updatePhysics())); connect(m_offsetX, SIGNAL(valueChanged(double)), this, SLOT(updateOffset())); connect(m_offsetX, SIGNAL(valueChanged(double)), this, SLOT(updatePhysics())); connect(m_offsetY, SIGNAL(valueChanged(double)), this, SLOT(updateOffset())); connect(m_offsetY, SIGNAL(valueChanged(double)), this, SLOT(updatePhysics())); connect(m_offsetZ, SIGNAL(valueChanged(double)), this, SLOT(updateOffset())); connect(m_offsetZ, SIGNAL(valueChanged(double)), this, SLOT(updatePhysics())); connect(m_resetWorld, SIGNAL(clicked()), this, SLOT(resetPhysics())); connect(m_debug, SIGNAL(toggled(bool)), this, SLOT(toggleDebugRendering(bool))); connect(m_enabled, SIGNAL(toggled(bool)), this, SLOT(togglePhysics(bool))); connect(m_addConstraint, SIGNAL(clicked()), this, SLOT(addConstraint())); m_debug->setChecked(GameEngine::physicsShapeRenderingEnabled()); m_enabled->setChecked(GameEngine::physicsEnabled()); }
Object::Object(Ogre::SceneManager * scene_mgr, OgreBulletDynamics::DynamicsWorld * dyn_world, const ObjectType & obj_type) : m_mass (msc_mass) , m_restitution (0.0f) , m_friction (3.0f) , mp_entity (NULL) , mp_node (NULL) , mp_body (NULL) , mp_world (NULL) , m_selected (false) , mp_pile (NULL) , m_freeze (false) { mp_world = dyn_world; m_name = "object" + Ogre::StringConverter::toString(ms_incrementor); m_type = obj_type; mp_entity = scene_mgr->createEntity(m_name, "cube.mesh"); mp_entity->setQueryFlags(OQF_DefaultSelectable); mp_entity->setUserAny(Ogre::Any(this)); mp_entity->setCastShadows(true); highlightVisual(false); mp_node = scene_mgr->getRootSceneNode()->createChildSceneNode(); mp_node->attachObject(mp_entity); mp_node->scale(msc_scale); mp_node->setPosition( mp_node->getPosition().x , mp_node->getScale().y * 100 / 2 , mp_node->getPosition().z ); resetPhysics(); ++ms_count; ++ms_incrementor; }
bool Magic3D::Object::update() { if (Scene::getInstance()->getUniqueUpdateFlag() != uniqueUpdate) { uniqueUpdate = Scene::getInstance()->getUniqueUpdateFlag(); bool needTransformOld = needTransform; if (isEnabled()) { if (isScripted()) { std::string function_AI("AI"); Script::getInstance()->execute(function_AI, 0, getName()); } if (AI) { AI->AI(); } updateTweens(); } if (needTransform || (getRigidBody() && Physics::getInstance()->isPlaying() && getRigidBody()->getActivationState() != ISLAND_SLEEPING) || (getParent() && getParent()->isInFrustum())) { if (needTransform && !needTransformOld) { resetPhysics(); } needTransform = false; updateMatrix(); } } return true; }
void Object::setScale(const Ogre::Vector3 & scl) { mp_node->setScale(scl); resetPhysics(); }