private void GenerateCurvedHitObjects(ICollection <ICollider> colliders)
        {
            var height  = _component.PositionZ;
            var vVertex = DragPoint.GetRgVertex <RenderVertex2D, CatmullCurve2DCatmullCurveFactory>(_component.DragPoints);

            var count = vVertex.Length;
            var rgv   = new RenderVertex2D[count];
            var rgv3D = new float3[count];

            for (var i = 0; i < count; i++)
            {
                rgv[i]   = vVertex[i];
                rgv3D[i] = new float3(rgv[i].X, rgv[i].Y, height + (float)(PhysicsConstants.PhysSkin * 2.0));
            }
            ColliderUtils.Generate3DPolyColliders(rgv3D, _api.GetColliderInfo(), colliders);

            for (var i = 0; i < count; i++)
            {
                var pv2 = rgv[i < count - 1 ? i + 1 : 0];
                var pv3 = rgv[i < count - 2 ? i + 2 : i + 2 - count];
                AddLineSeg(pv2.ToUnityFloat2(), pv3.ToUnityFloat2(), height, colliders);
            }
        }
예제 #2
0
        protected override void CreateColliders(List <ICollider> colliders, float margin)
        {
            var info = ((IApiColliderGenerator)this).GetColliderInfo();

            var meshComp = GameObject.GetComponent <PlayfieldMeshComponent>();

            if (meshComp && !meshComp.AutoGenerate)
            {
                var mf = GameObject.GetComponent <MeshFilter>();
                if (mf && mf.sharedMesh)
                {
                    ColliderUtils.GenerateCollidersFromMesh(mf.sharedMesh.ToVpMesh(), info, colliders);
                }
            }

            if (ColliderComponent.CollideWithBounds)
            {
                // simple outer borders:
                colliders.Add(new LineCollider(
                                  new float2(MainComponent.Right, MainComponent.Top),
                                  new float2(MainComponent.Right, MainComponent.Bottom),
                                  MainComponent.TableHeight,
                                  MainComponent.GlassHeight,
                                  info
                                  ));

                colliders.Add(new LineCollider(
                                  new float2(MainComponent.Left, MainComponent.Bottom),
                                  new float2(MainComponent.Left, MainComponent.Top),
                                  MainComponent.TableHeight,
                                  MainComponent.GlassHeight,
                                  info
                                  ));

                colliders.Add(new LineCollider(
                                  new float2(MainComponent.Right, MainComponent.Bottom),
                                  new float2(MainComponent.Left, MainComponent.Bottom),
                                  MainComponent.TableHeight,
                                  MainComponent.GlassHeight,
                                  info
                                  ));

                colliders.Add(new LineCollider(
                                  new float2(MainComponent.Left, MainComponent.Top),
                                  new float2(MainComponent.Right, MainComponent.Top),
                                  MainComponent.TableHeight,
                                  MainComponent.GlassHeight,
                                  info
                                  ));
            }

            // glass:
            var rgv3D = new[] {
                new float3(MainComponent.Left, MainComponent.Top, MainComponent.GlassHeight),
                new float3(MainComponent.Right, MainComponent.Top, MainComponent.GlassHeight),
                new float3(MainComponent.Right, MainComponent.Bottom, MainComponent.GlassHeight),
                new float3(MainComponent.Left, MainComponent.Bottom, MainComponent.GlassHeight)
            };

            ColliderUtils.Generate3DPolyColliders(rgv3D, info, colliders);
        }