void Camera::MenuCameraRotation() { // Create rotation matrix m_menuRotation += (float)GLOBAL::GetInstance().GetDeltaTime() / 16.0f; if (m_menuRotation > 6.28f) { m_menuRotation = 0.0f; } DirectX::XMMATRIX rotation = DirectX::XMMatrixRotationY(m_menuRotation); // Lock shadows in center. DirectX::XMFLOAT3 shadowPosition = GetPosition(); DirectX::XMStoreFloat3(&shadowPosition, DirectX::XMVector3TransformCoord(DirectX::XMLoadFloat3(&shadowPosition), rotation)); shadowPosition.x *= 0.8f; DirectX::XMFLOAT3 position = DirectX::XMFLOAT3(25.0f + shadowPosition.x, 100.0f, 50.0f); UpdatePosition(position); UpdateTarget(DirectX::XMFLOAT3(shadowPosition.x, 5.0f, 0.0f)); UpdateViewMatrix(); UpdateProjectionMatrix(true); GraphicsEngine::SetLightViewAndProjection(GetViewMatrix(), GetProjectionMatrix()); // Lock camera in center and rotate camera. position = DirectX::XMFLOAT3(0.0f, 40.0f, -24.0f); UpdatePosition(position); UpdateTarget(DirectX::XMFLOAT3(0.0f, 7.5f, 0.0f)); UpdateViewMatrix(); UpdateProjectionMatrix(false); DirectX::XMStoreFloat4x4(&m_viewMatrix, DirectX::XMMatrixMultiply(rotation, DirectX::XMLoadFloat4x4(&m_viewMatrix))); GraphicsEngine::SetViewAndProjection(GetViewMatrix(), GetProjectionMatrix()); }
void Player::UpdateStatus() { if ( GetKeyState(VK_ADD) == KEY_DOWN || GetKeyState(VK_ADD) == KEY_PRESSED ) { UpdateVelocity(1.05f) ; } if ( GetKeyState(VK_SUBTRACT) == KEY_DOWN || GetKeyState(VK_SUBTRACT) == KEY_PRESSED ) { UpdateVelocity(0.95f) ; } if ( GetKeyState(VK_DOWN) == KEY_DOWN || GetKeyState(VK_DOWN) == KEY_PRESSED ) { UpdatePosition(0, 10.f) ; } if ( GetKeyState(VK_UP) == KEY_DOWN || GetKeyState(VK_UP) == KEY_PRESSED ) { UpdatePosition(0, -10.f) ; } if ( GetKeyState(VK_LEFT) == KEY_DOWN || GetKeyState(VK_LEFT) == KEY_PRESSED ) { UpdatePosition(-10.f, 0) ; } if ( GetKeyState(VK_RIGHT) == KEY_DOWN || GetKeyState(VK_RIGHT) == KEY_PRESSED) { UpdatePosition(10.f, 0) ; } }
void Camera::FollowCharacter(DirectX::XMFLOAT3 p_playerPos) { // Lock shadows on the player. DirectX::XMFLOAT3 playerPosition = p_playerPos; DirectX::XMFLOAT3 position = DirectX::XMFLOAT3(playerPosition.x + 25.0f, playerPosition.y + 100.0f, playerPosition.z + 50.0f); DirectX::XMFLOAT3 target = playerPosition; UpdatePosition(position); UpdateTarget(target); UpdateViewMatrix(); UpdateProjectionMatrix(true); GraphicsEngine::SetLightViewAndProjection(GetViewMatrix(), GetProjectionMatrix()); // Visibility view projection.. playerPosition = p_playerPos; position = DirectX::XMFLOAT3(playerPosition.x, playerPosition.y + 30.0f, playerPosition.z); target = playerPosition; UpdatePosition(position); UpdateTarget(target); UpdateViewMatrix(); GraphicsEngine::SetViewPolygonMatrix(GetViewMatrix()); // Lock camera on the player. playerPosition = p_playerPos; position = DirectX::XMFLOAT3(playerPosition.x, playerPosition.y + 30.0f, playerPosition.z - 15.0f); target = playerPosition; SetOutliningRayPosition(position); SetOutliningRayTarget(target); if (GLOBAL::GetInstance().CAMERA_MOVING) { MovingCamera(playerPosition); } else { UpdatePosition(position); UpdateTarget(target); UpdateViewMatrix(); UpdateProjectionMatrix(false); GraphicsEngine::SetViewAndProjection(GetViewMatrix(), GetProjectionMatrix()); m_oldPosition = position; } GraphicsEngine::UpdateVisibilityPolygon(Point(playerPosition.x, playerPosition.z), (float)GLOBAL::GetInstance().GetDeltaTime()); }
bool Transport::TeleportTransport(uint32 newMapid, float x, float y, float z, float o) { Map const* oldMap = GetMap(); if (oldMap->GetId() != newMapid) { _delayedTeleport = true; UnloadStaticPassengers(); return true; } else { UpdatePosition(x, y, z, o); // Teleport players, they need to know it for (PassengerSet::iterator itr = _passengers.begin(); itr != _passengers.end(); ++itr) { if ((*itr)->GetTypeId() == TYPEID_PLAYER) { // will be relocated in UpdatePosition of the vehicle if (Unit* veh = (*itr)->ToUnit()->GetVehicleBase()) if (veh->GetTransport() == this) continue; float destX, destY, destZ, destO; (*itr)->m_movementInfo.transport.pos.GetPosition(destX, destY, destZ, destO); TransportBase::CalculatePassengerPosition(destX, destY, destZ, &destO, x, y, z, o); (*itr)->ToUnit()->NearTeleportTo(destX, destY, destZ, destO); } } return false; } }
// Processes the 'onpropertychange' event, checking for a change in position or size. void ElementDocument::ProcessEvent(Event& event) { Element::ProcessEvent(event); // Process generic keyboard events for this window in capture phase if (event.GetPhase() == Event::PHASE_BUBBLE && event == KEYDOWN) { int key_identifier = event.GetParameter<int>("key_identifier", Input::KI_UNKNOWN); // Process TAB if (key_identifier == Input::KI_TAB) { FocusNextTabElement(event.GetTargetElement(), !event.GetParameter<bool>("shift_key", false)); } // Process ENTER being pressed on a focusable object (emulate click) else if (key_identifier == Input::KI_RETURN || key_identifier == Input::KI_NUMPADENTER) { Element* focus_node = GetFocusLeafNode(); if (focus_node && focus_node->GetProperty<int>(TAB_INDEX) == TAB_INDEX_AUTO) { focus_node->Click(); } } } else if (event.GetTargetElement() == this) { if (event == RESIZE) UpdatePosition(); } }
void Player::Update() { float dt = UpdateClock::DeltaTime(); decisionTreeCooldown -= dt; if(decisionTreeCooldown <= 0 || needsNewState) { // run decision tree currentState = defensive ? NodeTree_Defensive->Evaluate() : NodeTree->Evaluate(); decisionTreeCooldown = decisionTreeTimeout; needsNewState = false; } currentState->Update(); UpdatePosition(); if(hasEnemyFlag) { for(uint i = 0; i < game->NUM_PLAYERS; i++) { if(game->players[i]->teamID != teamID) { if(glm::length(game->players[i]->position - position) < 0.75f) { game->ResetFlag(teamID == 0 ? 1 : 0); position = game->level.nodes[game->TeamFlags[teamID].homeNodeID].position; needsNewPath = true; needsNewState = true; hasEnemyFlag = false; } } } } }
void VsJoint::Physics_CollectData() { if(m_lpThisJoint && m_vxJoint) { UpdatePosition(); //Only update the joints data when we need to do robot synch, but still update our internal data. //Only attempt to make these calls if the coordinate ID is a valid number. if(m_iCoordID >= 0) //&& m_lpThisJoint->NeedsRobotSynch() { float fltDistanceUnits = m_lpThisAB->GetSimulator()->DistanceUnits(); float fltMassUnits = m_lpThisAB->GetSimulator()->MassUnits(); if(m_vxJoint->isAngular(m_iCoordID) == true) { m_lpThisJoint->JointPosition(m_vxJoint->getCoordinateCurrentPosition (m_iCoordID)); m_lpThisJoint->JointVelocity(m_vxJoint->getCoordinateVelocity (m_iCoordID)); m_lpThisJoint->JointForce(m_vxJoint->getCoordinateForce(m_iCoordID) * fltMassUnits * fltDistanceUnits * fltDistanceUnits); } else { m_lpThisJoint->JointPosition(m_vxJoint->getCoordinateCurrentPosition (m_iCoordID) * fltDistanceUnits); m_lpThisJoint->JointVelocity(m_vxJoint->getCoordinateVelocity(m_iCoordID) * fltDistanceUnits); m_lpThisJoint->JointForce(m_vxJoint->getCoordinateForce(m_iCoordID) * fltMassUnits * fltDistanceUnits); } } } }
void RichEditPara::OffsetCharRange(int nOffset) { RichEditObj::OffsetCharRange(nOffset); m_bNeedUpdateLayout = TRUE; UpdatePosition(); }
void CChartLegend::ClipArea(CRect& rcControl, CDC* pDC) { UpdatePosition(pDC,rcControl); if (m_ObjectRect.IsRectEmpty()) return; if (m_bDocked) { switch (m_DockSide) { case dsDockRight: rcControl.right = m_ObjectRect.left + 2; break; case dsDockLeft: rcControl.left = m_ObjectRect.right - 2; break; case dsDockTop: rcControl.top = m_ObjectRect.bottom + 2; break; case dsDockBottom: rcControl.bottom = m_ObjectRect.top - 2; break; } } }
/************************************************************************************ * * ***********************************************************************************/ bool BaaderDome::SetupParms() { targetAz = 0; if (UpdatePosition()) IDSetNumber(&DomeAbsPosNP, nullptr); if (UpdateShutterStatus()) IDSetSwitch(&DomeShutterSP, nullptr); if (UpdateFlapStatus()) IDSetSwitch(&DomeFlapSP, nullptr); if (InitPark()) { // If loading parking data is successful, we just set the default parking values. SetAxis1ParkDefault(0); } else { // Otherwise, we set all parking data to default in case no parking data is found. SetAxis1Park(0); SetAxis1ParkDefault(0); } return true; }
// Player movement behaviour and controls // void Player::Move(int screenX, int screenY) { if(IsKeyDown(KEY_UP) && y > height/2) { MoveY(-1.4); } else if(IsKeyDown(KEY_DOWN) && y < screenY-height/2) { MoveY(1.4); } if(IsKeyDown(KEY_LEFT) && x > width/2) { state = 3; MoveX(-1.4); } else if(IsKeyDown(KEY_RIGHT) && x < screenX-width/2) { state = 4; MoveX(1.4); } else state = 0; UpdatePosition(); }
void Transform::Update() { model = glm::toMat4(rotationQ); model[0] *= scale[0]; model[1] *= scale[1]; model[2] *= scale[2]; UpdatePosition(); }
TEST_F(MockWorld, TestEntityUpdatePosition) { auto const& w_ptr = std::make_shared<sbe::World>(RECT); EXPECT_CALL(*t_entity.get(), UpdatePosition(w_ptr)); world.UpdatePositions(w_ptr); }
void CAMERA_MOUNT::Update(const MATHVECTOR <float, 3> & newpos, const QUATERNION <float> & newdir, float dt) { rotation = newdir * offsetrot; MATHVECTOR <float, 3> pos = offset; newdir.RotateVector(pos); pos = pos + newpos; MATHVECTOR <float, 3> vel = pos - position; effect = (vel.Magnitude() - 0.02) / 0.04; if (effect < 0) effect = 0; else if (effect > 1) effect = 1; float bumpdiff = randgen.Get(); float power = pow(bumpdiff, 32); if (power < 0) power = 0; else if (power > 0.2) power = 0.2; float veleffect = std::min(pow(vel.Magnitude() * ( 2.0 - stiffness), 3.0), 1.0); float bumpimpulse = power * 130.0 * veleffect; float k = 800.0 + stiffness * 800.0 * 4.0; float c = 2.0 * std::sqrt(k * mass) * 0.35; MATHVECTOR <float, 3> bumpforce = direction::Up * bumpimpulse; MATHVECTOR <float, 3> springforce = -displacement * k; MATHVECTOR <float, 3> damperforce = -velocity * c; velocity = velocity + (springforce + damperforce + bumpforce) * dt; displacement = displacement + velocity * dt; UpdatePosition(pos); }
// New directional or spot light. lcLight::lcLight(float px, float py, float pz, float tx, float ty, float tz) : lcObject(LC_OBJECT_LIGHT) { Initialize(lcVector3(px, py, pz), lcVector3(tx, ty, tz)); mState |= LC_LIGHT_SPOT; UpdatePosition(1); }
void CameraMount::Update(const Vec3 & newpos, const Quat & newdir, float dt) { rotation = newdir * offsetrot; Vec3 pos = offset; newdir.RotateVector(pos); pos = pos + newpos; Vec3 vel = pos - position; effect = (vel.Magnitude() - 0.02) / 0.04; if (effect < 0) effect = 0; else if (effect > 1) effect = 1; float bumpdiff = randgen.Get(); float power = pow(bumpdiff, 32); if (power < 0) power = 0; else if (power > 0.2) power = 0.2; float veleffect = std::min(pow(vel.Magnitude() * ( 2.0 - stiffness), 3.0), 1.0); float bumpimpulse = power * 130.0 * veleffect; float k = 800.0 + stiffness * 800.0 * 4.0; float c = 2.0 * std::sqrt(k * mass) * 0.35; Vec3 bumpforce = Direction::Up * bumpimpulse; Vec3 springforce = -displacement * k; Vec3 damperforce = -velocity * c; velocity = velocity + (springforce + damperforce + bumpforce) * dt; displacement = displacement + velocity * dt; UpdatePosition(pos); }
void CViewer::InitFreeMode() { CORE->GetRenderer()->SetUniqueRenderPath("HDR"); m_fVelocity = 5.0f; CORE->GetRenderableObjectsManager()->SetAllVisibility(true); if(m_pCharacter) { m_pTargetObject->SetYaw(m_pCharacter->GetYaw()-m_fInitialCharacterYaw); m_pTargetObject->SetPosition(m_pCharacter->GetPosition()); ((CShoulderCamera*)m_pObjectCamera)->SetShoulderDistance(0.85f); ((CShoulderCamera*)m_pObjectCamera)->SetZoom(1.8f); }else{ m_pTargetObject->SetYaw(0.0f); m_pTargetObject->SetPosition(Vect3f(m_pTargetObject->GetPosition().x,0.0f,m_pTargetObject->GetPosition().z)); ((CShoulderCamera*)m_pObjectCamera)->SetShoulderDistance(0.0f); ((CShoulderCamera*)m_pObjectCamera)->SetZoom(0.0f); } m_pTargetObject->SetPitch(0.0f); ((CShoulderCamera*)m_pObjectCamera)->SetShoulderHeight(1.55f); m_pObjectModeLight = (CDirectionalLight*)CORE->GetLightManager()->GetResource("ObjectModeLight"); if(m_pObjectModeLight) { m_pObjectModeLight->SetActive(false); } UpdatePosition(Vect3f(0.0f),0.0f,0.0f); UpdateCamera(0.0f,0.0f); }
bool ZActor::ProcessMotion(float fDelta) { if (!m_pVMesh) return false; m_pVMesh->Frame(); rvector pos = m_Position; rvector dir = m_Direction; dir.z = 0; rmatrix world; MakeWorldMatrix(&world,rvector(0,0,0), dir,rvector(0,0,1)); rvector MeshPosition ; MeshPosition = pos; MakeWorldMatrix(&world,pos,dir,rvector(0,0,1)); m_pVMesh->SetWorldMatrix(world); UpdatePosition(fDelta); if(IsActiveModule(ZMID_LIGHTNINGDAMAGE)==false) { if (m_pVMesh->isOncePlayDone()) { m_Animation.Input(ZA_ANIM_DONE); } } return true; }
NTSTATUS CMiniportWaveRTStream::GetPosition ( _Out_ KSAUDIO_POSITION *Position_ ) { NTSTATUS ntStatus; #ifdef SYSVAD_BTH_BYPASS if (m_ScoOpen) { ntStatus = GetScoStreamNtStatus(); IF_FAILED_JUMP(ntStatus, Done); } #endif // SYSVAD_BTH_BYPASS if (m_KsState == KSSTATE_RUN) { // // Get the current time and update position. // LARGE_INTEGER ilQPC = KeQueryPerformanceCounter(NULL); UpdatePosition(ilQPC); } Position_->PlayOffset = m_ullPlayPosition; Position_->WriteOffset = m_ullWritePosition; ntStatus = STATUS_SUCCESS; #ifdef SYSVAD_BTH_BYPASS Done: #endif // SYSVAD_BTH_BYPASS return ntStatus; }
void CameraMount::Update(const Vec3 & newpos, const Quat & newdir, float dt) { rotation = newdir * offsetrot; Vec3 pos = offset; newdir.RotateVector(pos); pos = pos + newpos; Vec3 vel = pos - position; effect = (vel.Magnitude() - 0.02f) * 25; effect = Clamp(effect, 0.0f, 1.0f); float bumpdiff = randgen.Get(); float power = std::pow(bumpdiff, 32.0f); power = Clamp(power, 0.0f, 0.2f); float veleffect = Min(std::pow(vel.Magnitude() * (2 - stiffness), 3.0f), 1.0f); float bumpimpulse = power * 130 * veleffect; float k = 800 + stiffness * 800 * 4; float c = 2 * std::sqrt(k * mass) * 0.35f; Vec3 bumpforce = Direction::Up * bumpimpulse; Vec3 springforce = -displacement * k; Vec3 damperforce = -velocity * c; velocity = velocity + (springforce + damperforce + bumpforce) * dt; displacement = displacement + velocity * dt; UpdatePosition(pos); }
// return true if target is reached bool CCharacter::IsTargetReached( CCharacter* Enemy, CSkills* skill ) { UpdatePosition(); Enemy->UpdatePosition(); //??CMap* map = GServer->MapList.Index[Position->Map]; float fightdistance = GServer->distance( Position->current, Enemy->Position->current ); // if (!IsPlayer())Log(MSG_INFO,"dist 1 %f",fightdistance); // if (!IsPlayer())Log(MSG_INFO,"dist 2 %f",Stats->Attack_Distance); if(skill==NULL) { if((fightdistance)<=Stats->Attack_Distance) { Position->destiny=Position->current; return true; } Position->destiny=Enemy->Position->current; } else { if((fightdistance)<=skill->range) { Position->destiny=Position->current; return true; } Position->destiny=Enemy->Position->current; } return false; }
void Camera::ResetCameraToLight() { // Reset camera. DirectX::XMFLOAT3 target = DirectX::XMFLOAT3(0, 0, 0); DirectX::XMFLOAT3 position = DirectX::XMFLOAT3(25.0f, 100.0f, 50.0f); UpdatePosition(position); UpdateTarget(target); m_upVector = DirectX::XMFLOAT3(-25.0f, 100.0f, -50.0f); DirectX::XMStoreFloat3(&m_upVector, DirectX::XMVector3Normalize(DirectX::XMLoadFloat3(&m_upVector))); m_look = DirectX::XMFLOAT3(-25.0f, -100.0f, -50.0f); DirectX::XMStoreFloat3(&m_look, DirectX::XMVector3Normalize(DirectX::XMLoadFloat3(&m_look))); m_right = DirectX::XMFLOAT3(25.0f, 0.0f, -50.0f); DirectX::XMStoreFloat3(&m_right, DirectX::XMVector3Normalize(DirectX::XMLoadFloat3(&m_right))); // Projection data. float aspectRatio = (float)GLOBAL::GetInstance().MAX_SCREEN_WIDTH / (float)GLOBAL::GetInstance().MAX_SCREEN_HEIGHT; UpdateAspectRatio(aspectRatio); UpdateFieldOfView(3.141592f * 0.25f); UpdateClippingPlanes(0.1f, 1000.0f); UpdateViewMatrix(); UpdateProjectionMatrix(true); GraphicsEngine::SetLightViewAndProjection(GetViewMatrix(), GetProjectionMatrix()); }
bool CFeature::Update() { bool continueUpdating = UpdatePosition(); continueUpdating |= (smokeTime != 0); continueUpdating |= (fireTime != 0); continueUpdating |= (def->geoThermal); if (smokeTime != 0) { if (!((gs->frameNum + id) & 3) && projectileHandler->particleSaturation < 0.7f) { new CSmokeProjectile(NULL, midPos + gu->RandVector() * radius * 0.3f, gu->RandVector() * 0.3f + UpVector, smokeTime / 6 + 20, 6, 0.4f, 0.5f); } } if (fireTime == 1) { featureHandler->DeleteFeature(this); } if (def->geoThermal) { EmitGeoSmoke(); } smokeTime = std::max(smokeTime - 1, 0); fireTime = std::max(fireTime - 1, 0); // return true so long as we need to stay in the FH update-queue return continueUpdating; }
bool BSelection::Create(char* strLabel,char* btnLabel, unsigned char offset,CWnd* parent, UINT id) { DWORD elementWidth; BItem::Create(strLabel,offset,ELEMENT_WIDTH,LABEL_WIDTH,parent); buttonWidth = strlen(btnLabel)*7; CRect tempRect; GetClientRect(&tempRect); tempRect.left = tempRect.left+this->LabelWidth-(offset*OFFSET_SIZE)+SPACE_BETWEEN_ELEMENT; tempRect.right = tempRect.left+ tempRect.Width() - buttonWidth - SPACE_BETWEEN_ELEMENT; tempRect.bottom+=100; if(!comboBox.Create(WS_CHILD | WS_VISIBLE | WS_VSCROLL | CBS_DROPDOWNLIST, tempRect,this,COMBO_ELEMENT)){return false;}; //tempRect.right+=SPACE_BETWEEN_ELEMENT; comboBox.SetFont(&simpleFont,true); tempRect.bottom-=100; tempRect.left = tempRect.right + SPACE_BETWEEN_ELEMENT; tempRect.right = tempRect.left + buttonWidth; if(!button.Create(btnLabel,WS_CHILD | WS_VISIBLE |BS_PUSHBUTTON,tempRect,this,BUTTON_ELEMENT)){return false;} button.SetFont(&simpleFont,true); UpdatePosition(); return true; }
void CStereoGRView::OnInitialUpdate() { CView::OnInitialUpdate(); // Update the document GetDocument()->Initialize(); // Now initialize the view UpdateParams(); // Initialize the parent's data ((CChildFrame*)GetParent())->m_view = this; ((CMainFrame*)AfxGetMainWnd())->AddView(this); // Initialize OpenGL switch(GetDocument()->GetDocType()) { case PT_POINTCLOUD_IMAGE: case GR_MAGICCUBE: InitGL(); break; } UpdatePosition(); m_wasInitialized = TRUE; }
void FloatingCamera::Update() { MouseControls(); KeyboardControls(); UpdatePosition(); }
void CHostageImprov::__MAKE_VHOOK(OnUpkeep)(float deltaT) { if (IsAlive()) { UpdatePosition(deltaT); } }
void Player::MoveForward( double delta ) { if( mRoot ) { mRoot->Translate( delta * mVelocity ); UpdatePosition(); } }
void Player::TurnLeft( double delta ) { if( mRoot ) { mRoot->Rotate( 'y', delta * 70.0 ); UpdatePosition(); } }
unsigned char StdReader::Get(long offset) const { Seek(offset); unsigned char c = static_cast<unsigned char>(file.get()); UpdatePosition(1); return c; }