Example #1
0
    void _Export(string path,GameObject obj)
    {
        var bcs = obj.GetComponentsInChildren<BoxCollider>();
        System.Collections.Generic.List<Regulus.Utility.OBB> obbs = new System.Collections.Generic.List<Regulus.Utility.OBB>();
        foreach (var bc in bcs)
        {

            float x = bc.gameObject.transform.position.x;
            //float x = bc.bounds.center.x;
            float y = bc.gameObject.transform.position.z;
            //float y = bc.bounds.center.z;
            float w = bc.gameObject.transform.localScale.x * bc.size.x;
            //float w = bc.bounds.size.x;
            float h = bc.gameObject.transform.localScale.z * bc.size.z;
            //float h = bc.bounds.size.z;
            float r = bc.gameObject.transform.rotation.eulerAngles.y;

            Debug.Log("x" + x + " " + "y" + y + " " + "w" + w + " " + "h" + h + " " + "r" + r + " ");
            var obb = new Regulus.Utility.OBB(x,y,w,h);
            obb.setRotation(r);
            obbs.Add(obb);
        }
        Debug.Log("Expoty obb count : " + obbs.Count );
        Regulus.Utility.OBB.Write(path, obbs.ToArray());
    }
Example #2
0
    private Regulus.Project.TurnBasedRPG.Data.Entity _Build(Regulus.Project.TurnBasedRPG.Data.StaticEntity entity, GameObject game_object)
    {
        var bc = game_object.GetComponent<BoxCollider>();

        if (bc != null)
        {
            float x = game_object.transform.position.x;

            float y = game_object.transform.position.z;

            float w = game_object.transform.localScale.x * bc.size.x;

            float h = game_object.transform.localScale.z * bc.size.z;

            float r = game_object.transform.rotation.eulerAngles.y;

            Debug.Log("x" + x + " " + "y" + y + " " + "w" + w + " " + "h" + h + " " + "r" + r + " ");
            var obb = new Regulus.Utility.OBB(x, y, w, h);
            obb.setRotation(r);

            entity.Obb = obb;
            return _Build(entity as Regulus.Project.TurnBasedRPG.Data.Entity, game_object);
        }
        throw new System.Exception("BoxCollider is null " + game_object.name);
    }