private void PlaceMenu(Vector3 position, Vector3 normal, bool needsBillboarding = false) { // Offset in a bit position -= normal * 0.05f; Quaternion rotation = Quaternion.LookRotation(normal, Vector3.up); // Place it transform.position = position; transform.rotation = rotation; // Setup the menu SetupMenus(); // Enable it ParentCanvas.gameObject.SetActive(true); // Create up a box MenuAnimatedBox = new AnimatedBox(0.0f, position, rotation, new Color(1.0f, 1.0f, 1.0f, 0.25f), new Vector3(MenuWidth * 0.5f, MenuHeight * 0.5f, 0.025f), LineDrawer.DefaultLineWidth * 0.5f); // Initial position transform.position = MenuAnimatedBox.AnimPosition.Evaluate(MenuAnimatedBox.Time); transform.rotation = MenuAnimatedBox.Rotation * Quaternion.AngleAxis(360.0f * MenuAnimatedBox.AnimRotation.Evaluate(MenuAnimatedBox.Time), Vector3.up); // Billboarding (note that because of the transition animation we need to place this late) placedMenuNeedsBillboard = needsBillboarding; // And mark that we've done it HasPlacedMenu = true; }
/** * Create a new placement result. * * @param timeDelay time delay for the animated box * @param result placement result * @param drawBox indicates whether an animated box should be drawn around the placement result * @param callback callback method */ public PlacementResult(float timeDelay, SUDLLOP.ObjectPlacementResult result, bool drawBox = true, ResponseDelegate callback = null) { if (drawBox) { this.box = new AnimatedBox(timeDelay, result.Position, Quaternion.LookRotation(result.Forward, result.Up), Random.ColorHSV(0.0f, 1.0f, 1.0f, 1.0f, 0.5f, 1.0f), result.HalfDims); } if (callback != null) { callback(true, new Vector3(result.Position.x, result.Position.y - result.HalfDims.y, result.Position.z)); } this.result = result; }
protected bool Draw_AnimatedBox(AnimatedBox box) { // Update the time if (!box.Update(Time.deltaTime)) { return(false); } if (box.IsAnimationComplete) { // Animation is done, just pass through return(Draw_Box(box.Center, box.Rotation, box.Color, box.HalfSize, box.LineWidth)); } // Draw it using the current animation state return(Draw_Box( box.AnimPosition.Evaluate(box.Time), box.Rotation * Quaternion.AngleAxis(360.0f * box.AnimRotation.Evaluate(box.Time), Vector3.up), box.Color, box.HalfSize * box.AnimScale.Evaluate(box.Time), box.LineWidth)); }
public PlacementResult(float timeDelay, SpatialUnderstandingDllObjectPlacement.ObjectPlacementResult result) { Box = new AnimatedBox(timeDelay, result.Position, Quaternion.LookRotation(result.Forward, result.Up), Color.blue, result.HalfDims); Result = result; }
protected bool Draw_AnimatedBox(AnimatedBox box) { // Update the time if (!box.Update(Time.deltaTime)) { return false; } if (box.IsAnimationComplete) { // Animation is done, just pass through return Draw_Box(box.Center, box.Rotation, box.Color, box.HalfSize, box.LineWidth); } // Draw it using the current anim state return Draw_Box( box.AnimPosition.Evaluate(box.Time), box.Rotation * Quaternion.AngleAxis(360.0f * box.AnimRotation.Evaluate(box.Time), Vector3.up), box.Color, box.HalfSize * box.AnimScale.Evaluate(box.Time), box.LineWidth); }