/** Init component override. Create a new Sphere Shape in the PhysX scene. */ void SphereCollider::init() { // Deserializing if(initWithData) { shape = Physics::createSphereCollider(radius,center,getActor()); // The physics material is set but it's not yet linked to the shape if(physicsMaterial!=nullptr) setPhysicsMaterial(getPhysicsMaterial()); setRadius(radius); setIsTrigger(isTrigger); setQueryOnly(isQueryOnly); } // Create a new one else { shared_ptr<MeshFilter> meshFilter = getActor()->GetComponent<MeshFilter>(); radius = 0.5f; center = PxVec3(0,0,0); if(meshFilter) meshFilter->getSphereSize(getActor(), radius, center); shape = Physics::createSphereCollider(radius,center,getActor()); // Sets the material as the default one Collider::init(); } }
void CSPhysXObject_RigidStatic::getPositionAndRotation(vector3df &pos, vector3df &rot) { if (getActor()) { PxTransform tx = getActor()->getGlobalPose(); pos.set(tx.p.x, tx.p.y, tx.p.z); PxMat33 mat = PxMat33::PxMat33(tx.q); irr::core::matrix4 irrM; irr::f32 fM[16]; fM[0] = mat.column0.x; fM[1] = mat.column0.y; fM[2] = mat.column0.z; fM[4] = mat.column1.x; fM[5] = mat.column1.y; fM[6] = mat.column1.z; fM[8] = mat.column2.x; fM[9] = mat.column2.y; fM[10] = mat.column2.z; irrM.setM(fM); rot = irrM.getRotationDegrees(); } }
int pRigidBody::getNbWheels() { int result = 0; if (!getActor()) { return NULL; } int nbShapes = getActor()->getNbShapes(); NxShape ** slist = (NxShape **)getActor()->getShapes(); for (NxU32 j=0; j<nbShapes; j++) { NxShape *s = slist[j]; if (s) { pSubMeshInfo *sinfo = static_cast<pSubMeshInfo*>(s->userData); if (sinfo && sinfo->wheel !=NULL) { result ++; } } } return result; }
/** Component init override. Creates a RigidDynamic body in the PhysX scene and sets it as Kinematic by default */ void RigidStatic::init() { physxRigidStatic = Physics::createRigidDynamic(getActor()); //physxRigidStatic->setActorFlag(PxActorFlag::eDISABLE_SIMULATION,true); physxRigidStatic->setRigidDynamicFlag(PxRigidDynamicFlag::eKINEMATIC, true); notify(NewRigidStatic, shared_from_this(), getActor()->getEditorFlag()); }
void CSPhysXObject_RigidDynamic::setFreeze(bool value) { if (getActor()) { if (!value) getActor()->wakeUp(); else getActor()->putToSleep(); } }
// add a force to the object void CSPhysXObject_RigidDynamic::addForce(vector3df dir, float magnitude) { if (getActor()) { vector3df v = dir * magnitude; PxVec3 f(v.X, v.Y, v.Z); getActor()->addForce(f); } }
vector3df CSPhysXObject_RigidDynamic::getPosition() { vector3df pos(0, 0, 0); if (getActor()) { PxTransform tx = getActor()->getGlobalPose(); pos.set(tx.p.x, tx.p.y, tx.p.z); } return pos; }
void CSPhysXObject_RigidDynamic::setPosition(vector3df pos) { if (getActor()) { PxTransform tx = getActor()->getGlobalPose(); tx.p.x = pos.X; tx.p.y = pos.Y; tx.p.z = pos.Z; getActor()->setGlobalPose(tx); } }
void CSPhysXObject_RigidDynamic::setRotation(vector3df rot) { matrix4 irrM; irrM.setRotationDegrees(rot); PxTransform xform = getActor()->getGlobalPose(); quaternion q(irrM); xform.q.w = q.W; xform.q.x = q.X; xform.q.y = q.Y; xform.q.z = q.Z; getActor()->setGlobalPose(xform); }
void KillDistanceBased::checkDeath() { if(playerRef.lock()) { float distance = glm::distance(glm::vec3(),getActor()->transform->getWorldPosition()); if(distance >= distanceToKill) { Factory::DestroyActor(getActor()); } } }
// attach this to an object void CSPhysXObject_RigidStatic::setUserData(int id) { if (getActor()) { getActor()->userData = (void*)id; PxShape* shapes[10]; PxU32 nShapes = getActor()->getShapes(shapes, 10); while (nShapes--) { shapes[nShapes]->userData = (void*)id; } } }
/** Looks for a MeshComponent and gets the extent for the collider */ void SphereCollider::recalculateBounds() { shared_ptr<MeshFilter> meshFilter = getActor()->GetComponent<MeshFilter>(); float radius = 0.5f; PxVec3 center(0,0,0); if(meshFilter) meshFilter->getSphereSize(getActor(), radius, center); setRadius(radius); }
void FindPrimerPairsWorker::sl_onTaskFinished(Task* t) { QString reportFileUrl = getValue<QString>(FindPrimerPairsWorkerFactory::OUT_FILE); FindPrimersTask* findTask = qobject_cast<FindPrimersTask*>(t); if(!findTask->hasError() && !findTask->isCanceled()) { if(!findTask->getReport().isEmpty()) { context->getMonitor()->addOutputFile(reportFileUrl, getActor()->getId(), true); } else { context->getMonitor()->addError(tr("No correct primers pairs found"), getActor()->getId(), WorkflowNotification::U2_WARNING); } } setDone(); }
/** * @author JoSch * @date 09-03-2008 */ void SoundStitchingObject::_update() { ActorControlledObject::_update(); Actor *actor = getActor(); if (mMovableObject == NULL || actor == NULL) { return; } if (!getSoundStitching()->isValid()) { return; } if (isAttached()) { getSoundStitching()->setPosition(actor->getWorldPosition()); getSoundStitching()->setDirection(actor->getWorldOrientation()); LOG_DEBUG(Logger::CORE, "Pos SoundStitchingObject: " + StringConverter::toString(actor->getWorldPosition().x) + " " + StringConverter::toString(actor->getWorldPosition().y) + " " + StringConverter::toString(actor->getWorldPosition().z)); } }
void MultiActorAgent::controller(const LCreal dt) { if ( (getState() != nullptr) && (nAgents>0) ) { // update global state once for all agents getState()->updateGlobalState(); // for each behavior/actor pair, update state and generate action for (unsigned int i=0; i<nAgents; i++) { if (agentList[i].actor != nullptr) { setActor(agentList[i].actor); Basic::Ubf::Behavior* behavior = agentList[i].behavior; // update ubf state getState()->updateState(agentList[i].actor); // generate an action Basic::Ubf::Action* action = behavior->genAction(getState(), dt); if (action) { // allow possibility of no action returned action->execute(getActor()); action->unref(); } } } setActor(nullptr); } }
void Tractor::joinTrailer(ITrailer* trailer) { if(m_joinedTrailer && m_joint) return; NxD6JointDesc joint; Vec3 move = getJointPoint() - trailer->getJointPoint(); //if(trailer->getJointPoint().y < getJointPoint().y) //trailer->getActor()->setGlobalPosition(trailer->getActor()->getGlobalPosition() + NxVec3(0, getJointPoint().y - trailer->getJointPoint().y, 0)); trailer->getActor()->setGlobalPosition(trailer->getActor()->getGlobalPosition() + NxVec3(move)); joint.actor[0] = getActor(); joint.actor[1] = trailer->getActor(); joint.setGlobalAnchor(NxVec3(getJointPoint())); joint.setGlobalAxis(NxVec3(-m_forward)); joint.xMotion = NX_D6JOINT_MOTION_LOCKED; joint.yMotion = NX_D6JOINT_MOTION_LOCKED; joint.zMotion = NX_D6JOINT_MOTION_LOCKED; joint.swing1Motion = NX_D6JOINT_MOTION_LIMITED; joint.swing2Motion = NX_D6JOINT_MOTION_LIMITED; joint.twistMotion = NX_D6JOINT_MOTION_LIMITED; joint.swing1Limit.value = 0.3f; joint.swing2Limit.value = 1.8f; joint.twistLimit.low.value = -0.1f; joint.twistLimit.high.value = 0.1f; m_joint = m_scene->createJoint(joint); m_joinedTrailer = trailer; m_joinedTrailer->joinVehicle(); return; }
// ---------------------------------------------------------------------------- // NOTE: Dimmer channel should contain 0 for full off and 255 for full on and // no other values // void SceneMovementAnimatorTask::populateChannelAnimations( ParticipantArray& participants, size_t& particpant_index, AngleList& tilt, AngleList& pan, ChannelValueArray& dimmer, ChannelValueArray& speed, size_t group_size, bool run_once ) { size_t end = particpant_index + group_size; // If run once, add last entry to shut down the lights if ( run_once && dimmer.size() > 0 ) { dimmer.push_back( 0 ); } ChannelAnimationStyle style( run_once ? CAM_LIST_ONCE : CAM_LIST ); for ( ; particpant_index < end && particpant_index < participants.size(); particpant_index++ ) { channel_address pan_channel = participants[ particpant_index ].m_head.m_pan; channel_address tilt_channel = participants[ particpant_index ].m_head.m_tilt; channel_address dimmer_channel = participants[ particpant_index ].m_head.m_dimmer; channel_address speed_channel = participants[ particpant_index ].m_head.m_speed; UID actor_uid = participants[ particpant_index ].m_actor_uid; Fixture* pf = getActorRepresentative( actor_uid ); if ( !pf ) continue; if ( tilt_channel != INVALID_CHANNEL && tilt.size() ) { Channel* cp = pf->getChannel( tilt_channel ); add( actor_uid, tilt_channel, style, anglesToValues( cp, tilt, cp->getMinAngle(), cp->getMaxAngle() ) ); } if ( pan_channel != INVALID_CHANNEL && pan.size() ) { Channel* cp = pf->getChannel( pan_channel ); add( actor_uid, pan_channel, style, anglesToValues( cp, pan, cp->getMinAngle(), cp->getMaxAngle() ) ); } if ( speed_channel != INVALID_CHANNEL && speed.size() ) { add( actor_uid, speed_channel, style, speed ); } if ( dimmer_channel != INVALID_CHANNEL && dimmer.size() ) { Channel* ch = pf->getChannel( dimmer_channel ); STUDIO_ASSERT( ch, "Can't access dimmer channel %d on fixture %s", dimmer_channel, pf->getFullName() ); BYTE low = ch->getDimmerLowestIntensity(); BYTE high = ch->getDimmerHighestIntensity(); // Replace all 255 dimmer high value with the fixture's dimmer value iff the actors value != 0 SceneActor* actor = getActor( actor_uid ); if ( actor && actor->getFinalChannelValue( pf->getUID(), dimmer_channel ) != 0 ) high = actor->getFinalChannelValue( pf->getUID(), dimmer_channel ); if ( low != 0 || high != 255 ) { // Special case odd dimmer values for ( size_t i=0; i < dimmer.size(); i++ ) dimmer[i] = ( dimmer[i] == 255 ) ? high : low; } add( actor_uid, dimmer_channel, style, dimmer ); } } }
void NWorld::removeActor(std::size_t index) { NActor::Ptr a = getActor(index); if (a != nullptr) { add(instance().mActorsDeletions,a->getId()); } }
void MabdiSimulatedSensor::setObjectColor( int row, double r, double g, double b ){ LOG(INFO) << "Setting object color of object in row: " << row << " Color: " << r << " " << g << " " << b; vtkWeakPointer<vtkActor> actor = getActor( row ); actor->GetProperty()->SetColor( r, g, b ); }
int gMove::update(lua_State* /* aLua */, float aDelta) { eActor* actor = getActor(); const auto& oldPos = actor->getPos(); actor->setPos(oldPos + iDir * iSpeed * aDelta); return 0; }
/** Component tick override. Updates the PhysX scene with the Actor transform @param [in] deltaSeconds last frame duration */ void RigidStatic::tick(float deltaSeconds) { shared_ptr<Actor> actor = getActor(); // physxRigidStatic->setGlobalPose(transformToPhysXTransform(actor->transform)); physxRigidStatic->setGlobalPose(PxTransform(glmMat4ToPhysxMat4(actor->transform->getPosRotMatrix()))); }
void DiamondClassifyWorker::sl_taskFinished(Task *task) { DiamondClassifyTask *diamondTask = qobject_cast<DiamondClassifyTask *>(task); if (!diamondTask->isFinished() || diamondTask->hasError() || diamondTask->isCanceled()) { return; } const QString classificationUrl = diamondTask->getClassificationUrl(); QVariantMap data; const TaxonomyClassificationResult &classificationResult = diamondTask->getParsedReport(); data[TaxonomySupport::TAXONOMY_CLASSIFICATION_SLOT_ID] = QVariant::fromValue<U2::LocalWorkflow::TaxonomyClassificationResult>(classificationResult); output->put(Message(output->getBusType(), data)); context->getMonitor()->addOutputFile(classificationUrl, getActor()->getId()); LocalWorkflow::TaxonomyClassificationResult::const_iterator it; int classifiedCount = NgsReadsClassificationUtils::countClassified(classificationResult); context->getMonitor()->addInfo(tr("There were %1 input reads, %2 reads were classified.").arg(QString::number(classificationResult.size())).arg(QString::number(classifiedCount)) , getActor()->getId(), WorkflowNotification::U2_INFO); }
void pVehicle::_computeLocalVelocity() { _computeMostTouchedActor(); NxVec3 relativeVelocity; if (_mostTouchedActor == NULL || !_mostTouchedActor->isDynamic()) { relativeVelocity = getActor()->getLinearVelocity(); } else { relativeVelocity = getActor()->getLinearVelocity() - _mostTouchedActor->getLinearVelocity(); } NxQuat rotation = getActor()->getGlobalOrientationQuat(); NxQuat global2Local; _localVelocity = relativeVelocity; rotation.inverseRotate(_localVelocity); char master[512]; //sprintf(master,"Velocity: %2.3f %2.3f %2.3f\n", _localVelocity.x, _localVelocity.y, _localVelocity.z); //OutputDebugString(master); }
void MabdiSimulatedSensor::setObjectVisibility( int row, bool showObject ){ LOG(INFO) << "Setting object visibility of object in row: " << row; vtkWeakPointer<vtkActor> actor = getActor( row ); // show or hide object if( showObject ) actor->SetVisibility( 1 ); else actor->SetVisibility( 0 ); }
void CSPhysXObject_RigidStatic::rotate(vector3df rotOffset) { if (getActor()) { vector3df rot = getRotation(); rot.X = 0; rot.Z = 0; rot.Y += rotOffset.Y; setRotation(rot); } }
void ConservationPlotWorker::sl_taskFinished() { ConservationPlotTask *t = dynamic_cast<ConservationPlotTask*>(sender()); if (!t->isFinished() || t->hasError() || t->isCanceled()) { return; } context->getMonitor()->addOutputFile(t->getSettings().outFile, getActor()->getId(), true); if (inChannel->isEnded() && !inChannel->hasMessage()) { setDone(); } }
void CAP3Worker::sl_taskFinished() { CAP3SupportTask* capTask = qobject_cast<CAP3SupportTask*>(sender()); SAFE_POINT(NULL != capTask, "NULL task!", ); if (!capTask->isFinished()) { return; } QString outputFile = capTask->getOutputFile(); if (!outputFile.isEmpty()) { context->getMonitor()->addOutputFile(outputFile, getActor()->getId()); } }
void Entity::rotateActor(size_t inIndex, double inXRotation, double inYRotation, double inZRotation) { Actor* a = getActor(inIndex); if (a) { //a->matrix().rotateX(inXRotation); //a->matrix().rotateY(inYRotation); //a->matrix().rotateZ(inZRotation); a->rotateY(inYRotation); a->rotateX(inXRotation); a->rotateZ(inZRotation); } }
void Body::updateAfterPhysics() { // Don't update inactive or static bodies, as they can't possibly have moved as a result of // internal physics updates. Setting Actor position and transform fires off a bunch of signals // and invalidates internal state, which can get expensive. if (!isActive() || getBodyType() == StaticBody) { return; } Actor* actor = getActor(); if (actor) { actor->setPosition(getPosition()); actor->setRotation(qRadiansToDegrees(getAngleInRadians())); } }
vector3df CSPhysXObject_RigidDynamic::getRotation() { vector3df rot(0, 0, 0); if (getActor()) { PxMat33 mat = PxMat33::PxMat33(getActor()->getGlobalPose().q); irr::core::matrix4 irrM; irr::f32 fM[16]; fM[0] = mat.column0.x; fM[1] = mat.column0.y; fM[2] = mat.column0.z; fM[4] = mat.column1.x; fM[5] = mat.column1.y; fM[6] = mat.column1.z; fM[8] = mat.column2.x; fM[9] = mat.column2.y; fM[10] = mat.column2.z; irrM.setM(fM); rot = irrM.getRotationDegrees(); } return rot; }