예제 #1
0
		public Bone(Document doc, Face face)
		{
			if (face.PointCount != 3)
				throw new ArgumentException("face.PointCount must be 3");

			var vertices = face.Points.Select(_ => face.Object.Vertices[_]).ToArray();

			// 辺の長さ算出、長さ順
			var lengths = vertices.Select((_, idx) =>
			{
				var nextIdx = (idx + 1) % vertices.Length;
				var next = vertices[nextIdx];
				var length = (next.Point - _.Point).GetSizeSquared();

				return new
				{
					FirstIndex = idx,
					NextIndex = nextIdx,
					FirstVertex = _,
					NextVertex = next,
					Length = length
				};
			})
								  .OrderBy(_ => _.Length)
								  .ToArray();
			var middle = lengths[1];	// 二番目に長い辺がボーンの軸
			var shortest = lengths[0];	// 一番短い辺も取る

			// ボーン軸になる辺のどちらかの頂点が一番短い辺と頂点を共有しているかを調べる
			// 頂点を共有してる方がボーンの始点
			if (middle.FirstIndex == shortest.FirstIndex ||
				middle.FirstIndex == shortest.NextIndex)
			{
				this.Begin = middle.FirstVertex;
				this.End = middle.NextVertex;
				this.Helper = shortest.FirstIndex == middle.FirstIndex ? shortest.NextVertex : shortest.FirstVertex;
			}
			else
			{
				this.Begin = middle.NextVertex;
				this.End = middle.FirstVertex;
				this.Helper = shortest.FirstIndex == middle.NextIndex ? shortest.NextVertex : shortest.FirstVertex;
			}

			this.Face = face;
			this.Material = this.Face.Material == -1 ? null : doc.Materials[this.Face.Material];
		}
예제 #2
0
		public static unsafe int SendUserMessage(IPlugin plugin, Document doc, uint target_product, uint target_id, string description, IntPtr message)
		{
			var info = new SendMessageInfo();
			var result = 0;

			fixed (byte* documentString = GetASCII("document"),
						 targetProductString = GetASCII("target_product"),
						 targetIdString = GetASCII("target_id"),
						 descriptionString = GetASCII("description"),
						 messageString = GetASCII("message"),
						 resultString = GetASCII("result"),
						 descriptionPtr = Get932(description))
			{
				var array = new void*[]
				{
					documentString,
					(void*)(IntPtr)doc,
					targetProductString,
					&target_product,
					targetIdString,
					&target_id,
					descriptionString,
					descriptionPtr,
					messageString,
					(void*)message,
					resultString,
					&result,
					null,
				};

				plugin.GetPluginId(out info.Product, out info.ID);

				fixed (void** arrayPtr = array)
				{
					info.Option = (IntPtr)arrayPtr;

					NativeMethods.MQ_SendMessage((int)Message.UserMessage, ref info);
				}
			}

			return result;
		}
예제 #3
0
		partial void Initialize()
		{
			Instance = this;
			this.Objects = new ReadOnlyIndexer<Object>(this.GetObject, () => this.ObjectCount);
			this.Materials = new ReadOnlyIndexer<Material>(this.GetMaterial, () => this.MaterialCount);
		}