Beispiel #1
0
		public bool GetUpdatedPosition(HEU_HoudiniAsset asset, ref Vector3 inPosition)
		{
			if (_handleParamTranslateBinding == null || _handleParamTranslateBinding._bDisabled)
			{
				return false;
			}

			HEU_SessionBase session = asset.GetAssetSession(true);
			if(session == null)
			{
				return false;
			}

			if (IsSpecialRSTOrder(_rstOrder))
			{
				HAPI_TransformEuler transformEuler = _convertedTransformEuler;
				transformEuler.position[0] = inPosition[0];
				transformEuler.position[1] = inPosition[1];
				transformEuler.position[2] = inPosition[2];

				HAPI_TransformEuler newTransformEuler;
				if (!session.ConvertTransform(ref transformEuler, _rstOrder, _xyzOrder, out newTransformEuler))
				{
					return false;
				}

				inPosition[0] = newTransformEuler.position[0];
				inPosition[1] = newTransformEuler.position[1];
				inPosition[2] = newTransformEuler.position[2];
			}

			inPosition[0] = -inPosition[0];

			return true;
		}
Beispiel #2
0
		public bool GetUpdatedRotation(HEU_HoudiniAsset asset, ref Quaternion inRotation)
		{
			if (_handleParamTranslateBinding == null || _handleParamTranslateBinding._bDisabled)
			{
				return false;
			}

			HEU_SessionBase session = asset.GetAssetSession(true);
			if (session == null)
			{
				return false;
			}

			Vector3 newRotation = inRotation.eulerAngles;

			HAPI_TransformEuler transformEuler = _convertedTransformEuler;

			transformEuler.position[0] = 0;
			transformEuler.position[1] = 0;
			transformEuler.position[2] = 0;
			transformEuler.rotationEuler[0] = newRotation[0];
			transformEuler.rotationEuler[1] = newRotation[1];
			transformEuler.rotationEuler[2] = newRotation[2];
			transformEuler.scale[0] = 1;
			transformEuler.scale[1] = 1;
			transformEuler.scale[2] = 1;
			transformEuler.rotationOrder = HAPI_XYZOrder.HAPI_ZXY;
			transformEuler.rstOrder = HAPI_RSTOrder.HAPI_SRT;

			HAPI_TransformEuler newTransformEuler;
			if (!session.ConvertTransform(ref transformEuler, _rstOrder, _xyzOrder, out newTransformEuler))
			{
				return false;
			}

			inRotation[0] = newTransformEuler.rotationEuler[0];
			inRotation[1] = -newTransformEuler.rotationEuler[1];
			inRotation[2] = -newTransformEuler.rotationEuler[2];

			return true;
		}
Beispiel #3
0
		public void GenerateTransform(HEU_SessionBase session, HEU_Parameters parameters)
		{
			HAPI_TransformEuler transformEuler = new HAPI_TransformEuler(true);

			transformEuler.rstOrder = _rstOrder;
			transformEuler.rotationOrder = _xyzOrder;

			transformEuler.position[0] = 0;
			transformEuler.position[1] = 0;
			transformEuler.position[2] = 0;

			transformEuler.rotationEuler[0] = 0;
			transformEuler.rotationEuler[1] = 0;
			transformEuler.rotationEuler[2] = 0;

			transformEuler.scale[0] = 1;
			transformEuler.scale[1] = 1;
			transformEuler.scale[2] = 1;

			if (_handleParamTranslateBinding != null)
			{
				HEU_ParameterData parmData = parameters.GetParameterWithParmID(_handleParamTranslateBinding._parmID);
				if (parmData != null && !parmData._parmInfo.invisible)
				{
					transformEuler.position[0] = parmData._floatValues[0];
					transformEuler.position[1] = parmData._floatValues[1];
					transformEuler.position[2] = parmData._floatValues[2];
				}
			}

			if(_handleParamRotateBinding != null)
			{
				HEU_ParameterData parmData = parameters.GetParameterWithParmID(_handleParamRotateBinding._parmID);
				if (parmData != null && !parmData._parmInfo.invisible)
				{
					transformEuler.rotationEuler[0] = parmData._floatValues[0];
					transformEuler.rotationEuler[1] = parmData._floatValues[1];
					transformEuler.rotationEuler[2] = parmData._floatValues[2];
				}
			}

			if(_handleParamScaleBinding != null)
			{
				HEU_ParameterData parmData = parameters.GetParameterWithParmID(_handleParamScaleBinding._parmID);
				if (parmData != null && !parmData._parmInfo.invisible)
				{
					transformEuler.scale[0] = parmData._floatValues[0];
					transformEuler.scale[1] = parmData._floatValues[1];
					transformEuler.scale[2] = parmData._floatValues[2];
				}
			}

			if (!session.ConvertTransform(ref transformEuler, HAPI_RSTOrder.HAPI_SRT, HAPI_XYZOrder.HAPI_ZXY, out _convertedTransformEuler))
			{
				return;
			}

			// Convert to left-handed Unity
			_convertedTransformEuler.position[0] = -_convertedTransformEuler.position[0];
			_convertedTransformEuler.rotationEuler[1] = -_convertedTransformEuler.rotationEuler[1];
			_convertedTransformEuler.rotationEuler[2] = -_convertedTransformEuler.rotationEuler[2];

			if (IsSpecialRSTOrder(transformEuler.rstOrder))
			{
				_handlePosition = new Vector3(_convertedTransformEuler.position[0], _convertedTransformEuler.position[1], _convertedTransformEuler.position[2]);
			}
			else if (_handleParamTranslateBinding != null)
			{
				_handlePosition = new Vector3(-transformEuler.position[0], transformEuler.position[1], transformEuler.position[2]);
			}
			else
			{
				_handlePosition = Vector3.zero;
			}

			_handleRotation = Quaternion.Euler(_convertedTransformEuler.rotationEuler[0], _convertedTransformEuler.rotationEuler[1], _convertedTransformEuler.rotationEuler[2]);

			if (_handleParamScaleBinding != null)
			{
				_handleScale = new Vector3(transformEuler.scale[0], transformEuler.scale[1], transformEuler.scale[2]);
			}
			else
			{
				_handleScale = Vector3.one;
			}
		}