[Scummvm-git-logs] scummvm master -> 666750f5a4b7f42533187bbe92c3466b24960bc4
mduggan
noreply at scummvm.org
Sun Feb 12 09:24:35 UTC 2023
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
eebbc25d88 TETRAEDGE: Add casts to fix msvc warnings
dca762e828 TETRAEDGE: Add simpler way to create new meshes
666750f5a4 TETRAEDGE: Add support for loading masks for Syberia 2
Commit: eebbc25d8874b603651ed00713915b85f0325221
https://github.com/scummvm/scummvm/commit/eebbc25d8874b603651ed00713915b85f0325221
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2023-02-12T18:24:27+09:00
Commit Message:
TETRAEDGE: Add casts to fix msvc warnings
Changed paths:
engines/tetraedge/te/te_free_move_zone.cpp
diff --git a/engines/tetraedge/te/te_free_move_zone.cpp b/engines/tetraedge/te/te_free_move_zone.cpp
index 9935ca83aea..943bfc1ee12 100644
--- a/engines/tetraedge/te/te_free_move_zone.cpp
+++ b/engines/tetraedge/te/te_free_move_zone.cpp
@@ -195,19 +195,19 @@ void TeFreeMoveZone::calcGridMatrix() {
float len = diff2.length();
float f = fmod(atan2(diff.z(), diff.x()), M_PI_2);
if (f < 0)
- f += M_PI_2;
+ f += (float)M_PI_2;
if (f - angle < -M_PI_4) {
- angle -= M_PI_2;
+ angle -= (float)M_PI_2;
} else if (f - angle > M_PI_4) {
- f -= M_PI_2;
+ f -= (float)M_PI_2;
}
angle *= mul;
mul += len;
angle = fmod((f * len + angle) / mul, M_PI_2);
if (angle < 0)
- angle += M_PI_2;
+ angle += (float)M_PI_2;
}
const TeQuaternion rot = TeQuaternion::fromAxisAndAngle(TeVector3f32(0, 1, 0), angle);
Commit: dca762e8282892d23e26e206f460d048ad6d8781
https://github.com/scummvm/scummvm/commit/dca762e8282892d23e26e206f460d048ad6d8781
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2023-02-12T18:24:27+09:00
Commit Message:
TETRAEDGE: Add simpler way to create new meshes
Changed paths:
engines/tetraedge/te/te_model.cpp
engines/tetraedge/te/te_model.h
diff --git a/engines/tetraedge/te/te_model.cpp b/engines/tetraedge/te/te_model.cpp
index 774b42f190c..793c2c1502c 100644
--- a/engines/tetraedge/te/te_model.cpp
+++ b/engines/tetraedge/te/te_model.cpp
@@ -609,6 +609,15 @@ TeMatrix4x4 TeModel::skinOffset(uint boneno) const {
return _skinOffsets[boneno];
}
+void TeModel::setMeshCount(uint count) {
+ assert(count < 100000);
+ while (_meshes.size() < count)
+ _meshes.push_back(Common::SharedPtr<TeMesh>(TeMesh::makeInstance()));
+
+ if (_meshes.size() > count)
+ _meshes.resize(count);
+}
+
TeModel::BonesBlender::BonesBlender(TeIntrusivePtr<TeModelAnimation> anim, float seconds) : _anim(anim), _seconds(seconds) {
_anim.setDeleteFn(&TeModelAnimation::deleteLaterStatic);
_timer.stop();
diff --git a/engines/tetraedge/te/te_model.h b/engines/tetraedge/te/te_model.h
index 3e7e66d8d8a..e4b4f68d830 100644
--- a/engines/tetraedge/te/te_model.h
+++ b/engines/tetraedge/te/te_model.h
@@ -134,6 +134,7 @@ public:
void setEnableLights(bool val) { _enableLights = val; }
void setTexturePath(const Common::String &path) { _texturePath = path; }
+ void setMeshCount(uint count);
protected:
TeMatrix4x4 lerpElementsMatrix(uint weightNum, const Common::Array<TeMatrix4x4> &matricies);
Commit: 666750f5a4b7f42533187bbe92c3466b24960bc4
https://github.com/scummvm/scummvm/commit/666750f5a4b7f42533187bbe92c3466b24960bc4
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2023-02-12T18:24:27+09:00
Commit Message:
TETRAEDGE: Add support for loading masks for Syberia 2
Changed paths:
engines/tetraedge/game/game.cpp
engines/tetraedge/game/game.h
engines/tetraedge/game/in_game_scene.cpp
engines/tetraedge/game/in_game_scene.h
engines/tetraedge/game/lua_binds.cpp
engines/tetraedge/te/te_3d_texture.cpp
engines/tetraedge/te/te_3d_texture.h
engines/tetraedge/te/te_material.cpp
engines/tetraedge/te/te_material.h
diff --git a/engines/tetraedge/game/game.cpp b/engines/tetraedge/game/game.cpp
index ec69c08b21f..13a478abdb3 100644
--- a/engines/tetraedge/game/game.cpp
+++ b/engines/tetraedge/game/game.cpp
@@ -1302,7 +1302,7 @@ void Game::pauseMovie() {
sprite->pause();
}
-bool Game::playMovie(const Common::String &vidPath, const Common::String &musicPath) {
+bool Game::playMovie(const Common::String &vidPath, const Common::String &musicPath, float volume /* = 1.0f */) {
Application *app = g_engine->getApplication();
app->captureFade();
TeButtonLayout *videoBackgroundButton = _inGameGui.buttonLayoutChecked("videoBackgroundButton");
@@ -1315,7 +1315,7 @@ bool Game::playMovie(const Common::String &vidPath, const Common::String &musicP
music.stop();
music.setChannelName("video");
music.repeat(false);
- music.volume(1.0f);
+ music.volume(volume);
music.load(musicPath);
_running = false;
diff --git a/engines/tetraedge/game/game.h b/engines/tetraedge/game/game.h
index b035c4f0930..2b1bf49aabc 100644
--- a/engines/tetraedge/game/game.h
+++ b/engines/tetraedge/game/game.h
@@ -145,7 +145,7 @@ public:
void pauseMovie();
void pauseSounds() {}; // does nothing?
- bool playMovie(const Common::String &vidPath, const Common::String &musicPath);
+ bool playMovie(const Common::String &vidPath, const Common::String &musicPath, float volume = 1.0f);
void playRandomSound(const Common::String &name);
void playSound(const Common::String &name, int param_2, float volume);
void removeNoScale2Child(TeLayout *layout);
@@ -181,9 +181,9 @@ public:
bool _isCharacterWalking;
bool _isCharacterIdle;
- const Common::String ¤tZone() { return _currentZone; }
- const Common::String ¤tScene() { return _currentScene; }
- const Common::Path &sceneZonePath() { return _sceneZonePath; }
+ const Common::String ¤tZone() const { return _currentZone; }
+ const Common::String ¤tScene() const { return _currentScene; }
+ const Common::Path &sceneZonePath() const { return _sceneZonePath; }
TeLuaScript &luaScript() { return _luaScript; }
TeLuaContext &luaContext() { return _luaContext; }
InGameScene &scene() { return _scene; }
diff --git a/engines/tetraedge/game/in_game_scene.cpp b/engines/tetraedge/game/in_game_scene.cpp
index 7d4418a6acf..ef7037282d7 100644
--- a/engines/tetraedge/game/in_game_scene.cpp
+++ b/engines/tetraedge/game/in_game_scene.cpp
@@ -53,8 +53,7 @@ bool InGameScene::_collisionSlide = false;
InGameScene::InGameScene() : _character(nullptr), _charactersShadow(nullptr),
_shadowLightNo(-1), _waitTime(-1.0f), _shadowColor(0, 0, 0, 0x80), _shadowFov(20.0f),
-_shadowFarPlane(1000), _shadowNearPlane(1)
- {
+_shadowFarPlane(1000), _shadowNearPlane(1), _maskAlpha(false) {
}
void InGameScene::activateAnchorZone(const Common::String &name, bool val) {
@@ -227,7 +226,7 @@ void InGameScene::close() {
void InGameScene::convertPathToMesh(TeFreeMoveZone *zone) {
TeIntrusivePtr<TeModel> model = new TeModel();
model->meshes().clear();
- model->meshes().push_back(Common::SharedPtr<TeMesh>(TeMesh::makeInstance()));
+ model->setMeshCount(1);
model->setName("shadowReceiving");
model->setPosition(zone->position());
model->setRotation(zone->rotation());
@@ -664,6 +663,17 @@ bool InGameScene::load(const Common::FSNode &sceneNode) {
return true;
}
+static Common::Path _sceneFileNameBase(const Common::String &zone, const Common::String &scene) {
+ Common::Path retval("scenes");
+ retval.joinInPlace(zone).joinInPlace(scene);
+ return retval;
+}
+
+static Common::Path _sceneFileNameBase() {
+ const Game *game = g_engine->getGame();
+ return _sceneFileNameBase(game->currentZone(), game->currentScene());
+}
+
bool InGameScene::loadXml(const Common::String &zone, const Common::String &scene) {
_zoneName = zone;
_sceneName = scene;
@@ -673,7 +683,7 @@ bool InGameScene::loadXml(const Common::String &zone, const Common::String &scen
loadActZones();
loadBlockers();
- Common::Path xmlpath = Common::Path("scenes").joinInPlace(zone).joinInPlace(scene).joinInPlace("Scene")
+ Common::Path xmlpath = _sceneFileNameBase(zone, scene).joinInPlace("Scene")
.appendInPlace(scene).appendInPlace(".xml");
Common::FSNode node = g_engine->getCore()->findFile(xmlpath);
InGameSceneXmlParser parser;
@@ -710,14 +720,6 @@ void InGameScene::loadActZones() {
}
}
-static Common::Path _sceneFileNameBase() {
- Game *game = g_engine->getGame();
- Common::Path retval("scenes");
- retval.joinInPlace(game->currentZone());
- retval.joinInPlace(game->currentScene());
- return retval;
-}
-
bool InGameScene::loadCamera(const Common::String &name) {
Common::Path p = _sceneFileNameBase().joinInPlace(name).appendInPlace(".xml");
TeCamera *cam = new TeCamera();
@@ -873,12 +875,9 @@ bool InGameScene::loadDynamicLightBloc(const Common::String &name, const Common:
file.open(datnode);
TeModel *model = new TeModel();
- model->meshes().resize(1);
+ model->setMeshCount(1);
model->setName(datnode.getName());
- TeVector3f32 vec;
- TeVector2f32 vec2;
- TeVector3f32::deserialize(file, vec);
// Read position/rotation/scale.
model->deserialize(file, *model);
@@ -890,6 +889,8 @@ bool InGameScene::loadDynamicLightBloc(const Common::String &name, const Common:
TeMesh *mesh = model->meshes()[0].get();
mesh->setConf(verts, tricount * 3, TeMesh::MeshMode_Triangles, 0, 0);
+ TeVector3f32 vec;
+ TeVector2f32 vec2;
for (uint i = 0; i < verts; i++) {
TeVector3f32::deserialize(file, vec);
mesh->setVertex(i, vec);
@@ -901,14 +902,14 @@ bool InGameScene::loadDynamicLightBloc(const Common::String &name, const Common:
mesh->setTextureUV(i, vec2);
}
- for (uint i = 0; i < tricount; i++)
+ for (uint i = 0; i < tricount * 3; i++)
mesh->setIndex(i, file.readUint16LE());
file.close();
if (texnode.isReadable()) {
TeIntrusivePtr<Te3DTexture> tex = Te3DTexture::makeInstance();
- tex->load2(texnode, 0x500);
+ tex->load2(texnode, false);
mesh->defaultMaterial(tex);
} else if (texture.size()) {
warning("loadDynamicLightBloc: Failed to load texture %s", texture.c_str());
@@ -926,7 +927,66 @@ bool InGameScene::loadLight(const Common::String &fname, const Common::String &z
}
bool InGameScene::loadMask(const Common::String &name, const Common::String &texture, const Common::String &zone, const Common::String &scene) {
- warning("TODO: Implement InGameScene::loadMask");
+ TeCore *core = g_engine->getCore();
+ Common::Path datpath = _sceneFileNameBase(zone, scene).joinInPlace(name).appendInPlace(".bin");
+ Common::Path texpath = _sceneFileNameBase(zone, scene).joinInPlace(texture);
+ Common::FSNode datnode = core->findFile(datpath);
+ if (!datnode.isReadable()) {
+ warning("[InGameScene::loadMask] Can't open file : %s.", datpath.toString().c_str());
+ return false;
+ }
+ TeModel *model = new TeModel();
+ model->setMeshCount(1);
+ model->setName(name);
+
+ Common::File file;
+ file.open(datnode);
+
+ // Load position, rotation, size.
+ Te3DObject2::deserialize(file, *model, false);
+
+ uint32 verts = file.readUint32LE();
+ uint32 tricount = file.readUint32LE();
+ if (verts > 100000 || tricount > 10000)
+ error("Improbable number of verts (%d) or triangles (%d)", verts, tricount);
+
+ TeMesh *mesh = model->meshes()[0].get();
+ mesh->setConf(verts, tricount * 3, TeMesh::MeshMode_Triangles, 0, 0);
+
+ TeVector3f32 vec;
+ TeVector2f32 vec2;
+ for (uint i = 0; i < verts; i++) {
+ TeVector3f32::deserialize(file, vec);
+ mesh->setVertex(i, vec);
+ mesh->setNormal(i, TeVector3f32(0, 0, 1));
+ if (_maskAlpha) {
+ mesh->setColor(TeColor(255, 255, 255, 128));
+ }
+ }
+ for (uint i = 0; i < verts; i++) {
+ TeVector2f32::deserialize(file, vec2);
+ vec.y() = 1.0 - vec.y();
+ mesh->setTextureUV(i, vec2);
+ }
+
+ // For some reason this one has the indexes in reverse order :(
+ for (uint i = 0; i < tricount * 3; i += 3) {
+ mesh->setIndex(i + 2, file.readUint16LE());
+ mesh->setIndex(i + 1, file.readUint16LE());
+ mesh->setIndex(i, file.readUint16LE());
+ }
+
+ file.close();
+ Common::FSNode texnode = core->findFile(texpath);
+ TeIntrusivePtr<Te3DTexture> tex = Te3DTexture::makeInstance();
+ tex->load2(texnode, !_maskAlpha);
+ mesh->defaultMaterial(tex);
+
+ if (!_maskAlpha) {
+ mesh->materials()[0]._mode = TeMaterial::MaterialMode2;
+ }
+
+ _masks.push_back(model);
return true;
}
diff --git a/engines/tetraedge/game/in_game_scene.h b/engines/tetraedge/game/in_game_scene.h
index 7ff1955db76..02bd3948688 100644
--- a/engines/tetraedge/game/in_game_scene.h
+++ b/engines/tetraedge/game/in_game_scene.h
@@ -277,7 +277,7 @@ private:
static bool _collisionSlide;
Common::String _sceneName;
Common::String _zoneName;
-
+ bool _maskAlpha;
};
diff --git a/engines/tetraedge/game/lua_binds.cpp b/engines/tetraedge/game/lua_binds.cpp
index 4b533ad5aab..531c2d71386 100644
--- a/engines/tetraedge/game/lua_binds.cpp
+++ b/engines/tetraedge/game/lua_binds.cpp
@@ -82,14 +82,16 @@ static void PlayMovie(const Common::String &vidpath, const Common::String &music
game->playMovie(vidpath, musicpath);
}
-static void PlayMovie(const Common::String &vidpath, const Common::String &musicpath, double f) {
+static void PlayMovie(const Common::String &vidpath, const Common::String &musicpath, double volume) {
Game *game = g_engine->getGame();
- warning("TODO: handle float value %f in PlayMovie for Syberia 2", f);
- if (!game->playMovie(vidpath, musicpath)) {
- warning("[PlayMovie] Movie \"%s\" doesn\'t exist.", vidpath.c_str());
+ if (!game->playMovie(vidpath, musicpath, (float)volume)) {
+ warning("[PlayMovie] Movie \"%s\" doesn't exist.", vidpath.c_str());
+ return;
}
- // TODO: call Game::addMoviePlayed
+
+ warning("TODO: call Game::addMoviePlayed");
+ //game->addMoviePlayed(vidpath, musicpath);
}
diff --git a/engines/tetraedge/te/te_3d_texture.cpp b/engines/tetraedge/te/te_3d_texture.cpp
index 8a9e5517128..fcaa8841023 100644
--- a/engines/tetraedge/te/te_3d_texture.cpp
+++ b/engines/tetraedge/te/te_3d_texture.cpp
@@ -44,7 +44,7 @@ bool Te3DTexture::hasAlpha() const {
}
/*static*/
-TeIntrusivePtr<Te3DTexture> Te3DTexture::load2(const Common::FSNode &node, uint size) {
+TeIntrusivePtr<Te3DTexture> Te3DTexture::load2(const Common::FSNode &node, bool alphaOnly) {
const Common::String fullPath = node.getPath() + ".3dtex";
TeResourceManager *resMgr = g_engine->getResourceManager();
diff --git a/engines/tetraedge/te/te_3d_texture.h b/engines/tetraedge/te/te_3d_texture.h
index fa146c7bc33..df614cdda1c 100644
--- a/engines/tetraedge/te/te_3d_texture.h
+++ b/engines/tetraedge/te/te_3d_texture.h
@@ -50,7 +50,9 @@ public:
bool load(const Common::FSNode &path);
virtual bool load(const TeImage &img) = 0;
- static TeIntrusivePtr<Te3DTexture> load2(const Common::FSNode &node, uint size);
+ // The original passes a GL enum param, but it's only ever GL_INVALID or GL_ALPHA.
+ // Simplify to avoid leaking gl types.
+ static TeIntrusivePtr<Te3DTexture> load2(const Common::FSNode &node, bool alphaOnly);
static TeVector2s32 optimisedSize(const TeVector2s32 &size);
diff --git a/engines/tetraedge/te/te_material.cpp b/engines/tetraedge/te/te_material.cpp
index e5c45ad7dbc..5e6465ec1db 100644
--- a/engines/tetraedge/te/te_material.cpp
+++ b/engines/tetraedge/te/te_material.cpp
@@ -99,7 +99,7 @@ void TeMaterial::deserialize(Common::SeekableReadStream &stream, TeMaterial &mat
if (nameStr.size()) {
TeCore *core = g_engine->getCore();
Common::FSNode texNode = core->findFile(Common::Path(texPath).join(nameStr));
- material._texture = Te3DTexture::load2(texNode, 0x500);
+ material._texture = Te3DTexture::load2(texNode, false);
if (!material._texture)
warning("failed to load texture %s (texpath %s)", nameStr.c_str(), texPath.c_str());
}
diff --git a/engines/tetraedge/te/te_material.h b/engines/tetraedge/te/te_material.h
index 86648a08ff0..047f1e4f08f 100644
--- a/engines/tetraedge/te/te_material.h
+++ b/engines/tetraedge/te/te_material.h
@@ -36,7 +36,8 @@ class TeMaterial {
public:
enum Mode {
MaterialMode0,
- MaterialMode1
+ MaterialMode1,
+ MaterialMode2
};
TeMaterial();
More information about the Scummvm-git-logs
mailing list