add gettable feature which lists texture names

This commit is contained in:
ZappoMan 2014-11-07 09:05:47 -08:00
parent 786c08f196
commit c48d79ad8b
7 changed files with 46 additions and 0 deletions

View file

@ -54,6 +54,8 @@ EntityPropertyDialogBox = (function () {
index++;
array.push({ label: "Textures:", value: properties.textures });
index++;
array.push({ label: "Texture Names:" + properties.textureNames, type: "header" });
index++;
}
array.push({ label: "Position:", type: "header" });
index++;
@ -239,6 +241,7 @@ EntityPropertyDialogBox = (function () {
properties.animationFPS = array[index++].value;
properties.animationFrameIndex = array[index++].value;
properties.textures = array[index++].value;
index++; // skip textureNames label
}
index++; // skip header
properties.position.x = array[index++].value;

View file

@ -234,6 +234,17 @@ bool RenderableModelEntityItem::needsSimulation() const {
return _needsInitialSimulation || simulationState == Moving || simulationState == Changing;
}
EntityItemProperties RenderableModelEntityItem::getProperties() const {
EntityItemProperties properties = ModelEntityItem::getProperties(); // get the properties from our base class
if (_model) {
const QSharedPointer<NetworkGeometry>& networkGeometry = _model->getGeometry();
if (networkGeometry) {
properties.setTextureNames(networkGeometry->getTextureNames());
}
}
return properties;
}

View file

@ -41,6 +41,7 @@ public:
virtual ~RenderableModelEntityItem();
virtual EntityItemProperties getProperties() const;
virtual bool setProperties(const EntityItemProperties& properties, bool forceCopy);
virtual int readEntitySubclassDataFromBuffer(const unsigned char* data, int bytesLeftToRead,
ReadBitstreamToTreeParams& args,

View file

@ -734,6 +734,29 @@ void NetworkGeometry::setTextureWithNameToURL(const QString& name, const QUrl& u
}
}
QStringList NetworkGeometry::getTextureNames() const {
QStringList result;
for (int i = 0; i < _meshes.size(); i++) {
const NetworkMesh& mesh = _meshes[i];
for (int j = 0; j < mesh.parts.size(); j++) {
const NetworkMeshPart& part = mesh.parts[j];
if (!part.diffuseTextureName.isEmpty()) {
result << part.diffuseTextureName;
}
if (!part.normalTextureName.isEmpty()) {
result << part.normalTextureName;
}
if (!part.specularTextureName.isEmpty()) {
result << part.specularTextureName;
}
}
}
return result;
}
/// Reads geometry in a worker thread.
class GeometryReader : public QRunnable {
public:

View file

@ -112,6 +112,7 @@ public:
virtual void clearLoadPriority(const QPointer<QObject>& owner);
void setTextureWithNameToURL(const QString& name, const QUrl& url);
QStringList getTextureNames() const;
protected:

View file

@ -243,6 +243,9 @@ QScriptValue EntityItemProperties::copyToScriptValue(QScriptEngine* engine) cons
boundingBox.setProperty("dimensions", boundingBoxDimensions);
COPY_PROPERTY_TO_QSCRIPTVALUE_GETTER(boundingBox, boundingBox); // gettable, but not settable
QString textureNamesList = _textureNames.join(",");
COPY_PROPERTY_TO_QSCRIPTVALUE_GETTER(textureNames, textureNamesList); // gettable, but not settable
return properties;
}

View file

@ -285,6 +285,9 @@ public:
const QString& getTextures() const { return _textures; }
void setTextures(const QString& value) { _textures = value; _texturesChanged = true; }
const QStringList& getTextureNames() const { return _textureNames; }
void setTextureNames(const QStringList& value) { _textureNames = value; }
void setLastEdited(quint64 usecTime) { _lastEdited = usecTime; }
@ -381,6 +384,7 @@ private:
// properties of model geometry. But these properties are not serialized like other properties.
QVector<SittingPoint> _sittingPoints;
glm::vec3 _naturalDimensions;
QStringList _textureNames;
};
Q_DECLARE_METATYPE(EntityItemProperties);
QScriptValue EntityItemPropertiesToScriptValue(QScriptEngine* engine, const EntityItemProperties& properties);