Fix parent transform for rotation if pane uses matrix from shader
This commit is contained in:
parent
2205174ffe
commit
3be9e0c9de
@ -47,28 +47,26 @@ namespace LayoutBXLYT
|
|||||||
|
|
||||||
public void SetMaterials(BasePane pane, Dictionary<string, STGenericTexture> textures)
|
public void SetMaterials(BasePane pane, Dictionary<string, STGenericTexture> textures)
|
||||||
{
|
{
|
||||||
var paneRotate = pane.Rotate;
|
var paneRotate = pane.GetRotation();
|
||||||
if (pane.animController.PaneSRT?.Count > 0)
|
|
||||||
{
|
|
||||||
foreach (var animItem in pane.animController.PaneSRT)
|
|
||||||
{
|
|
||||||
switch (animItem.Key)
|
|
||||||
{
|
|
||||||
case LPATarget.RotateX:
|
|
||||||
paneRotate.X = animItem.Value; break;
|
|
||||||
case LPATarget.RotateY:
|
|
||||||
paneRotate.Y = animItem.Value; break;
|
|
||||||
case LPATarget.RotateZ:
|
|
||||||
paneRotate.Z = animItem.Value; break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Matrix4 rotationX = Matrix4.CreateRotationX(MathHelper.DegreesToRadians(paneRotate.X));
|
Matrix4 rotationX = Matrix4.CreateRotationX(MathHelper.DegreesToRadians(paneRotate.X));
|
||||||
Matrix4 rotationY = Matrix4.CreateRotationY(MathHelper.DegreesToRadians(paneRotate.Y));
|
Matrix4 rotationY = Matrix4.CreateRotationY(MathHelper.DegreesToRadians(paneRotate.Y));
|
||||||
Matrix4 rotationZ = Matrix4.CreateRotationZ(MathHelper.DegreesToRadians(paneRotate.Z));
|
Matrix4 rotationZ = Matrix4.CreateRotationZ(MathHelper.DegreesToRadians(paneRotate.Z));
|
||||||
var rotationMatrix = rotationX * rotationY * rotationZ;
|
var rotationMatrix = rotationX * rotationY * rotationZ;
|
||||||
|
|
||||||
|
//Get parent rotation if using material rotation transforms
|
||||||
|
//If it's a null pane, it would rotate automatically with GL.Rotate
|
||||||
|
if (pane.Parent is IPicturePane || pane.Parent is IWindowPane)
|
||||||
|
{
|
||||||
|
var parentRotate = pane.Parent.GetRotation();
|
||||||
|
|
||||||
|
Matrix4 parentRotationX = Matrix4.CreateRotationX(MathHelper.DegreesToRadians(parentRotate.X));
|
||||||
|
Matrix4 parentRotationY = Matrix4.CreateRotationY(MathHelper.DegreesToRadians(parentRotate.Y));
|
||||||
|
Matrix4 parentRotationZ = Matrix4.CreateRotationZ(MathHelper.DegreesToRadians(parentRotate.Z));
|
||||||
|
var parentRotationMatrix = parentRotationX * parentRotationY * parentRotationZ;
|
||||||
|
rotationMatrix = parentRotationMatrix * rotationMatrix;
|
||||||
|
}
|
||||||
|
|
||||||
SetMatrix("rotationMatrix", ref rotationMatrix);
|
SetMatrix("rotationMatrix", ref rotationMatrix);
|
||||||
|
|
||||||
STColor8 WhiteColor = material.WhiteColor;
|
STColor8 WhiteColor = material.WhiteColor;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user