コード例 #1
0
ファイル: ExportZone.cs プロジェクト: jiowchern/TurnBasedRPG
    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);
    }
コード例 #2
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());
    }
コード例 #3
0
ファイル: Obb.cs プロジェクト: jiowchern/Regulus
 public static void Write(string path, OBB[] obbs)
 {
     Serialization.Write(obbs, path);
 }
コード例 #4
0
ファイル: Obb.cs プロジェクト: jiowchern/Regulus
        /**
         * OBB is collision with other OBB
         */
        public bool isCollision(OBB obb)
        {
            // two OBB center distance vector
            float[] centerDistanceVertor =
            {
                centerPoint[0] - obb.centerPoint[0],
                centerPoint[1] - obb.centerPoint[1]
            };

            float[][] axes =
            {
                axisX,
                axisY,
                obb.axisX,
                obb.axisY
            };

            for(var i = 0; i < axes.Length; i++)
            {
                // compare OBB1 radius projection add OBB2 radius projection to centerDistance projection
                if(getProjectionRadius(axes[i]) + obb.getProjectionRadius(axes[i]) <= dot(centerDistanceVertor, axes[i]))
                {
                    return false;
                }
            }

            return true;
        }
コード例 #5
0
ファイル: utility_obb.cs プロジェクト: kof1016/Regulus
 public static void Write(string path , OBB[] obbs)
 {
     Regulus.Utility.IO.Serialization.Write<OBB[]>(obbs , path);
 }