From c74602fbcccf07d077258b59069fd9dc3404cdd3 Mon Sep 17 00:00:00 2001 From: David Mansolino Date: Tue, 1 Sep 2020 10:11:24 +0200 Subject: [PATCH 1/7] Update UnevenTerrain.proto --- projects/objects/floors/protos/UnevenTerrain.proto | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/projects/objects/floors/protos/UnevenTerrain.proto b/projects/objects/floors/protos/UnevenTerrain.proto index 73d006f0083..ead789ecb61 100644 --- a/projects/objects/floors/protos/UnevenTerrain.proto +++ b/projects/objects/floors/protos/UnevenTerrain.proto @@ -81,8 +81,18 @@ PROTO UnevenTerrain [ local nOctave = fields.perlinNOctaves.value local size = fields.size.value + local xDimension = fields.xDimension.value + if xDimension < 2 thens + xDimension = fields.xDimension.defaultValue + io.stderr:write("'xDimension' should be at least equalt to 2.\n") + end + local zDimension = fields.zDimension.value + if zDimension < 2 thens + zDimension = fields.zDimension.defaultValue + io.stderr:write("'zDimension' should be at least equalt to 2.\n") + end }% Solid { translation IS translation @@ -96,9 +106,9 @@ PROTO UnevenTerrain [ geometry ElevationGrid { %{ if xDimension > 2 and zDimension > 2 then }% xDimension IS xDimension - xSpacing %{= size.x / xDimension }% + xSpacing %{= size.x / (xDimension - 1) }% zDimension IS zDimension - zSpacing %{= size.z / zDimension }% + zSpacing %{= size.z / (zDimension - 1) }% height [ %{ for i=0, xDimension - 1 do }% From a769bd3d0b7f797c64b1ac7fd57b0a69dd76019d Mon Sep 17 00:00:00 2001 From: David Mansolino Date: Tue, 1 Sep 2020 10:12:30 +0200 Subject: [PATCH 2/7] Update UnevenTerrain.proto --- projects/objects/floors/protos/UnevenTerrain.proto | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/objects/floors/protos/UnevenTerrain.proto b/projects/objects/floors/protos/UnevenTerrain.proto index ead789ecb61..8781f917131 100644 --- a/projects/objects/floors/protos/UnevenTerrain.proto +++ b/projects/objects/floors/protos/UnevenTerrain.proto @@ -83,13 +83,13 @@ PROTO UnevenTerrain [ local size = fields.size.value local xDimension = fields.xDimension.value - if xDimension < 2 thens + if xDimension < 2 then xDimension = fields.xDimension.defaultValue io.stderr:write("'xDimension' should be at least equalt to 2.\n") end local zDimension = fields.zDimension.value - if zDimension < 2 thens + if zDimension < 2 then zDimension = fields.zDimension.defaultValue io.stderr:write("'zDimension' should be at least equalt to 2.\n") end From c7fe1c3e50377b99a8140a82b28f957714a313d3 Mon Sep 17 00:00:00 2001 From: David Mansolino Date: Tue, 1 Sep 2020 10:25:13 +0200 Subject: [PATCH 3/7] fix texture mapping. --- src/wren/StaticMesh.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wren/StaticMesh.cpp b/src/wren/StaticMesh.cpp index 57e8859c5ba..004f0ce7e4c 100644 --- a/src/wren/StaticMesh.cpp +++ b/src/wren/StaticMesh.cpp @@ -623,8 +623,8 @@ namespace wren { for (int zi = 0; zi < dimensionZ; ++zi) { for (int xi = 0; xi < dimensionX; ++xi) { mesh->addCoord(glm::vec3(spacingX * xi, heightData[dimensionX * zi + xi], spacingZ * zi)); - mesh->addTexCoord(glm::vec2(du * xi, dv * (stepsZ - zi))); - mesh->addUnwrappedTexCoord(glm::vec2(du * xi, dv * (stepsZ - zi))); + mesh->addTexCoord(glm::vec2(du * xi, dv * zi)); + mesh->addUnwrappedTexCoord(glm::vec2(du * xi, dv * zi)); } } From 2de512e030d5e2ef6a3a1af87c67276ede187f1b Mon Sep 17 00:00:00 2001 From: David Mansolino Date: Tue, 1 Sep 2020 10:34:23 +0200 Subject: [PATCH 4/7] Changelog. --- docs/reference/changelog-r2020.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/reference/changelog-r2020.md b/docs/reference/changelog-r2020.md index 82d621483dc..9b566758f56 100644 --- a/docs/reference/changelog-r2020.md +++ b/docs/reference/changelog-r2020.md @@ -16,6 +16,8 @@ Released on September 1st, 2020. - Fixed crash when inserting an empty [PointSet](pointset.md) node ([#2182](https://github.com/cyberbotics/webots/pull/2182)). - Fixed crash occurring when selecting a [Robot](robot.md) with mechanical closed-loop ([#2117](https://github.com/cyberbotics/webots/pull/2117)). - Fixed various issues when an extern [Robot](robot.md) controller exits and then a new one connects to the same [Robot](robot.md) ([#2152](https://github.com/cyberbotics/webots/pull/2152)). + - Fixed size of the [UnevenTerrain](../guide/object-floors.md#uneventerrain) PROTO node ([#2185](https://github.com/cyberbotics/webots/pull/2185)). + - Fixed texture mapping of the [ElevationGrid](elevationgrid.md) node ([#2185](https://github.com/cyberbotics/webots/pull/2185)). - macOS: Fixed crash of the `animated_skin` simulation ([#2141](https://github.com/cyberbotics/webots/pull/2141)). - Remove scaling factor in matrix returned by [`wb_supervisor_node_get_orientation`](supervisor.md#wb_supervisor_node_get_orientation) ([#2112](https://github.com/cyberbotics/webots/pull/2112)). - Fixed conversion of identity matrix to quaternion in ROS API ([#2112](https://github.com/cyberbotics/webots/pull/2112)). From a635faea418f909b165011d4af2631f62e9943dd Mon Sep 17 00:00:00 2001 From: David Mansolino Date: Tue, 1 Sep 2020 10:42:17 +0200 Subject: [PATCH 5/7] Improve anaglyph --- projects/samples/demos/worlds/anaglyph.wbt | 24 ++++++---------------- 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/projects/samples/demos/worlds/anaglyph.wbt b/projects/samples/demos/worlds/anaglyph.wbt index 5992f6f7db5..f3507e92cc8 100644 --- a/projects/samples/demos/worlds/anaglyph.wbt +++ b/projects/samples/demos/worlds/anaglyph.wbt @@ -26,16 +26,10 @@ DEF GROUND Solid { translation -8 0 -8 children [ Shape { - appearance PBRAppearance { - baseColorMap ImageTexture { - url [ - "textures/grass.jpg" - ] - } - roughness 1 - metalness 0 + appearance Grass { + type "mossy" textureTransform TextureTransform { - scale 10 10 + scale 8.5 8.5 } } geometry ElevationGrid { @@ -49,16 +43,10 @@ DEF GROUND Solid { ] } Shape { - appearance PBRAppearance { - baseColorMap ImageTexture { - url [ - "textures/grass.jpg" - ] - } - roughness 1 - metalness 0 + appearance Grass { + type "mossy" textureTransform TextureTransform { - scale 50 50 + scale 250 250 } } geometry Plane { From aa2d7f10cd7ce1c8422c0cae28827fbd6cb98458 Mon Sep 17 00:00:00 2001 From: David Mansolino Date: Tue, 1 Sep 2020 10:49:25 +0200 Subject: [PATCH 6/7] Fix UnevenTerrain worlds. --- projects/robots/micromagic/mantis/worlds/mantis.wbt | 2 +- projects/robots/sphero/bb8/worlds/bb-8.wbt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/robots/micromagic/mantis/worlds/mantis.wbt b/projects/robots/micromagic/mantis/worlds/mantis.wbt index 67092baf597..fc9b7b11f70 100644 --- a/projects/robots/micromagic/mantis/worlds/mantis.wbt +++ b/projects/robots/micromagic/mantis/worlds/mantis.wbt @@ -38,6 +38,6 @@ UnevenTerrain { perlinNOctaves 8 } Mantis { - translation -24.12 61.31 -6.15 + translation -24.12 61.42 -6.15 rotation 0 1 0 1.3 } diff --git a/projects/robots/sphero/bb8/worlds/bb-8.wbt b/projects/robots/sphero/bb8/worlds/bb-8.wbt index 7103d71bace..d88de2875e5 100644 --- a/projects/robots/sphero/bb8/worlds/bb-8.wbt +++ b/projects/robots/sphero/bb8/worlds/bb-8.wbt @@ -31,7 +31,7 @@ UnevenTerrain { perlinNOctaves 6 } BB-8 { - translation -16.19 36.5 -4.36 + translation -16.19 36.68 -4.36 rotation 0 1 0 5.75959 headSlot [ Camera { From cb03c9140c2a8f362b9645c5dca52fc56ca9bcbe Mon Sep 17 00:00:00 2001 From: David Mansolino Date: Tue, 1 Sep 2020 12:07:06 +0200 Subject: [PATCH 7/7] Fixed texture picking. --- src/webots/nodes/WbElevationGrid.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/webots/nodes/WbElevationGrid.cpp b/src/webots/nodes/WbElevationGrid.cpp index 9712583c6cf..213f96a559a 100644 --- a/src/webots/nodes/WbElevationGrid.cpp +++ b/src/webots/nodes/WbElevationGrid.cpp @@ -482,15 +482,15 @@ bool WbElevationGrid::isAValidBoundingObject(bool checkOde, bool warning) const bool WbElevationGrid::pickUVCoordinate(WbVector2 &uv, const WbRay &ray, int textureCoordSet) const { WbVector3 localCollisionPoint; - double collisionDistance = computeLocalCollisionPoint(ray, localCollisionPoint); + const double collisionDistance = computeLocalCollisionPoint(ray, localCollisionPoint); if (collisionDistance < 0) return false; - double sizeX = scaledWidth(); - double sizeZ = scaledDepth(); + const double sizeX = scaledWidth(); + const double sizeZ = scaledDepth(); - double u = (double)localCollisionPoint.x() / sizeX; - double v = 1 - (double)localCollisionPoint.z() / sizeZ; + const double u = (double)localCollisionPoint.x() / sizeX; + const double v = (double)localCollisionPoint.z() / sizeZ; // result uv.setXy(u, v);