void FlightPathMovementGenerator::DoReset(Player* player) { player->getHostileRefManager().setOnlineOfflineState(false); player->AddUnitState(UNIT_STATE_IN_FLIGHT); player->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_REMOVE_CLIENT_CONTROL | UNIT_FLAG_TAXI_FLIGHT); Movement::MoveSplineInit init(player); uint32 end = GetPathAtMapEnd(); for (uint32 i = i_currentNode; i != end; ++i) { G3D::Vector3 vertice(i_path[i]->Loc.X, i_path[i]->Loc.Y, i_path[i]->Loc.Z); init.Path().push_back(vertice); } init.SetFirstPointId(i_currentNode); init.SetFly(); init.SetSmooth(); init.SetUncompressed(); init.SetWalk(true); init.SetVelocity(PLAYER_FLIGHT_SPEED); init.Launch(); }
void caCircularGauge::drawLabels(QPainter *p) { double angle = m_startAngle*3.1415927/180.0; double step = m_arcLength/(m_numMajorTicks-1)*3.1415927/180.0; QFont f = p->font(); if (m_externalScale) f.setPointSizeF(5.5); else f.setPointSizeF(5.4); p->setFont(f); for (int i = 0; i < m_numMajorTicks; i++) { QPointF vertice(m_labelRadius*cos(angle), -m_labelRadius*sin(angle)); vertice -= QPointF(13,10); QRectF br(vertice, QSize(26, 20)); br = QRectF(vertice, QSize(26, 20)); p->drawText(br, Qt::AlignCenter, labels[i]); angle -= step; } }
RTRay RTRayTracer::genRefractRay(RTVector d, RTVector normal, RTVector closestPoint, double refractionIndex,bool isInside) { double n,nt,ni; if(isInside) { ni=refractionIndex; nt=AIR_REFRA; normal=-normal; } else { ni=AIR_REFRA; nt=refractionIndex; } n = ni / nt; double cosI = -normal.dot(d); double sinT2 = n * n * (1.0 - cosI * cosI); if (sinT2 > 1.0) { exit(EXIT_FAILURE); } double cosT = sqrt(1.0 - sinT2); RTVector refracVector= d * n + normal * (n * cosI - cosT); double bias = 1e-4; RTVector ori = (closestPoint-normal)*bias; // RTVector ori=closestPoint; RTPoint vertice(ori.getX(),ori.getY(),ori.getZ()); RTRay refracRay(vertice,refracVector); return refracRay; }
void MotionMaster::MovePointSmooth(float x, float y, float diffDist, bool vmapsOnly, Movement::MoveSplineInit * _init) { // Creature current(start) position Movement::Location real_position(_owner->GetPositionX(), _owner->GetPositionY(), _owner->GetPositionZMinusOffset(), _owner->GetOrientation()); // Current position may differ if creature is moving if (!_owner->movespline->Finalized()) real_position = _owner->movespline->ComputePosition(); Movement::MoveSplineInit init(_owner); if (_init && _init->GetMasterUnit() == _owner) init = *_init; float dist = 5.f; float angle = _owner->GetAngle(x, y); float controllZ = _owner->GetPositionZ() + 5.f; float _controllMinZ = controllZ; float _controllMaxZ = controllZ; float _x, _y, _z; // Total travel distance based on real creature position float dx = real_position.x - x; float dy = real_position.y - y;; // Dist between 2 last waypoints must be >= diffDist float controllDist = sqrt(dx*dx + dy*dy) - diffDist; // Fake waypoint for spline system G3D::Vector3 fake_vertice(0.f, 0.f, 0.f); init.Path().push_back(fake_vertice); // Generate intermediate waypoints while (dist < controllDist) { _x = real_position.x + dist * std::cos(angle); _y = real_position.y + dist * std::sin(angle); if (vmapsOnly) _z = _owner->GetMap()->GetHeight(_x, _y, controllZ + diffDist); else _z = _owner->GetMap()->GetHeight(_owner->GetPhaseMask(), _x, _y, controllZ + diffDist); dist += diffDist; controllZ = _z; if (controllZ > _controllMaxZ) { _controllMaxZ = controllZ; _controllMinZ = controllZ; } else { if (_controllMaxZ - _controllMinZ > 250.f) _controllMinZ = _controllMaxZ; if (_controllMinZ - controllZ > diffDist * 2) controllZ = _controllMinZ; else _controllMinZ = controllZ; } G3D::Vector3 vertice(_x, _y, _z); init.Path().push_back(vertice); } // Add last waypoint _x = x; _y = y; _z = _owner->GetMap()->GetHeight(_owner->GetPhaseMask(), _x, _y, controllZ, true); G3D::Vector3 last_vertice(_x, _y, _z); init.Path().push_back(last_vertice); init.SetUncompressed(); init.Launch(); }
void HookGui::HGWidgetShader::UpdateInstanceData(VulkanWrapper::Context* _context) { // Create the vertex position buffer VkDeviceSize bufferSize = sizeof(InstanceData) * MaximumInstances; // Set the instance temporary data //TODO: usar memória por frame e não ficar alocando usando new/delete InstanceData* tempData = new InstanceData[MaximumInstances]; // For each renderable for (int i = 0; i < m_Renderables.size(); i++) { // Get the current widget HGWidget* widget = m_Renderables[i]; // Get the instance data InstanceData& instanceData = tempData[i]; // Get the widget frame HGFrame widgetFrame = widget->GetFrame(); // Get the widget transform matrix glm::mat4 widgetTransformMatrix = widget->GetTransformMatrix(); // Set the transform data instanceData.position = glm::vec4(widgetFrame.x, widgetFrame.y, 0, 0); instanceData.size = glm::vec4(widgetFrame.width, widgetFrame.height, 1, 0); instanceData.rotation = glm::vec4(0, 0, 0, 0); instanceData.extra = glm::vec4(0, 0, 0, 0); // Get the swap chain dimensions float width = _context->GetSwapChain()->GetExtent().width; float height = _context->GetSwapChain()->GetExtent().height; // TEST glm::vec4 vertice(0, 0, 0, 0); vertice.x *= 330; vertice.y *= 240; vertice.x += 0; vertice.y += 0; glm::mat4 projMatrix = glm::ortho(0.0f, width, -height, 0.0f, -1.0f, 1.0f); glm::vec4 result = projMatrix * vertice; result.x -= 1; result.y -= 1; // TEST // Get the diffuse texture from the object VulkanWrapper::Texture widgetTextureImage = widget->GetImage()->GetTexture(); // Set the texture fetch instance instanceData.extra.w = widgetTextureImage.GetTextureFetchIndex(); } // Update the instance buffer m_InstanceBuffer.Update(_context, tempData); // Delete the temporary data delete[] tempData; }