mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-14 08:04:40 +00:00
Merge remote-tracking branch 'upstream/development' into imageAsset_refactor_rev3
This commit is contained in:
commit
9ff4c84bc8
8 changed files with 321 additions and 44 deletions
|
|
@ -45,8 +45,177 @@ ConsoleDocClass( GameTSCtrl,
|
||||||
"@brief The main 3D viewport for a Torque 3D game.\n\n"
|
"@brief The main 3D viewport for a Torque 3D game.\n\n"
|
||||||
"@ingroup Gui3D\n");
|
"@ingroup Gui3D\n");
|
||||||
|
|
||||||
|
IMPLEMENT_CALLBACK(GameTSCtrl, onMouseDown, void, (const Point2I& screenPosition, const Point3F& worldPosition, const Point3F& clickVector), (screenPosition, worldPosition, clickVector),
|
||||||
|
"@brief Callback that occurs whenever the left mouse button is pressed while in this control.\n\n"
|
||||||
|
"@param screenPosition Position of screen when mouse was pressed during this callback.\n\n"
|
||||||
|
"@param worldPosition Position of world when mouse was pressed during this callback.\n\n"
|
||||||
|
"@param clickVector Vector for the click when mouse was pressed during this callback.\n\n"
|
||||||
|
"@tsexample\n"
|
||||||
|
"// Mouse was pressed down in this control, causing the callback\n"
|
||||||
|
"GameTSCtrl::onMouseDown(%this,%screenPosition,%worldPosition,%clickVector)\n"
|
||||||
|
"{\n"
|
||||||
|
" // Code to call when a mouse event occurs.\n"
|
||||||
|
"}\n"
|
||||||
|
"@endtsexample\n\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
IMPLEMENT_CALLBACK(GameTSCtrl, onRightMouseDown, void, (const Point2I& screenPosition, const Point3F& worldPosition, const Point3F& clickVector), (screenPosition, worldPosition, clickVector),
|
||||||
|
"@brief Callback that occurs whenever the right mouse button is pressed while in this control.\n\n"
|
||||||
|
"@param screenPosition Position of screen when mouse was pressed during this callback.\n\n"
|
||||||
|
"@param worldPosition Position of world when mouse was pressed during this callback.\n\n"
|
||||||
|
"@param clickVector Vector for the click when mouse was pressed during this callback.\n\n"
|
||||||
|
"@tsexample\n"
|
||||||
|
"// Mouse was pressed down in this control, causing the callback\n"
|
||||||
|
"GameTSCtrl::onRightMouseDown(%this,%screenPosition,%worldPosition,%clickVector)\n"
|
||||||
|
"{\n"
|
||||||
|
" // Code to call when a mouse event occurs.\n"
|
||||||
|
"}\n"
|
||||||
|
"@endtsexample\n\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
IMPLEMENT_CALLBACK(GameTSCtrl, onMiddleMouseDown, void, (const Point2I& screenPosition, const Point3F& worldPosition, const Point3F& clickVector), (screenPosition, worldPosition, clickVector),
|
||||||
|
"@brief Callback that occurs whenever the middle mouse button is pressed while in this control.\n\n"
|
||||||
|
"@param screenPosition Position of screen when mouse was pressed during this callback.\n\n"
|
||||||
|
"@param worldPosition Position of world when mouse was pressed during this callback.\n\n"
|
||||||
|
"@param clickVector Vector for the click when mouse was pressed during this callback.\n\n"
|
||||||
|
"@tsexample\n"
|
||||||
|
"// Mouse was pressed down in this control, causing the callback\n"
|
||||||
|
"GameTSCtrl::onMiddleMouseDown(%this,%screenPosition,%worldPosition,%clickVector)\n"
|
||||||
|
"{\n"
|
||||||
|
" // Code to call when a mouse event occurs.\n"
|
||||||
|
"}\n"
|
||||||
|
"@endtsexample\n\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
IMPLEMENT_CALLBACK(GameTSCtrl, onMouseUp, void, (const Point2I& screenPosition, const Point3F& worldPosition, const Point3F& clickVector), (screenPosition, worldPosition, clickVector),
|
||||||
|
"@brief Callback that occurs whenever the left mouse button is released while in this control.\n\n"
|
||||||
|
"@param screenPosition Position of screen when mouse was released during this callback.\n\n"
|
||||||
|
"@param worldPosition Position of world when mouse was released during this callback.\n\n"
|
||||||
|
"@param clickVector Vector for the click when mouse was released during this callback.\n\n"
|
||||||
|
"@tsexample\n"
|
||||||
|
"// Mouse was released down in this control, causing the callback\n"
|
||||||
|
"GameTSCtrl::onMouseUp(%this,%screenPosition,%worldPosition,%clickVector)\n"
|
||||||
|
"{\n"
|
||||||
|
" // Code to call when a mouse event occurs.\n"
|
||||||
|
"}\n"
|
||||||
|
"@endtsexample\n\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
IMPLEMENT_CALLBACK(GameTSCtrl, onRightMouseUp, void, (const Point2I& screenPosition, const Point3F& worldPosition, const Point3F& clickVector), (screenPosition, worldPosition, clickVector),
|
||||||
|
"@brief Callback that occurs whenever the right mouse button is released while in this control.\n\n"
|
||||||
|
"@param screenPosition Position of screen when mouse was released during this callback.\n\n"
|
||||||
|
"@param worldPosition Position of world when mouse was released during this callback.\n\n"
|
||||||
|
"@param clickVector Vector for the click when mouse was released during this callback.\n\n"
|
||||||
|
"@tsexample\n"
|
||||||
|
"// Mouse was released down in this control, causing the callback\n"
|
||||||
|
"GameTSCtrl::onRightMouseUp(%this,%screenPosition,%worldPosition,%clickVector)\n"
|
||||||
|
"{\n"
|
||||||
|
" // Code to call when a mouse event occurs.\n"
|
||||||
|
"}\n"
|
||||||
|
"@endtsexample\n\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
IMPLEMENT_CALLBACK(GameTSCtrl, onMiddleMouseUp, void, (const Point2I& screenPosition, const Point3F& worldPosition, const Point3F& clickVector), (screenPosition, worldPosition, clickVector),
|
||||||
|
"@brief Callback that occurs whenever the middle mouse button is released while in this control.\n\n"
|
||||||
|
"@param screenPosition Position of screen when mouse was released during this callback.\n\n"
|
||||||
|
"@param worldPosition Position of world when mouse was released during this callback.\n\n"
|
||||||
|
"@param clickVector Vector for the click when mouse was released during this callback.\n\n"
|
||||||
|
"@tsexample\n"
|
||||||
|
"// Mouse was released down in this control, causing the callback\n"
|
||||||
|
"GameTSCtrl::onMiddleMouseUp(%this,%screenPosition,%worldPosition,%clickVector)\n"
|
||||||
|
"{\n"
|
||||||
|
" // Code to call when a mouse event occurs.\n"
|
||||||
|
"}\n"
|
||||||
|
"@endtsexample\n\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
IMPLEMENT_CALLBACK(GameTSCtrl, onMouseDragged, void, (const Point2I& screenPosition, const Point3F& worldPosition, const Point3F& clickVector), (screenPosition, worldPosition, clickVector),
|
||||||
|
"@brief Callback that occurs whenever the left mouse button is dragged while in this control.\n\n"
|
||||||
|
"@param screenPosition Position of screen when mouse was dragged during this callback.\n\n"
|
||||||
|
"@param worldPosition Position of world when mouse was dragged during this callback.\n\n"
|
||||||
|
"@param clickVector Vector for the click when mouse was dragged during this callback.\n\n"
|
||||||
|
"@tsexample\n"
|
||||||
|
"// Mouse was dragged down in this control, causing the callback\n"
|
||||||
|
"GameTSCtrl::onMouseDragged(%this,%screenPosition,%worldPosition,%clickVector)\n"
|
||||||
|
"{\n"
|
||||||
|
" // Code to call when a mouse event occurs.\n"
|
||||||
|
"}\n"
|
||||||
|
"@endtsexample\n\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
IMPLEMENT_CALLBACK(GameTSCtrl, onRightMouseDragged, void, (const Point2I& screenPosition, const Point3F& worldPosition, const Point3F& clickVector), (screenPosition, worldPosition, clickVector),
|
||||||
|
"@brief Callback that occurs whenever the right mouse button is dragged while in this control.\n\n"
|
||||||
|
"@param screenPosition Position of screen when mouse was dragged during this callback.\n\n"
|
||||||
|
"@param worldPosition Position of world when mouse was dragged during this callback.\n\n"
|
||||||
|
"@param clickVector Vector for the click when mouse was dragged during this callback.\n\n"
|
||||||
|
"@tsexample\n"
|
||||||
|
"// Mouse was dragged down in this control, causing the callback\n"
|
||||||
|
"GameTSCtrl::onRightMouseDragged(%this,%screenPosition,%worldPosition,%clickVector)\n"
|
||||||
|
"{\n"
|
||||||
|
" // Code to call when a mouse event occurs.\n"
|
||||||
|
"}\n"
|
||||||
|
"@endtsexample\n\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
IMPLEMENT_CALLBACK(GameTSCtrl, onMiddleMouseDragged, void, (const Point2I& screenPosition, const Point3F& worldPosition, const Point3F& clickVector), (screenPosition, worldPosition, clickVector),
|
||||||
|
"@brief Callback that occurs whenever the middle mouse button is dragged while in this control.\n\n"
|
||||||
|
"@param screenPosition Position of screen when mouse was dragged during this callback.\n\n"
|
||||||
|
"@param worldPosition Position of world when mouse was dragged during this callback.\n\n"
|
||||||
|
"@param clickVector Vector for the click when mouse was dragged during this callback.\n\n"
|
||||||
|
"@tsexample\n"
|
||||||
|
"// Mouse was dragged down in this control, causing the callback\n"
|
||||||
|
"GameTSCtrl::onMiddleMouseDragged(%this,%screenPosition,%worldPosition,%clickVector)\n"
|
||||||
|
"{\n"
|
||||||
|
" // Code to call when a mouse event occurs.\n"
|
||||||
|
"}\n"
|
||||||
|
"@endtsexample\n\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
IMPLEMENT_CALLBACK(GameTSCtrl, onMouseWheelUp, void, (const Point2I& screenPosition, const Point3F& worldPosition, const Point3F& clickVector), (screenPosition, worldPosition, clickVector),
|
||||||
|
"@brief Callback that occurs whenever the mouse wheel up is pressed while in this control.\n\n"
|
||||||
|
"@param screenPosition Position of screen when mouse wheel up was pressed during this callback.\n\n"
|
||||||
|
"@param worldPosition Position of world when mouse wheel up was pressed during this callback.\n\n"
|
||||||
|
"@param clickVector Vector for the click when mouse wheel up was pressed during this callback.\n\n"
|
||||||
|
"@tsexample\n"
|
||||||
|
"// Mouse wheel up was pressed in this control, causing the callback\n"
|
||||||
|
"GameTSCtrl::onMouseWheelUp(%this,%screenPosition,%worldPosition,%clickVector)\n"
|
||||||
|
"{\n"
|
||||||
|
" // Code to call when a mouse event occurs.\n"
|
||||||
|
"}\n"
|
||||||
|
"@endtsexample\n\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
IMPLEMENT_CALLBACK(GameTSCtrl, onMouseWheelDown, void, (const Point2I& screenPosition, const Point3F& worldPosition, const Point3F& clickVector), (screenPosition, worldPosition, clickVector),
|
||||||
|
"@brief Callback that occurs whenever the mouse wheel down is pressed while in this control.\n\n"
|
||||||
|
"@param screenPosition Position of screen when mouse wheel down was pressed during this callback.\n\n"
|
||||||
|
"@param worldPosition Position of world when mouse wheel down was pressed during this callback.\n\n"
|
||||||
|
"@param clickVector Vector for the click when mouse wheel down was pressed during this callback.\n\n"
|
||||||
|
"@tsexample\n"
|
||||||
|
"// Mouse wheel down was pressed in this control, causing the callback\n"
|
||||||
|
"GameTSCtrl::onMouseWheelDown(%this,%screenPosition,%worldPosition,%clickVector)\n"
|
||||||
|
"{\n"
|
||||||
|
" // Code to call when a mouse event occurs.\n"
|
||||||
|
"}\n"
|
||||||
|
"@endtsexample\n\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
IMPLEMENT_CALLBACK(GameTSCtrl, onMouseMove, void, (const Point2I& screenPosition, const Point3F& worldPosition, const Point3F& clickVector), (screenPosition, worldPosition, clickVector),
|
||||||
|
"@brief Callback that occurs whenever the mouse is moved (without dragging) while in this control.\n\n"
|
||||||
|
"@param screenPosition Position of screen when mouse was moved during this callback.\n\n"
|
||||||
|
"@param worldPosition Position of world when mouse was moved during this callback.\n\n"
|
||||||
|
"@param clickVector Vector for the click when mouse was moved during this callback.\n\n"
|
||||||
|
"@tsexample\n"
|
||||||
|
"// Mouse was moved down in this control, causing the callback\n"
|
||||||
|
"GameTSCtrl::onMouseMove(%this,%screenPosition,%worldPosition,%clickVector)\n"
|
||||||
|
"{\n"
|
||||||
|
" // Code to call when a mouse event occurs.\n"
|
||||||
|
"}\n"
|
||||||
|
"@endtsexample\n\n"
|
||||||
|
);
|
||||||
|
|
||||||
GameTSCtrl::GameTSCtrl()
|
GameTSCtrl::GameTSCtrl()
|
||||||
{
|
{
|
||||||
|
mFrameTime = PlatformTimer::create();
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
@ -71,71 +240,136 @@ void GameTSCtrl::renderWorld(const RectI &updateRect)
|
||||||
GameRenderWorld();
|
GameRenderWorld();
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
void GameTSCtrl::makeScriptCall(const char *func, const GuiEvent &evt) const
|
void GameTSCtrl::sendMouseEvent(const char *name, const GuiEvent &event)
|
||||||
{
|
{
|
||||||
// write screen position
|
// write screen position
|
||||||
char *sp = Con::getArgBuffer(32);
|
Point2I screenPosition = event.mousePoint;
|
||||||
dSprintf(sp, 32, "%d %d", evt.mousePoint.x, evt.mousePoint.y);
|
|
||||||
|
|
||||||
// write world position
|
// write world position
|
||||||
char *wp = Con::getArgBuffer(32);
|
Point3F worldPosition;
|
||||||
Point3F camPos;
|
mLastCameraQuery.cameraMatrix.getColumn(3, &worldPosition);
|
||||||
mLastCameraQuery.cameraMatrix.getColumn(3, &camPos);
|
|
||||||
dSprintf(wp, 32, "%g %g %g", camPos.x, camPos.y, camPos.z);
|
|
||||||
|
|
||||||
// write click vector
|
// write click vector
|
||||||
char *vec = Con::getArgBuffer(32);
|
Point3F fp(event.mousePoint.x, event.mousePoint.y, 1.0);
|
||||||
Point3F fp(evt.mousePoint.x, evt.mousePoint.y, 1.0);
|
Point3F clickVector;
|
||||||
Point3F ray;
|
unproject(fp, &clickVector);
|
||||||
unproject(fp, &ray);
|
clickVector -= worldPosition;
|
||||||
ray -= camPos;
|
clickVector.normalizeSafe();
|
||||||
ray.normalizeSafe();
|
|
||||||
dSprintf(vec, 32, "%g %g %g", ray.x, ray.y, ray.z);
|
|
||||||
|
|
||||||
Con::executef( (SimObject*)this, func, sp, wp, vec );
|
if (dStricmp(name, "onMouseDown") == 0)
|
||||||
|
onMouseDown_callback(screenPosition, worldPosition, clickVector);
|
||||||
|
else if (dStricmp(name, "onRightMouseDown") == 0)
|
||||||
|
onRightMouseDown_callback(screenPosition, worldPosition, clickVector);
|
||||||
|
else if (dStricmp(name, "onMiddleMouseDown") == 0)
|
||||||
|
onMiddleMouseDown_callback(screenPosition, worldPosition, clickVector);
|
||||||
|
else if (dStricmp(name, "onMouseUp") == 0)
|
||||||
|
onMouseUp_callback(screenPosition, worldPosition, clickVector);
|
||||||
|
else if (dStricmp(name, "onRightMouseUp") == 0)
|
||||||
|
onRightMouseUp_callback(screenPosition, worldPosition, clickVector);
|
||||||
|
else if (dStricmp(name, "onMiddleMouseUp") == 0)
|
||||||
|
onMiddleMouseUp_callback(screenPosition, worldPosition, clickVector);
|
||||||
|
else if (dStricmp(name, "onMouseDragged") == 0)
|
||||||
|
onMouseDragged_callback(screenPosition, worldPosition, clickVector);
|
||||||
|
else if (dStricmp(name, "onRightMouseDragged") == 0)
|
||||||
|
onRightMouseDragged_callback(screenPosition, worldPosition, clickVector);
|
||||||
|
else if (dStricmp(name, "onMiddleMouseDragged") == 0)
|
||||||
|
onMiddleMouseDragged_callback(screenPosition, worldPosition, clickVector);
|
||||||
|
else if (dStricmp(name, "onMouseWheelUp") == 0)
|
||||||
|
onMouseWheelUp_callback(screenPosition, worldPosition, clickVector);
|
||||||
|
else if (dStricmp(name, "onMouseWheelDown") == 0)
|
||||||
|
onMouseWheelDown_callback(screenPosition, worldPosition, clickVector);
|
||||||
|
else if (dStricmp(name, "onMouseMove") == 0)
|
||||||
|
onMouseMove_callback(screenPosition, worldPosition, clickVector);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameTSCtrl::onMouseDown(const GuiEvent &evt)
|
void GameTSCtrl::onMouseDown(const GuiEvent &evt)
|
||||||
{
|
{
|
||||||
Parent::onMouseDown(evt);
|
Parent::onMouseDown(evt);
|
||||||
if( isMethod( "onMouseDown" ) )
|
|
||||||
makeScriptCall( "onMouseDown", evt );
|
sendMouseEvent("onMouseDown", evt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameTSCtrl::onRightMouseDown(const GuiEvent &evt)
|
void GameTSCtrl::onRightMouseDown(const GuiEvent &evt)
|
||||||
{
|
{
|
||||||
Parent::onRightMouseDown(evt);
|
Parent::onRightMouseDown(evt);
|
||||||
if( isMethod( "onRightMouseDown" ) )
|
|
||||||
makeScriptCall( "onRightMouseDown", evt );
|
sendMouseEvent("onRightMouseDown", evt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameTSCtrl::onMiddleMouseDown(const GuiEvent &evt)
|
void GameTSCtrl::onMiddleMouseDown(const GuiEvent &evt)
|
||||||
{
|
{
|
||||||
Parent::onMiddleMouseDown(evt);
|
Parent::onMiddleMouseDown(evt);
|
||||||
if( isMethod( "onMiddleMouseDown" ) )
|
|
||||||
makeScriptCall( "onMiddleMouseDown", evt );
|
sendMouseEvent("onMiddleMouseDown", evt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameTSCtrl::onMouseUp(const GuiEvent &evt)
|
void GameTSCtrl::onMouseUp(const GuiEvent &evt)
|
||||||
{
|
{
|
||||||
Parent::onMouseUp(evt);
|
Parent::onMouseUp(evt);
|
||||||
if( isMethod( "onMouseUp" ) )
|
|
||||||
makeScriptCall( "onMouseUp", evt );
|
sendMouseEvent("onMouseUp", evt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameTSCtrl::onRightMouseUp(const GuiEvent &evt)
|
void GameTSCtrl::onRightMouseUp(const GuiEvent &evt)
|
||||||
{
|
{
|
||||||
Parent::onRightMouseUp(evt);
|
Parent::onRightMouseUp(evt);
|
||||||
if( isMethod( "onRightMouseUp" ) )
|
|
||||||
makeScriptCall( "onRightMouseUp", evt );
|
sendMouseEvent("onRightMouseUp", evt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameTSCtrl::onMiddleMouseUp(const GuiEvent &evt)
|
void GameTSCtrl::onMiddleMouseUp(const GuiEvent &evt)
|
||||||
{
|
{
|
||||||
Parent::onMiddleMouseUp(evt);
|
Parent::onMiddleMouseUp(evt);
|
||||||
if( isMethod( "onMiddleMouseUp" ) )
|
|
||||||
makeScriptCall( "onMiddleMouseUp", evt );
|
sendMouseEvent("onMiddleMouseUp", evt);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameTSCtrl::onMouseDragged(const GuiEvent &evt)
|
||||||
|
{
|
||||||
|
Parent::onMouseDragged(evt);
|
||||||
|
|
||||||
|
if (mFrameTime && mFrameTime->getElapsedMs() > 16)
|
||||||
|
{
|
||||||
|
sendMouseEvent("onMouseDragged", evt);
|
||||||
|
mFrameTime->reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameTSCtrl::onRightMouseDragged(const GuiEvent &evt)
|
||||||
|
{
|
||||||
|
Parent::onRightMouseDragged(evt);
|
||||||
|
|
||||||
|
if (mFrameTime && mFrameTime->getElapsedMs() > 16)
|
||||||
|
{
|
||||||
|
sendMouseEvent("onRightMouseDragged", evt);
|
||||||
|
mFrameTime->reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameTSCtrl::onMiddleMouseDragged(const GuiEvent &evt)
|
||||||
|
{
|
||||||
|
Parent::onMiddleMouseDragged(evt);
|
||||||
|
|
||||||
|
if (mFrameTime && mFrameTime->getElapsedMs() > 16)
|
||||||
|
{
|
||||||
|
sendMouseEvent("onMiddleMouseDragged", evt);
|
||||||
|
mFrameTime->reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GameTSCtrl::onMouseWheelUp(const GuiEvent &evt)
|
||||||
|
{
|
||||||
|
sendMouseEvent("onMouseWheelUp", evt);
|
||||||
|
|
||||||
|
return Parent::onMouseWheelUp(evt);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GameTSCtrl::onMouseWheelDown(const GuiEvent &evt)
|
||||||
|
{
|
||||||
|
sendMouseEvent("onMouseWheelDown", evt);
|
||||||
|
|
||||||
|
return Parent::onMouseWheelDown(evt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameTSCtrl::onMouseMove(const GuiEvent &evt)
|
void GameTSCtrl::onMouseMove(const GuiEvent &evt)
|
||||||
|
|
@ -158,8 +392,12 @@ void GameTSCtrl::onMouseMove(const GuiEvent &evt)
|
||||||
lineTestEnd = pos + vec * 1000;
|
lineTestEnd = pos + vec * 1000;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isMethod("onMouseMove"))
|
|
||||||
makeScriptCall("onMouseMove", evt);
|
if (mFrameTime->getElapsedMs() > 16)
|
||||||
|
{
|
||||||
|
sendMouseEvent("onMouseMove", evt);
|
||||||
|
mFrameTime->reset();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameTSCtrl::onRender(Point2I offset, const RectI &updateRect)
|
void GameTSCtrl::onRender(Point2I offset, const RectI &updateRect)
|
||||||
|
|
|
||||||
|
|
@ -39,11 +39,31 @@ class GameTSCtrl : public GuiTSCtrl
|
||||||
private:
|
private:
|
||||||
typedef GuiTSCtrl Parent;
|
typedef GuiTSCtrl Parent;
|
||||||
|
|
||||||
void makeScriptCall(const char *func, const GuiEvent &evt) const;
|
void sendMouseEvent(const char *name, const GuiEvent &evt);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
PlatformTimer *mFrameTime;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GameTSCtrl();
|
GameTSCtrl();
|
||||||
|
|
||||||
|
/// @name Callbacks
|
||||||
|
/// @{
|
||||||
|
|
||||||
|
DECLARE_CALLBACK(void, onMouseDown, (const Point2I& screenPosition, const Point3F& worldPosition, const Point3F& clickVector));
|
||||||
|
DECLARE_CALLBACK(void, onRightMouseDown, (const Point2I& screenPosition, const Point3F& worldPosition, const Point3F& clickVector));
|
||||||
|
DECLARE_CALLBACK(void, onMiddleMouseDown, (const Point2I& screenPosition, const Point3F& worldPosition, const Point3F& clickVector));
|
||||||
|
DECLARE_CALLBACK(void, onMouseUp, (const Point2I& screenPosition, const Point3F& worldPosition, const Point3F& clickVector));
|
||||||
|
DECLARE_CALLBACK(void, onRightMouseUp, (const Point2I& screenPosition, const Point3F& worldPosition, const Point3F& clickVector));
|
||||||
|
DECLARE_CALLBACK(void, onMiddleMouseUp, (const Point2I& screenPosition, const Point3F& worldPosition, const Point3F& clickVector));
|
||||||
|
DECLARE_CALLBACK(void, onMouseDragged, (const Point2I& screenPosition, const Point3F& worldPosition, const Point3F& clickVector));
|
||||||
|
DECLARE_CALLBACK(void, onRightMouseDragged, (const Point2I& screenPosition, const Point3F& worldPosition, const Point3F& clickVector));
|
||||||
|
DECLARE_CALLBACK(void, onMiddleMouseDragged, (const Point2I& screenPosition, const Point3F& worldPosition, const Point3F& clickVector));
|
||||||
|
DECLARE_CALLBACK(void, onMouseWheelUp, (const Point2I& screenPosition, const Point3F& worldPosition, const Point3F& clickVector));
|
||||||
|
DECLARE_CALLBACK(void, onMouseWheelDown, (const Point2I& screenPosition, const Point3F& worldPosition, const Point3F& clickVector));
|
||||||
|
DECLARE_CALLBACK(void, onMouseMove, (const Point2I& screenPosition, const Point3F& worldPosition, const Point3F& clickVector));
|
||||||
|
/// }
|
||||||
|
|
||||||
DECLARE_CONOBJECT(GameTSCtrl);
|
DECLARE_CONOBJECT(GameTSCtrl);
|
||||||
DECLARE_DESCRIPTION( "A control that renders a 3D view from the current control object." );
|
DECLARE_DESCRIPTION( "A control that renders a 3D view from the current control object." );
|
||||||
|
|
||||||
|
|
@ -59,6 +79,13 @@ public:
|
||||||
void onRightMouseUp(const GuiEvent &evt) override;
|
void onRightMouseUp(const GuiEvent &evt) override;
|
||||||
void onMiddleMouseUp(const GuiEvent &evt) override;
|
void onMiddleMouseUp(const GuiEvent &evt) override;
|
||||||
|
|
||||||
|
void onMouseDragged(const GuiEvent &evt);
|
||||||
|
void onRightMouseDragged(const GuiEvent &evt);
|
||||||
|
void onMiddleMouseDragged(const GuiEvent &evt);
|
||||||
|
|
||||||
|
bool onMouseWheelUp(const GuiEvent &evt);
|
||||||
|
bool onMouseWheelDown(const GuiEvent &evt);
|
||||||
|
|
||||||
void onMouseMove(const GuiEvent &evt) override;
|
void onMouseMove(const GuiEvent &evt) override;
|
||||||
void onRender(Point2I offset, const RectI &updateRect) override;
|
void onRender(Point2I offset, const RectI &updateRect) override;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1332,7 +1332,7 @@ void ProcessedShaderMaterial::setSceneInfo(SceneRenderState * state, const Scene
|
||||||
if (sgData.cubemap)
|
if (sgData.cubemap)
|
||||||
shaderConsts->setSafe(handles->mCubeMipsSC, (F32)sgData.cubemap->getMipMapLevels());
|
shaderConsts->setSafe(handles->mCubeMipsSC, (F32)sgData.cubemap->getMipMapLevels());
|
||||||
else
|
else
|
||||||
shaderConsts->setSafe(handles->mCubeMipsSC, 1.0f);
|
shaderConsts->setSafe(handles->mCubeMipsSC, (F32)getBinLog2(PROBEMGR->getProbeTexSize()));
|
||||||
|
|
||||||
shaderConsts->setSafe(handles->mVisiblitySC, sgData.visibility);
|
shaderConsts->setSafe(handles->mVisiblitySC, sgData.visibility);
|
||||||
|
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -319,7 +319,7 @@ float computeSpecOcclusion( float NdotV , float AO , float roughness )
|
||||||
|
|
||||||
float roughnessToMipLevel(float roughness, float numMips)
|
float roughnessToMipLevel(float roughness, float numMips)
|
||||||
{
|
{
|
||||||
return saturate((roughness * numMips) - (pow(roughness, 6.0) * (numMips * 0.125)));
|
return roughness * (numMips+1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
vec4 compute4Lights( Surface surface,
|
vec4 compute4Lights( Surface surface,
|
||||||
|
|
@ -585,10 +585,14 @@ vec4 computeForwardProbes(Surface surface,
|
||||||
|
|
||||||
vec2 envBRDF = textureLod(BRDFTexture, vec2(surface.NdotV, surface.roughness),0).rg;
|
vec2 envBRDF = textureLod(BRDFTexture, vec2(surface.NdotV, surface.roughness),0).rg;
|
||||||
vec3 diffuse = irradiance * lerp(surface.baseColor.rgb, vec3(0.04f,0.04f,0.04f), surface.metalness);
|
vec3 diffuse = irradiance * lerp(surface.baseColor.rgb, vec3(0.04f,0.04f,0.04f), surface.metalness);
|
||||||
vec3 specularCol = ((specular + surface.baseColor.rgb) * envBRDF.x + envBRDF.y)*surface.metalness;
|
vec3 specularCol = ((specular * surface.baseColor.rgb) * envBRDF.x + envBRDF.y)*surface.metalness;
|
||||||
|
|
||||||
|
float horizonOcclusion = 1.3;
|
||||||
|
float horizon = saturate( 1 + horizonOcclusion * dot(surface.R, surface.N));
|
||||||
|
horizon *= horizon;
|
||||||
|
|
||||||
// Final color output after environment lighting
|
// Final color output after environment lighting
|
||||||
vec3 finalColor = diffuse + specularCol;
|
vec3 finalColor = diffuse + specularCol * horizon;
|
||||||
finalColor *= surface.ao;
|
finalColor *= surface.ao;
|
||||||
|
|
||||||
if(isCapturing == 1)
|
if(isCapturing == 1)
|
||||||
|
|
@ -738,10 +742,14 @@ vec4 debugVizForwardProbes(Surface surface,
|
||||||
|
|
||||||
vec2 envBRDF = textureLod(BRDFTexture, vec2(surface.NdotV, surface.roughness),0).rg;
|
vec2 envBRDF = textureLod(BRDFTexture, vec2(surface.NdotV, surface.roughness),0).rg;
|
||||||
vec3 diffuse = irradiance * lerp(surface.baseColor.rgb, vec3(0.04f,0.04f,0.04f), surface.metalness);
|
vec3 diffuse = irradiance * lerp(surface.baseColor.rgb, vec3(0.04f,0.04f,0.04f), surface.metalness);
|
||||||
vec3 specularCol = ((specular + surface.baseColor.rgb) * envBRDF.x + envBRDF.y)*surface.metalness;
|
vec3 specularCol = ((specular * surface.baseColor.rgb) * envBRDF.x + envBRDF.y)*surface.metalness;
|
||||||
|
|
||||||
|
float horizonOcclusion = 1.3;
|
||||||
|
float horizon = saturate( 1 + horizonOcclusion * dot(surface.R, surface.N));
|
||||||
|
horizon *= horizon;
|
||||||
|
|
||||||
// Final color output after environment lighting
|
// Final color output after environment lighting
|
||||||
vec3 finalColor = diffuse + specularCol;
|
vec3 finalColor = diffuse + specularCol * horizon;
|
||||||
finalColor *= surface.ao;
|
finalColor *= surface.ao;
|
||||||
|
|
||||||
if(isCapturing == 1)
|
if(isCapturing == 1)
|
||||||
|
|
|
||||||
|
|
@ -320,7 +320,7 @@ float computeSpecOcclusion( float NdotV , float AO , float roughness )
|
||||||
|
|
||||||
float roughnessToMipLevel(float roughness, float numMips)
|
float roughnessToMipLevel(float roughness, float numMips)
|
||||||
{
|
{
|
||||||
return saturate((roughness * numMips) - (pow(roughness, 6.0) * (numMips * 0.125)));
|
return roughness * (numMips+1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
float4 compute4Lights( Surface surface,
|
float4 compute4Lights( Surface surface,
|
||||||
|
|
@ -591,7 +591,7 @@ float4 computeForwardProbes(Surface surface,
|
||||||
|
|
||||||
float2 envBRDF = TORQUE_TEX2DLOD(BRDFTexture, float4(surface.NdotV, surface.roughness,0,0)).rg;
|
float2 envBRDF = TORQUE_TEX2DLOD(BRDFTexture, float4(surface.NdotV, surface.roughness,0,0)).rg;
|
||||||
float3 diffuse = irradiance * lerp(surface.baseColor.rgb, 0.04f, surface.metalness);
|
float3 diffuse = irradiance * lerp(surface.baseColor.rgb, 0.04f, surface.metalness);
|
||||||
float3 specularCol = ((specular + surface.baseColor.rgb) * envBRDF.x + envBRDF.y)*surface.metalness;
|
float3 specularCol = ((specular * surface.baseColor.rgb) * envBRDF.x + envBRDF.y)*surface.metalness;
|
||||||
|
|
||||||
float horizonOcclusion = 1.3;
|
float horizonOcclusion = 1.3;
|
||||||
float horizon = saturate( 1 + horizonOcclusion * dot(surface.R, surface.N));
|
float horizon = saturate( 1 + horizonOcclusion * dot(surface.R, surface.N));
|
||||||
|
|
@ -748,7 +748,7 @@ float4 debugVizForwardProbes(Surface surface,
|
||||||
|
|
||||||
float2 envBRDF = TORQUE_TEX2DLOD(BRDFTexture, float4(surface.NdotV, surface.roughness,0,0)).rg;
|
float2 envBRDF = TORQUE_TEX2DLOD(BRDFTexture, float4(surface.NdotV, surface.roughness,0,0)).rg;
|
||||||
float3 diffuse = irradiance * lerp(surface.baseColor.rgb, 0.04f, surface.metalness);
|
float3 diffuse = irradiance * lerp(surface.baseColor.rgb, 0.04f, surface.metalness);
|
||||||
float3 specularCol = ((specular + surface.baseColor.rgb) * envBRDF.x + envBRDF.y)*surface.metalness;
|
float3 specularCol = ((specular * surface.baseColor.rgb) * envBRDF.x + envBRDF.y)*surface.metalness;
|
||||||
|
|
||||||
float horizonOcclusion = 1.3;
|
float horizonOcclusion = 1.3;
|
||||||
float horizon = saturate( 1 + horizonOcclusion * dot(surface.R, surface.N));
|
float horizon = saturate( 1 + horizonOcclusion * dot(surface.R, surface.N));
|
||||||
|
|
|
||||||
|
|
@ -206,10 +206,14 @@ void main()
|
||||||
|
|
||||||
vec2 envBRDF = textureLod(BRDFTexture, vec2(surface.NdotV, surface.roughness),0).rg;
|
vec2 envBRDF = textureLod(BRDFTexture, vec2(surface.NdotV, surface.roughness),0).rg;
|
||||||
vec3 diffuse = irradiance * lerp(surface.baseColor.rgb, vec3(0.04f,0.04f,0.04f), surface.metalness);
|
vec3 diffuse = irradiance * lerp(surface.baseColor.rgb, vec3(0.04f,0.04f,0.04f), surface.metalness);
|
||||||
vec3 specularCol = ((specular + surface.baseColor.rgb) * envBRDF.x + envBRDF.y)*surface.metalness;
|
vec3 specularCol = ((specular * surface.baseColor.rgb) * envBRDF.x + envBRDF.y)*surface.metalness;
|
||||||
|
|
||||||
|
float horizonOcclusion = 1.3;
|
||||||
|
float horizon = saturate( 1 + horizonOcclusion * dot(surface.R, surface.N));
|
||||||
|
horizon *= horizon;
|
||||||
|
|
||||||
// Final color output after environment lighting
|
// Final color output after environment lighting
|
||||||
vec3 finalColor = diffuse + specularCol;
|
vec3 finalColor = diffuse + specularCol * horizon;
|
||||||
finalColor *= surface.ao;
|
finalColor *= surface.ao;
|
||||||
|
|
||||||
if(isCapturing == 1)
|
if(isCapturing == 1)
|
||||||
|
|
|
||||||
|
|
@ -194,14 +194,14 @@ float4 main(PFXVertToPix IN) : SV_TARGET
|
||||||
|
|
||||||
float2 envBRDF = TORQUE_TEX2DLOD(BRDFTexture, float4(surface.NdotV, surface.roughness,0,0)).rg;
|
float2 envBRDF = TORQUE_TEX2DLOD(BRDFTexture, float4(surface.NdotV, surface.roughness,0,0)).rg;
|
||||||
float3 diffuse = irradiance * lerp(surface.baseColor.rgb, 0.04f, surface.metalness);
|
float3 diffuse = irradiance * lerp(surface.baseColor.rgb, 0.04f, surface.metalness);
|
||||||
float3 specularCol = ((specular + surface.baseColor.rgb) * envBRDF.x + envBRDF.y)*surface.metalness;
|
float3 specularCol = ((specular * surface.baseColor.rgb) * envBRDF.x + envBRDF.y)*surface.metalness;
|
||||||
|
|
||||||
float horizonOcclusion = 1.3;
|
float horizonOcclusion = 1.3;
|
||||||
float horizon = saturate( 1 + horizonOcclusion * dot(surface.R, surface.N));
|
float horizon = saturate( 1 + horizonOcclusion * dot(surface.R, surface.N));
|
||||||
horizon *= horizon;
|
horizon *= horizon;
|
||||||
|
|
||||||
// Final color output after environment lighting
|
// Final color output after environment lighting
|
||||||
float3 finalColor = diffuse + specularCol;
|
float3 finalColor = diffuse + specularCol*horizon;
|
||||||
finalColor *= surface.ao;
|
finalColor *= surface.ao;
|
||||||
|
|
||||||
if(isCapturing == 1)
|
if(isCapturing == 1)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue