mirror of
https://github.com/overte-org/overte.git
synced 2025-04-23 00:33:37 +02:00
use icons to show network and physics status
This commit is contained in:
parent
774e2ab6d6
commit
66387c4530
7 changed files with 45 additions and 21 deletions
libraries
entities-renderer/src
gpu/src/gpu
render-utils/src
render/src/render
|
@ -15,6 +15,17 @@
|
|||
#include <render/Scene.h>
|
||||
#include <EntityItem.h>
|
||||
|
||||
// These or the icon "name" used by the render item status value, they correspond to the atlas texture used by the DrawItemStatus
|
||||
// job in the current rendering pipeline defined as of now (11/2015) in render-utils/RenderDeferredTask.cpp.
|
||||
enum class RenderItemStatusIcon {
|
||||
PACKET_RECEIVED = 2,
|
||||
PACKET_SENT = 1,
|
||||
ACTIVE_IN_BULLET = 0,
|
||||
SIMULATION_OWNER = 3,
|
||||
|
||||
NONE = 255
|
||||
};
|
||||
|
||||
|
||||
class RenderableEntityItemProxy {
|
||||
public:
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "EntityTreeRenderer.h"
|
||||
#include "EntitiesRendererLogging.h"
|
||||
#include "RenderableModelEntityItem.h"
|
||||
#include "RenderableEntityItem.h"
|
||||
|
||||
EntityItemPointer RenderableModelEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
|
||||
return std::make_shared<RenderableModelEntityItem>(entityID, properties);
|
||||
|
@ -189,7 +190,8 @@ void makeEntityItemStatusGetters(RenderableModelEntityItem* entity, render::Item
|
|||
// Color is red if last update is after WAIT_THRESHOLD, green otherwise (120 deg is green)
|
||||
return render::Item::Status::Value(1.0f - normalizedDelta, (normalizedDelta > 1.0f ?
|
||||
render::Item::Status::Value::GREEN :
|
||||
render::Item::Status::Value::RED));
|
||||
render::Item::Status::Value::RED),
|
||||
(unsigned char) RenderItemStatusIcon::PACKET_RECEIVED);
|
||||
});
|
||||
|
||||
statusGetters.push_back([entity] () -> render::Item::Status::Value {
|
||||
|
@ -200,15 +202,18 @@ void makeEntityItemStatusGetters(RenderableModelEntityItem* entity, render::Item
|
|||
// Color is Magenta if last update is after WAIT_THRESHOLD, cyan otherwise (180 deg is green)
|
||||
return render::Item::Status::Value(1.0f - normalizedDelta, (normalizedDelta > 1.0f ?
|
||||
render::Item::Status::Value::MAGENTA :
|
||||
render::Item::Status::Value::CYAN));
|
||||
render::Item::Status::Value::CYAN),
|
||||
(unsigned char)RenderItemStatusIcon::PACKET_SENT);
|
||||
});
|
||||
|
||||
statusGetters.push_back([entity] () -> render::Item::Status::Value {
|
||||
ObjectMotionState* motionState = static_cast<ObjectMotionState*>(entity->getPhysicsInfo());
|
||||
if (motionState && motionState->isActive()) {
|
||||
return render::Item::Status::Value(1.0f, render::Item::Status::Value::BLUE);
|
||||
return render::Item::Status::Value(1.0f, render::Item::Status::Value::BLUE,
|
||||
(unsigned char)RenderItemStatusIcon::ACTIVE_IN_BULLET);
|
||||
}
|
||||
return render::Item::Status::Value(0.0f, render::Item::Status::Value::BLUE);
|
||||
return render::Item::Status::Value(0.0f, render::Item::Status::Value::BLUE,
|
||||
(unsigned char)RenderItemStatusIcon::ACTIVE_IN_BULLET);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -331,7 +331,7 @@ public:
|
|||
|
||||
template <typename T> Iterator<T> begin() { return Iterator<T>(&edit<T>(0), _stride); }
|
||||
template <typename T> Iterator<T> end() { return Iterator<T>(&edit<T>(getNum<T>()), _stride); }
|
||||
template <typename T> Iterator<const T> cbegin() const { return Iterator<const T>(&get<T>(0), _stride); }
|
||||
template <typename T> Iterator<const T> cbegin() const { return Iterator<const T>(&get<T>(), _stride); }
|
||||
template <typename T> Iterator<const T> cend() const { return Iterator<const T>(&get<T>(getNum<T>()), _stride); }
|
||||
|
||||
// the number of elements of the specified type fitting in the view size
|
||||
|
|
|
@ -112,12 +112,11 @@ RenderDeferredTask::RenderDeferredTask() : Task() {
|
|||
_jobs.push_back(Job(new DepthSortItems::JobModel("DepthSortTransparent", _jobs.back().getOutput(), DepthSortItems(false))));
|
||||
_jobs.push_back(Job(new DrawTransparentDeferred::JobModel("TransparentDeferred", _jobs.back().getOutput())));
|
||||
|
||||
// Grab a texture map representing the different status icons and assign that to the drawStatsuJob
|
||||
auto iconMapPath = PathUtils::resourcesPath() + "images/hifi-logo.svg";
|
||||
|
||||
auto statusIconMap = DependencyManager::get<TextureCache>()->getImageTexture(iconMapPath);
|
||||
_jobs.push_back(Job(new render::DrawStatus::JobModel("DrawStatus", renderedOpaques, DrawStatus(statusIconMap))));
|
||||
// Grab a texture map representing the different status icons and assign that to the drawStatsuJob
|
||||
auto iconMapPath = PathUtils::resourcesPath() + "icons/statusIconAtlas.svg";
|
||||
|
||||
auto statusIconMap = DependencyManager::get<TextureCache>()->getImageTexture(iconMapPath);
|
||||
_jobs.push_back(Job(new render::DrawStatus::JobModel("DrawStatus", renderedOpaques, DrawStatus(statusIconMap))));
|
||||
|
||||
_jobs.back().setEnabled(false);
|
||||
_drawStatusJobIndex = _jobs.size() - 1;
|
||||
|
|
|
@ -212,7 +212,7 @@ public:
|
|||
const static Value INVALID; // Invalid value meanss the status won't show
|
||||
|
||||
Value() {}
|
||||
Value(float scale, float hue, unsigned char icon = 0) { setScale(scale); setColor(hue); setIcon(icon); }
|
||||
Value(float scale, float hue, unsigned char icon = 0xFF) { setScale(scale); setColor(hue); setIcon(icon); }
|
||||
|
||||
// It can be scaled in the range [0, 1]
|
||||
void setScale(float scale);
|
||||
|
|
|
@ -16,12 +16,16 @@ in vec3 varTexcoord;
|
|||
out vec4 outFragColor;
|
||||
|
||||
uniform sampler2D _icons;
|
||||
|
||||
vec2 getIconTexcoord(float icon, vec2 uv) {
|
||||
const vec2 ICON_COORD_SIZE = vec2(0.0625, 1.0);
|
||||
return vec2((uv.x + icon) * ICON_COORD_SIZE.x, uv.y * ICON_COORD_SIZE.y);
|
||||
}
|
||||
|
||||
void main(void) {
|
||||
if (varTexcoord.z > 0.0f) {
|
||||
outFragColor = texture(_icons, varTexcoord.xy) * varColor;
|
||||
if (varTexcoord.z < 254.5) {
|
||||
outFragColor = texture(_icons, getIconTexcoord(varTexcoord.z, varTexcoord.xy)) * varColor;
|
||||
} else {
|
||||
outFragColor = varColor;
|
||||
vec2 centerDir = varTexcoord.xy * 2.0f - 1.0f;
|
||||
outFragColor = vec4(varColor.xyz, 1.0 - step(1.0f, dot(centerDir.xy, centerDir.xy)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,11 +47,11 @@ vec3 paintRainbow(float normalizedHue) {
|
|||
vec3 unpackStatus(int v) {
|
||||
return vec3(clamp(float(int((v >> 0) & 0xFFFF) - 32727) / 32727.0, -1.0, 1.0),
|
||||
clamp(float(uint((v >> 16) & 0xFF)) / 255.0, 0.0, 1.0),
|
||||
clamp(float(int((v >> 24) & 0xFF)), 0.0, 256.0));
|
||||
clamp(float(int((v >> 24) & 0xFF)), 0.0, 255.0));
|
||||
}
|
||||
|
||||
void main(void) {
|
||||
const vec2 ICON_PIXEL_SIZE = vec2(10, 10);
|
||||
const vec2 ICON_PIXEL_SIZE = vec2(20, 20);
|
||||
const vec2 MARGIN_PIXEL_SIZE = vec2(2, 2);
|
||||
const int NUM_VERTICES = 6;
|
||||
const vec4 UNIT_QUAD[NUM_VERTICES] = vec4[NUM_VERTICES](
|
||||
|
@ -79,12 +79,19 @@ void main(void) {
|
|||
return;
|
||||
}
|
||||
|
||||
// Which quad vertex pos?
|
||||
int twoTriID = gl_VertexID - iconNum * NUM_VERTICES;
|
||||
vec4 quadPos = UNIT_QUAD[twoTriID];
|
||||
|
||||
// unpack to get x and y satus
|
||||
vec3 iconStatus = unpackStatus(inStatus[iconNum]);
|
||||
|
||||
// Use the status for showing a color
|
||||
varColor = vec4(paintRainbow(abs(iconStatus.y)), 1.0);
|
||||
|
||||
// Pass the texcoord and the z texcoord is representing the texture icon
|
||||
varTexcoord = vec3((quadPos.xy + 1.0) * 0.5, iconStatus.z);
|
||||
|
||||
// Also changes the size of the notification
|
||||
vec2 iconScale = ICON_PIXEL_SIZE;
|
||||
iconScale = max(vec2(0, 0), (iconScale * iconStatus.x));
|
||||
|
@ -93,13 +100,11 @@ void main(void) {
|
|||
vec2 offset = vec2(iconNum * (ICON_PIXEL_SIZE.x + MARGIN_PIXEL_SIZE.x), 0);
|
||||
|
||||
// Final position in pixel space
|
||||
int twoTriID = gl_VertexID - iconNum * NUM_VERTICES;
|
||||
vec4 pos = UNIT_QUAD[twoTriID];
|
||||
vec2 quadPixelPos = offset.xy + pos.xy * 0.5 * iconScale;
|
||||
vec2 quadPixelPos = offset.xy + quadPos.xy * 0.5 * iconScale;
|
||||
|
||||
vec4 viewport;
|
||||
<$transformCameraViewport(cam, viewport)$>;
|
||||
vec2 pixelToClip = vec2(2.0 / viewport.z, 2.0 / viewport.w);
|
||||
gl_Position = anchorPoint + (anchorPoint.w * vec4(quadPixelPos * pixelToClip, 0.0, 0.0));
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue