mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-04 01:46:42 +00:00
EMI: Implement Lua functions for getting camera rotation.
This commit is contained in:
parent
ff9f26981c
commit
32a41525ee
@ -308,14 +308,100 @@ void Lua_V2::GetCameraPosition() {
|
|||||||
lua_pushnumber(setup->_pos.z());
|
lua_pushnumber(setup->_pos.z());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Lua_V2::GetCameraPitch() {
|
||||||
|
Set *set = g_grim->getCurrSet();
|
||||||
|
if (set == nullptr) {
|
||||||
|
lua_pushnil();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Set::Setup *setup = set->getCurrSetup();
|
||||||
|
float pitch;
|
||||||
|
if (g_grim->getGameType() == GType_MONKEY4) {
|
||||||
|
setup->getRotation(nullptr, nullptr, &pitch);
|
||||||
|
} else {
|
||||||
|
setup->getRotation(nullptr, &pitch, nullptr);
|
||||||
|
}
|
||||||
|
lua_pushnumber(pitch);
|
||||||
|
}
|
||||||
|
|
||||||
void Lua_V2::GetCameraYaw() {
|
void Lua_V2::GetCameraYaw() {
|
||||||
warning("Lua_V2::GetCameraYaw: implement opcode, just returns 0");
|
Set *set = g_grim->getCurrSet();
|
||||||
lua_pushnumber(0);
|
if (set == nullptr) {
|
||||||
|
lua_pushnil();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Set::Setup *setup = set->getCurrSetup();
|
||||||
|
float yaw;
|
||||||
|
if (g_grim->getGameType() == GType_MONKEY4) {
|
||||||
|
setup->getRotation(nullptr, &yaw, nullptr);
|
||||||
|
} else {
|
||||||
|
setup->getRotation(&yaw, nullptr, nullptr);
|
||||||
|
}
|
||||||
|
lua_pushnumber(yaw);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Lua_V2::GetCameraRoll() {
|
void Lua_V2::GetCameraRoll() {
|
||||||
warning("Lua_V2::GetCameraRoll: implement opcode, just returns 0");
|
Set *set = g_grim->getCurrSet();
|
||||||
lua_pushnumber(0);
|
if (set == nullptr) {
|
||||||
|
lua_pushnil();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Set::Setup *setup = set->getCurrSetup();
|
||||||
|
float roll;
|
||||||
|
if (g_grim->getGameType() == GType_MONKEY4) {
|
||||||
|
setup->getRotation(&roll, nullptr, nullptr);
|
||||||
|
} else {
|
||||||
|
setup->getRotation(nullptr, nullptr, &roll);
|
||||||
|
}
|
||||||
|
lua_pushnumber(roll);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Lua_V2::PitchCamera() {
|
||||||
|
lua_Object pitchObj = lua_getparam(1);
|
||||||
|
if (!lua_isnumber(pitchObj)) {
|
||||||
|
error("Lua_V2::PitchCamera - Parameter is not a number!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Set *set = g_grim->getCurrSet();
|
||||||
|
if (set == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Set::Setup *setup = set->getCurrSetup();
|
||||||
|
setup->setPitch(Math::Angle(lua_getnumber(pitchObj)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Lua_V2::YawCamera() {
|
||||||
|
lua_Object yawObj = lua_getparam(1);
|
||||||
|
if (!lua_isnumber(yawObj)) {
|
||||||
|
error("Lua_V2::YawCamera - Parameter is not a number!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Set *set = g_grim->getCurrSet();
|
||||||
|
if (set == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Set::Setup *setup = set->getCurrSetup();
|
||||||
|
setup->setYaw(Math::Angle(lua_getnumber(yawObj)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Lua_V2::RollCamera() {
|
||||||
|
lua_Object rollObj = lua_getparam(1);
|
||||||
|
if (!lua_isnumber(rollObj)) {
|
||||||
|
error("Lua_V2::RollCamera - Parameter is not a number!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Set *set = g_grim->getCurrSet();
|
||||||
|
if (set == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Set::Setup *setup = set->getCurrSetup();
|
||||||
|
setup->setRoll(Math::Angle(lua_getnumber(rollObj)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Lua_V2::PushText() {
|
void Lua_V2::PushText() {
|
||||||
@ -638,41 +724,6 @@ static void stubError(const char *funcName) {
|
|||||||
|
|
||||||
// Stubbed functions with semi-known arguments:
|
// Stubbed functions with semi-known arguments:
|
||||||
// TODO: Verify and implement these: (And add type-checking), also rename params
|
// TODO: Verify and implement these: (And add type-checking), also rename params
|
||||||
void Lua_V2::GetCameraPitch() {
|
|
||||||
error("Lua_V2::GetCameraPitch() - TODO: Implement opcode");
|
|
||||||
}
|
|
||||||
|
|
||||||
// No idea about parameter types for these three, presumably float
|
|
||||||
void Lua_V2::PitchCamera() {
|
|
||||||
lua_Object param1 = lua_getparam(1);
|
|
||||||
|
|
||||||
if (!lua_isnumber(param1))
|
|
||||||
error("Lua_V2::PitchCamera - Unknown parameters");
|
|
||||||
|
|
||||||
float floatValue = lua_getnumber(param1);
|
|
||||||
error("Lua_V2::PitchCamera(%f) - TODO: Implement opcode", floatValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Lua_V2::RollCamera() {
|
|
||||||
lua_Object param1 = lua_getparam(1);
|
|
||||||
|
|
||||||
if (!lua_isnumber(param1))
|
|
||||||
error("Lua_V2::RollCamera - Unknown parameters");
|
|
||||||
|
|
||||||
float floatValue = lua_getnumber(param1);
|
|
||||||
error("Lua_V2::RollCamera(%f) - TODO: Implement opcode", floatValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Lua_V2::YawCamera() {
|
|
||||||
lua_Object param1 = lua_getparam(1);
|
|
||||||
|
|
||||||
if (!lua_isnumber(param1))
|
|
||||||
error("Lua_V2::YawCamera - Unknown parameters");
|
|
||||||
|
|
||||||
float floatValue = lua_getnumber(param1);
|
|
||||||
error("Lua_V2::YawCamera(%f) - TODO: Implement opcode", floatValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Lua_V2::NukeAllScriptLocks() {
|
void Lua_V2::NukeAllScriptLocks() {
|
||||||
warning("Lua_V2::NukeAllScriptLocks() - TODO: Implement opcode");
|
warning("Lua_V2::NukeAllScriptLocks() - TODO: Implement opcode");
|
||||||
}
|
}
|
||||||
|
@ -461,6 +461,54 @@ Light::Light() : _intensity(0.0f), _umbraangle(0.0f), _penumbraangle(0.0f),
|
|||||||
_falloffNear(0.0f), _falloffFar(0.0f), _enabled(false), _id(0) {
|
_falloffNear(0.0f), _falloffFar(0.0f), _enabled(false), _id(0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Set::Setup::getRotation(float *x, float *y, float *z) {
|
||||||
|
Math::Angle aX, aY, aZ;
|
||||||
|
if (g_grim->getGameType() == GType_MONKEY4)
|
||||||
|
_rot.getXYZ(&aX, &aY, &aZ, Math::EO_ZYX);
|
||||||
|
else
|
||||||
|
_rot.getXYZ(&aX, &aY, &aZ, Math::EO_ZXY);
|
||||||
|
|
||||||
|
if (x != nullptr)
|
||||||
|
*x = aX.getDegrees();
|
||||||
|
if (y != nullptr)
|
||||||
|
*y = aY.getDegrees();
|
||||||
|
if (z != nullptr)
|
||||||
|
*z = aZ.getDegrees();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Set::Setup::setPitch(Math::Angle pitch) {
|
||||||
|
Math::Angle oldYaw, oldRoll;
|
||||||
|
if (g_grim->getGameType() == GType_MONKEY4) {
|
||||||
|
_rot.getXYZ(&oldRoll, &oldYaw, nullptr, Math::EO_ZYX);
|
||||||
|
_rot.buildFromXYZ(oldRoll, oldYaw, pitch, Math::EO_ZYX);
|
||||||
|
} else {
|
||||||
|
_rot.getXYZ(&oldYaw, nullptr, &oldRoll, Math::EO_ZXY);
|
||||||
|
_rot.buildFromXYZ(oldYaw, pitch, oldRoll, Math::EO_ZXY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Set::Setup::setYaw(Math::Angle yaw) {
|
||||||
|
Math::Angle oldPitch, oldRoll;
|
||||||
|
if (g_grim->getGameType() == GType_MONKEY4) {
|
||||||
|
_rot.getXYZ(&oldRoll, nullptr, &oldPitch, Math::EO_ZYX);
|
||||||
|
_rot.buildFromXYZ(oldRoll, yaw, oldPitch, Math::EO_ZYX);
|
||||||
|
} else {
|
||||||
|
_rot.getXYZ(nullptr, &oldPitch, &oldRoll, Math::EO_ZXY);
|
||||||
|
_rot.buildFromXYZ(yaw, oldPitch, oldRoll, Math::EO_ZXY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Set::Setup::setRoll(Math::Angle roll) {
|
||||||
|
Math::Angle oldPitch, oldYaw;
|
||||||
|
if (g_grim->getGameType() == GType_MONKEY4) {
|
||||||
|
_rot.getXYZ(nullptr, &oldYaw, &oldPitch, Math::EO_ZYX);
|
||||||
|
_rot.buildFromXYZ(roll, oldYaw, oldPitch, Math::EO_ZYX);
|
||||||
|
} else {
|
||||||
|
_rot.getXYZ(&oldYaw, &oldPitch, nullptr, Math::EO_ZXY);
|
||||||
|
_rot.buildFromXYZ(oldYaw, oldPitch, roll, Math::EO_ZXY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Light::load(TextSplitter &ts) {
|
void Light::load(TextSplitter &ts) {
|
||||||
char buf[256];
|
char buf[256];
|
||||||
|
|
||||||
|
@ -120,6 +120,12 @@ public:
|
|||||||
void saveState(SaveGame *savedState) const;
|
void saveState(SaveGame *savedState) const;
|
||||||
bool restoreState(SaveGame *savedState);
|
bool restoreState(SaveGame *savedState);
|
||||||
|
|
||||||
|
void getRotation(float *x, float *y, float *z);
|
||||||
|
Math::Matrix4 getRotation() { return _rot; }
|
||||||
|
void setPitch(Math::Angle p);
|
||||||
|
void setYaw(Math::Angle y);
|
||||||
|
void setRoll(Math::Angle r);
|
||||||
|
|
||||||
Common::String _name;
|
Common::String _name;
|
||||||
Bitmap::Ptr _bkgndBm, _bkgndZBm;
|
Bitmap::Ptr _bkgndBm, _bkgndZBm;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user