From fe008c0e52f6f063da732c0f910d852f2aa71213 Mon Sep 17 00:00:00 2001 From: Ulukyn Date: Tue, 7 Jan 2020 17:13:01 +0100 Subject: [PATCH 1/2] Added: moveCam and setCamMode lua functions --- .../client/src/interface_v3/lua_ihm_ryzom.cpp | 36 +++++++++++++++++++ .../client/src/interface_v3/lua_ihm_ryzom.h | 2 ++ code/ryzom/client/src/main_loop.cpp | 15 ++++++++ code/ryzom/client/src/user_entity.h | 12 +++++++ 4 files changed, 65 insertions(+) diff --git a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp index cd1df8d2f..547388698 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp +++ b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp @@ -112,6 +112,7 @@ #include "../entities.h" #include "../misc.h" #include "../gabarit.h" +#include "../view.h" #include "bot_chat_page_all.h" #include "bot_chat_page_ring_sessions.h" @@ -442,6 +443,8 @@ void CLuaIHMRyzom::RegisterRyzomFunctions(NLGUI::CLuaState &ls) ls.registerFunc("enableModalWindow", enableModalWindow); ls.registerFunc("getPlayerPos", getPlayerPos); ls.registerFunc("getGroundAtMouse", getGroundAtMouse), + ls.registerFunc("moveCam", moveCam), + ls.registerFunc("setCamMode", setCamMode), ls.registerFunc("getMousePos", getMousePos), ls.registerFunc("getMouseDown", getMouseDown), ls.registerFunc("getMouseMiddleDown", getMouseMiddleDown), @@ -1331,6 +1334,39 @@ int CLuaIHMRyzom::getGroundAtMouse(CLuaState &ls) return 3; } +int CLuaIHMRyzom::moveCam(CLuaState &ls) +{ + const char *funcName = "moveCam"; + CLuaIHM::checkArgCount(ls, funcName, 3); + CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); + CLuaIHM::checkArgType(ls, funcName, 2, LUA_TNUMBER); + CLuaIHM::checkArgType(ls, funcName, 3, LUA_TNUMBER); + + float x = (float)ls.toNumber(1); + float y = (float)ls.toNumber(2); + float z = (float)ls.toNumber(3); + CVector moves(x, y, z); + UserEntity->setCameraMoves(moves); + + return 0; +} + +int CLuaIHMRyzom::setCamMode(CLuaState &ls) +{ + const char *funcName = "setCamMode"; + CLuaIHM::checkArgCount(ls, funcName, 1); + + bool aiMode = ls.toBoolean(1); + + if(aiMode) + UserControls.mode(CUserControls::AIMode); + else + UserEntity->viewMode(UserEntity->viewMode()); + + return 0; +} + + // *************************************************************************** int CLuaIHMRyzom::getPlayerPos(CLuaState &ls) { diff --git a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h index c2d47b7ec..5103d2fcf 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h +++ b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h @@ -232,6 +232,8 @@ private: static std::string getRegionByAlias(uint32 alias); static float getGroundZ(float x, float y); static int getGroundAtMouse(CLuaState &ls); + static int moveCam(CLuaState &ls); + static int setCamMode(CLuaState &ls); static int getMousePos(CLuaState &ls); static int getMouseDown(CLuaState &ls); static int getMouseMiddleDown(CLuaState &ls); diff --git a/code/ryzom/client/src/main_loop.cpp b/code/ryzom/client/src/main_loop.cpp index 981bc7c72..5051fe193 100644 --- a/code/ryzom/client/src/main_loop.cpp +++ b/code/ryzom/client/src/main_loop.cpp @@ -1411,8 +1411,23 @@ bool mainLoop() // Update Camera Position/Orientation. CVector currViewPos = View.currentViewPos(); MainCam.setTransformMode(UTransformable::RotQuat); + + CVector cameraMoves = UserEntity->getCameraMoves(); + + currViewPos.z += cameraMoves.z; MainCam.setPos(currViewPos); MainCam.setRotQuat(View.currentViewQuat()); + + if (cameraMoves.x) + { + CMatrix viewMatrix; + viewMatrix = MainCam.getMatrix(); + viewMatrix.rotateZ(cameraMoves.x); + MainCam.setRotQuat(viewMatrix.getRot()); + } + + UserEntity->setCameraMoves(CVector(0, 0, 0)); + if (StereoHMD) { CMatrix camMatrix; diff --git a/code/ryzom/client/src/user_entity.h b/code/ryzom/client/src/user_entity.h index 5149b46e8..e240622c9 100644 --- a/code/ryzom/client/src/user_entity.h +++ b/code/ryzom/client/src/user_entity.h @@ -490,6 +490,16 @@ public: return _LoginName; } + CVector getCameraMoves() + { + return _CameraMoves; + } + + void setCameraMoves(CVector moves) + { + _CameraMoves = moves; + } + protected: class CSpeedFactor : public NLMISC::ICDBNode::IPropertyObserver { @@ -602,6 +612,8 @@ protected: /// Time in MS when the User started beiing in collision with anything that avoid him to do an Action (and still is). sint64 _MoveToColStartTime; + CVector _CameraMoves; + /// CSkill points observer class CSkillPointsObserver : public NLMISC::ICDBNode::IPropertyObserver From 34c1265bceaf1c421cb5f37b660062c898565971 Mon Sep 17 00:00:00 2001 From: Ulukyn Date: Tue, 7 Jan 2020 18:09:33 +0100 Subject: [PATCH 2/2] Revert "Merge remote-tracking branch 'origin/ryzom/ark/features' into ryzom/ark/features" This reverts commit a6ee9fec6344ec65e0803539ee1d50f4a4964ded. --- code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp index 80c36520c..547388698 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp +++ b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp @@ -2339,8 +2339,8 @@ int CLuaIHMRyzom::addShape(CLuaState &ls) NLMISC::CAABBox bbox; instance.getShapeAABBox(bbox); - primitive->setReactionType(UMovePrimitive::DoNothing); - primitive->setTriggerType(UMovePrimitive::OverlapStairsTrigger); + primitive->setReactionType(UMovePrimitive::Slide); + primitive->setTriggerType(UMovePrimitive::NotATrigger); primitive->setAbsorbtion(0); primitive->setPrimitiveType(UMovePrimitive::_2DOrientedBox); @@ -2349,10 +2349,10 @@ int CLuaIHMRyzom::addShape(CLuaState &ls) primitive->setCollisionMask(MaskColPlayer | MaskColNpc | MaskColDoor); primitive->setOcclusionMask(MaskColPlayer | MaskColNpc | MaskColDoor); - primitive->setObstacle(false); + primitive->setObstacle(true); - primitive->setGlobalPosition(instance.getPos()+CVector(0, 0, 0.5f), dynamicWI); + primitive->setGlobalPosition(instance.getPos(), dynamicWI); primitive->insertInWorldImage(dynamicWI); }