Esempio n. 1
0
    public void OnBeginDrag(PointerEventData eventData)
    {
        Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit))
        {
            var selection = hit.transform;

            if (hit.collider.tag.Equals("Vertex"))
            {
                vertex1 = hit.transform.gameObject.GetComponent <CreateVertex>();
                if (!vertex1.isCabled)
                {
                    hitFlag = true;

                    nullObject         = new GameObject("Pointer");
                    currentCableObject = Instantiate(cableObject, GameObject.Find("Cables").transform);
                    cable       = currentCableObject.GetComponent <CableComponent>();
                    cable.Begin = hit.transform;
                    cable.End   = nullObject.transform;
                }
                else
                {
                    vertex1 = null;
                }
            }
        }
    }
Esempio n. 2
0
    // Включение и отключение воздуха по ветке исходящая из точки vertexSource
    //
    private void ToggleAirWalking(string vertexSource, bool turnTo)
    {
        dfs.Compute(vertexSource);

        if (turnTo == true)
        {
            foreach (var u in AirSystem.graphAir.Vertices)
            {
                if (dfs.VertexColors[u] == GraphColor.Black)
                {
                    CreateVertex currentVertex = airSystem.GetVertexObjectByName(u);
                    currentVertex.isAir         = true;
                    currentVertex.pressureValue = input.pressureValue - input.pressureValue * slider.value / 100;
                }
            }
        }
        else
        {
            foreach (var u in AirSystem.graphAir.Vertices)
            {
                if (dfs.VertexColors[u] == GraphColor.Black)
                {
                    airSystem.GetVertexObjectByName(u).isAir         = false;
                    airSystem.GetVertexObjectByName(u).pressureValue = 0;
                }
            }
        }
    }
Esempio n. 3
0
 private void GetVertexComponents()
 {
     if (!input || !output)
     {
         input  = transform.Find("Input").GetComponent <CreateVertex>();
         output = transform.Find("Output").GetComponent <CreateVertex>();
     }
 }
Esempio n. 4
0
    // Start is called before the first frame update
    void Start()
    {
        // Получение вершины
        //
        input = GetComponentInChildren <CreateVertex>();

        desiredPosition = minAngle - maxAngle;
        lerpValue       = (minAngle - (currentPressure / 8) * desiredPosition);
    }
Esempio n. 5
0
    //public bool status;

    void Start()
    {
        dfs    = new UndirectedDepthFirstSearchAlgorithm <string, UndirectedEdge <string> >(AirSystem.graphAir);
        output = GetComponentInChildren <CreateVertex>();

        canv   = this.transform.Find("Canvas").GetComponent <Canvas>();
        slider = canv.GetComponentInChildren <Slider>();

        airSystem = GameObject.Find("PneumaticSystem").GetComponent <AirSystem>();
    }
Esempio n. 6
0
    void Start()
    {
        // Получение компонентов вершин и аниматора
        //
        anim  = GetComponent <Animator>();
        input = transform.Find("Input").GetComponent <CreateVertex>();
        //

        lastStatus = 0;
    }
Esempio n. 7
0
    public void AddEdge(CreateVertex v1, CreateVertex v2)
    {
        vertex1     = v1;
        vertex2     = v2;
        isConnected = true;

        var edge = new TaggedUndirectedEdge <string, string>(v1.myVertexName, v2.myVertexName, "CableEdge");

        AirSystem.graphAir.AddEdge(edge);
    }
Esempio n. 8
0
 private void OnDestroy()
 {
     foreach (var u in AirSystem.graphAir.Vertices)
     {
         if (dfs.VertexColors[u] == GraphColor.Black)
         {
             CreateVertex currentVertex = airSystem.GetVertexObjectByName(u);
             currentVertex.isAir         = false;
             currentVertex.pressureValue = 0;
         }
     }
 }
    private void Start()
    {
        // Получение компонентов вершин
        //
        input   = transform.Find("Input").GetComponent <CreateVertex>();
        output1 = transform.Find("Output 1").GetComponent <CreateVertex>();
        output2 = transform.Find("Output 2").GetComponent <CreateVertex>();
        //

        // Получение компонента сладйера
        //
        canv   = this.transform.Find("Canvas").GetComponent <Canvas>();
        slider = canv.GetComponentInChildren <Slider>();
        //

        dfs       = new UndirectedDepthFirstSearchAlgorithm <string, UndirectedEdge <string> >(AirSystem.graphAir);
        airSystem = GameObject.Find("PneumaticSystem").GetComponent <AirSystem>();
    }
Esempio n. 10
0
 private void Update()
 {
     if (!input || !output1 || !output2)
     {
         input   = transform.Find("Input").GetComponent <CreateVertex>();
         output1 = transform.Find("Output 1").GetComponent <CreateVertex>();
         output2 = transform.Find("Output 2").GetComponent <CreateVertex>();
     }
     else
     {
         if (!AirSystem.graphAir.ContainsEdge(input.myVertexName, output1.myVertexName) || !AirSystem.graphAir.ContainsEdge(input.myVertexName, output2.myVertexName))
         {
             var edge1 = new TaggedUndirectedEdge <string, string>(input.myVertexName, output1.myVertexName, "FittingEdge1");
             var edge2 = new TaggedUndirectedEdge <string, string>(input.myVertexName, output2.myVertexName, "FittingEdge2");
             AirSystem.graphAir.AddEdge(edge1);
             AirSystem.graphAir.AddEdge(edge2);
         }
     }
 }
Esempio n. 11
0
        protected virtual void LoadResources(
            Renderer renderer,
            WrappedContentManager wrappedContent,
            GraphicsDevice device
            )
        {
            // create texture maps
            activeTexture = 0;

            positionTextures    = new RenderTarget2D[2];
            positionTextures[0] = renderer.StatefulParticleResourceManager.AllocateStateTexture(GetSystemSize());
            positionTextures[1] = renderer.StatefulParticleResourceManager.AllocateStateTexture(GetSystemSize());
            velocityTextures    = new RenderTarget2D[2];
            velocityTextures[0] = renderer.StatefulParticleResourceManager.AllocateStateTexture(GetSystemSize());
            velocityTextures[1] = renderer.StatefulParticleResourceManager.AllocateStateTexture(GetSystemSize());

            // initialize the first two textures
            RenderTargetBinding[] currentRenderTargets = device.GetRenderTargets();
            device.SetRenderTargets(positionTextures[0], velocityTextures[0]);
            device.Clear(ClearOptions.Target, new Vector4(0, 0, 0, 0), 0, 0);
            device.SetRenderTargets(currentRenderTargets);

            //positionTextures[0].GetTexture().Save("PositionMaps/initial.dds", ImageFileFormat.Dds);

            // create effect
            localCreateVertices     = new CreateVertex[createVertexBufferSize];
            createVertexDeclaration = new VertexDeclaration(CreateVertex.SizeInBytes, CreateVertex.VertexElements);
            createVertexBuffer      = new DynamicVertexBuffer(device, createVertexDeclaration, CreateVertex.SizeInBytes * createVertexBufferSize, /*BufferUsage.Points |*/ BufferUsage.WriteOnly);
            // no more point sprites... :-( TODO: fix

            particleCreateEffect = LoadCreateEffect(wrappedContent).Clone();
            particleCreateEffect.CurrentTechnique = particleCreateEffect.Techniques["CreateParticles"];

            // update effect
            particleUpdateEffect = LoadUpdateEffect(wrappedContent).Clone();
            particleUpdateEffect.CurrentTechnique = particleUpdateEffect.Techniques["UpdateParticles"];

            // rendering effect
            particleRenderingEffect = LoadRenderEffect(wrappedContent).Clone();
            particleRenderingEffect.CurrentTechnique = particleRenderingEffect.Techniques["RenderParticles"];

            spriteTexture = LoadSprite(wrappedContent);
        }
Esempio n. 12
0
    // Start is called before the first frame update
    void Start()
    {
        dfs = new UndirectedDepthFirstSearchAlgorithm <string, UndirectedEdge <string> >(AirSystem.graphAir);

        // Получение компонентов вершин
        //
        input  = transform.Find("Input").GetComponent <CreateVertex>();
        output = transform.Find("Output").GetComponent <CreateVertex>();

        // Получение компонента слайдера
        //
        canv   = this.transform.Find("Canvas").GetComponent <Canvas>();
        slider = canv.GetComponentInChildren <Slider>();

        // Получение компонента AirSystem
        //
        airSystem = GameObject.Find("PneumaticSystem").GetComponent <AirSystem>();

        isMethodCalled = false;

        Debug.Log("input name: " + input.myVertexName + " output name: " + output.myVertexName);
    }