summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/guiFormSpecMenu.cpp4
-rw-r--r--src/gui/guiScene.cpp15
-rw-r--r--src/gui/guiScene.h1
3 files changed, 16 insertions, 4 deletions
diff --git a/src/gui/guiFormSpecMenu.cpp b/src/gui/guiFormSpecMenu.cpp
index 5aa6dc9ae..5d763a4be 100644
--- a/src/gui/guiFormSpecMenu.cpp
+++ b/src/gui/guiFormSpecMenu.cpp
@@ -2746,7 +2746,7 @@ void GUIFormSpecMenu::parseModel(parserData *data, const std::string &element)
{
std::vector<std::string> parts = split(element, ';');
- if (parts.size() < 5 || (parts.size() > 9 &&
+ if (parts.size() < 5 || (parts.size() > 10 &&
m_formspec_version <= FORMSPEC_API_VERSION)) {
errorstream << "Invalid model element (" << parts.size() << "): '" << element
<< "'" << std::endl;
@@ -2766,6 +2766,7 @@ void GUIFormSpecMenu::parseModel(parserData *data, const std::string &element)
bool inf_rotation = is_yes(parts[6]);
bool mousectrl = is_yes(parts[7]) || parts[7].empty(); // default true
std::vector<std::string> frame_loop = split(parts[8], ',');
+ std::string speed = unescape_string(parts[9]);
MY_CHECKPOS("model", 0);
MY_CHECKGEOM("model", 1);
@@ -2825,6 +2826,7 @@ void GUIFormSpecMenu::parseModel(parserData *data, const std::string &element)
}
e->setFrameLoop(frame_loop_begin, frame_loop_end);
+ e->setAnimationSpeed(stof(speed));
auto style = getStyleForElement("model", spec.fname);
e->setStyles(style);
diff --git a/src/gui/guiScene.cpp b/src/gui/guiScene.cpp
index 5f4c50b91..f0cfbec5e 100644
--- a/src/gui/guiScene.cpp
+++ b/src/gui/guiScene.cpp
@@ -34,9 +34,6 @@ GUIScene::GUIScene(gui::IGUIEnvironment *env, scene::ISceneManager *smgr,
m_cam = m_smgr->addCameraSceneNode(0, v3f(0.f, 0.f, -100.f), v3f(0.f));
m_cam->setFOV(30.f * core::DEGTORAD);
- scene::ILightSceneNode *light = m_smgr->addLightSceneNode(m_cam);
- light->setRadius(1000.f);
-
m_smgr->getParameters()->setAttribute(scene::ALLOW_ZWRITE_ON_TRANSPARENT, true);
}
@@ -60,6 +57,7 @@ scene::IAnimatedMeshSceneNode *GUIScene::setMesh(scene::IAnimatedMesh *mesh)
m_mesh = m_smgr->addAnimatedMeshSceneNode(mesh);
m_mesh->setPosition(-m_mesh->getBoundingBox().getCenter());
m_mesh->animateJoints();
+
return m_mesh;
}
@@ -73,10 +71,13 @@ void GUIScene::setTexture(u32 idx, video::ITexture *texture)
material.setFlag(video::EMF_FOG_ENABLE, true);
material.setFlag(video::EMF_BILINEAR_FILTER, false);
material.setFlag(video::EMF_BACK_FACE_CULLING, false);
+ material.setFlag(video::EMF_ZWRITE_ENABLE, true);
}
void GUIScene::draw()
{
+ m_driver->clearBuffers(video::ECBF_DEPTH);
+
// Control rotation speed based on time
u64 new_time = porting::getTimeMs();
u64 dtime_ms = 0;
@@ -161,6 +162,14 @@ void GUIScene::setFrameLoop(s32 begin, s32 end)
m_mesh->setFrameLoop(begin, end);
}
+/**
+ * Sets the animation speed (FPS) for the mesh
+ */
+void GUIScene::setAnimationSpeed(f32 speed)
+{
+ m_mesh->setAnimationSpeed(speed);
+}
+
/* Camera control functions */
inline void GUIScene::calcOptimalDistance()
diff --git a/src/gui/guiScene.h b/src/gui/guiScene.h
index 08eb7f350..0f5f3a891 100644
--- a/src/gui/guiScene.h
+++ b/src/gui/guiScene.h
@@ -37,6 +37,7 @@ public:
void setTexture(u32 idx, video::ITexture *texture);
void setBackgroundColor(const video::SColor &color) noexcept { m_bgcolor = color; };
void setFrameLoop(s32 begin, s32 end);
+ void setAnimationSpeed(f32 speed);
void enableMouseControl(bool enable) noexcept { m_mouse_ctrl = enable; };
void setRotation(v2f rot) noexcept { m_custom_rot = rot; };
void enableContinuousRotation(bool enable) noexcept { m_inf_rot = enable; };