mirror of
https://github.com/overte-org/overte.git
synced 2025-04-19 13:43:49 +02:00
added image button to edit.js, working on connecting to cpp
This commit is contained in:
parent
3a7290c3ed
commit
fdca8ab93e
9 changed files with 87 additions and 5 deletions
|
@ -101,6 +101,18 @@ TabView {
|
|||
}
|
||||
}
|
||||
|
||||
// for image
|
||||
NewEntityButton {
|
||||
icon: "icons/create-icons/25-web-1-01.svg"
|
||||
text: "IMAGE"
|
||||
onClicked: {
|
||||
editRoot.sendToScript({
|
||||
method: "newEntityButtonClicked", params: { buttonName: "newImageButton" }
|
||||
});
|
||||
editTabView.currentIndex = 2
|
||||
}
|
||||
}
|
||||
|
||||
NewEntityButton {
|
||||
icon: "icons/create-icons/25-web-1-01.svg"
|
||||
text: "WEB"
|
||||
|
|
|
@ -1369,6 +1369,10 @@ OctreeElement::AppendState EntityItemProperties::encodeEntityEditPacket(PacketTy
|
|||
APPEND_ENTITY_PROPERTY(PROP_DPI, properties.getDPI());
|
||||
}
|
||||
|
||||
if (properties.getType() == EntityTypes::Image) {
|
||||
APPEND_ENTITY_PROPERTY(PROP_IMAGE_URL, properties.getImageURL());
|
||||
}
|
||||
|
||||
if (properties.getType() == EntityTypes::Text) {
|
||||
APPEND_ENTITY_PROPERTY(PROP_TEXT, properties.getText());
|
||||
APPEND_ENTITY_PROPERTY(PROP_LINE_HEIGHT, properties.getLineHeight());
|
||||
|
|
|
@ -194,6 +194,7 @@ public:
|
|||
DEFINE_PROPERTY_GROUP(Haze, haze, HazePropertyGroup);
|
||||
DEFINE_PROPERTY_GROUP(Animation, animation, AnimationPropertyGroup);
|
||||
DEFINE_PROPERTY_REF(PROP_SOURCE_URL, SourceUrl, sourceUrl, QString, "");
|
||||
DEFINE_PROPERTY_REF(PROP_IMAGE_URL, ImageURL, imageURL, QString, "");
|
||||
DEFINE_PROPERTY(PROP_LINE_WIDTH, LineWidth, lineWidth, float, LineEntityItem::DEFAULT_LINE_WIDTH);
|
||||
DEFINE_PROPERTY_REF(LINE_POINTS, LinePoints, linePoints, QVector<glm::vec3>, QVector<glm::vec3>());
|
||||
DEFINE_PROPERTY_REF(PROP_HREF, Href, href, QString, "");
|
||||
|
|
|
@ -42,6 +42,9 @@ enum EntityPropertyList {
|
|||
PROP_ANIMATION_ALLOW_TRANSLATION,
|
||||
PROP_RELAY_PARENT_JOINTS,
|
||||
|
||||
// for image
|
||||
PROP_IMAGE_URL,
|
||||
|
||||
// these properties are supported by the EntityItem base class
|
||||
PROP_REGISTRATION_POINT,
|
||||
PROP_ANGULAR_VELOCITY,
|
||||
|
|
|
@ -89,6 +89,7 @@ EntityItemPointer EntityTypes::constructEntityItem(EntityType entityType, const
|
|||
EntityItemPointer newEntityItem = NULL;
|
||||
EntityTypeFactory factory = NULL;
|
||||
if (entityType >= 0 && entityType <= LAST) {
|
||||
qCDebug(entities) << "type: " << entityType;
|
||||
factory = _factories[entityType];
|
||||
}
|
||||
if (factory) {
|
||||
|
|
|
@ -48,8 +48,8 @@ public:
|
|||
Line,
|
||||
PolyVox,
|
||||
PolyLine,
|
||||
Shape,
|
||||
Image,
|
||||
Shape,
|
||||
LAST = Shape
|
||||
} EntityType;
|
||||
|
||||
|
|
|
@ -38,14 +38,14 @@ FlatImageEntity::FlatImageEntity(const EntityItemID& entityItemID) : EntityItem(
|
|||
|
||||
EntityItemProperties FlatImageEntity::getProperties(EntityPropertyFlags desiredProperties) const {
|
||||
EntityItemProperties properties = EntityItem::getProperties(desiredProperties); // get the properties from our base class
|
||||
properties.setShape("Image");
|
||||
properties.setShape("Quad");
|
||||
return properties;
|
||||
}
|
||||
|
||||
bool FlatImageEntity::setProperties(const EntityItemProperties& properties) {
|
||||
bool somethingChanged = EntityItem::setProperties(properties); // set the properties in our base class
|
||||
|
||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(shape, setShape);
|
||||
//SET_ENTITY_PROPERTY_FROM_PROPERTIES(shape, setShape);
|
||||
|
||||
if (somethingChanged) {
|
||||
bool wantDebug = false;
|
||||
|
@ -60,6 +60,13 @@ bool FlatImageEntity::setProperties(const EntityItemProperties& properties) {
|
|||
return somethingChanged;
|
||||
}
|
||||
|
||||
// TODO: eventually only include properties changed since the params.nodeData->getLastTimeBagEmpty() time
|
||||
EntityPropertyFlags FlatImageEntity::getEntityProperties(EncodeBitstreamParams& params) const {
|
||||
EntityPropertyFlags requestedProperties = EntityItem::getEntityProperties(params);
|
||||
|
||||
return requestedProperties;
|
||||
}
|
||||
|
||||
void FlatImageEntity::appendSubclassData(OctreePacketData* packetData, EncodeBitstreamParams& params,
|
||||
EntityTreeElementExtraEncodeDataPointer modelTreeElementExtraEncodeData,
|
||||
EntityPropertyFlags& requestedProperties,
|
||||
|
@ -69,6 +76,36 @@ void FlatImageEntity::appendSubclassData(OctreePacketData* packetData, EncodeBit
|
|||
OctreeElement::AppendState& appendState) const {
|
||||
|
||||
bool successPropertyFits = true;
|
||||
APPEND_ENTITY_PROPERTY(PROP_SHAPE, entity::stringFromShape(getShape()));
|
||||
// Using "Quad" shape as defined in ShapeEntityItem.cpp
|
||||
APPEND_ENTITY_PROPERTY(PROP_SHAPE, "Quad");
|
||||
}
|
||||
|
||||
int FlatImageEntity::readEntitySubclassDataFromBuffer(const unsigned char* data, int bytesLeftToRead,
|
||||
ReadBitstreamToTreeParams& args,
|
||||
EntityPropertyFlags& propertyFlags, bool overwriteLocalData,
|
||||
bool& somethingChanged) {
|
||||
|
||||
int bytesRead = 0;
|
||||
const unsigned char* dataAt = data;
|
||||
|
||||
return bytesRead;
|
||||
}
|
||||
|
||||
void ShapeEntityItem::setUnscaledDimensions(const glm::vec3& value) {
|
||||
const float MAX_FLAT_DIMENSION = 0.0001f;
|
||||
if (value.y > MAX_FLAT_DIMENSION) {
|
||||
// enforce flatness in Y
|
||||
glm::vec3 newDimensions = value;
|
||||
newDimensions.y = MAX_FLAT_DIMENSION;
|
||||
EntityItem::setUnscaledDimensions(newDimensions);
|
||||
} else {
|
||||
EntityItem::setUnscaledDimensions(value);
|
||||
}
|
||||
}
|
||||
|
||||
QString FlatImageEntity::getImageURL() const {
|
||||
return resultWithReadLock<QString>([&] {
|
||||
return _imageURL;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,8 @@ public:
|
|||
virtual EntityItemProperties getProperties(EntityPropertyFlags desiredProperties = EntityPropertyFlags()) const override;
|
||||
virtual bool setProperties(const EntityItemProperties& properties) override;
|
||||
|
||||
EntityPropertyFlags getEntityProperties(EncodeBitstreamParams& params) const override;
|
||||
|
||||
virtual void appendSubclassData(OctreePacketData* packetData, EncodeBitstreamParams& params,
|
||||
EntityTreeElementExtraEncodeDataPointer entityTreeElementExtraEncodeData,
|
||||
EntityPropertyFlags& requestedProperties,
|
||||
|
@ -34,7 +36,17 @@ public:
|
|||
int& propertyCount,
|
||||
OctreeElement::AppendState& appendState) const override;
|
||||
|
||||
int readEntitySubclassDataFromBuffer(const unsigned char* data, int bytesLeftToRead,
|
||||
ReadBitstreamToTreeParams& args,
|
||||
EntityPropertyFlags& propertyFlags, bool overwriteLocalData,
|
||||
bool& somethingChanged) override;
|
||||
|
||||
|
||||
static const QString DEFAULT_IMAGE_URL;
|
||||
QString getImageURL() const;
|
||||
|
||||
protected:
|
||||
QString _imageURL;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -251,7 +251,8 @@ var toolBar = (function () {
|
|||
// Align entity with Avatar orientation.
|
||||
properties.rotation = MyAvatar.orientation;
|
||||
|
||||
var PRE_ADJUST_ENTITY_TYPES = ["Box", "Sphere", "Shape", "Text", "Web"];
|
||||
// added image here
|
||||
var PRE_ADJUST_ENTITY_TYPES = ["Box", "Sphere", "Shape", "Text", "Image", "Web"];
|
||||
if (PRE_ADJUST_ENTITY_TYPES.indexOf(properties.type) !== -1) {
|
||||
|
||||
// Adjust position of entity per bounding box prior to creating it.
|
||||
|
@ -286,6 +287,7 @@ var toolBar = (function () {
|
|||
properties.userData = JSON.stringify({ grabbableKey: { grabbable: false } });
|
||||
}
|
||||
|
||||
print("properties.type: " + properties.type);
|
||||
entityID = Entities.addEntity(properties);
|
||||
|
||||
if (properties.type === "ParticleEffect") {
|
||||
|
@ -538,6 +540,16 @@ var toolBar = (function () {
|
|||
});
|
||||
});
|
||||
|
||||
// for image button
|
||||
addButton("newImageButton", "web-01.svg", function () {
|
||||
print("new image message is received");
|
||||
createNewEntity({
|
||||
type: "Image",
|
||||
dimensions: DEFAULT_DIMENSIONS,
|
||||
sourceUrl: "https://highfidelity.com/"
|
||||
});
|
||||
});
|
||||
|
||||
addButton("newWebButton", "web-01.svg", function () {
|
||||
createNewEntity({
|
||||
type: "Web",
|
||||
|
|
Loading…
Reference in a new issue