mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 13:40:02 +02:00
working on loading fade
This commit is contained in:
parent
a9c6d69aa6
commit
217a102926
2 changed files with 22 additions and 1 deletions
|
@ -329,6 +329,8 @@ ModelMeshPartPayload::ModelMeshPartPayload(Model* model, int _meshIndex, int par
|
||||||
|
|
||||||
updateTransform(transform, offsetTransform);
|
updateTransform(transform, offsetTransform);
|
||||||
initCache();
|
initCache();
|
||||||
|
|
||||||
|
_fadeStartTime = usecTimestampNow();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelMeshPartPayload::initCache() {
|
void ModelMeshPartPayload::initCache() {
|
||||||
|
@ -352,6 +354,11 @@ void ModelMeshPartPayload::initCache() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float ModelMeshPartPayload::calcFadeRatio() const {
|
||||||
|
const float FADE_TIME = 0.5f;
|
||||||
|
float t = std::min(((float)(usecTimestampNow() - _fadeStartTime)) / ((float)(FADE_TIME * USECS_PER_SECOND)), 1.0f);
|
||||||
|
return -0.5f * (cosf(M_PI*t) - 1.0f);
|
||||||
|
}
|
||||||
|
|
||||||
void ModelMeshPartPayload::notifyLocationChanged() {
|
void ModelMeshPartPayload::notifyLocationChanged() {
|
||||||
|
|
||||||
|
@ -392,6 +399,10 @@ ItemKey ModelMeshPartPayload::getKey() const {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (calcFadeRatio() < 1.0f) {
|
||||||
|
builder.withTransparent();
|
||||||
|
}
|
||||||
|
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -429,7 +440,7 @@ ShapeKey ModelMeshPartPayload::getShapeKey() const {
|
||||||
drawMaterialKey = _drawMaterial->getKey();
|
drawMaterialKey = _drawMaterial->getKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isTranslucent = drawMaterialKey.isTranslucent();
|
bool isTranslucent = drawMaterialKey.isTranslucent() || calcFadeRatio() < 1.0f;
|
||||||
bool hasTangents = drawMaterialKey.isNormalMap() && !mesh.tangents.isEmpty();
|
bool hasTangents = drawMaterialKey.isNormalMap() && !mesh.tangents.isEmpty();
|
||||||
bool hasSpecular = drawMaterialKey.isMetallicMap();
|
bool hasSpecular = drawMaterialKey.isMetallicMap();
|
||||||
bool hasLightmap = drawMaterialKey.isLightmapMap();
|
bool hasLightmap = drawMaterialKey.isLightmapMap();
|
||||||
|
@ -541,6 +552,9 @@ void ModelMeshPartPayload::render(RenderArgs* args) const {
|
||||||
// apply material properties
|
// apply material properties
|
||||||
bindMaterial(batch, locations);
|
bindMaterial(batch, locations);
|
||||||
|
|
||||||
|
// model fading
|
||||||
|
batch._glColor4f(1.0f, 1.0f, 1.0f, calcFadeRatio());
|
||||||
|
|
||||||
if (args) {
|
if (args) {
|
||||||
args->_details._materialSwitches++;
|
args->_details._materialSwitches++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,6 +81,9 @@ public:
|
||||||
void notifyLocationChanged() override;
|
void notifyLocationChanged() override;
|
||||||
void updateTransformForSkinnedMesh(const Transform& transform, const Transform& offsetTransform, const QVector<glm::mat4>& clusterMatrices);
|
void updateTransformForSkinnedMesh(const Transform& transform, const Transform& offsetTransform, const QVector<glm::mat4>& clusterMatrices);
|
||||||
|
|
||||||
|
// Entity fade in
|
||||||
|
float calcFadeRatio() const;
|
||||||
|
|
||||||
// Render Item interface
|
// Render Item interface
|
||||||
render::ItemKey getKey() const override;
|
render::ItemKey getKey() const override;
|
||||||
render::ShapeKey getShapeKey() const override; // shape interface
|
render::ShapeKey getShapeKey() const override; // shape interface
|
||||||
|
@ -99,6 +102,10 @@ public:
|
||||||
|
|
||||||
bool _isSkinned{ false };
|
bool _isSkinned{ false };
|
||||||
bool _isBlendShaped{ false };
|
bool _isBlendShaped{ false };
|
||||||
|
|
||||||
|
private:
|
||||||
|
quint64 _fadeStartTime { usecTimestampNow() };
|
||||||
|
bool _hasFadeStarted { false };
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace render {
|
namespace render {
|
||||||
|
|
Loading…
Reference in a new issue