LTriangle2 LMesh::GetTriangle2(uint index) { LTriangle2 f; LTriangle t = GetTriangle(index); f.vertices[0] = GetVertex(t.a); f.vertices[1] = GetVertex(t.b); f.vertices[2] = GetVertex(t.c); f.vertexNormals[0] = GetNormal(t.a); f.vertexNormals[1] = GetNormal(t.b); f.vertexNormals[2] = GetNormal(t.c); f.textureCoords[0] = GetUV(t.a); f.textureCoords[1] = GetUV(t.b); f.textureCoords[2] = GetUV(t.c); LVector3 a, b; a = SubtractVectors(_4to3(f.vertices[1]), _4to3(f.vertices[0])); b = SubtractVectors(_4to3(f.vertices[1]), _4to3(f.vertices[2])); f.faceNormal = CrossProduct(b, a); f.faceNormal = NormalizeVector(f.faceNormal); f.materialId = m_tris[index].materialId; return f; }
void GenerateArrowsTriangles(glsl::vec4 const & pivot, vector<glsl::vec2> const & normals, m2::RectF const & texRect, vector<glsl::vec2> const & uv, bool normalizedUV, RouteShape::TArrowGeometryBuffer & joinsGeometry) { size_t const trianglesCount = normals.size() / 3; for (int j = 0; j < trianglesCount; j++) { joinsGeometry.push_back(RouteShape::AV(pivot, normals[3 * j], normalizedUV ? GetUV(texRect, uv[3 * j]) : uv[3 * j])); joinsGeometry.push_back(RouteShape::AV(pivot, normals[3 * j + 1], normalizedUV ? GetUV(texRect, uv[3 * j + 1]) : uv[3 * j + 1])); joinsGeometry.push_back(RouteShape::AV(pivot, normals[3 * j + 2], normalizedUV ? GetUV(texRect, uv[3 * j + 2]) : uv[3 * j + 2])); } }
/** * @brief CoordinateTransform::LongitudeLatitudeToUV * 将经纬度坐标转换成图像坐标 * @param u_v * 传入图像坐标 * @param local_longitude_latitude * @param dst_longitude_latitude * 转换成经纬度坐标 * @param heading_angle * 航向角 */ void CoordinateTransform::LongitudeLatitudeToUV(cv::Point2d &u_v,cv::Point2d local_longitude_latitude, cv::Point2d dst_longitude_latitude,double heading_angle){ lng_lat_dis_.x = (dst_longitude_latitude.x-local_longitude_latitude.x)*per_longitute_dis_*1000.0; lng_lat_dis_.y = (dst_longitude_latitude.y-local_longitude_latitude.y)*per_latitude_dis_*1000.0; lng_lat_dis_mat_.at<double>(0,0) = lng_lat_dis_.x; lng_lat_dis_mat_.at<double>(1,0) = lng_lat_dis_.y; if(heading_angle> 0) { counter_clkwise_mat_ = init_counter_clkwise_mat(heading_angle); uv_dis_mat_ = counter_clkwise_mat_*lng_lat_dis_mat_; }else{ clkwise_mat_ = init_clkwise_mat(heading_angle); uv_dis_mat_ = clkwise_mat_*lng_lat_dis_mat_; } uv_dis_.x = uv_dis_mat_.at<double>(0,0); uv_dis_.y = uv_dis_mat_.at<double>(1,0); // std::cout<<" uv_dis_.x = "<< uv_dis_.x<< std::endl; // std::cout<<" uv_dis_.y = "<< uv_dis_.y<< std::endl; //GetUV(uv_dis_,u_v); u_v.x=getPerspectiveUV(uv_dis_).x; //横向距离用透视法求像素位置 u_v.y=GetUV(uv_dis_).y; //纵向距离用标定法求像素位置 //处理异常的经纬度输入 if(u_v.x<0 || u_v.x>1280 || u_v.y<0 || u_v.y>720) { std::cout<<"Invalid geographical position!"<<std::endl; u_v.x=u_v.y=-1; } }
FVector GetPosition_Torus(const FVector2D& InUV) const { const auto A = 1.0f; const auto B = 0.5f; const auto UV = GetUV(InUV); return FVector((A + B * FMath::Cos(UV.Y)) * FMath::Cos(UV.X), (A + B * FMath::Cos(UV.Y)) * FMath::Sin(UV.X), B * FMath::Sin(UV.Y)); }
//!< FPrimitiveSceneProxy virtual void GetDynamicMeshElements(const TArray<const FSceneView*>& Views, const FSceneViewFamily& ViewFamily, uint32 VisibilityMap, class FMeshElementCollector& Collector) const override { FDynamicMeshBuilder MeshBuilder; const auto Num = 20; const auto DeltaUV = 1.0f / (Num - 1); TArray<FDynamicMeshVertex> Vertices; Vertices.Reserve(Num * Num); for (auto i = 0; i < Num; ++i) { for (auto j = 0; j < Num; ++j) { const auto UV = FVector2D(DeltaUV * j, DeltaUV * i); FDynamicMeshVertex Vertex; Vertex.Position = GetPosition(UV); Vertex.TextureCoordinate = GetUV(UV); const auto Edge01 = GetPosition(UV + FVector2D(0.01f, 0.0f)) - Vertex.Position; const auto Edge02 = GetPosition(UV - FVector2D(0.0f, 0.01f)) - Vertex.Position; Vertex.TangentX = Edge01.GetSafeNormal(); Vertex.TangentZ = (Edge02 ^ Edge01).GetSafeNormal(); Vertex.Color = FColor::Green; Vertices.Add(Vertex); } } MeshBuilder.AddVertices(Vertices); TArray<int32> Indices; Indices.Reserve((Num - 1) * (Num - 1) * 6); for (auto i = 0; i < Num - 1; ++i) { for (auto j = 0; j < Num - 1; ++j) { const auto Index = j + i * Num; Indices.Add(Index); Indices.Add(Index + Num); Indices.Add(Index + 1); Indices.Add(Index + 1); Indices.Add(Index + Num); Indices.Add(Index + Num + 1); } } MeshBuilder.AddTriangles(Indices); auto MaterialRenderProxy = UMaterial::GetDefaultMaterial(MD_Surface)->GetRenderProxy(IsSelected()); if (nullptr != MaterialInterface) { MaterialRenderProxy = MaterialInterface->GetRenderProxy(false); } if (Views[0]->Family->EngineShowFlags.Wireframe) { MaterialRenderProxy = GEngine->WireframeMaterial->GetRenderProxy(IsSelected()); } MeshBuilder.GetMesh(GetLocalToWorld(), MaterialRenderProxy, 0, false, false, 0, Collector); }
/************************************************************************ * desc: Set the frame ID from index ************************************************************************/ void CVisualComponent2d::SetFrameID( uint index ) { if( GENERATION_TYPE == NDefs::EGT_SPRITE_SHEET ) { auto rGlyph = m_visualData.GetSpriteSheet().GetGlyph( index ); m_glyphUV = rGlyph.GetUV(); auto rSize = rGlyph.GetSize(); m_quadVertScale.x = rSize.w; m_quadVertScale.y = rSize.h; } else m_textureID = m_visualData.GetTextureID( index ); } // SetFrameID
//----------------------------------------------------------------------------------- static void ImportVertex(MeshBuilder& builder, const Matrix4x4& transform, FbxMesh* mesh, int polyIndex, int vertIndex, std::vector<SkinWeight>& skinWeights) { Vector3 normal; if (GetNormal(normal, transform, mesh, polyIndex, vertIndex)) { builder.SetNormal(normal); //Temporary hack to get around not supporting multiple vertex definitions Vector3 bitangent = Vector3::UP; if (normal == bitangent) { bitangent = Vector3::FORWARD; } Vector3 tangent = Vector3::Cross(bitangent, normal); bitangent = Vector3::Cross(normal, tangent); builder.SetTangent(tangent); builder.SetBitangent(bitangent); } RGBA color; if (GetColor(color, mesh, polyIndex, vertIndex)) { builder.SetColor(color); } Vector2 uv; if (GetUV(uv, mesh, polyIndex, vertIndex, 0)) { builder.SetUV(uv); } //Set Skin Weights int controlIndex = mesh->GetPolygonVertex(polyIndex, vertIndex); if (controlIndex < skinWeights.size()) { builder.SetBoneWeights(skinWeights[controlIndex].indices, skinWeights[controlIndex].weights); builder.RenormalizeSkinWeights(); //Just to be safe. } else { builder.ClearBoneWeights(); } Vector3 position; if (GetPosition(&position, transform, mesh, polyIndex, vertIndex)) { builder.AddVertex(position); } }
void proFont::FillVertChar(peUint color, peFloat x, peFloat y, peChar character, peChar *pBuffer) { proVertHeader &tempHeader = m_vertBuff.GetHeader(); peFloat baseUV[2] = {0.0f, 0.0f}; peFloat tempUV[2] = {0.0f, 0.0f}; proVec3f tempPos = Vec3fZ(); GetUV(character, &baseUV[0], &baseUV[1]); tempPos = Vec3f(x, y, 0.0f); tempUV[0] = baseUV[0]; tempUV[1] = baseUV[1]; tempHeader.Bind(pBuffer); tempHeader.PackData(PVV_UINT_COLOR, &color, sizeof(color)); tempHeader.PackData(PVV_TU, &tempUV[0], sizeof(tempUV)); tempHeader.PackData(PVV_XYZ, &tempPos, sizeof(tempPos)); pBuffer += tempHeader.GetHeaderSize(); tempPos = Vec3f(x+m_quadWidth, y, 0.0f); tempUV[0] = baseUV[0] + sc_fPageCharacterWidth/sc_fPageWidth; tempUV[1] = baseUV[1]; tempHeader.Bind(pBuffer); tempHeader.PackData(PVV_UINT_COLOR, &color, sizeof(color)); tempHeader.PackData(PVV_TU, &tempUV[0], sizeof(tempUV)); tempHeader.PackData(PVV_XYZ, &tempPos, sizeof(tempPos)); pBuffer += tempHeader.GetHeaderSize(); tempHeader.Bind(pBuffer); tempPos = Vec3f(x, y-m_quadHeight, 0.0f); tempUV[0] = baseUV[0]; tempUV[1] = baseUV[1] + sc_fPageCharacterHeight/sc_fPageHeight; tempHeader.PackData(PVV_UINT_COLOR, &color, sizeof(color)); tempHeader.PackData(PVV_TU, &tempUV[0], sizeof(tempUV)); tempHeader.PackData(PVV_XYZ, &tempPos, sizeof(tempPos)); pBuffer += tempHeader.GetHeaderSize(); tempHeader.Bind(pBuffer); tempUV[0] = baseUV[0]; tempUV[1] = baseUV[1] + sc_fPageCharacterHeight/sc_fPageHeight; tempPos = Vec3f(x, y-m_quadHeight, 0.0f); tempHeader.PackData(PVV_UINT_COLOR, &color, sizeof(color)); tempHeader.PackData(PVV_TU, &tempUV[0], sizeof(tempUV)); tempHeader.PackData(PVV_XYZ, &tempPos, sizeof(tempPos)); pBuffer += tempHeader.GetHeaderSize(); tempHeader.Bind(pBuffer); tempPos = Vec3f(x+m_quadWidth, y, 0.0f); tempUV[0] = baseUV[0] + sc_fPageCharacterWidth/sc_fPageWidth; tempUV[1] = baseUV[1]; tempHeader.PackData(PVV_UINT_COLOR, &color, sizeof(color)); tempHeader.PackData(PVV_TU, &tempUV[0], sizeof(tempUV)); tempHeader.PackData(PVV_XYZ, &tempPos, sizeof(tempPos)); pBuffer += tempHeader.GetHeaderSize(); tempHeader.Bind(pBuffer); tempPos = Vec3f(x+m_quadWidth, y-m_quadHeight, 0.0f); tempUV[0] = baseUV[0] + sc_fPageCharacterWidth/sc_fPageWidth; tempUV[1] = baseUV[1] + sc_fPageCharacterHeight/sc_fPageHeight; tempHeader.PackData(PVV_UINT_COLOR, &color, sizeof(color)); tempHeader.PackData(PVV_TU, &tempUV[0], sizeof(tempUV)); tempHeader.PackData(PVV_XYZ, &tempPos, sizeof(tempPos)); }
FVector GetPosition_Snail(const FVector2D& InUV) const { const auto UV = GetUV(InUV); return FVector(UV.X * FMath::Cos(UV.Y) * FMath::Sin(UV.X), UV.X * FMath::Cos(UV.X) * FMath::Cos(UV.Y), -UV.X * FMath::Sin(UV.Y)); }
FVector GetPosition_Pillow(const FVector2D& InUV) const { const auto A = 0.5f; const auto UV = GetUV(InUV); return FVector(FMath::Cos(UV.X), FMath::Cos(UV.Y), A * FMath::Sin(UV.X) * FMath::Sin(UV.Y)); }
glsl::vec2 GetUV(m2::RectF const & texRect, glsl::vec2 const & uv) { return GetUV(texRect, uv.x, uv.y); }