コード例 #1
0
        public static void AddPColliders()
        {
            if (hScene == null)
            {
                return;
            }

            male_list = hScene.GetMales().Where(male => male != null).ToArray();
            fem_list  = hScene.GetFemales().Where(female => female != null).ToArray();

            danPoints             = new DanPoints[male_list.Length];
            referenceLookAtTarget = new Transform[male_list.Length];
            constrainPoints       = new ConstrainPoints[fem_list.Length];
            kokanBones            = new List <DynamicBone> [fem_list.Length];

            int maleNum = 0;

            foreach (var male in male_list.Where(male => male != null))
            {
                Transform dan101 = male.GetComponentsInChildren <Transform>().Where(x => x.name.Contains(dan_base)).FirstOrDefault();
                Transform dan109 = male.GetComponentsInChildren <Transform>().Where(x => x.name.Contains(dan_head)).FirstOrDefault();
                Transform danTop = male.GetComponentsInChildren <Transform>().Where(x => x.name.Contains(dan_sack)).FirstOrDefault();

                bDansFound[maleNum]      = false;
                bDanPenetration[maleNum] = false;
                targetF[maleNum]         = 0;
                if (dan101 != null && dan109 != null && danTop != null)
                {
                    danPoints[maleNum] = new DanPoints(dan101, dan109, danTop);

                    bDansFound[maleNum] = true;
                    dan101.localScale   = new Vector3(_dan_girth[maleNum].Value, _dan_girth[maleNum].Value, 1);

                    danCollider[maleNum] = dan101.GetComponent <DynamicBoneCollider>();

                    if (danCollider[maleNum] == null)
                    {
                        danCollider[maleNum] = dan101.gameObject.AddComponent(typeof(DynamicBoneCollider)) as DynamicBoneCollider;
                    }

                    danCollider[maleNum].m_Direction = DynamicBoneColliderBase.Direction.Z;
                    danCollider[maleNum].m_Center    = new Vector3(0, _dan_collider_verticalcenter[maleNum].Value, _dan_length[maleNum].Value / 2);
                    danCollider[maleNum].m_Bound     = DynamicBoneColliderBase.Bound.Outside;
                    danCollider[maleNum].m_Radius    = _dan_collider_radius[maleNum].Value;
                    danCollider[maleNum].m_Height    = _dan_length[maleNum].Value + (_dan_collider_headlength[maleNum].Value * 2);

                    danPoints[maleNum].danTop.localScale = new Vector3(_dan_sack_size[maleNum].Value, _dan_sack_size[maleNum].Value, _dan_sack_size[maleNum].Value);
                    lastDan109Position[maleNum]          = danPoints[maleNum].danEnd.position;
                    lastDanRotation[maleNum]             = danPoints[maleNum].danEnd.rotation;
                    lastAdjustTime[maleNum] = Time.time;
                }

                referenceLookAtTarget[maleNum]    = danPoints[maleNum].danEnd;
                lastDan101TargetDistance[maleNum] = Vector3.Distance(referenceLookAtTarget[maleNum].position, danPoints[maleNum].danStart.position);
                Console.WriteLine("bDansFound " + bDansFound[maleNum]);
                maleNum++;
            }

            int femaleNum = 0;

            foreach (var female in fem_list.Where(female => female != null))
            {
                List <Transform> frontHPoints = new List <Transform>();
                List <Transform> backHPoints  = new List <Transform>();
                Transform        hPointBackOfHead;
                bHPointsFound[femaleNum] = false;

                for (int index = 0; index < frontHPointsList.Length; index++)
                {
                    frontHPoints.Add(female.GetComponentsInChildren <Transform>().Where(x => x.name.Contains(frontHPointsList[index])).FirstOrDefault());
                }

                for (int index = 0; index < backHPointsList.Length; index++)
                {
                    backHPoints.Add(female.GetComponentsInChildren <Transform>().Where(x => x.name.Contains(backHPointsList[index])).FirstOrDefault());
                }

                hPointBackOfHead = female.GetComponentsInChildren <Transform>().Where(x => x.name.Contains(headHPoint)).FirstOrDefault();

                bpKokanTarget[femaleNum] = female.GetComponentsInChildren <Transform>().Where(x => x.name.Equals(bp_kokan_target)).FirstOrDefault();
                if (bpKokanTarget[femaleNum] != null)
                {
                    Console.WriteLine("BP Target Found " + bpKokanTarget[femaleNum].name);
                    frontHPoints[0] = bpKokanTarget[femaleNum];
                }

                if (frontHPoints.Count == frontHPointsList.Length && backHPoints.Count == backHPointsList.Length && hPointBackOfHead != null)
                {
                    bHPointsFound[femaleNum]   = true;
                    constrainPoints[femaleNum] = new ConstrainPoints(frontHPoints, backHPoints, hPointBackOfHead);
                }

                foreach (DynamicBone db in female.GetComponentsInChildren <DynamicBone>().Where(x => x.name.Contains("cf_J_Vagina")))
                {
                    db.m_Colliders.Clear();
                }

                Console.WriteLine("bHPointsFound " + bHPointsFound[femaleNum]);

                List <DynamicBone> dbList = new List <DynamicBone>();
                foreach (DynamicBone db in female.GetComponentsInChildren <DynamicBone>().Where(x => x.name.Contains("cf_J_Vagina")))
                {
                    if (db == null)
                    {
                        continue;
                    }

                    if (db.m_Root != null)
                    {
                        for (int i = 0; i < colliderList.Length; i++)
                        {
                            if (db.m_Root.name.Equals(dynamicBonesList[i]))
                            {
                                DynamicBoneCollider dbc = female.GetComponentsInChildren <DynamicBoneCollider>().Where(x => x.name.Contains(colliderList[i])).FirstOrDefault();
                                if (dbc == null)
                                {
                                    Transform colliderTransform = female.GetComponentsInChildren <Transform>().Where(x => x.name.Contains(colliderList[i])).FirstOrDefault();

                                    if (colliderTransform != null)
                                    {
                                        Console.WriteLine("collider " + colliderTransform.name);

                                        dbc             = colliderTransform.gameObject.AddComponent(typeof(DynamicBoneCollider)) as DynamicBoneCollider;
                                        dbc.m_Bound     = DynamicBoneColliderBase.Bound.Inside;
                                        dbc.m_Direction = DynamicBoneColliderBase.Direction.Y;
                                        dbc.m_Height    = colliderHeightList[i];
                                        dbc.m_Radius    = colliderRadiusList[i];
                                    }
                                }

                                if (dbc != null)
                                {
                                    db.m_Colliders.Add(dbc);
                                    foreach (DynamicBoneColliderBase dbcb in db.m_Colliders)
                                    {
                                        Console.WriteLine(db.m_Root.name + " collider " + dbcb.name);
                                    }
                                }
                                else
                                {
                                    Console.WriteLine(colliderList[i] + " collider not found for " + female.name);
                                }
                            }
                        }
                    }

                    dbList.Add(db);
                }

                kokanBones[femaleNum] = dbList;
                femaleNum++;
            }

            Console.WriteLine("AddColliders done.");
        }
コード例 #2
0
        public static void AddPColliders(HScene __instance)
        {
            hScene    = __instance;
            male_list = __instance.GetMales().Where(male => male != null).ToArray();
            fem_list  = __instance.GetFemales().Where(female => female != null).ToArray();

            danPoints             = new DanPoints[male_list.Length];
            referenceLookAtTarget = new Transform[male_list.Length];
            constrainPoints       = new ConstrainPoints[fem_list.Length];
            kokanBones            = new List <DynamicBone> [fem_list.Length];

            int maleNum = 0;

            foreach (var male in male_list.Where(male => male != null))
            {
                Transform dan101 = male.GetComponentsInChildren <Transform>().Where(x => x.name.Contains(dan_base)).FirstOrDefault();
                Transform dan109 = male.GetComponentsInChildren <Transform>().Where(x => x.name.Contains(dan_head)).FirstOrDefault();
                Transform danTop = male.GetComponentsInChildren <Transform>().Where(x => x.name.Contains(dan_sack)).FirstOrDefault();

                bDansFound[maleNum]      = false;
                bDanPenetration[maleNum] = false;
                targetF[maleNum]         = 0;
                if (dan101 != null && dan109 != null && danTop != null)
                {
                    danPoints[maleNum] = new DanPoints(dan101, dan109, danTop);

                    bDansFound[maleNum] = true;
                    dan101.localScale   = new Vector3(_dan_girth[maleNum].Value, _dan_girth[maleNum].Value, 1);

                    danCollider[maleNum] = dan101.GetComponent <DynamicBoneCollider>();

                    if (danCollider[maleNum] == null)
                    {
                        danCollider[maleNum] = dan101.gameObject.AddComponent(typeof(DynamicBoneCollider)) as DynamicBoneCollider;
                    }

                    danCollider[maleNum].m_Direction     = DynamicBoneColliderBase.Direction.Z;
                    danCollider[maleNum].m_Center        = new Vector3(0, 0, _dan_length[maleNum].Value / 2);
                    danCollider[maleNum].m_Bound         = DynamicBoneColliderBase.Bound.Outside;
                    danCollider[maleNum].m_Radius        = _dan_collider_radius[maleNum].Value;
                    danCollider[maleNum].m_Height        = _dan_length[maleNum].Value + (_dan_collider_headlength[maleNum].Value * 2);
                    danPoints[maleNum].danTop.localScale = new Vector3(_dan_sack_size[maleNum].Value, _dan_sack_size[maleNum].Value, _dan_sack_size[maleNum].Value);

                    lastDan109Position[maleNum] = danPoints[maleNum].danEnd.position;
                    lastDanRotation[maleNum]    = danPoints[maleNum].danEnd.rotation;
                    lastDanVector[maleNum]      = danPoints[maleNum].danEnd.position - danPoints[maleNum].danStart.position;
                    lastDanLength[maleNum]      = _dan_length[maleNum].Value;
                    lastAdjustTime[maleNum]     = Time.time;
                }

                referenceLookAtTarget[maleNum]    = danPoints[maleNum].danEnd;
                lastDan101TargetDistance[maleNum] = Vector3.Distance(referenceLookAtTarget[maleNum].position, danPoints[maleNum].danStart.position);
                Console.WriteLine("bDansFound " + bDansFound[maleNum]);
                maleNum++;
            }

            int femaleNum = 0;

            foreach (var female in fem_list.Where(female => female != null))
            {
                List <Transform> frontHPoints = new List <Transform>();
                List <Transform> backHPoints  = new List <Transform>();
                Transform        hPointBackOfHead;
                bHPointsFound[femaleNum] = false;

                for (int index = 0; index < frontHPointsList.Length; index++)
                {
                    frontHPoints.Add(female.GetComponentsInChildren <Transform>().Where(x => x.name.Contains(frontHPointsList[index])).FirstOrDefault());
                }

                for (int index = 0; index < backHPointsList.Length; index++)
                {
                    backHPoints.Add(female.GetComponentsInChildren <Transform>().Where(x => x.name.Contains(backHPointsList[index])).FirstOrDefault());
                }

                hPointBackOfHead = female.GetComponentsInChildren <Transform>().Where(x => x.name.Contains(headHPoint)).FirstOrDefault();

                if (frontHPoints.Count == frontHPointsList.Length && backHPoints.Count == backHPointsList.Length && hPointBackOfHead != null)
                {
                    bHPointsFound[femaleNum]   = true;
                    constrainPoints[femaleNum] = new ConstrainPoints(frontHPoints, backHPoints, hPointBackOfHead);
                }

                Console.WriteLine("bHPointsFound " + bHPointsFound[femaleNum]);

                List <DynamicBone> dbList = new List <DynamicBone>();

                foreach (DynamicBone db in female.GetComponentsInChildren <DynamicBone>().Where(x => x.name.Contains("cf_J_Vagina")))
                {
                    if (db != null)
                    {
                        Console.WriteLine(db.m_Root.name + " found, adding collilders");

                        dbList.Add(db);

                        for (int i = 0; i < danCollider.Length; i++)
                        {
                            if (db.m_Colliders.Contains(danCollider[i]))
                            {
                                Console.WriteLine("Instance of " + danCollider[i].name + " already exists in list for DB " + db.name);
                            }
                            else
                            {
                                db.m_Colliders.Add(danCollider[i]);
                                Console.WriteLine(danCollider[i].name + " added to " + female.name + " for bone " + db.name);
                            }
                        }
                    }
                }

                kokanBones[femaleNum] = dbList;
                femaleNum++;
            }
            inHScene = true;
            Console.WriteLine("AddColliders done.");
        }