当前位置: 首页>>代码示例>>C#>>正文


C# BodyPart.TransformPointToOpposite方法代码示例

本文整理汇总了C#中BodyPart.TransformPointToOpposite方法的典型用法代码示例。如果您正苦于以下问题:C# BodyPart.TransformPointToOpposite方法的具体用法?C# BodyPart.TransformPointToOpposite怎么用?C# BodyPart.TransformPointToOpposite使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BodyPart的用法示例。


在下文中一共展示了BodyPart.TransformPointToOpposite方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DrawShapeHandle


//.........这里部分代码省略.........
						
						// apply the result
						DoShapeSizeThresholdTest(parts[1], CapsuleToSize(parts[1], height, radius));
						parts[1].PasteShapeSizeToOpposite(isScaleSymmetrical);
					}
				}
				break;
			case ShapeType.Sphere:
				// create a simple radius handle
				float oldRadius = Mathf.Max(
					part.shapeSize.x*part.bone.lossyScale.x*0.5f, 
					part.shapeSize.y*part.bone.lossyScale.y*0.5f, 
					part.shapeSize.z*part.bone.lossyScale.z*0.5f);
				radius = Handles.RadiusHandle(part.bone.rotation*part.shapeRotation, part.bone.TransformPoint(part.shapeCenter), oldRadius);
				if (Mathf.Abs(radius-oldRadius)>changeThreshold)
				{
					float scaleFactor = 1f/VectorHelpers.MaxValue(part.bone.lossyScale);
					part.shapeSize.x = 2f*radius*scaleFactor;
					part.shapeSize.y = 2f*radius*scaleFactor;
					part.shapeSize.z = 2f*radius*scaleFactor;
					oldRadius = radius;
				}
				
				// handle symmetry
				if (parts.Length>1)
				{
					part.PasteShapeSizeToOpposite(isScaleSymmetrical);
					if (drawOpposite)
					{
						// ghost the opposite part
						CustomHandleUtilities.SetHandleColor(oldColor, symmetryAlpha);
						oldRadius = Mathf.Max(
							parts[1].shapeSize.x*parts[1].bone.lossyScale.x*0.5f, 
							parts[1].shapeSize.y*parts[1].bone.lossyScale.y*0.5f, 
							parts[1].shapeSize.z*parts[1].bone.lossyScale.z*0.5f);
						radius = Handles.RadiusHandle(parts[1].bone.rotation*part.shapeRotation, parts[1].bone.TransformPoint(parts[1].shapeCenter), oldRadius);
						if (Mathf.Abs(radius-oldRadius)>changeThreshold)
						{
							parts[1].shapeSize.x = 2f*radius;
							parts[1].shapeSize.y = 2f*radius;
							parts[1].shapeSize.z = 2f*radius;
							parts[1].PasteShapeSizeToOpposite(isScaleSymmetrical);
						}
					}
				}
				break;
			}
		}
		
		// center handles
		if (isCenterHandleEnabled)
		{
			// position handle for the center
			Vector3 center = part.bone.InverseTransformPoint(Handles.PositionHandle(part.bone.TransformPoint(part.shapeCenter), part.bone.rotation*part.shapeRotation));
			
			// rotation handle
//			Quaternion rotation = Quaternion.Inverse(part.bone.rotation)*Handles.RotationHandle(part.bone.rotation*part.shapeRotation, part.bone.TransformPoint(part.shapeCenter));
			
			// handle symmetry
			if (parts.Length>1)
			{
				center = part.TransformPointToOpposite(center, isScaleSymmetrical);
//				rotation = part.TransformRotationToOpposite(rotation);
				if (drawOpposite)
				{
					center = parts[1].bone.InverseTransformPoint(Handles.PositionHandle(parts[1].bone.TransformPoint(center), parts[1].bone.rotation*part.shapeRotation));
//					rotation = Quaternion.Inverse(parts[1].bone.rotation)*Handles.RotationHandle(parts[1].bone.rotation*parts[1].shapeRotation, parts[1].bone.TransformPoint(parts[1].shapeCenter));
				}
				center = parts[1].TransformPointToOpposite(center, isScaleSymmetrical);
//				rotation = parts[1].TransformRotationToOpposite(rotation);
			}
			
			// apply results
			if ((part.shapeCenter-center).sqrMagnitude>changeThreshold*changeThreshold)
				part.shapeCenter = center;
//			if (Quaternion.Angle(part.shapeRotation, rotation)>changeThreshold) part.shapeRotation = rotation;
		}
		
		if (parts.Length>1)
		{	
			// update values
			parts[1].shapeType = part.shapeType;
			
			Vector3 oldValue = parts[1].shapeCenter;
			Vector3 newValue = part.TransformPointToOpposite(part.shapeCenter, isScaleSymmetrical);
			if ((oldValue-newValue).sqrMagnitude>changeThreshold*changeThreshold)
				parts[1].shapeCenter = newValue;
			
			oldValue = parts[1].shapeSize;
			part.PasteShapeSizeToOpposite(isScaleSymmetrical);
			if ((oldValue-parts[1].shapeSize).sqrMagnitude<changeThreshold*changeThreshold)
				parts[1].shapeSize = oldValue;
				
			// TODO: mirror rotation if/when collider rotation is implemented
		}
		
		CustomHandleUtilities.SetHandleColor(oldColor);
		
		foreach (BodyPart p in parts) EditorUtility.SetDirty(p);
	}
开发者ID:hyper-active,项目名称:virtual-reality,代码行数:101,代码来源:BodyPartEditor.cs


注:本文中的BodyPart.TransformPointToOpposite方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。