mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-04-29 16:25:42 +00:00
Update guiMaterialPreview.cpp
light movement now makes sense
This commit is contained in:
parent
a92b9d0e2d
commit
7810ee4f51
1 changed files with 14 additions and 14 deletions
|
|
@ -115,20 +115,20 @@ void GuiMaterialPreview::setLightTranslate(S32 modifier, F32 xstep, F32 ystep)
|
||||||
F32 _lighttransstep = (modifier & SI_SHIFT ? mLightTransStep : (mLightTransStep*mLightTranMult));
|
F32 _lighttransstep = (modifier & SI_SHIFT ? mLightTransStep : (mLightTransStep*mLightTranMult));
|
||||||
|
|
||||||
Point3F relativeLightDirection = GuiMaterialPreview::mFakeSun->getDirection();
|
Point3F relativeLightDirection = GuiMaterialPreview::mFakeSun->getDirection();
|
||||||
// May be able to get rid of this. For now, it helps to fix the position of the light if i gets messed up.
|
|
||||||
if (modifier & SI_PRIMARY_CTRL)
|
F32 azimuth = mAtan2(relativeLightDirection.y, relativeLightDirection.x);
|
||||||
{
|
F32 elevation = mAsin(relativeLightDirection.z);
|
||||||
relativeLightDirection.x += ( xstep * _lighttransstep * -1 );//need to invert this for some reason. Otherwise, it's backwards.
|
|
||||||
relativeLightDirection.y += ( ystep * _lighttransstep );
|
// Modify azimuth and elevation based on input
|
||||||
GuiMaterialPreview::mFakeSun->setDirection(relativeLightDirection);
|
azimuth += xstep * _lighttransstep;
|
||||||
}
|
elevation = mClampF(elevation + ystep * _lighttransstep, -M_2PI_F, M_2PI_F);
|
||||||
// Default action taken by mouse wheel clicking.
|
|
||||||
else
|
// Convert back to Cartesian coordinates
|
||||||
{
|
relativeLightDirection.x = mCos(elevation) * mCos(azimuth);
|
||||||
relativeLightDirection.x += ( xstep * _lighttransstep * -1 ); //need to invert this for some reason. Otherwise, it's backwards.
|
relativeLightDirection.y = mCos(elevation) * mSin(azimuth);
|
||||||
relativeLightDirection.z += ( ystep * _lighttransstep );
|
relativeLightDirection.z = mSin(elevation);
|
||||||
GuiMaterialPreview::mFakeSun->setDirection(relativeLightDirection);
|
|
||||||
}
|
GuiMaterialPreview::mFakeSun->setDirection(relativeLightDirection);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is for panning the viewport camera.
|
// This is for panning the viewport camera.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue