Пример #1
0
    public override void OnActionReceived(float[] vectorAction)
    {
        for (int i = 0; i < rightCtlPos.Count; i++)
        {
            var tempX = rightCtlPos[i].x + vectorAction[i];
            tempX          = Mathf.Clamp(tempX, rightPosMin, rightPosMax);
            rightCtlPos[i] = new Vector3(tempX, rightCtlPos[i].y, 0);
        }

        if (!isMirror)
        {
            for (int i = 0; i < leftCtlPos.Count; i++)
            {
                int idx   = i + rightCtlPos.Count;
                var tempX = leftCtlPos[i].x + vectorAction[idx];
                tempX         = Mathf.Clamp(tempX, leftPosMin, leftPosMax);
                leftCtlPos[i] = new Vector3(tempX, leftCtlPos[i].y, 0);
            }
        }
        else
        {
            for (int i = 0; i < leftCtlPos.Count; i++)
            {
                int idx   = i + rightCtlPos.Count;
                var tempX = rightCtlPos[i].x * -1f;
                tempX         = Mathf.Clamp(tempX, leftPosMin, leftPosMax);
                leftCtlPos[i] = new Vector3(tempX, leftCtlPos[i].y, 0);
            }
        }

        bottleMesh.CreateMesh(leftCtlPos, rightCtlPos);
        var predict = predictor.TexturePredict();

        SetReward(predict[0]);
    }
Пример #2
0
    // Start is called before the first frame update
    void Start()
    {
        for (int i = 0; i < 10; i++)
        {
            var tempSphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
            tempSphere.transform.position = new Vector3(Random.Range(-1f, 1f), i, 0);
            leftControlePts.Add(tempSphere);
        }
        for (int j = 0; j < 10; j++)
        {
            var tempSphere1 = GameObject.CreatePrimitive(PrimitiveType.Sphere);
            tempSphere1.transform.position = new Vector3(5 + Random.Range(-1f, 1f), j, 0);
            rightControlePts.Add(tempSphere1);
        }

        foreach (var sphere in leftControlePts)
        {
            leftControleVec.Add(sphere.transform.position);
        }

        foreach (var sphere in rightControlePts)
        {
            rightControleVec.Add(sphere.transform.position);
        }

        var filter = GetComponent <MeshFilter>();

        bottleMesh = new BottleMesh(filter);
        bottleMesh.CreateMesh(leftControleVec, rightControleVec);
        GetComponent <MeshRenderer>().material = mat;
    }
Пример #3
0
    private void Start()
    {
        predictor = GetComponent <Predictor>();
        InitializeBottle();
        bottleMesh = new BottleMesh(GetComponent <MeshFilter>());
        bottleMesh.CreateMesh(leftCtlPos, rightCtlPos);

        int agentNum = int.Parse(gameObject.name.Split('(')[1].Split(')')[0]);

        Debug.Log(agentNum);
        predictor.inputTexture = renderTextures[agentNum];
        GetComponentInChildren <Camera>().targetTexture = renderTextures[agentNum];
    }
Пример #4
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            leftControleVec.Clear();
            rightControleVec.Clear();

            foreach (var sphere in leftControlePts)
            {
                leftControleVec.Add(sphere.transform.position);
            }

            foreach (var sphere in rightControlePts)
            {
                rightControleVec.Add(sphere.transform.position);
            }
            bottleMesh.CreateMesh(leftControleVec, rightControleVec);
        }
    }