Beispiel #1
0
    public void start_astro()
    {
        //TODO this wont work, you need to do manual rescaling...
        //GameConstants.SCALE = 1 / 200f;
        //mSimian = new FarseerSimian();
        //mSimian.initialize(mMode.NGM.mManager.gameObject);
        //mSimian.setup_with_body(mMode.NGM.mManager.mBodyManager.mFlat,false);
        //TODO add the asteroids
        //mSimian.add_environment(GameObject.FindObjectsOfType(typeof(Transform)).Where(e=>e.name.StartsWith("FS_")).Select(e=>((Transform)e).gameObject));

        ZgJointId[] colliders = new ZgJointId[]
        {
            //ZgJointId.Head,
            ZgJointId.LeftHand,
            ZgJointId.RightHand,
            ZgJointId.LeftAnkle,
            ZgJointId.RightAnkle
        };
        foreach (var e in colliders)
        {
            mParts[e] = new GameObject("genCollider" + e.ToString());
            mParts[e].AddComponent <Rigidbody>().isKinematic = true;
            mParts[e].AddComponent <SphereCollider>();
            mParts[e].transform.localScale = Vector3.one * (e == ZgJointId.Head ? 350:150);
            if (e == ZgJointId.Head)
            {
                mParts[e].transform.position = mMode.NGM.mManager.mBodyManager.mFlat.mParts[ZgJointId.Head].transform.position;
            }
        }

        mStartingPos = mMode.NGM.mManager.mBodyManager.mFlat.SoftPosition;
    }
Beispiel #2
0
 public ZgInputJoint(ZgJointId id, Vector3 position, Quaternion rotation, bool inferred)
 {
     this.Id       = id;
     this.Position = position;
     this.Rotation = rotation;
     this.Inferred = inferred;
 }
Beispiel #3
0
    public static ZgJointId get_parent(ZgJointId joint)
    {
        switch (joint)
        {
        case ZgJointId.LeftKnee:
            return(ZgJointId.LeftHip);

        case ZgJointId.RightKnee:
            return(ZgJointId.RightHip);

        case ZgJointId.LeftHip:
            return(ZgJointId.Waist);

        case ZgJointId.RightHip:
            return(ZgJointId.Waist);

        case ZgJointId.LeftElbow:
            return(ZgJointId.LeftShoulder);

        case ZgJointId.RightElbow:
            return(ZgJointId.RightShoulder);

        case ZgJointId.LeftShoulder:
            return(ZgJointId.Torso);

        case ZgJointId.RightShoulder:
            return(ZgJointId.Torso);

        case ZgJointId.Neck:
            return(ZgJointId.Torso);

        default:
            return(ZgJointId.None);
        }
    }
    GameObject create_object(ZgJointId aId, Texture2D aTex, Texture2D aAttachTex)
    {
        List <Vector3> attach = new List <Vector3>()
        {
            get_attachment_point(0, aAttachTex)
        };

        return(create_object(aId, aTex, new Vector2(aTex.width, aTex.height), attach));
    }
Beispiel #5
0
 public PoseElement find_element(ZgJointId id)
 {
     foreach (PoseElement e in mElements)
     {
         if (e.joint == id)
         {
             return(e);
         }
     }
     throw new UnityException("can't find ZigJointId " + id + " in Pose");
 }
    public int get_joint_alpha_index(ZgJointId aId)
    {
        int r = -1;

        for (int i = 0; i < mRenderedJoints.Length; i++)
        {
            if (mRenderedJoints[i] == aId)
            {
                r = i;
            }
        }
        return(r);
    }
    Vector3 get_connection_point_list(ZgJointId A, ZgJointId B, List <Vector3> aConnect)
    {
        int index = -1;

        if (A == B)
        {
            index = 0;
        }
        if (B == ZgJointId.Waist)
        {
            if (A == ZgJointId.Torso)
            {
                index = 0;
            }
            else if (A == ZgJointId.LeftHip)
            {
                index = 1;
            }
            else if (A == ZgJointId.RightHip)
            {
                index = 2;
            }
        }
        else if (B == ZgJointId.Torso)
        {
            if (A == ZgJointId.Neck)
            {
                index = 3;
            }
            else if (A == ZgJointId.LeftShoulder)
            {
                index = 1;
            }
            else if (A == ZgJointId.RightShoulder)
            {
                index = 2;
            }
        }
        else
        {
            index = 1;
        }
        if (index == -1)
        {
            throw new UnityException("uh oh, can't find attachment point zigjointid map");
        }
        return(aConnect[index] * GameConstants.SCALE);
    }
Beispiel #8
0
    public static float grade_joint(Pose A, Pose B, ZgJointId aJoint)
    {
        PoseElement e      = A.find_element(aJoint);
        PoseElement bPose  = B.find_element(aJoint);
        float       target = bPose.angle;
        float       actual = e.angle;
        float       diff   = target - actual;

        while (diff > 180)
        {
            diff -= 360;
        }
        while (diff < -180)
        {
            diff += 360;
        }
        return(diff);
    }
 Vector3 get_connection_point_image(ZgJointId A, ZgJointId B, Texture2D aBTex)
 {
     if (A == B)
     {
         return(get_attachment_point(0, aBTex));
     }
     if (B == ZgJointId.Waist)
     {
         if (A == ZgJointId.Torso)
         {
             return(get_attachment_point(0, aBTex));
         }
         else if (A == ZgJointId.LeftHip)
         {
             return(get_attachment_point(1, aBTex));
         }
         else if (A == ZgJointId.RightHip)
         {
             return(get_attachment_point(2, aBTex));
         }
     }
     else if (B == ZgJointId.Torso)
     {
         if (A == ZgJointId.Neck)
         {
             return(get_attachment_point(3, aBTex));
         }
         else if (A == ZgJointId.LeftShoulder)
         {
             return(get_attachment_point(1, aBTex));
         }
         else if (A == ZgJointId.RightShoulder)
         {
             return(get_attachment_point(2, aBTex));
         }
     }
     else
     {
         return(get_attachment_point(1, aBTex));
     }
     throw new UnityException("uh oh, can't find attachment point zigjointid map");
 }
    GameObject create_object(ZgJointId aId, Texture2D aTex, Vector2 aDim, List <Vector3> aAttach)
    {
        GameObject parent = new GameObject("genParent" + aId.ToString());
        //GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
        //sphere.transform.localScale = Vector3.one * 0.2f;
        //sphere.transform.parent = parent.transform;
        GameObject kid = (GameObject)GameObject.Instantiate(ManagerManager.Manager.mReferences.mPlanePrefab);

        //GameObject kid = (GameObject)GameObject.CreatePrimitive(PrimitiveType.Plane); //TODO use prefab instead
        kid.GetComponent <Renderer>().material             = new Material(ManagerManager.Manager.mReferences.mDefaultCharacterShader);
        kid.GetComponent <Renderer>().material.mainTexture = aTex;
        kid.transform.rotation = Quaternion.AngleAxis(90, Vector3.right) * kid.transform.rotation;

        kid.transform.localScale = new Vector3(BodyManager.convert_units(aDim.x) / 10.0f, 1, BodyManager.convert_units(aDim.y) / 10.0f) * GameConstants.SCALE;
        kid.transform.position   = -aAttach[0] * GameConstants.SCALE;
        kid.transform.parent     = parent.transform;

        mParts[aId] = parent;
        return(parent);
    }
    public Vector3 get_headfirst_Z_offset(ZgJointId id)
    {
        switch (id)
        {
        case ZgJointId.Neck:
            return(new Vector3(0, 0, 0.9f));

        case ZgJointId.RightElbow:
            return(new Vector3(0, 0, 0.8f));

        case ZgJointId.LeftElbow:
            return(new Vector3(0, 0, 0.7f));

        case ZgJointId.RightShoulder:
            return(new Vector3(0, 0, 0.6f));

        case ZgJointId.LeftShoulder:
            return(new Vector3(0, 0, 0.55f));

        case ZgJointId.Torso:
            return(new Vector3(0, 0, 0.5f));

        case ZgJointId.Waist:
            return(new Vector3(0, 0, 0.4f));

        case ZgJointId.LeftHip:
            return(new Vector3(0, 0, 0.3f));

        case ZgJointId.RightHip:
            return(new Vector3(0, 0, 0.2f));

        case ZgJointId.RightKnee:
            return(new Vector3(0, 0, 0.1f));

        case ZgJointId.LeftKnee:
            return(new Vector3(0, 0, 0.0f));
        }
        return(Vector3.zero);
    }
Beispiel #12
0
 public float joint_score(ZgJointId aJoint)
 {
     return(mCurrentScore[aJoint]);
 }
Beispiel #13
0
 public ZgInputJoint(ZgJointId id) : this(id, Vector3.zero, Quaternion.identity, false)
 {
     this.GoodPosition = false;
     this.GoodRotation = false;
 }
Beispiel #14
0
 public Stupid(ZgJointId other)
 {
     otherEnds.Add(other);
 }
 public Stupid(ZgJointId other)
 {
     otherEnd = other;
 }
 public float get_smoothed_relative(ZgJointId A, ZgJointId B)
 {
     return(mImportant[A].smoothing.current);
 }
 public Vector3 get_body_part_position(ZgJointId aJoint)
 {
     return(mParts[aJoint].transform.position);
 }
 public GameObject create_extremety(ZgJointId aId)
 {
     mParts[aId] = new GameObject("genExtremety");
     return(mParts[aId]);
 }