GetAttributeSetValueFunction() public static method

public static GetAttributeSetValueFunction ( HEU_AttributeData.AttributeType attrType, HEU_ToolsInfo.PaintMergeMode paintMergeMode ) : SetAttributeValueFunc
attrType HEU_AttributeData.AttributeType
paintMergeMode HEU_ToolsInfo.PaintMergeMode
return SetAttributeValueFunc
示例#1
0
		public void FillAttribute(HEU_AttributeData attributeData, HEU_ToolsInfo sourceTools)
		{
			if(attributeData._attributeState == HEU_AttributeData.AttributeState.INVALID)
			{
				return;
			}

			HEU_AttributesStore.SetAttributeValueFunc setAttrFunc = HEU_AttributesStore.GetAttributeSetValueFunction(attributeData._attributeType, sourceTools._paintMergeMode);
			if (setAttrFunc == null)
			{
				return;
			}

			int tupleSize = attributeData._attributeInfo.tupleSize;
			int count = attributeData._attributeInfo.count;
			for (int pt = 0; pt < count; ++pt)
			{
				setAttrFunc(attributeData, pt * tupleSize, sourceTools, 0, sourceTools._paintBrushOpacity);
			}

			SetAttributeDataDirty(attributeData);
		}
示例#2
0
		private void HandlePaintEvent(RaycastHit hit, float brushRadius, HEU_ToolsInfo.PaintMergeMode paintMergeMode)
		{
			if(_selectedAttributesStore == null || _selectedAttributeData == null)
			{
				return;
			}

			HEU_AttributesStore.SetAttributeValueFunc setAttrFunc = HEU_AttributesStore.GetAttributeSetValueFunction(_selectedAttributeData._attributeType, paintMergeMode);
			if(setAttrFunc == null)
			{
				return;
			}

			Vector3[] positionArray = new Vector3[0];
			_selectedAttributesStore.GetPositionAttributeValues(out positionArray);

			int[] indices = new int[0];
			_selectedAttributesStore.GetVertexIndices(out indices);

			int numPositions = positionArray.Length;
			if (positionArray != null && numPositions > 0 && indices != null && indices.Length > 0)
			{
				Vector3 localHitPoint = _selectedAttributesStore.OutputTransform.InverseTransformPoint(hit.point);

				Mesh mesh = _selectedAttributesStore.OutputMesh;
				Color[] colors = mesh.colors;

				for (int posIndex = 0; posIndex < numPositions; ++posIndex)
				{
					float distance = Vector3.Distance(localHitPoint, positionArray[posIndex]);
					if (distance <= brushRadius)
					{
						float paintFactor = Mathf.Abs((brushRadius - distance) / brushRadius) * _toolsInfo._paintBrushOpacity;

						// Update the attribute
						_selectedAttributesStore.PaintAttribute(_selectedAttributeData, _toolsInfo, posIndex, paintFactor, setAttrFunc);

						// Get the paint color
						Color paintColor = _toolsInfo._affectedAreaPaintColor;
						if (_selectedAttributeData.IsColorAttribute())
						{
							if (_selectedAttributeData._attributeInfo.tupleSize >= 3 && _toolsInfo._paintFloatValue.Length >= 3)
							{
								paintColor.r = _toolsInfo._paintFloatValue[0];
								paintColor.g = _toolsInfo._paintFloatValue[1];
								paintColor.b = _toolsInfo._paintFloatValue[2];

								if (_selectedAttributeData._attributeInfo.tupleSize >= 4 && _toolsInfo._paintFloatValue.Length >= 4)
								{
									paintColor.a = _toolsInfo._paintFloatValue[3];
								}
							}
						}

						// Update local temporary mesh to show area of effect.
						// The position index, a point attribute, must be mapped to the vertex color,
						// which is a vertex attribute, via the vertex index
						int numIndices = indices.Length;
						for(int i = 0; i < numIndices; ++i)
						{
							if(indices[i] == posIndex && i < colors.Length)
							{
								colors[i] = Color.Lerp(colors[i], paintColor, paintFactor);
							}
						}
					}
				}

				mesh.colors = colors;
			}
		}