Is it possible to change the origin of a floor from center to say left upper corner in Webots? For exmaple the size of then rectangular arena is 20x20 and I want to set its origin from 0,0 to 10,10
Asked
Active
Viewed 559 times
1 Answers
1
Yes, you can do that by creating your own proto file. I would recommend you to start from an existing proto, for example, WEBOTS_HOME/projects/objects/floors/protos/Floor.proto
. Copy and rename this file to MyFloor.proto
for example and edit it to change the coordinates of the IndexedFaceSet
node. Typically you will have to replace:
geometry IndexedFaceSet {
coord Coordinate {
point [
%{= -(size.x / 2) }% 0 %{= -(size.y / 2) }%
%{= size.x / 2 }% 0 %{= -(size.y / 2) }%
%{= -(size.x / 2) }% 0 %{= size.y / 2 }%
%{= size.x / 2 }% 0 %{= size.y / 2 }%
]
}
by:
geometry IndexedFaceSet {
coord Coordinate {
point [
0 0 0
%{= size.x }% 0 0
0 0 %{= size.y }%
%{= size.x }% 0 %{= size.y }%
]
}
That will move the floor origin at a corner of the floor. Also, the boundingObject should be updated so that the floor looks nicer when selected. Replace:
boundingObject Plane {
size IS size
}
by:
boundingObject Transform {
translation %{= size.x / 2 }% 0 %{= size.y / 2 }%
children Plane {
size IS size
}
}

Olivier Michel
- 755
- 6
- 10
-
This changed the origin but moved the floor in a strange way. you can see the image here in the URL. https://imgur.com/a/VKzF8Lr – Tahir Mahmood May 21 '19 at 08:57
-
This shouldn't harm the simulation. But I agree it doesn't look nice when the floor is selected. I updated my answer to explain how to modify the `boundingObject` so that the selected floor corresponds to the actual one, and hence looks nicer when selected. – Olivier Michel May 22 '19 at 09:26