Пример #1
0
void MaterialEntityItem::setParentID(const QUuid& parentID) {
    if (getParentID() != parentID) {
        removeMaterial();
        EntityItem::setParentID(parentID);
        applyMaterial();
    }
}
Пример #2
0
void MaterialEntityItem::setClientOnly(bool clientOnly) {
    if (getClientOnly() != clientOnly) {
        removeMaterial();
        EntityItem::setClientOnly(clientOnly);
        applyMaterial();
    }
}
Пример #3
0
void MaterialEntityItem::setPriority(quint16 priority) {
    if (_priority != priority) {
        removeMaterial();
        _priority = priority;
        applyMaterial();
    }
}
Пример #4
0
void MaterialEntityItem::setParentMaterialName(const QString& parentMaterialName) {
    if (_parentMaterialName != parentMaterialName) {
        removeMaterial();
        _parentMaterialName = parentMaterialName;
        applyMaterial();
    }
}
Пример #5
0
void MaterialEntityItem::setMaterialMappingRot(const float& materialMappingRot) {
    if (_materialMappingRot != materialMappingRot) {
        removeMaterial();
        _materialMappingRot = materialMappingRot;
        applyMaterial();
    }
}
Пример #6
0
void MaterialEntityItem::setMaterialMappingScale(const glm::vec2& materialMappingScale) {
    if (_materialMappingScale != materialMappingScale) {
        removeMaterial();
        _materialMappingScale = materialMappingScale;
        applyMaterial();
    }
}
Пример #7
0
void MaterialEntityItem::setMaterialMappingPos(const glm::vec2& materialMappingPos) {
    if (_materialMappingPos != materialMappingPos) {
        removeMaterial();
        _materialMappingPos = materialMappingPos;
        applyMaterial();
    }
}
Пример #8
0
void MaterialEntityItem::setOwningAvatarID(const QUuid& owningAvatarID) {
    if (getOwningAvatarID() != owningAvatarID) {
        removeMaterial();
        EntityItem::setOwningAvatarID(owningAvatarID);
        applyMaterial();
    }
}
Пример #9
0
bool TrussMaterialLibrary::removeMaterial ( const QString& uuid )
{
    TrussMaterialListConstIter iter = materials.begin();
    for ( ; iter != materials.end(); ++iter ) {
        TrussMaterial* material = *iter;
        if ( material->getUUID() == uuid )
            return removeMaterial( *material );
    }
    return false;
}
Пример #10
0
bool TrussMaterialLibrary::removeMaterial ( int indx )
{
    if ( indx > materials.size() )
        return false;

    try {
        return removeMaterial( *materials.at(indx) );
    }
    catch ( ... ) {
        return false;
    }
}
Пример #11
0
void FEMesh::refreshMaterials(PyObject *skeletoncontext) {
  for(ElementIterator ei=element_iterator(); !ei.end(); ++ei) {
    Element *element = ei.element();
    const Material *oldmat = element->material();
    element->refreshMaterial(skeletoncontext);
    const Material *newmat = element->material();
    if(newmat != oldmat) {
      if(oldmat)
	removeMaterial(oldmat);
      if(newmat)
	addMaterial(newmat);
    }
  }
  // TODO INTERFACE: Should this just be in-line here?
  refreshInterfaceMaterials(skeletoncontext);
}
Пример #12
0
// TODO INTERFACE: Called from FEMesh::refreshMaterials, but possibly
// from elsewhere also.  Should this function just be in-line in
// refreshMaterials, or is there a good reason for it to stand alone?
void FEMesh::refreshInterfaceMaterials(PyObject *skelctxt)
{
  for(ElementIterator ei=edgement_iterator(); !ei.end(); ++ei) {
    Element *el = ei.element();
    const Material *om = el->material();
    InterfaceElement *ed = dynamic_cast<InterfaceElement*>(el);
    ed->refreshInterfaceMaterial(skelctxt);
    const Material *nm = el->material();
    if (nm != om) {
      if (om) 
	removeMaterial(om);
      if (nm)
	addMaterial(nm);
    }
  }

}
Пример #13
0
// Replace the material specified by id with another one
void GLC_Mesh::replaceMaterial(const GLC_uint oldId, GLC_Material* pMat)
{
	Q_ASSERT(containsMaterial(oldId));
	Q_ASSERT(!containsMaterial(pMat->id()) || (pMat->id() == oldId));

	if (pMat->id() != oldId)
	{
		// Iterate over Level of detail
		PrimitiveGroupsHash::const_iterator iGroups= m_PrimitiveGroups.constBegin();
		while (m_PrimitiveGroups.constEnd() != iGroups)
		{
			LodPrimitiveGroups* pPrimitiveGroups= iGroups.value();
			// Iterate over material group
			LodPrimitiveGroups::iterator iGroup= pPrimitiveGroups->begin();
			while (pPrimitiveGroups->constEnd() != iGroup)
			{
				if (iGroup.key() == oldId)
				{
					GLC_PrimitiveGroup* pGroup= iGroup.value();
					// Erase old group pointer
					pPrimitiveGroups->erase(iGroup);
					// Change the group ID
					pGroup->setId(pMat->id());
					// Add the group with  new ID
					pPrimitiveGroups->insert(pMat->id(), pGroup);
					iGroup= pPrimitiveGroups->end();
				}
				else
				{
					++iGroup;
				}
			}
			++iGroups;
		}
	}

	if (pMat != m_MaterialHash.value(oldId))
	{
		// Remove old material
		removeMaterial(oldId);

		addMaterial(pMat);
	}

}
Пример #14
0
// Replace the Master material
void GLC_Geometry::replaceMasterMaterial(GLC_Material* pMaterial)
{
	Q_ASSERT(!m_IsWire);
	if (!m_MaterialHash.isEmpty())
	{
		if (pMaterial != firstMaterial())
		{
			// Remove the first material
			MaterialHash::iterator iMaterial= m_MaterialHash.begin();
			removeMaterial(iMaterial.value()->id());

			// Add the new material
			addMaterial(pMaterial);
		}
	}
	else
	{
		addMaterial(pMaterial);
	}
}
Пример #15
0
void MaterialEntityItem::setMaterialURL(const QString& materialURLString, bool userDataChanged) {
    bool usingUserData = materialURLString.startsWith("userData");
    if (_materialURL != materialURLString || (usingUserData && userDataChanged)) {
        removeMaterial();
        _materialURL = materialURLString;

        if (materialURLString.contains("?")) {
            auto split = materialURLString.split("?");
            _currentMaterialName = split.last().toStdString();
        }

        if (usingUserData) {
            _parsedMaterials = NetworkMaterialResource::parseJSONMaterials(QJsonDocument::fromJson(getUserData().toUtf8()));

            // Since our material changed, the current name might not be valid anymore, so we need to update
            setCurrentMaterialName(_currentMaterialName);
            applyMaterial();
        } else {
            _networkMaterial = MaterialCache::instance().getMaterial(materialURLString);
            auto onMaterialRequestFinished = [&](bool success) {
                if (success) {
                    _parsedMaterials = _networkMaterial->parsedMaterials;

                    setCurrentMaterialName(_currentMaterialName);
                    applyMaterial();
                }
            };
            if (_networkMaterial) {
                if (_networkMaterial->isLoaded()) {
                    onMaterialRequestFinished(!_networkMaterial->isFailed());
                } else {
                    connect(_networkMaterial.data(), &Resource::finished, this, onMaterialRequestFinished);
                }
            }
        }
    }
}
Пример #16
0
MaterialEntityItem::~MaterialEntityItem() {
    removeMaterial();
}
Пример #17
0
void kore::ResourceManager::removeMaterial(const Material* mat) {
  removeMaterial(mat->getID());
}
Пример #18
0
void MaterialEntityItem::postParentFixup() {
    removeMaterial();
    applyMaterial();
}
Пример #19
0
void MaterialEntityItem::preDelete() {
    EntityItem::preDelete();
    removeMaterial();
}