Beispiel #1
0
    private AnchorPosition GetAnchorPosition(AnchorNode n)
    {
        float xOffset = transform.position.x - n.transform.position.x;
        float zOffset = transform.position.z - n.transform.position.z;

        if (xOffset > 0)
        {
            if (zOffset > 0)
            {
                return(AnchorPosition.TopRight);
            }
            else
            {
                return(AnchorPosition.BottomRight);
            }
        }
        else
        {
            if (zOffset > 0)
            {
                return(AnchorPosition.TopLeft);
            }
            else
            {
                return(AnchorPosition.BottomLeft);
            }
        }
    }
Beispiel #2
0
        private static AnchorNode CreateWithType(AnchorNode.Mode type)
        {
            var node = new AnchorNode();

            node.InputAnchorType.Value = type;
            return(node);
        }
Beispiel #3
0
 public NodeFactory()
 {
     builtin["Anchor"]                  = new AnchorNode();
     builtin["Appearance"]              = new AppearanceNode();
     builtin["Background"]              = new BackgroundNode();
     builtin["Box"]                     = new BoxNode();
     builtin["Color"]                   = new ColorNode();
     builtin["Cone"]                    = new ConeNode();
     builtin["Coordinate"]              = new CoordinateNode();
     builtin["CoordinateInterpolator"]  = new CoordinateInterpolatorNode();
     builtin["Cylinder"]                = new CylinderNode();
     builtin["DirectionalLight"]        = new DirectionalLightNode();
     builtin["Extrusion"]               = new ExtrusionNode();
     builtin["Group"]                   = new GroupNode();
     builtin["Collision"]               = new CollisionNode();
     builtin["Switch"]                  = new SwitchNode();
     builtin["IndexedFaceSet"]          = new IndexedFaceSetNode();
     builtin["IndexedLineSet"]          = new IndexedLineSetNode();
     builtin["Material"]                = new MaterialNode();
     builtin["NavigationInfo"]          = new NavigationInfoNode();
     builtin["OrientationInterpolator"] = new OrientationInterpolatorNode();
     builtin["Normal"]                  = new NormalNode();
     builtin["PixelTexture"]            = new PixelTextureNode();
     builtin["PointLight"]              = new PointLightNode();
     builtin["PositionInterpolator"]    = new PositionInterpolatorNode();
     builtin["ScalarInterpolator"]      = new ScalarInterpolationNode();
     builtin["Shape"]                   = new ShapeNode();
     builtin["Sphere"]                  = new SphereNode();
     builtin["TextureCoordinate"]       = new TextureCoordinateNode();
     builtin["TimeSensor"]              = new TimeSensorNode();
     builtin["Transform"]               = new TransformNode();
     builtin["Viewpoint"]               = new ViewpointNode();
     builtin["WorldInfo"]               = new WorldInfoNode();
 }
Beispiel #4
0
 public void AddToScene(ArFragment arFragment)
 {
     MainThread.BeginInvokeOnMainThread(() =>
     {
         RecreateRenderableOnMainThread();
         AnchorNode.SetParent(arFragment.ArSceneView.Scene);
     });
 }
Beispiel #5
0
 public void SetWall(AnchorNode firstAnchor, AnchorNode secondAnchor, Wall wall)
 {
     if (_anchors.ContainsKey(firstAnchor) && _anchors.ContainsKey(secondAnchor))
     {
         if (!walls.Contains(wall))
         {
             walls.Add(wall);
         }
     }
 }
Beispiel #6
0
        public AnchorVisual(ArFragment arFragment, Anchor localAnchor)
        {
            AnchorNode = new AnchorNode(localAnchor);

            transformableNode = new TransformableNode(arFragment.TransformationSystem);
            transformableNode.ScaleController.Enabled       = false;
            transformableNode.TranslationController.Enabled = false;
            transformableNode.RotationController.Enabled    = false;
            transformableNode.SetParent(AnchorNode);
        }
Beispiel #7
0
    public AnchorNode GetAnchorFromPos(Vector3 pos)
    {
        AnchorNode result = null;

        foreach (AnchorNode n in _anchors)
        {
            if (n.transform.position == new Vector3(pos.x, 0, pos.z))
            {
                return(n);
            }
        }
        return(result);
    }
Beispiel #8
0
        private static void VisitorSection()
        {
            var htmlDocument = new HtmlDocument();

            htmlDocument.AddNode(new AnchorNode());
            htmlDocument.AddNode(new HeadingNode());
            htmlDocument.Execute(new HighlightOperation());
            htmlDocument.Execute(new BoldOperation());

            var anchor = new AnchorNode();

            anchor.Execute(new HighlightOperation());
        }
Beispiel #9
0
 public void Destroy()
 {
     MainThread.BeginInvokeOnMainThread(() =>
     {
         AnchorNode.Renderable = null;
         AnchorNode.SetParent(null);
         Anchor localAnchor = AnchorNode.Anchor;
         if (localAnchor != null)
         {
             AnchorNode.Anchor = null;
             localAnchor.Detach();
         }
     });
 }
        /// <summary>
        /// Creates 3D model with the specified anchors
        /// </summary>
        private AnchorModel CreateModel(AnchorNode localAnchor, CloudSpatialAnchor cloudAnchor)
        {
            var anchorModel = new AnchorModel
            {
                LocalAnchor = localAnchor,
                CloudAnchor = cloudAnchor
            };

            localAnchor.SetParent(arFragment.ArSceneView.Scene);
            var model = new TransformableNode(arFragment.TransformationSystem);

            model.SetParent(localAnchor);
            model.Renderable = this.modelRenderable;
            model.Select();
            return(anchorModel);
        }
        // CompletableFuture requires api level 24
        // FutureReturnValueIgnored is not valid
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            if (!CheckIsSupportedDeviceOrFinish(this))
            {
                return;
            }

            SetContentView(Resource.Layout.activity_main);
            arFragment = (ArFragment)SupportFragmentManager.FindFragmentById(Resource.Id.ux_fragment);

            // When you build a Renderable, Sceneform loads its resources in the background while returning
            // a CompletableFuture. Call thenAccept(), handle(), or check isDone() before calling get().
            ModelRenderable.InvokeBuilder()
            .SetSource(this, Resource.Raw.andy)
            .Build()
            .ThenAccept(new Consumer(t => andyRenderable = (ModelRenderable)t))
            .Exceptionally(new Function(_ =>
            {
                Toast toast = Toast.MakeText(this, "Unable to load andy renderable", ToastLength.Long);
                toast.SetGravity(GravityFlags.Center, 0, 0);
                toast.Show();
                return(null);
            }
                                        ));

            arFragment.SetOnTapArPlaneListener(new OnTapArPlaneListener((hitResult, plane, motionEvent) =>
            {
                if (andyRenderable == null)
                {
                    return;
                }

                // Create the Anchor.
                Anchor anchor         = hitResult.CreateAnchor();
                AnchorNode anchorNode = new AnchorNode(anchor);
                anchorNode.SetParent(arFragment.ArSceneView.Scene);

                // Create the transformable andy and add it to the anchor.
                TransformableNode andy = new TransformableNode(arFragment.TransformationSystem);
                andy.SetParent(anchorNode);
                andy.Renderable = andyRenderable;
                andy.Select();
            }
                                                                        ));
        }
Beispiel #12
0
    private void SpawnAnchors()
    {
        for (int y = 1; y < _levelHeight; y++)
        {
            for (int x = 1; x < _levelWidth; x++)
            {
                GameObject g = GameObject.CreatePrimitive(PrimitiveType.Sphere);
                g.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);
                g.transform.position   = new Vector3(x - (_levelHeight / 2), 0, y - (_levelWidth / 2));
                g.name = "Anchor (" + x + "," + y + ")";

                AnchorNode n = g.AddComponent <AnchorNode>();
                n.transform.SetParent(transform);
                n.Initialize(x - 1, y - 1);
                _anchors[x - 1, y - 1] = n;
            }
        }
    }
Beispiel #13
0
 public void SetAnchors(WorldController worldController)
 {
     _anchors = new Dictionary <AnchorNode, AnchorPosition>();
     for (int dx = -1; dx <= 1; ++dx)
     {
         for (int dy = -1; dy <= 1; ++dy)
         {
             if (dx != 0 || dy != 0)
             {
                 AnchorNode n = worldController.GetAnchorFromPos(new Vector3((_posX + (dx * 0.5f) + 0.5f) - (worldController._levelWidth / 2), 0, (_posY + (dy * 0.5f) + 0.5f) - (worldController._levelHeight / 2)));
                 if (n != null)
                 {
                     AnchorPosition anchorPos = GetAnchorPosition(n);
                     _anchors.Add(n, anchorPos);
                 }
             }
         }
     }
 }
        private void OnTapArPlane(object sender, BaseArFragment.TapArPlaneEventArgs e)
        {
            if (andyRenderable == null)
            {
                return;
            }

            // Create the Anchor.
            Anchor     anchor     = e.HitResult.CreateAnchor();
            AnchorNode anchorNode = new AnchorNode(anchor);

            anchorNode.SetParent(arFragment.ArSceneView.Scene);

            // Create the transformable andy and add it to the anchor.
            TransformableNode andy = new TransformableNode(arFragment.TransformationSystem);

            andy.SetParent(anchorNode);
            andy.Renderable = andyRenderable;
            andy.Select();
        }
Beispiel #15
0
    // TODO: Clean grid and anchor generation
    void Awake()
    {
        GameAccesPoint.worldController = this;

        _levelWidth  = 10;
        _levelHeight = 10;

        _grid    = new TileNode[_levelWidth, _levelHeight];
        _anchors = new AnchorNode[_levelWidth - 1, _levelHeight - 1];

        floorTilePrefab = (GameObject)Resources.Load("Prefabs/Floor_Tile");

        SpawnTiles();
        SpawnAnchors();

        foreach (TileNode t in _grid)
        {
            t.SetNeighbours(this);
            t.SetAnchors(this);
        }
    }
Beispiel #16
0
        /*
         * Used as the listener for setOnTapArPlaneListener.
         */
        private void OnPlaneTap(HitResult hitResult, Google.AR.Core.Plane unusedPlane, MotionEvent unusedMotionEvent)
        {
            if (andyRenderable == null || hatRenderable == null)
            {
                return;
            }
            // Create the Anchor.
            Anchor anchor = hitResult.CreateAnchor();

            if (anchorNode == null)
            {
                anchorNode = new AnchorNode(anchor);
                anchorNode.SetParent(arFragment.ArSceneView.Scene);

                andy = new SkeletonNode();

                andy.SetParent(anchorNode);
                andy.Renderable = andyRenderable;
                hatNode         = new Node();

                // Attach a node to the bone.  This node takes the internal scale of the bone, so any
                // renderables should be added to child nodes with the world pose reset.
                // This also allows for tweaking the position relative to the bone.
                Node boneNode = new Node();
                boneNode.SetParent(andy);
                andy.SetBoneAttachment(HAT_BONE_NAME, boneNode);
                hatNode.Renderable = hatRenderable;
                hatNode.SetParent(boneNode);
                hatNode.WorldScale    = Vector3.One();
                hatNode.WorldRotation = Quaternion.Identity();
                Vector3 pos = hatNode.WorldPosition;

                // Lower the hat down over the antennae.
                pos.Y -= .1f;

                hatNode.WorldPosition = pos;
            }
        }
Beispiel #17
0
 public void Apply(AnchorNode anchorNode)
 {
     System.Console.WriteLine("Highlight Anchor");
 }
Beispiel #18
0
 public void Apply(AnchorNode anchor)
 {
     Console.WriteLine("highlight-anchor");
 }
Beispiel #19
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        if (!PedestrianSystem || !PedestrianSystem.Instance)
        {
            return;
        }

        GUILayout.Space(10.0f);
        GUILayout.BeginVertical("box");

        if (GUILayout.Button("Generate Node", GUILayout.Height(49)))
        {
            if (!PedestrianSystem.Instance.m_nodePrefab)
            {
                Debug.LogError("Node Prefab not set. You can find one in \"Assets\\Pedestrian System\\Prefabs\\Pathing\". Node Generation Cancelled.");
                return;
            }

            PedestrianNode node = PrefabUtility.InstantiatePrefab(PedestrianSystem.Instance.m_nodePrefab) as PedestrianNode;
            Selection.activeGameObject = node.gameObject;
            node.transform.parent      = PedestrianSystem.Instance.transform;

            if (PedestrianSystem.Instance.m_autoLink)
            {
                if (PedestrianSystem.Instance.m_linkBothDir)
                {
                    if (EditNode)
                    {
                        EditNode.AddNode(node);
                        EditorUtility.SetDirty(EditNode);

                        node.AddNode(EditNode);
                        EditorUtility.SetDirty(node);

                        Vector3 pos = EditNode.transform.position;
                        pos.x += 4.0f;
                        node.transform.position = pos;
                    }
                    else if (AnchorNode)
                    {
                        AnchorNode.AddNode(node);
                        EditorUtility.SetDirty(AnchorNode);

                        node.AddNode(AnchorNode);
                        EditorUtility.SetDirty(node);

                        Vector3 pos = AnchorNode.transform.position;
                        pos.x += 4.0f;
                        node.transform.position = pos;
                    }
                }
                else if (EditNode)
                {
                    EditNode.AddNode(node);
                    EditorUtility.SetDirty(EditNode);

                    Vector3 pos = EditNode.transform.position;
                    pos.x += 4.0f;
                    node.transform.position = pos;
                }
                else if (AnchorNode)
                {
                    AnchorNode.AddNode(node);
                    EditorUtility.SetDirty(AnchorNode);

                    Vector3 pos = AnchorNode.transform.position;
                    pos.x += 4.0f;
                    node.transform.position = pos;
                }
            }

            if (EditNode)
            {
                if (AnchorNode)
                {
                    AnchorNode.transform.parent = PedestrianSystem.transform;
                }

                AnchorNode = EditNode;
                AnchorNode.transform.parent = AnchorNodeFolder.transform;

                EditNode = node;
                EditNode.transform.parent = EditNodeFolder.transform;

                PedestrianSystem.Instance.SetPedestrianNode(PedestrianSystem.Tooltip.ANCHOR, AnchorNode);
            }
            else
            {
                EditNode = node;
                EditNode.transform.parent = EditNodeFolder.transform;
            }

            PedestrianSystem.Instance.SetPedestrianNode(PedestrianSystem.Tooltip.EDIT, node);
        }

        GUILayout.EndVertical();
        bool guiChanged = false;

        if (EditNode && AnchorNode)
        {
            GUILayout.BeginHorizontal("box");
            if (GUILayout.Button("Go to 'Edit' Piece", GUILayout.Height(49)))
            {
                Selection.activeObject = EditNode.transform;
            }

            if (GUILayout.Button("Go to 'Anchor' Piece", GUILayout.Height(49)))
            {
                Selection.activeObject = AnchorNode.transform;
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(10.0f);
        }

        PedestrianNode useAnchorNode = null;
        PedestrianNode useEditNode   = null;

        if (PedestrianSystem.Instance.EditNode)
        {
            useEditNode = PedestrianSystem.Instance.EditNode;
        }
        else if (PedestrianSystem.Instance.PreviousEditNode)
        {
            useEditNode = PedestrianSystem.Instance.PreviousEditNode;
        }

        if (PedestrianSystem.Instance.AnchorNode)
        {
            useAnchorNode = PedestrianSystem.Instance.AnchorNode;
        }
        else if (PedestrianSystem.Instance.PreviousAnchorNode)
        {
            useAnchorNode = PedestrianSystem.Instance.PreviousAnchorNode;
        }

        if (useAnchorNode && useEditNode)
        {
            GUILayout.BeginHorizontal("box");

            if (PedestrianSystem && PedestrianSystem.TextureIconAnchorToEdit)
            {
                if (GUILayout.Button(PedestrianSystem.TextureIconAnchorToEdit))
                {
                    // link Anchor To Edit
                    PedestrianSystem.Instance.LinkNode();
                    guiChanged = true;
                }
            }
            else
            {
                if (GUILayout.Button("Link Anchor To Edit", GUILayout.Height(49)))
                {
                    // link Anchor To Edit
                    PedestrianSystem.Instance.LinkNode();
                    guiChanged = true;
                }
            }

            if (PedestrianSystem.TextureIconEditToAnchor)
            {
                if (GUILayout.Button(PedestrianSystem.TextureIconEditToAnchor))
                {
                    // link Edit to Anchor
                    PedestrianSystem.Instance.LinkNode(false);
                    guiChanged = true;
                }
            }
            else
            {
                if (GUILayout.Button("Link Edit to Anchor", GUILayout.Height(49)))
                {
                    // link Edit to Anchor
                    PedestrianSystem.Instance.LinkNode(false);
                    guiChanged = true;
                }
            }
            GUILayout.EndHorizontal();
        }

//		if(PedestrianSystem.Instance.EditNode)
//		{
//			SetPedestrianNode( PedestrianSystem.Tooltip.EDIT, PedestrianSystem.Instance.EditNode );
//			PedestrianSystem.Instance.SetPedestrianNode( PedestrianSystem.Tooltip.EDIT, null );
//		}
//
//		if(PedestrianSystem.Instance.AnchorNode)
//		{
//			SetPedestrianNode( PedestrianSystem.Tooltip.ANCHOR, PedestrianSystem.Instance.AnchorNode );
//			PedestrianSystem.Instance.SetPedestrianNode( PedestrianSystem.Tooltip.ANCHOR, null );
//		}

        if (guiChanged)
        {
            EditorUtility.SetDirty(useAnchorNode);
            EditorUtility.SetDirty(useEditNode);
        }

        if (EditNodeFolder)
        {
            for (int cIndex = 0; cIndex < EditNodeFolder.childCount; cIndex++)
            {
                EditNodeFolder.GetChild(cIndex).transform.parent = PedestrianSystem.transform;
            }

            if (EditNode)
            {
                EditNode.transform.parent = EditNodeFolder;
            }
        }

        if (AnchorNodeFolder)
        {
            for (int cIndex = 0; cIndex < AnchorNodeFolder.childCount; cIndex++)
            {
                AnchorNodeFolder.GetChild(cIndex).transform.parent = PedestrianSystem.transform;
            }

            if (AnchorNode)
            {
                AnchorNode.transform.parent = AnchorNodeFolder;
            }
        }

        if (AnchorNode)
        {
            SetPedestrianNode(PedestrianSystem.Tooltip.ANCHOR, AnchorNode);
        }

        if (EditNode)
        {
            SetPedestrianNode(PedestrianSystem.Tooltip.EDIT, EditNode);
        }

        if (GUI.changed)
        {
            EditorUtility.SetDirty(PedestrianSystem);
        }
    }
Beispiel #20
0
 public void Apply(AnchorNode anchor)
 {
     Console.WriteLine("text-anchor");
 }
 public AnchorVisual(Anchor localAnchor)
 {
     anchorNode = new AnchorNode(localAnchor);
 }