From cf1ea3b093b96bc306c569dc73e70be220e02b4f Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 8 May 2018 16:58:15 +0100 Subject: [PATCH] breaking map (warp3d) suport default map parameters. Planar not suported ( will render as deafaul --- .../World/Warp3DMap/Warp3DImageModule.cs | 81 +++++++++++++++---- 1 file changed, 66 insertions(+), 15 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs b/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs index e0e851fbae..4c0023c2ec 100644 --- a/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs +++ b/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs @@ -490,13 +490,73 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap continue; warp_Object faceObj = new warp_Object(); - for (int j = 0; j < face.Vertices.Count; j++) + + Primitive.TextureEntryFace teFace = prim.Shape.Textures.GetFace((uint)i); + Color4 faceColor = teFace.RGBA; + + string materialName = String.Empty; + if (m_texturePrims && primScaleLenSquared > m_texturePrimSize*m_texturePrimSize) + materialName = GetOrCreateMaterial(renderer, faceColor, teFace.TextureID); + else + materialName = GetOrCreateMaterial(renderer, GetFaceColor(teFace)); + + if(renderer.Scene.material(materialName).getTexture() == null) { - Vertex v = face.Vertices[j]; - warp_Vector pos = ConvertVector(v.Position); - warp_Vertex vert = new warp_Vertex(pos, v.TexCoord.X, 1.0f - v.TexCoord.Y); - faceObj.addVertex(vert); - } + for (int j = 0; j < face.Vertices.Count; j++) + { + Vertex v = face.Vertices[j]; + warp_Vector pos = ConvertVector(v.Position); + warp_Vertex vert = new warp_Vertex(pos, v.TexCoord.X, 1.0f - v.TexCoord.Y); + faceObj.addVertex(vert); + } + } + else + { + float tu; + float tv; + float offsetu = teFace.OffsetU + 0.5f; + float offsetv = teFace.OffsetV + 0.5f; + float scaleu = teFace.RepeatU; + float scalev = teFace.RepeatV; + float rotation = teFace.Rotation; + float rc = 0; + float rs = 0; + if(rotation != 0) + { + rc = (float)Math.Cos(rotation); + rs = (float)Math.Sin(rotation); + } + + for (int j = 0; j < face.Vertices.Count; j++) + { + warp_Vertex vert; + Vertex v = face.Vertices[j]; + warp_Vector pos = ConvertVector(v.Position); + tu = v.TexCoord.X - 0.5f; + tv = 0.5f - v.TexCoord.Y; + if(rotation != 0) + { + float tur = tu * rc - tv * rs; + float tvr = tu * rs + tv * rc; + tur *= scaleu; + tur += offsetu; + + tvr *= scalev; + tvr += offsetv; + vert = new warp_Vertex(pos, tur, tvr); + } + else + { + tu *= scaleu; + tu += offsetu; + tv *= scalev; + tv += offsetv; + vert = new warp_Vertex(pos, tu, tv); + } + + faceObj.addVertex(vert); + } + } for (int j = 0; j < face.Indices.Count; j += 3) { @@ -506,15 +566,6 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap face.Indices[j + 2]); } - Primitive.TextureEntryFace teFace = prim.Shape.Textures.GetFace((uint)i); - Color4 faceColor = teFace.RGBA; - string materialName = String.Empty; - - if (m_texturePrims && primScaleLenSquared > m_texturePrimSize*m_texturePrimSize) - materialName = GetOrCreateMaterial(renderer, faceColor, teFace.TextureID); - else - materialName = GetOrCreateMaterial(renderer, GetFaceColor(teFace)); - faceObj.scaleSelf(prim.Scale.X, prim.Scale.Z, prim.Scale.Y); faceObj.transform(m); faceObj.setPos(primPos);