Exemplo n.º 1
0
    // Use this for a play with a trained Neural network
    void Start () {

        isFinished = false;

        max_increment = 2000;
        sinceWhen = 0;
        memory = new List<bool>();
        //isInit = true;
        Object loadedObject = Resources.Load("Tansegrity");
        tansegrity = Instantiate(loadedObject) as GameObject;

        springManager = tansegrity.GetComponent<SpringManager>() as SpringManager;

        // get the limits of the terrain

        setMinMax();

        //get the goal position
        arrival = GameObject.Find("Arrival").transform.position;
        arrival = dividVect(arrival - min, max-min);
      
        increment = 0;

        posMemory = new Vector3(0,0,0);

        // Gestion des stick
        sticks = tansegrity.GetComponentsInChildren<Stick>();
       
    }
Exemplo n.º 2
0
 public static List <SpringBone> GetAllUnitychanSpringBoneRoot(SpringManager springManager)
 {
     return(springManager.springBones
            .Where(sb => sb != null && sb.transform.parent.GetComponent <SpringBone>() == null)
            .Distinct()
            .ToList());
 }
Exemplo n.º 3
0
    private GenericMenu GetWeaponListMenu(SpringManager manager, int current)
    {
        GetWeaponInfo(0);

        var ws = m_weapons.GetItems();

        if (ws.Count < 1)
        {
            return(null);
        }

        var menu = new GenericMenu();

        foreach (var w in ws)
        {
            if (w.ID >= Creature.MAX_WEAPON_ID)
            {
                continue;
            }

            menu.AddItem(new GUIContent(GetWeaponString(w.ID, w.name)), current == w.ID, i =>
            {
                manager.currentWeapon = (int)i;
                if (!EditorApplication.isPlaying)
                {
                    manager.Refresh();
                }
                InternalEditorUtility.RepaintAllViews();
            }, w.ID);
        }
        return(menu);
    }
Exemplo n.º 4
0
    static void WriteSpringManager(Component com)
    {
        WriteString("SpringManager");

        SpringManager manager = com as SpringManager;

        bw.Write(manager.dynamicRatio);
        bw.Write(manager.stiffnessForce);
        WriteAnimationCurve(manager.stiffnessCurve);
        bw.Write(manager.dragForce);
        WriteAnimationCurve(manager.dragCurve);

        int bone_count = manager.springBones.Length;

        bw.Write(bone_count);
        for (int i = 0; i < bone_count; ++i)
        {
            var bone = manager.springBones[i];
            if (bone)
            {
                string path = GetRelativePath(manager.transform, bone.transform);
                WriteString(path);
            }
            else
            {
                WriteString("");
            }
        }
    }
Exemplo n.º 5
0
 private void Awake()
 {
     trs           = transform;
     localRotation = transform.localRotation;
     //Kobayashi:Reference for "SpringManager" component with unitychan
     // GameObject.Find("unitychan_dynamic").GetComponent<SpringManager>();
     managerRef = GetParentSpringManager(transform);
 }
Exemplo n.º 6
0
    public static Transform SearchRootNode(SpringManager manager)
    {
        var boneRoot = manager.transform.Find("model/Bip001");

        if (!boneRoot)
        {
            boneRoot = manager.transform.Find("Bip001");
        }
        return(boneRoot ? boneRoot : manager.transform);
    }
Exemplo n.º 7
0
    public static Transform SearchParentNode(SpringManager manager)
    {
        var root = manager.transform.parent;

        while (root)
        {
            var m = root.GetComponent <SpringManager>();
            if (m)
            {
                return(root);
            }
            root = root.parent;
        }

        return(manager.transform);
    }
Exemplo n.º 8
0
    private GenericMenu GetWeaponsMenu(SpringManager manager, int current)
    {
        if (!manager)
        {
            return(null);
        }

        var ids = manager.GetSavedWeaponIDs();

        if (ids.Count < 1)
        {
            return(null);
        }

        var menu = new GenericMenu();

        foreach (var id in ids)
        {
            menu.AddItem(new GUIContent(GetWeaponString(id)), current == id, i => manager.CopyParams((int)i, current), id);
        }

        return(menu);
    }
Exemplo n.º 9
0
 // Use this for initialization
 void Start()
 {
     springManager = new SpringManager();
     OnStart();
 }
Exemplo n.º 10
0
    void OnDrawGizmos()
    {
        Gizmos.color = Color.red;
        drawbone(transform, 0);
        if (drawcoordinate)
        {
            drawbone(transform, 1);
            drawbone(transform, 2);
            drawbone(transform, 3);
        }

        SpringManager sm         = GetComponent <SpringManager>();
        int           boneCounts = sm.springBones.Length;

        for (int i = 0; i < boneCounts; ++i)
        {
            drawbone1(sm.springBones[i].transform, 0);
        }

        //Debug.Log(     CreateSomeClass( ) );
        return;

        //Physics2D.ci

        SkinnedMeshRenderer TRender = GetComponent <SkinnedMeshRenderer>( );

        if (TRender != null && TRender.bones != null)
        {
            Transform[] M4Array = TRender.bones;

            if (M4Array != null)
            {
                for (int nLoop = 0; nLoop < M4Array.Length; ++nLoop)
                {
                    //TRender.bon

                    DrawCurrent(M4Array[nLoop]);

                    //  Gizmos.DrawSphere( M4Array[nLoop].MultiplyPoint3x4( new Vector3(0,0,0) ), 0.1f );
                    //Gizmos.DrawLine(TRender.bones[nLoop].position, new Vector3(0,0,0));
                }
            }
        }
        Animator T = gameObject.GetComponent <Animator>( );


        for (int nLoop = 0; nLoop < 49; ++nLoop)
        {
            //Gizmos.DrawSphere( T., 0.1f );
        }

        //TRender.sharedMesh.bindposes;


        //  drawbone(transform);
        //Animation
        //T.GetBoneTransform( );
        //Avatar;
        //SkeletonBone

        //   Gizmos.DrawLine(VLIn, VLOut);
        //  Gizmos.DrawLine(VRIn, VROut);
    }