//STEP 3: SENSE (COMPONENT) -> EXTRACT FROM COMPONENT: // 1) STATION // 2) START_VECTOR // 3) END_VECTOR // 4) RADIUS // 5) GLOBAL TRANSFORMATION MATRIX // -> USE MATRIX ON START_VECTOR AND END_VECTOR TO MAKE GLOBAL_START_VECTOR & GLOBAL_END_VECTOR // MAKE NEW NULL PART // MAKE A POINT OBJECT AS ZERO-LENGTH-VECTOR (WHAT'S A ZERO-LENGTH-VECTOR?) // MAKE NEW NULL GRAPHICS COMPONENT -> (ASSUMPTION: TRY TO ALLOCATE A GRAPHICS COMPONENT VIA component.GraphicComponents.TryGetGraphicComponent()) // CHECK FOR LINE INTERSECTION: // IF INTERSECTION -> ALLOCATE PART AND POINT TO COMPONENT -> RETURN 1 // ELSE -> ALLOCATE NULL AND ZERO_POINT TO COMPONENT -> RETURN 0 protected int Sense(SmartComponent component) { Station stn = component.ContainingProject as Station; if (stn == null) { return(0); //?? } Vector3 start = (Vector3)component.Properties["Start"].Value; Vector3 end = (Vector3)component.Properties["End"].Value; double radius = (double)component.Properties["Radius"].Value; // Convert to global (i.e. translate start and end point from component frame coorinates to global coordinates) Matrix4 mat = component.Transform.GlobalMatrix; start = mat.MultiplyPoint(start); end = mat.MultiplyPoint(end); Part part = null; Vector3 point = Vector3.ZeroVector; GraphicComponent gc = null; component.GraphicComponents.TryGetGraphicComponent("_sensorPart_", out gc);//<- WHAT'S ALL THIS THEN?! int result; if (CollisionDetector.CheckLineIntersection(stn, start, end, radius, out part, out point)) { component.Properties["SensedPart"].Value = part; component.Properties["SensedPoint"].Value = point; result = 1; } else { component.Properties["SensedPart"].Value = null; component.Properties["SensedPoint"].Value = Vector3.ZeroVector; result = 0; } return(result); }