gama.old
gama.old copied to clipboard
rotated_by apply on a textured shape seems to be broken
Describe the bug Problem with rotated_by on textured geometry (maybe on all geometry but we didn't realize it?) Run this model
model NewModel
/* Insert your model definition here */
global{
file imageRaster <- file('./../images/Kent_Sketches.png');
}
experiment TEST{
output{
display goodwithCam2 type:opengl
{
graphics "image" {
draw rectangle(500#px,500#px) rotated_by (cycle,{1,0,0}) texture:[imageRaster.path];
}
}
}
}
Can be tested running this picture_test.zip
Here is what I get with
draw rectangle(500#px,500#px) rotated_by (89,{1,0,0}) texture:[imageRaster.path]
and with
draw rectangle(500#px,500#px) rotated_by (90,{1,0,0}) texture:[imageRaster.path]
Expected behavior I would assume to see a spinning image (the idea was to draw an image as a white board to applying a 90° rotation on the X axis. However I see that the picture is flipped.
Hi, Not sure to understand this bug report. Is it a problem with
- the texture being flipped or
- the shape not being correctly rotated ?
Besides, what does (maybe on all geometry but we didn't realize it?) mean ?
I mean if you just draw a non textured rectangle we don't see that there is a problem as the geometry is "invariant" in term of rotation
Sorry, I don't get it. The only 3D geometry I know which is 'invariant' in terms of rotation is the sphere. Rotating a rectangle around the x-axis should rotate the geometry, no ?
Yes it will rotate the geometry what I mean by invariant is the texture (e.g a pure white picture is invariant)
I just did a gif that can maybe help to track the issue.
So first I display my rotated picture with the draw rectangle(500#px,500#px) rotated_by (89,{1,0,0}) as 90 doesn't work as explained below.
However I just discover that if I inspect the agent (so I guess the size of the window of the display change then the picture is being flipped no way to have it back in the right orientation unless i relaunch the experiment

It also happens (the flipped of the texture) if I switch to fullscreen
Now tracked under #2209 -- for the OpenGL adventurous !
Reopening this issue for the next round of development on GAMA 2.0
There is actually a place in the code (in OpenGL.java) where we declare:
private final Rotation3D currentTextureRotation = Rotation3D.identity();
This field is then used to provide a "best guess" at how to rotate the texture according to the rotation of the object. I'm not quite sure to understand why it's failing here. ..
Spent some time on this, few thing have changed except that the flip now happens between 90 and 91 instead of 89 and 90 degrees...
I have pushed a commit that adds a new preference (pref_texture_orientation), which can be set or not in models. When set (default value), the textures are applied using a heuristic "best guess" algorithm, like now. When unset, no rotation/orientation is applied to the texture coordinates. This adresses your issue, but not applying any rotation also raises issues in some models, hence the possibility to set/unset this preference. I've added it in some models of the library by the way. Please test !