Ejemplo n.º 1
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();
 }
Ejemplo n.º 2
0
    /* Generates a node using a given prefab, set the info and returns a GameObject */
    public GameObject generateNode(GameObject prefab, NodeInfo info)
    {
        GameObject node = generateNode(prefab);
        NormalNode n    = node.GetComponent <NormalNode>();

        n.setInfo(info);
        return(node);
    }
Ejemplo n.º 3
0
    /* Initializes the tee with a given fab and populates the node with info */
    public GameObject init(GameObject preFab, NodeInfo info)
    {
        GameObject nN = Instantiate(preFab);

        nN.transform.position = START_POS;
        NormalNode nNode = nN.GetComponent <NormalNode>();

        nNode.connectionFab = connectionFab;
        nNode.init(info);
        nodes.Add(nN);
        isInit = true;
        return(nN);
    }
Ejemplo n.º 4
0
 public WorkflowStation(string id, NormalNode rootNode, WalkerContext context)
 {
     _walkerContext      = context ?? throw new ArgumentNullException(nameof(context));
     _rootNode           = rootNode ?? throw new ArgumentNullException(nameof(rootNode));
     _registeredNodeList = new List <Node> {
         _rootNode
     };
     Id               = id;
     Name             = _rootNode.Name;
     _rootNode.IsRoot = true;
     _rootNode.UpdateWorkflowContainer(this);
     _startNode = new StartNode(this);
     _endNode   = new EndNode(this);
 }
Ejemplo n.º 5
0
 /* Generates the core star */
 public void init(NodeInfo info, GameObject fab, float size)
 {
     rTree               = new RRT();
     rTree.XMAX          = BOX_SIZE;
     rTree.XMIN          = -BOX_SIZE;
     rTree.YMAX          = BOX_SIZE;
     rTree.YMIN          = -BOX_SIZE;
     rTree.ZMAX          = BOX_SIZE;
     rTree.ZMIN          = -BOX_SIZE;
     rTree.START_POS     = this.transform.position;
     rTree.nodeFab       = fab;
     rTree.connectionFab = connectionFab;
     mainNode            = rTree.init(fab, info).GetComponent <NormalNode>();
     mainNode.size       = size;
     isInit              = true;
 }
Ejemplo n.º 6
0
    /* Generates a node using a given prefab, returns the node GameObject */
    public GameObject generateNode(GameObject prefab)
    {
        GameObject  newNode = Instantiate(prefab);
        NodeWithPos nP      = getNextNodePos();

        newNode.transform.position = nP.nextPos;
        NormalNode cNode = newNode.GetComponent <NormalNode>();

        cNode.connectionFab = connectionFab;
        cNode.init();
        NormalNode pNode = nP.lastNode.GetComponent <NormalNode>();

        cNode.addParent(pNode);
        pNode.addChild(cNode);
        nodes.Add(newNode);
        return(newNode);
    }
Ejemplo n.º 7
0
    public void addParent(NormalNode parent)
    {
        this.parent = parent;

        // Connection fabrication
        connection = Instantiate(connectionFab);

        // Positions
        Vector3 gPos = this.parent.gameObject.transform.position;
        Vector3 sPos = this.gameObject.transform.position;

        // Get the transform and distance
        Transform t    = connection.transform;
        float     dist = Vector3.Distance(gPos, sPos);

        // Get and set the link between the stars
        t.position   = Vector3.Lerp(sPos, gPos, 0.5f);
        cScaleGoal   = dist;
        t.localScale = new Vector3(t.localScale.x, t.localScale.y, 0f);
        t.LookAt(gPos);
    }
Ejemplo n.º 8
0
    // Update is called once per frame
    void Update()
    {
        //dataContainer = dataObject.GetComponent<DataContainer>();
        foreach (GameObject o in selection.Keys)
        {
            o.GetComponent <NormalNode>().tempColor(originalColor, 1f);
        }

        if (cSelected != null)
        {
            cSelected.GetComponent <NormalNode>().tempColor(pinColor, 1f);
            displayInfo(cSelected.GetComponent <NormalNode>().getInfo());
        }

        /* This is for both style and user feedback */
        if ((getTouchType() == TButtonType.middle || getTouchType() == TButtonType.left || getTouchType() == TButtonType.right) && alpha < 255f)
        {
            alpha += alphaIncrement;
        }
        else if (alpha > 0f)
        {
            alpha -= alphaIncrement;
        }

        // Sets the color of the laser according to the type
        if (getTouchType() == TButtonType.left)
        {
            line.GetComponent <Renderer>().material.color = deleteColor;
        }
        else if (getTouchType() == TButtonType.right)
        {
            line.GetComponent <Renderer>().material.color = pinColor;
        }
        else
        {
            line.GetComponent <Renderer>().material.color = originalColor;
        }

        textObject.transform.position = controllerPose.transform.position + Vector3.up * 0.1f;
        textObject.transform.LookAt(headObject.transform);

        /* This handles the laser that shoots out of the controller and how it collides with things */
        if (alpha > 0)
        {
            RaycastHit hit;

            if (Physics.Raycast(controllerPose.transform.position, transform.forward, out hit, 50, layerMask))
            {
                showLine(hit.point, hit.distance);
                GameObject o = hit.transform.gameObject;
                if (o.GetComponent <NormalNode>() != null)
                {
                    if (lastTouched != null && !lastTouched.Equals(o))
                    {
                    }
                    else
                    {
                        o.GetComponent <NormalNode>().tempColor(line.GetComponent <Renderer>().material.color, 1f);
                        lastTouched = o;
                        displayInfo(o.GetComponent <NormalNode>().getInfo());
                    }
                }
            }
            else
            {
                showLine(controllerPose.transform.position + transform.forward * 10000f, 10000f);
                if (lastTouched != null)
                {
                    lastTouched = null;
                    if (cSelected == null)
                    {
                        hideInfo();
                    }
                }
            }
        }
        else
        {
            line.SetActive(false);
            if (cSelected == null)
            {
                hideInfo();
            }
        }

        // Animates the little nodes in and out
        if (getTouchType() == TButtonType.bottom)
        {
            if (rad < outerLimit)
            {
                rad = Mathf.Min(rad + 0.001f, outerLimit);
            }
        }
        else if (getTouchType() == TButtonType.top)
        {
            if (rad > innerLimit)
            {
                rad = Mathf.Max(rad - 0.001f, innerLimit);
            }
        }
        else
        {
            if (rad > middleLimit)
            {
                rad = Mathf.Max(rad - 0.001f, middleLimit);
            }
            else if (rad < middleLimit)
            {
                rad = Mathf.Min(rad + 0.001f, middleLimit);
            }
        }

        if (isClick.state && !isClick.lastState)
        {
            // Selection add case
            if (lastTouched != null && getButtonPress() == TButtonType.middle)
            {
                if (selection.ContainsKey(lastTouched))
                {
                    selection[lastTouched].GetComponent <NormalNode>().remove();
                    selection.Remove(lastTouched);
                }
                else
                {
                    GameObject copy  = Instantiate(lastTouched);
                    NormalNode nCopy = copy.GetComponent <NormalNode>();
                    nCopy.setColor(lastTouched.GetComponent <NormalNode>().getColor());
                    nCopy.size           = 0.02f;
                    nCopy.nodeGrowthRate = 0.001f;
                    copy.layer           = noTouch;
                    nCopy.init(lastTouched.GetComponent <NormalNode>().getInfo());
                    copy.transform.parent = controllerPose.transform;
                    selection.Add(lastTouched, copy);
                }
            }

            // Deletion case
            if (lastTouched != null && getButtonPress() == TButtonType.left)
            {
                lastTouched.GetComponent <NormalNode>().remove();
                foreach (GameObject o in selection.Values)
                {
                    o.GetComponent <NormalNode>().remove();
                }
                selection.Clear();
            }

            // Pin case
            if (getButtonPress() == TButtonType.right)
            {
                if (lastTouched != null)
                {
                    if (cSelected == lastTouched)
                    {
                        cSelected = null;
                        hideInfo();
                    }
                    else
                    {
                        cSelected = lastTouched;
                        cSelected.GetComponent <NormalNode>().tempColor(pinColor, 1f);
                    }
                }
                else
                {
                    hideInfo();
                    cSelected = null;
                }
            }


            // Clear selection case
            if (getButtonPress() == TButtonType.bottom)
            {
                foreach (GameObject o in selection.Values)
                {
                    o.GetComponent <NormalNode>().remove();
                }
                selection.Clear();
            }

            // Spawn case
            if (getButtonPress() == TButtonType.top)
            {
                spawnConstellation();
            }
        }

        // Animation code
        animateSelected();
        circleDeg = (circleDeg + 1f) % 360f;
    }
Ejemplo n.º 9
0
    /* Spawns a constellation using the nodes currently selected */
    private void spawnConstellation()
    {
        if (selection.Count <= 0)
        {
            return;
        }

        Vector3         tColor = Vector3.zero;
        List <NodeInfo> info   = new List <NodeInfo>();
        NodeInfo        n;
        GameObject      theFab = customNodeFab;

        n.name      = "";
        n.details   = "";
        n.type      = NodeType.custom;
        n.genreType = GenreType.None;
        bool noSkip = true;

        // Special case for movies
        if (selection.Count == 1)
        {
            foreach (GameObject nObject in selection.Values)
            {
                if (nObject.GetComponent <NormalNode>().getType() == NodeType.movie)
                {
                    info = dataContainer.fromMovie(nObject.GetComponent <NormalNode>().getInfo().name);
                    n    = info[0];
                    info.RemoveAt(0);
                    noSkip = false;
                    theFab = movieNodeFab;
                    Color tempColor = nObject.GetComponent <Renderer>().material.color;
                    tColor = new Vector3(tempColor.r, tempColor.g, tempColor.b);
                    nObject.GetComponent <NormalNode>().remove();
                }
            }
        }

        // If no movies see if all the objects are a genre
        if (noSkip)
        {
            bool             isGenre = true;
            List <GenreType> gens    = new List <GenreType>();
            foreach (GameObject nObject in selection.Values)
            {
                if (nObject.GetComponent <NormalNode>().getType() != NodeType.genre)
                {
                    isGenre = false;
                }
                else
                {
                    gens.Add(nObject.GetComponent <NormalNode>().getInfo().genreType);
                }
            }

            n.name    = "Custom Node";
            n.details = "Filters: ";

            // Add in the custom node text
            foreach (GameObject o in selection.Values)
            {
                NormalNode nN = o.GetComponent <NormalNode>();
                n.details += nN.getInfo().name + ", ";
                info.Add(nN.getInfo());
                Color c = nN.getColor();
                tColor += new Vector3(c.r, c.g, c.b);
                nN.remove();
            }
            tColor /= info.Count;
            // If it's a genre load the relevent movies
            if (isGenre)
            {
                info = dataContainer.fromGenres(gens);
            }
        }
        selection.Clear();

        GameObject constellation = Instantiate(ConstellationSpawner);

        constellation.transform.position = controllerPose.transform.position;
        ConstellationManager cM = constellation.GetComponent <ConstellationManager>();

        cM.init(n, theFab, 0.50f);
        cM.mainNode.setColor(new Color(tColor.x, tColor.y, tColor.z));

        // Spawn the nodes
        foreach (NodeInfo i in info)
        {
            NormalNode nN = cM.addNode(i);
            if (nN.getType() == NodeType.movie)
            {
                nN.setColor(new Color(Random.value, Random.value, Random.value));
            }
        }
        cM.mainNode.setColor(new Color(tColor.x, tColor.y, tColor.z));
    }
Ejemplo n.º 10
0
 public void addChild(NormalNode child)
 {
     children.Add(child);
 }