mirror of
https://github.com/overte-org/overte.git
synced 2025-08-11 19:51:31 +02:00
texture support in model entities
This commit is contained in:
parent
c650cabb5d
commit
95c5b417c9
6 changed files with 43 additions and 50 deletions
|
@ -2988,36 +2988,3 @@ Controller.keyReleaseEvent.connect(function (event) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Window.inlineButtonClicked.connect(function (name) {
|
|
||||||
if (name == "resetDimensions") {
|
|
||||||
var decimals = 3;
|
|
||||||
Window.reloadNonBlockingForm([
|
|
||||||
{ value: propertiesForEditedEntity.naturalDimensions.x.toFixed(decimals), oldIndex: dimensionX },
|
|
||||||
{ value: propertiesForEditedEntity.naturalDimensions.y.toFixed(decimals), oldIndex: dimensionY },
|
|
||||||
{ value: propertiesForEditedEntity.naturalDimensions.z.toFixed(decimals), oldIndex: dimensionZ }
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (name == "rescaleDimensions") {
|
|
||||||
var decimals = 3;
|
|
||||||
var peekValues = editEntityFormArray;
|
|
||||||
Window.peekNonBlockingFormResult(peekValues);
|
|
||||||
var peekX = peekValues[dimensionX].value;
|
|
||||||
var peekY = peekValues[dimensionY].value;
|
|
||||||
var peekZ = peekValues[dimensionZ].value;
|
|
||||||
var peekRescale = peekValues[rescalePercentage].value;
|
|
||||||
var rescaledX = peekX * peekRescale / 100.0;
|
|
||||||
var rescaledY = peekY * peekRescale / 100.0;
|
|
||||||
var rescaledZ = peekZ * peekRescale / 100.0;
|
|
||||||
|
|
||||||
Window.reloadNonBlockingForm([
|
|
||||||
{ value: rescaledX.toFixed(decimals), oldIndex: dimensionX },
|
|
||||||
{ value: rescaledY.toFixed(decimals), oldIndex: dimensionY },
|
|
||||||
{ value: rescaledZ.toFixed(decimals), oldIndex: dimensionZ },
|
|
||||||
{ value: 100, oldIndex: rescalePercentage }
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,8 @@ EntityPropertyDialogBox = (function () {
|
||||||
index++;
|
index++;
|
||||||
array.push({ label: "Animation Frame:", value: properties.animationFrameIndex });
|
array.push({ label: "Animation Frame:", value: properties.animationFrameIndex });
|
||||||
index++;
|
index++;
|
||||||
|
array.push({ label: "Textures:", value: properties.textures });
|
||||||
|
index++;
|
||||||
}
|
}
|
||||||
array.push({ label: "Position:", type: "header" });
|
array.push({ label: "Position:", type: "header" });
|
||||||
index++;
|
index++;
|
||||||
|
@ -233,6 +235,7 @@ EntityPropertyDialogBox = (function () {
|
||||||
properties.animationIsPlaying = array[index++].value;
|
properties.animationIsPlaying = array[index++].value;
|
||||||
properties.animationFPS = array[index++].value;
|
properties.animationFPS = array[index++].value;
|
||||||
properties.animationFrameIndex = array[index++].value;
|
properties.animationFrameIndex = array[index++].value;
|
||||||
|
properties.textures = array[index++].value;
|
||||||
}
|
}
|
||||||
index++; // skip header
|
index++; // skip header
|
||||||
properties.position.x = array[index++].value;
|
properties.position.x = array[index++].value;
|
||||||
|
|
|
@ -38,9 +38,12 @@ RenderableModelEntityItem::~RenderableModelEntityItem() {
|
||||||
|
|
||||||
bool RenderableModelEntityItem::setProperties(const EntityItemProperties& properties, bool forceCopy) {
|
bool RenderableModelEntityItem::setProperties(const EntityItemProperties& properties, bool forceCopy) {
|
||||||
QString oldModelURL = getModelURL();
|
QString oldModelURL = getModelURL();
|
||||||
|
QString oldTextures = getTextures();
|
||||||
bool somethingChanged = ModelEntityItem::setProperties(properties, forceCopy);
|
bool somethingChanged = ModelEntityItem::setProperties(properties, forceCopy);
|
||||||
if (somethingChanged && oldModelURL != getModelURL()) {
|
if (somethingChanged) {
|
||||||
_needsModelReload = true;
|
if ((oldModelURL != getModelURL()) || (oldTextures != getTextures())) {
|
||||||
|
_needsModelReload = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return somethingChanged;
|
return somethingChanged;
|
||||||
}
|
}
|
||||||
|
@ -180,6 +183,18 @@ Model* RenderableModelEntityItem::getModel(EntityTreeRenderer* renderer) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// here's where we remap any textures if needed...
|
||||||
|
if (!_textures.isEmpty() && _model) {
|
||||||
|
QJsonDocument texturesAsJson = QJsonDocument::fromJson(_textures.toUtf8());
|
||||||
|
QJsonObject texturesAsJsonObject = texturesAsJson.object();
|
||||||
|
QVariantMap textureMap = texturesAsJsonObject.toVariantMap();
|
||||||
|
foreach(const QString& key, textureMap.keys()) {
|
||||||
|
QUrl newTextureURL = textureMap[key].toUrl();
|
||||||
|
qDebug() << "Updating texture named" << key << "to texture at URL" << newTextureURL;
|
||||||
|
_model->setTextureWithNameToURL(key, newTextureURL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -288,6 +288,8 @@ void EntityItemProperties::copyFromScriptValue(const QScriptValue& object) {
|
||||||
COPY_PROPERTY_FROM_QSCRIPTVALUE_FLOAT(cutoff, setCutoff);
|
COPY_PROPERTY_FROM_QSCRIPTVALUE_FLOAT(cutoff, setCutoff);
|
||||||
COPY_PROPERTY_FROM_QSCRIPTVALUE_BOOL(locked, setLocked);
|
COPY_PROPERTY_FROM_QSCRIPTVALUE_BOOL(locked, setLocked);
|
||||||
COPY_PROPERTY_FROM_QSCRIPTVALUE_STRING(textures, setTextures);
|
COPY_PROPERTY_FROM_QSCRIPTVALUE_STRING(textures, setTextures);
|
||||||
|
|
||||||
|
qDebug() << "COPY_PROPERTY_FROM_QSCRIPTVALUE_STRING.... textures: " << getTextures();
|
||||||
|
|
||||||
_lastEdited = usecTimestampNow();
|
_lastEdited = usecTimestampNow();
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,20 +41,15 @@ ModelEntityItem::ModelEntityItem(const EntityItemID& entityItemID, const EntityI
|
||||||
|
|
||||||
EntityItemProperties ModelEntityItem::getProperties() const {
|
EntityItemProperties ModelEntityItem::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._modelURL = getModelURL();
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(color, getXColor);
|
||||||
properties._animationURL = getAnimationURL();
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(modelURL, getModelURL);
|
||||||
properties._animationIsPlaying = getAnimationIsPlaying();
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(animationURL, getAnimationURL);
|
||||||
properties._animationFrameIndex = getAnimationFrameIndex();
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(animationIsPlaying, getAnimationIsPlaying);
|
||||||
properties._animationFPS = getAnimationFPS();
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(animationFrameIndex, getAnimationFrameIndex);
|
||||||
properties._colorChanged = false;
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(animationFPS, getAnimationFPS);
|
||||||
properties._modelURLChanged = false;
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(glowLevel, getGlowLevel);
|
||||||
properties._animationURLChanged = false;
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(textures, getTextures);
|
||||||
properties._animationIsPlayingChanged = false;
|
|
||||||
properties._animationFrameIndexChanged = false;
|
|
||||||
properties._animationFPSChanged = false;
|
|
||||||
properties._glowLevel = getGlowLevel();
|
|
||||||
properties._glowLevelChanged = false;
|
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,6 +63,7 @@ bool ModelEntityItem::setProperties(const EntityItemProperties& properties, bool
|
||||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(animationIsPlaying, setAnimationIsPlaying);
|
SET_ENTITY_PROPERTY_FROM_PROPERTIES(animationIsPlaying, setAnimationIsPlaying);
|
||||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(animationFrameIndex, setAnimationFrameIndex);
|
SET_ENTITY_PROPERTY_FROM_PROPERTIES(animationFrameIndex, setAnimationFrameIndex);
|
||||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(animationFPS, setAnimationFPS);
|
SET_ENTITY_PROPERTY_FROM_PROPERTIES(animationFPS, setAnimationFPS);
|
||||||
|
SET_ENTITY_PROPERTY_FROM_PROPERTIES(textures, setTextures);
|
||||||
|
|
||||||
if (somethingChanged) {
|
if (somethingChanged) {
|
||||||
bool wantDebug = false;
|
bool wantDebug = false;
|
||||||
|
@ -107,6 +103,7 @@ int ModelEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data,
|
||||||
READ_ENTITY_PROPERTY(PROP_ANIMATION_FPS, float, _animationFPS);
|
READ_ENTITY_PROPERTY(PROP_ANIMATION_FPS, float, _animationFPS);
|
||||||
READ_ENTITY_PROPERTY(PROP_ANIMATION_FRAME_INDEX, float, _animationFrameIndex);
|
READ_ENTITY_PROPERTY(PROP_ANIMATION_FRAME_INDEX, float, _animationFrameIndex);
|
||||||
READ_ENTITY_PROPERTY(PROP_ANIMATION_PLAYING, bool, _animationIsPlaying);
|
READ_ENTITY_PROPERTY(PROP_ANIMATION_PLAYING, bool, _animationIsPlaying);
|
||||||
|
READ_ENTITY_PROPERTY_STRING(PROP_TEXTURES, setTextures);
|
||||||
|
|
||||||
return bytesRead;
|
return bytesRead;
|
||||||
}
|
}
|
||||||
|
@ -230,6 +227,7 @@ EntityPropertyFlags ModelEntityItem::getEntityProperties(EncodeBitstreamParams&
|
||||||
requestedProperties += PROP_ANIMATION_FPS;
|
requestedProperties += PROP_ANIMATION_FPS;
|
||||||
requestedProperties += PROP_ANIMATION_FRAME_INDEX;
|
requestedProperties += PROP_ANIMATION_FRAME_INDEX;
|
||||||
requestedProperties += PROP_ANIMATION_PLAYING;
|
requestedProperties += PROP_ANIMATION_PLAYING;
|
||||||
|
requestedProperties += PROP_TEXTURES;
|
||||||
|
|
||||||
return requestedProperties;
|
return requestedProperties;
|
||||||
}
|
}
|
||||||
|
@ -250,6 +248,7 @@ void ModelEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBit
|
||||||
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_FPS, appendValue, getAnimationFPS());
|
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_FPS, appendValue, getAnimationFPS());
|
||||||
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_FRAME_INDEX, appendValue, getAnimationFrameIndex());
|
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_FRAME_INDEX, appendValue, getAnimationFrameIndex());
|
||||||
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_PLAYING, appendValue, getAnimationIsPlaying());
|
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_PLAYING, appendValue, getAnimationIsPlaying());
|
||||||
|
APPEND_ENTITY_PROPERTY(PROP_TEXTURES, appendValue, getTextures());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -88,6 +88,10 @@ public:
|
||||||
bool getAnimationIsPlaying() const { return _animationIsPlaying; }
|
bool getAnimationIsPlaying() const { return _animationIsPlaying; }
|
||||||
float getAnimationFrameIndex() const { return _animationFrameIndex; }
|
float getAnimationFrameIndex() const { return _animationFrameIndex; }
|
||||||
float getAnimationFPS() const { return _animationFPS; }
|
float getAnimationFPS() const { return _animationFPS; }
|
||||||
|
|
||||||
|
static const QString DEFAULT_TEXTURES;
|
||||||
|
const QString& getTextures() const { return _textures; }
|
||||||
|
void setTextures(const QString& textures) { _textures = textures; }
|
||||||
|
|
||||||
static void cleanupLoadedAnimations();
|
static void cleanupLoadedAnimations();
|
||||||
|
|
||||||
|
@ -105,9 +109,12 @@ protected:
|
||||||
float _animationFrameIndex; // we keep this as a float and round to int only when we need the exact index
|
float _animationFrameIndex; // we keep this as a float and round to int only when we need the exact index
|
||||||
bool _animationIsPlaying;
|
bool _animationIsPlaying;
|
||||||
float _animationFPS;
|
float _animationFPS;
|
||||||
|
QString _textures;
|
||||||
|
|
||||||
|
// used on client side
|
||||||
bool _jointMappingCompleted;
|
bool _jointMappingCompleted;
|
||||||
QVector<int> _jointMapping;
|
QVector<int> _jointMapping;
|
||||||
|
|
||||||
static Animation* getAnimation(const QString& url);
|
static Animation* getAnimation(const QString& url);
|
||||||
static QMap<QString, AnimationPointer> _loadedAnimations;
|
static QMap<QString, AnimationPointer> _loadedAnimations;
|
||||||
static AnimationCache _animationCache;
|
static AnimationCache _animationCache;
|
||||||
|
|
Loading…
Reference in a new issue