mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 05:29:34 +02:00
send PolyVox voxel dimensions and compressed data over the wire
This commit is contained in:
parent
ed6fdcfb31
commit
988ecf9d55
6 changed files with 44 additions and 21 deletions
|
@ -126,19 +126,9 @@ void RenderablePolyVoxEntityItem::getModel() {
|
||||||
setVoxelVolumeSize(_voxelVolumeSize);
|
setVoxelVolumeSize(_voxelVolumeSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
// glm::vec3 center(_volData->getDepth() / 2.0f,
|
|
||||||
// _volData->getHeight() / 2.0f,
|
|
||||||
// _volData->getWidth() / 2.0f);
|
|
||||||
// createSphereInVolume(center, 15);
|
|
||||||
// createSphereInVolume(center + glm::vec3(8.0f, 0.0f, 0.0f), 15);
|
|
||||||
// eraseSphereInVolume(center + glm::vec3(4.0f, 0.0f, 4.0f), 15);
|
|
||||||
|
|
||||||
|
|
||||||
glm::vec3 center = getCenter();
|
glm::vec3 center = getCenter();
|
||||||
createSphere(center, 4);
|
createSphere(center, 4);
|
||||||
createSphere(center + glm::vec3(6.0f, 0.0f, 0.0f), 2);
|
createSphere(center + glm::vec3(6.0f, 0.0f, 0.0f), 2);
|
||||||
// eraseSphere(center + glm::vec3(0.5f, 0.0f, 4.0f), 0.8);
|
|
||||||
|
|
||||||
|
|
||||||
// A mesh object to hold the result of surface extraction
|
// A mesh object to hold the result of surface extraction
|
||||||
PolyVox::SurfaceMesh<PolyVox::PositionMaterialNormal> polyVoxMesh;
|
PolyVox::SurfaceMesh<PolyVox::PositionMaterialNormal> polyVoxMesh;
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include "ParticleEffectEntityItem.h"
|
#include "ParticleEffectEntityItem.h"
|
||||||
#include "TextEntityItem.h"
|
#include "TextEntityItem.h"
|
||||||
#include "ZoneEntityItem.h"
|
#include "ZoneEntityItem.h"
|
||||||
|
#include "PolyVoxEntityItem.h"
|
||||||
|
|
||||||
AtmospherePropertyGroup EntityItemProperties::_staticAtmosphere;
|
AtmospherePropertyGroup EntityItemProperties::_staticAtmosphere;
|
||||||
SkyboxPropertyGroup EntityItemProperties::_staticSkybox;
|
SkyboxPropertyGroup EntityItemProperties::_staticSkybox;
|
||||||
|
@ -90,6 +91,9 @@ CONSTRUCT_PROPERTY(keyLightDirection, ZoneEntityItem::DEFAULT_KEYLIGHT_DIRECTION
|
||||||
CONSTRUCT_PROPERTY(name, ENTITY_ITEM_DEFAULT_NAME),
|
CONSTRUCT_PROPERTY(name, ENTITY_ITEM_DEFAULT_NAME),
|
||||||
CONSTRUCT_PROPERTY(backgroundMode, BACKGROUND_MODE_INHERIT),
|
CONSTRUCT_PROPERTY(backgroundMode, BACKGROUND_MODE_INHERIT),
|
||||||
CONSTRUCT_PROPERTY(sourceUrl, ""),
|
CONSTRUCT_PROPERTY(sourceUrl, ""),
|
||||||
|
CONSTRUCT_PROPERTY(voxelVolumeSize, PolyVoxEntityItem::DEFAULT_VOXEL_VOLUME_SIZE),
|
||||||
|
CONSTRUCT_PROPERTY(voxelData, PolyVoxEntityItem::DEFAULT_VOXEL_DATA),
|
||||||
|
|
||||||
|
|
||||||
_id(UNKNOWN_ENTITY_ID),
|
_id(UNKNOWN_ENTITY_ID),
|
||||||
_idSet(false),
|
_idSet(false),
|
||||||
|
|
|
@ -142,6 +142,8 @@ public:
|
||||||
DEFINE_PROPERTY_GROUP(Atmosphere, atmosphere, AtmospherePropertyGroup);
|
DEFINE_PROPERTY_GROUP(Atmosphere, atmosphere, AtmospherePropertyGroup);
|
||||||
DEFINE_PROPERTY_GROUP(Skybox, skybox, SkyboxPropertyGroup);
|
DEFINE_PROPERTY_GROUP(Skybox, skybox, SkyboxPropertyGroup);
|
||||||
DEFINE_PROPERTY_REF(PROP_SOURCE_URL, SourceUrl, sourceUrl, QString);
|
DEFINE_PROPERTY_REF(PROP_SOURCE_URL, SourceUrl, sourceUrl, QString);
|
||||||
|
DEFINE_PROPERTY_REF(PROP_VOXEL_VOLUME_SIZE, VoxelVolumeSize, voxelVolumeSize, glm::vec3);
|
||||||
|
DEFINE_PROPERTY_REF(PROP_VOXEL_DATA, VoxelData, voxelData, QByteArray);
|
||||||
|
|
||||||
static QString getBackgroundModeString(BackgroundMode mode);
|
static QString getBackgroundModeString(BackgroundMode mode);
|
||||||
|
|
||||||
|
@ -282,6 +284,8 @@ inline QDebug operator<<(QDebug debug, const EntityItemProperties& properties) {
|
||||||
DEBUG_PROPERTY_IF_CHANGED(debug, properties, ParticleRadius, particleRadius, "");
|
DEBUG_PROPERTY_IF_CHANGED(debug, properties, ParticleRadius, particleRadius, "");
|
||||||
DEBUG_PROPERTY_IF_CHANGED(debug, properties, MarketplaceID, marketplaceID, "");
|
DEBUG_PROPERTY_IF_CHANGED(debug, properties, MarketplaceID, marketplaceID, "");
|
||||||
DEBUG_PROPERTY_IF_CHANGED(debug, properties, BackgroundMode, backgroundMode, "");
|
DEBUG_PROPERTY_IF_CHANGED(debug, properties, BackgroundMode, backgroundMode, "");
|
||||||
|
DEBUG_PROPERTY_IF_CHANGED(debug, properties, VoxelVolumeSize, voxelVolumeSize, "");
|
||||||
|
DEBUG_PROPERTY_IF_CHANGED(debug, properties, VoxelData, voxelData, "");
|
||||||
|
|
||||||
properties.getStage().debugDump();
|
properties.getStage().debugDump();
|
||||||
properties.getAtmosphere().debugDump();
|
properties.getAtmosphere().debugDump();
|
||||||
|
|
|
@ -110,6 +110,9 @@ enum EntityPropertyList {
|
||||||
PROP_RESTITUTION,
|
PROP_RESTITUTION,
|
||||||
PROP_FRICTION,
|
PROP_FRICTION,
|
||||||
|
|
||||||
|
PROP_VOXEL_VOLUME_SIZE,
|
||||||
|
PROP_VOXEL_DATA,
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// ATTENTION: add new properties ABOVE this line
|
// ATTENTION: add new properties ABOVE this line
|
||||||
PROP_AFTER_LAST_ITEM,
|
PROP_AFTER_LAST_ITEM,
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
|
#include <QByteArray>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
#include <ByteCountCoding.h>
|
#include <ByteCountCoding.h>
|
||||||
|
@ -20,17 +21,19 @@
|
||||||
#include "EntityTreeElement.h"
|
#include "EntityTreeElement.h"
|
||||||
|
|
||||||
|
|
||||||
|
const glm::vec3 PolyVoxEntityItem::DEFAULT_VOXEL_VOLUME_SIZE = glm::vec3(32, 32, 32);
|
||||||
|
const QByteArray PolyVoxEntityItem::DEFAULT_VOXEL_DATA(qCompress(QByteArray(0), 9));
|
||||||
|
|
||||||
EntityItem* PolyVoxEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
|
EntityItem* PolyVoxEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
|
||||||
qDebug() << "XXXXXXXXXXXX XXXXXXXXXXXX making PolyVoxEntityItem entity";
|
|
||||||
EntityItem* result = new PolyVoxEntityItem(entityID, properties);
|
EntityItem* result = new PolyVoxEntityItem(entityID, properties);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
PolyVoxEntityItem::PolyVoxEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties) :
|
PolyVoxEntityItem::PolyVoxEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties) :
|
||||||
EntityItem(entityItemID)
|
EntityItem(entityItemID),
|
||||||
|
_voxelVolumeSize(PolyVoxEntityItem::DEFAULT_VOXEL_VOLUME_SIZE),
|
||||||
|
_voxelData(PolyVoxEntityItem::DEFAULT_VOXEL_DATA)
|
||||||
{
|
{
|
||||||
qDebug() << "XXXXXXXXXXXX XXXXXXXXXXXX making PolyVoxEntityItem entity";
|
|
||||||
|
|
||||||
_type = EntityTypes::PolyVox;
|
_type = EntityTypes::PolyVox;
|
||||||
_created = properties.getCreated();
|
_created = properties.getCreated();
|
||||||
setProperties(properties);
|
setProperties(properties);
|
||||||
|
@ -39,11 +42,14 @@ PolyVoxEntityItem::PolyVoxEntityItem(const EntityItemID& entityItemID, const Ent
|
||||||
EntityItemProperties PolyVoxEntityItem::getProperties() const {
|
EntityItemProperties PolyVoxEntityItem::getProperties() const {
|
||||||
EntityItemProperties properties = EntityItem::getProperties(); // get the properties from our base class
|
EntityItemProperties properties = EntityItem::getProperties(); // get the properties from our base class
|
||||||
|
|
||||||
properties._color = getXColor();
|
// properties._color = getXColor();
|
||||||
properties._colorChanged = false;
|
// properties._colorChanged = false;
|
||||||
|
// properties._glowLevel = getGlowLevel();
|
||||||
|
// properties._glowLevelChanged = false;
|
||||||
|
|
||||||
properties._glowLevel = getGlowLevel();
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(color, getXColor);
|
||||||
properties._glowLevelChanged = false;
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(voxelVolumeSize, getVoxelVolumeSize);
|
||||||
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(voxelData, getVoxelData);
|
||||||
|
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
@ -52,7 +58,9 @@ bool PolyVoxEntityItem::setProperties(const EntityItemProperties& properties) {
|
||||||
bool somethingChanged = false;
|
bool somethingChanged = false;
|
||||||
somethingChanged = EntityItem::setProperties(properties); // set the properties in our base class
|
somethingChanged = EntityItem::setProperties(properties); // set the properties in our base class
|
||||||
|
|
||||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(color, setColor);
|
SET_ENTITY_PROPERTY_FROM_PROPERTIES(color, setXColor);
|
||||||
|
SET_ENTITY_PROPERTY_FROM_PROPERTIES(voxelVolumeSize, setVoxelVolumeSize);
|
||||||
|
SET_ENTITY_PROPERTY_FROM_PROPERTIES(voxelData, setVoxelData);
|
||||||
|
|
||||||
if (somethingChanged) {
|
if (somethingChanged) {
|
||||||
bool wantDebug = false;
|
bool wantDebug = false;
|
||||||
|
@ -75,6 +83,8 @@ int PolyVoxEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* dat
|
||||||
const unsigned char* dataAt = data;
|
const unsigned char* dataAt = data;
|
||||||
|
|
||||||
READ_ENTITY_PROPERTY(PROP_COLOR, rgbColor, setColor);
|
READ_ENTITY_PROPERTY(PROP_COLOR, rgbColor, setColor);
|
||||||
|
READ_ENTITY_PROPERTY(PROP_VOXEL_VOLUME_SIZE, glm::vec3, setVoxelVolumeSize);
|
||||||
|
READ_ENTITY_PROPERTY(PROP_VOXEL_DATA, QByteArray, setVoxelData);
|
||||||
|
|
||||||
return bytesRead;
|
return bytesRead;
|
||||||
}
|
}
|
||||||
|
@ -84,6 +94,8 @@ int PolyVoxEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* dat
|
||||||
EntityPropertyFlags PolyVoxEntityItem::getEntityProperties(EncodeBitstreamParams& params) const {
|
EntityPropertyFlags PolyVoxEntityItem::getEntityProperties(EncodeBitstreamParams& params) const {
|
||||||
EntityPropertyFlags requestedProperties = EntityItem::getEntityProperties(params);
|
EntityPropertyFlags requestedProperties = EntityItem::getEntityProperties(params);
|
||||||
requestedProperties += PROP_COLOR;
|
requestedProperties += PROP_COLOR;
|
||||||
|
requestedProperties += PROP_VOXEL_VOLUME_SIZE;
|
||||||
|
requestedProperties += PROP_VOXEL_DATA;
|
||||||
return requestedProperties;
|
return requestedProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,6 +110,8 @@ void PolyVoxEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeB
|
||||||
bool successPropertyFits = true;
|
bool successPropertyFits = true;
|
||||||
|
|
||||||
APPEND_ENTITY_PROPERTY(PROP_COLOR, getColor());
|
APPEND_ENTITY_PROPERTY(PROP_COLOR, getColor());
|
||||||
|
APPEND_ENTITY_PROPERTY(PROP_VOXEL_VOLUME_SIZE, getVoxelVolumeSize());
|
||||||
|
APPEND_ENTITY_PROPERTY(PROP_VOXEL_DATA, getVoxelData());
|
||||||
}
|
}
|
||||||
|
|
||||||
void PolyVoxEntityItem::debugDump() const {
|
void PolyVoxEntityItem::debugDump() const {
|
||||||
|
|
|
@ -45,7 +45,7 @@ class PolyVoxEntityItem : public EntityItem {
|
||||||
xColor getXColor() const { xColor color = { _color[RED_INDEX], _color[GREEN_INDEX], _color[BLUE_INDEX] }; return color; }
|
xColor getXColor() const { xColor color = { _color[RED_INDEX], _color[GREEN_INDEX], _color[BLUE_INDEX] }; return color; }
|
||||||
|
|
||||||
void setColor(const rgbColor& value) { memcpy(_color, value, sizeof(_color)); }
|
void setColor(const rgbColor& value) { memcpy(_color, value, sizeof(_color)); }
|
||||||
void setColor(const xColor& value) {
|
void setXColor(const xColor& value) {
|
||||||
_color[RED_INDEX] = value.red;
|
_color[RED_INDEX] = value.red;
|
||||||
_color[GREEN_INDEX] = value.green;
|
_color[GREEN_INDEX] = value.green;
|
||||||
_color[BLUE_INDEX] = value.blue;
|
_color[BLUE_INDEX] = value.blue;
|
||||||
|
@ -62,10 +62,18 @@ class PolyVoxEntityItem : public EntityItem {
|
||||||
virtual void debugDump() const;
|
virtual void debugDump() const;
|
||||||
|
|
||||||
virtual void setVoxelVolumeSize(glm::vec3 voxelVolumeSize) { _voxelVolumeSize = voxelVolumeSize; }
|
virtual void setVoxelVolumeSize(glm::vec3 voxelVolumeSize) { _voxelVolumeSize = voxelVolumeSize; }
|
||||||
|
virtual const glm::vec3& getVoxelVolumeSize() const { return _voxelVolumeSize; }
|
||||||
|
|
||||||
|
virtual void setVoxelData(QByteArray voxelData) { _voxelData = voxelData; }
|
||||||
|
virtual const QByteArray& getVoxelData() const { return _voxelData; }
|
||||||
|
|
||||||
|
static const glm::vec3 DEFAULT_VOXEL_VOLUME_SIZE;
|
||||||
|
static const QByteArray DEFAULT_VOXEL_DATA;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
rgbColor _color;
|
rgbColor _color;
|
||||||
glm::vec3 _voxelVolumeSize = glm::vec3(64, 64, 64);
|
glm::vec3 _voxelVolumeSize; // this is always 3 bytes
|
||||||
|
QByteArray _voxelData;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_PolyVoxEntityItem_h
|
#endif // hifi_PolyVoxEntityItem_h
|
||||||
|
|
Loading…
Reference in a new issue