Rotation of TextureTransform

112 Views Asked by At

I'm having a devil of a time rotating a TextureTransform that is applied to an ElevationGrid. I'm building a scene with walls, floor and a ceiling (all elevation grids) and, among other options, I want to be able to apply a full image to each.

Of course, to create a "room", the each elevation grid must be rotated and/or translated from it's original location and, not surprisingly, this causes the image to be rotated accordingly.

As you can see from this example, this is all happening, exactly as anticipated. This is looking at the origin. enter image description here

Here we are looking at the corner opposite the origin. enter image description here

All of the images look exactly as I would anticipate, the problem comes when I want to start rotating the images so that they are all consistent.

I'll be referring to a single "wall" here for simplicity, it will be the "northeast" wall (upper-right in the first image), it shows the image upside down.

My understanding (which seems good to me but is obviously deficient), is that rotation is based on the center of the image (optionally offset using the center attribute - which I am not). I understand there is some oddness with the direction of rotation, but I don't see that as an obstruction (although I could be wrong).

I can figure out what I want to do to each image, that's not my problem, my problem is that when I apply a rotation, I don't get the results I'm expecting.

In this example, it seems to me that I want to rotate 180 degrees (1.5708rad) but when I do that, I get a distorted image (for the sake of completeness, I have tried a negative value with no change).

In fact, the only 2 values that work as anticipated are 0 and 2pi (full rotation which, in effect, has no effect). All of the "standard" rotation values for 45, 90 and 180 just produce garbage.

Here is what the "wall" in question looks like in the markup.

<Transform translation="0 3 0" rotation="1 0 0 1.5708" visible="True" onclick="ShowContextMenu(this, event)" render="true" bboxCenter="0,0,0" bboxSize="-1,-1,-1" center="0,0,0" scale="1,1,1" scaleOrientation="0,0,0,0">
    <Shape DEF="shape_egWallNE" render="true" visible="true" bboxCenter="0,0,0" bboxSize="-1,-1,-1" isPickable="true" id="Base__shape_egWallNE">
        <Appearance sortType="auto" alphaClipThreshold="0.1">
            <Material ambientIntensity="0.2" diffuseColor="0.8 0.8 0.8" emissiveColor="0,0,0" shininess="0.2" specularColor="0,0,0"></Material>
            <ImageTexture DEF="itegWallNE" url="/images/Campaign/fba19b32-46f0-4650-b260-a0079a907c28/TestImage.png" repeatS="false" repeatT="false" scale="true" hideChildren="true" id="Base__itegWallNE"></ImageTexture>
            <TextureTransform DEF="ttegWallNE" scale="1 1" rotation="0" center="0,0" translation="0,0" id="Base__ttegWallNE"></TextureTransform>
        </Appearance>
        <ElevationGrid egid="ab9258a8-2ddf-4214-a43a-9704f238fe26" egname="Wall NE" DEF="egWallNE" xDimension="8" xSpacing="1" zDimension="4" zSpacing="1" solid="true" height="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0" ccw="true" useGeoCache="true" lit="true" colorPerVertex="true" normalPerVertex="true" id="Base__egWallNE"></ElevationGrid>
    </Shape>
</Transform>

I'm clearly missing something, any thoughts on what it/they might be?

1

There are 1 best solutions below

0
On

The crux of the problem had to do with the center of rotation for the TextureImage. It does not rotate about the center of the image (offset by the center attribute).

It rotates about the s,t origin of the image. Once I realized this, the rotation could be done along with some translation to reposition the image and life is good!