mirror of
https://github.com/overte-org/overte.git
synced 2025-04-15 07:27:17 +02:00
Initial broken work for Canvas entity
This commit is contained in:
parent
b38237cb8d
commit
e97ded844b
7 changed files with 195 additions and 1 deletions
|
@ -0,0 +1,33 @@
|
||||||
|
//
|
||||||
|
// Created by Ada <ada@thingvellir.net> on 2025-02-24
|
||||||
|
// Copyright 2025 Overte e.V.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "RenderableCanvasEntityItem.h"
|
||||||
|
|
||||||
|
using namespace render;
|
||||||
|
using namespace render::entities;
|
||||||
|
|
||||||
|
CanvasEntityRenderer::CanvasEntityRenderer(const EntityItemPointer& entity) : Parent(entity) {
|
||||||
|
gpu::Byte pixels[256 * 256 * 4];
|
||||||
|
|
||||||
|
// grayscale XOR placeholder texture
|
||||||
|
for (int x = 0; x < 256; x++) {
|
||||||
|
for (int y = 0; y < 256; y++) {
|
||||||
|
pixels[(y * 256 * 4) + (x * 4) + 0] = 255;
|
||||||
|
pixels[(y * 256 * 4) + (x * 4) + 1] = 0;
|
||||||
|
pixels[(y * 256 * 4) + (x * 4) + 2] = 255;
|
||||||
|
pixels[(y * 256 * 4) + (x * 4) + 3] = 255;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_texture = gpu::Texture::create2D(gpu::Element::COLOR_SRGBA_32, 256, 256);
|
||||||
|
_texture->setStoredMipFormat(gpu::Element::COLOR_SRGBA_32);
|
||||||
|
_texture->assignStoredMip(0, 256 * 256 * 4, pixels);
|
||||||
|
_texture->setSource(__FUNCTION__);
|
||||||
|
}
|
||||||
|
|
||||||
|
CanvasEntityRenderer::~CanvasEntityRenderer() { }
|
41
libraries/entities-renderer/src/RenderableCanvasEntityItem.h
Normal file
41
libraries/entities-renderer/src/RenderableCanvasEntityItem.h
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
//
|
||||||
|
// Created by Ada <ada@thingvellir.net> on 2025-02-24
|
||||||
|
// Copyright 2025 Overte e.V.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef hifi_RenderableCanvasEntityItem_h
|
||||||
|
#define hifi_RenderableCanvasEntityItem_h
|
||||||
|
|
||||||
|
#include <CanvasEntityItem.h>
|
||||||
|
#include "RenderableEntityItem.h"
|
||||||
|
|
||||||
|
namespace render { namespace entities {
|
||||||
|
|
||||||
|
class CanvasEntityRenderer : public TypedEntityRenderer<CanvasEntityItem> {
|
||||||
|
Q_OBJECT
|
||||||
|
using Parent = TypedEntityRenderer<CanvasEntityItem>;
|
||||||
|
friend class EntityRenderer;
|
||||||
|
|
||||||
|
public:
|
||||||
|
CanvasEntityRenderer(const EntityItemPointer& entity);
|
||||||
|
~CanvasEntityRenderer();
|
||||||
|
|
||||||
|
gpu::TexturePointer getTexture() override { return _texture; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void doRender(RenderArgs* args) override { }
|
||||||
|
virtual bool isTransparent() const override { return false; }
|
||||||
|
virtual bool wantsHandControllerPointerEvents() const override { return false; }
|
||||||
|
virtual bool wantsKeyboardFocus() const override { return false; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
gpu::TexturePointer _texture;
|
||||||
|
};
|
||||||
|
|
||||||
|
} }
|
||||||
|
|
||||||
|
#endif // hifi_RenderableCanvasEntityItem_h
|
88
libraries/entities/src/CanvasEntityItem.cpp.in
Normal file
88
libraries/entities/src/CanvasEntityItem.cpp.in
Normal file
|
@ -0,0 +1,88 @@
|
||||||
|
//
|
||||||
|
// Created by Ada <ada@thingvellir.net> on 2025-02-04
|
||||||
|
// Copyright 2025 Overte e.V.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache license, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
|
||||||
|
#include "CanvasEntityItem.h"
|
||||||
|
|
||||||
|
#include <QtCore/QDebug>
|
||||||
|
|
||||||
|
#include "EntitiesLogging.h"
|
||||||
|
#include "EntityItemProperties.h"
|
||||||
|
#include "EntityTreeElement.h"
|
||||||
|
|
||||||
|
EntityItemPointer CanvasEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
|
||||||
|
std::shared_ptr<CanvasEntityItem> entity(new CanvasEntityItem(entityID), [](CanvasEntityItem* ptr) { ptr->deleteLater(); });
|
||||||
|
entity->setProperties(properties);
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
|
|
||||||
|
CanvasEntityItem::CanvasEntityItem(const EntityItemID& entityItemID) : EntityItem(entityItemID) {
|
||||||
|
_type = EntityTypes::Canvas;
|
||||||
|
}
|
||||||
|
|
||||||
|
CanvasEntityItem::~CanvasEntityItem() {}
|
||||||
|
|
||||||
|
void CanvasEntityItem::debugDump() const {
|
||||||
|
qCDebug(entities) << "CanvasEntityItem id:" << getEntityItemID() << "---------------------------------------------";
|
||||||
|
qCDebug(entities) << " name:" << _name;
|
||||||
|
qCDebug(entities) << " position:" << debugTreeVector(getWorldPosition());
|
||||||
|
qCDebug(entities) << " dimensions:" << debugTreeVector(getScaledDimensions());
|
||||||
|
qCDebug(entities) << " editedAgo:" << debugTime(getLastEdited(), usecTimestampNow());
|
||||||
|
qCDebug(entities) << " pointer:" << this;
|
||||||
|
|
||||||
|
@Base_ENTITY_DEBUG@
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CanvasEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBitstreamParams& params,
|
||||||
|
EntityTreeElementExtraEncodeDataPointer entityTreeElementExtraEncodeData,
|
||||||
|
EntityPropertyFlags& requestedProperties,
|
||||||
|
EntityPropertyFlags& propertyFlags,
|
||||||
|
EntityPropertyFlags& propertiesDidntFit,
|
||||||
|
int& propertyCount,
|
||||||
|
OctreeElement::AppendState& appendState) const {
|
||||||
|
|
||||||
|
bool successPropertyFits = true;
|
||||||
|
|
||||||
|
@Canvas_ENTITY_APPEND@
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int CanvasEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data, int bytesLeftToRead,
|
||||||
|
ReadBitstreamToTreeParams& args,
|
||||||
|
EntityPropertyFlags& propertyFlags, bool overwriteLocalData,
|
||||||
|
bool& somethingChanged) {
|
||||||
|
int bytesRead = 0;
|
||||||
|
const unsigned char* dataAt = data;
|
||||||
|
|
||||||
|
@Canvas_ENTITY_READ@
|
||||||
|
|
||||||
|
return bytesRead;
|
||||||
|
}
|
||||||
|
|
||||||
|
EntityPropertyFlags CanvasEntityItem::getEntityProperties(EncodeBitstreamParams& params) const {
|
||||||
|
EntityPropertyFlags requestedProperties = EntityItem::getEntityProperties(params);
|
||||||
|
|
||||||
|
@Canvas_REQUESTED_PROPS@
|
||||||
|
|
||||||
|
return requestedProperties;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CanvasEntityItem::setSubClassProperties(const EntityItemProperties& properties) {
|
||||||
|
bool somethingChanged = false;
|
||||||
|
|
||||||
|
@Canvas_ENTITY_SET_FROM@
|
||||||
|
|
||||||
|
return somethingChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
EntityItemProperties CanvasEntityItem::getProperties(const EntityPropertyFlags& desiredProperties, bool allowEmptyDesiredProperties) const {
|
||||||
|
EntityItemProperties properties = EntityItem::getProperties(desiredProperties, allowEmptyDesiredProperties); // get the properties from our base class
|
||||||
|
|
||||||
|
@Canvas_ENTITY_COPY_TO@
|
||||||
|
|
||||||
|
return properties;
|
||||||
|
}
|
28
libraries/entities/src/CanvasEntityItem.h.in
Normal file
28
libraries/entities/src/CanvasEntityItem.h.in
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
//
|
||||||
|
// Created by Ada <ada@thingvellir.net> on 2025-02-04
|
||||||
|
// Copyright 2025 Overte e.V.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache license, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
|
||||||
|
#ifndef hifi_CanvasEntityItem_h
|
||||||
|
#define hifi_CanvasEntityItem_h
|
||||||
|
|
||||||
|
#include "EntityItem.h"
|
||||||
|
|
||||||
|
class CanvasEntityItem : public EntityItem {
|
||||||
|
public:
|
||||||
|
static EntityItemPointer factory(const EntityItemID& entityID, const EntityItemProperties& properties);
|
||||||
|
|
||||||
|
CanvasEntityItem(const EntityItemID& entityItemID);
|
||||||
|
~CanvasEntityItem();
|
||||||
|
|
||||||
|
bool shouldBePhysical() const override { return false; }
|
||||||
|
|
||||||
|
virtual bool supportsDetailedIntersection() const override { return false; }
|
||||||
|
|
||||||
|
ALLOW_INSTANTIATION // This class can be instantiated
|
||||||
|
ENTITY_PROPERTY_SUBCLASS_METHODS
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // hifi_CanvasEntityItem_h
|
|
@ -265,4 +265,5 @@ enum:SOUND_PITCH, prop:pitch type:float default:1.0f min:1.0f/16.0f max:16.0f,
|
||||||
enum:SOUND_PLAYING prop:playing type:bool default:true,
|
enum:SOUND_PLAYING prop:playing type:bool default:true,
|
||||||
enum:SOUND_LOOP prop:loop type:bool default:true,
|
enum:SOUND_LOOP prop:loop type:bool default:true,
|
||||||
enum:SOUND_POSITIONAL prop:positional type:bool default:true,
|
enum:SOUND_POSITIONAL prop:positional type:bool default:true,
|
||||||
enum:SOUND_LOCAL_ONLY prop:localOnly type:bool default:false,
|
enum:SOUND_LOCAL_ONLY prop:localOnly type:bool default:false,
|
||||||
|
Canvas
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
#include "ZoneEntityItem.h"
|
#include "ZoneEntityItem.h"
|
||||||
#include "MaterialEntityItem.h"
|
#include "MaterialEntityItem.h"
|
||||||
#include "SoundEntityItem.h"
|
#include "SoundEntityItem.h"
|
||||||
|
#include "CanvasEntityItem.h"
|
||||||
|
|
||||||
QMap<EntityTypes::EntityType, QString> EntityTypes::_typeToNameMap;
|
QMap<EntityTypes::EntityType, QString> EntityTypes::_typeToNameMap;
|
||||||
QMap<QString, EntityTypes::EntityType> EntityTypes::_nameToTypeMap;
|
QMap<QString, EntityTypes::EntityType> EntityTypes::_nameToTypeMap;
|
||||||
|
@ -64,6 +65,7 @@ REGISTER_ENTITY_TYPE(Light)
|
||||||
REGISTER_ENTITY_TYPE(Zone)
|
REGISTER_ENTITY_TYPE(Zone)
|
||||||
REGISTER_ENTITY_TYPE(Material)
|
REGISTER_ENTITY_TYPE(Material)
|
||||||
REGISTER_ENTITY_TYPE(Sound)
|
REGISTER_ENTITY_TYPE(Sound)
|
||||||
|
REGISTER_ENTITY_TYPE(Canvas)
|
||||||
|
|
||||||
bool EntityTypes::typeIsValid(EntityType type) {
|
bool EntityTypes::typeIsValid(EntityType type) {
|
||||||
return type > EntityType::Unknown && type <= EntityType::NUM_TYPES;
|
return type > EntityType::Unknown && type <= EntityType::NUM_TYPES;
|
||||||
|
|
|
@ -116,6 +116,7 @@ public:
|
||||||
Zone,
|
Zone,
|
||||||
Material,
|
Material,
|
||||||
Sound,
|
Sound,
|
||||||
|
Canvas,
|
||||||
NUM_TYPES
|
NUM_TYPES
|
||||||
} EntityType;
|
} EntityType;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue