Exemplo n.º 1
0
        public static void Instantiate(RigidTransform transform,
                                       Entity prefabEntityBody,
                                       Entity prefabEntityGroin,
                                       Entity prefabEntityThigh,
                                       Entity prefabEntityShin)
        {
            var em     = World.Active.EntityManager;
            var hexped = new Hexped();

            _data = HexpedData.Create();
            hexped.Initialize(in _data,
                              em,
                              transform,
                              prefabEntityBody,
                              prefabEntityGroin,
                              prefabEntityThigh,
                              prefabEntityShin);
            hexped.ApplyTransform(em);
            // hexped.createJoints(em);
        }
Exemplo n.º 2
0
        public static HexpedData Create()
        {
            var result = new HexpedData
            {
                FromBodyToGroin  = new float3(0, 0, LengthBase),
                FromGroinToThigh = new float3(0, 0, LengthGroin),
                FromThighToShin  = new float3(0, 0, LengthThigh),
                GroinYaws        = new NativeArray <float>(6, Allocator.Persistent)
                {
                    [0] = math.radians(30),
                    [1] = math.radians(90),
                    [2] = math.radians(150),
                    [3] = math.radians(210),
                    [4] = math.radians(270),
                    [5] = math.radians(330)
                }
            };

            result.GroinRotations = new NativeArray <quaternion>(6, Allocator.Persistent);
            for (var i = 0; i < 6; ++i)
            {
                result.GroinRotations[i] = quaternion.Euler(0f, result.GroinYaws[i], 0f);
            }
            result.GroinPositions = new NativeArray <float3>(6, Allocator.Persistent);
            for (var i = 0; i < 6; ++i)
            {
                result.GroinPositions[i] = math.mul(result.GroinRotations[i], result.FromBodyToGroin);
            }
            result.ThighRotation = quaternion.identity;
            result.ShinRotation  = quaternion.identity;
            result.RegularPoint  = new NativeArray <float3>(6, Allocator.Persistent);
            for (var i = 0; i < 6; ++i)
            {
                result.RegularPoint[i] = math.mul(result.GroinRotations[i], new float3(0, -HeightRegular, LENGTH_REGULAR));
            }

            {
                int idx = 0;
                result.WayPointList = new NativeArray <float3>(16, Allocator.Persistent)
                {
                    [idx++] = new float3(0, 0, 8),
                    [idx++] = new float3(0, 0, 8),
                    [idx++] = new float3(0, 0, 8),
                    [idx++] = new float3(0, 0, 8),
                    [idx++] = new float3(8, 0, 0),
                    [idx++] = new float3(8, 0, 0),
                    [idx++] = new float3(8, 0, 0),
                    [idx++] = new float3(8, 0, 0),
                    [idx++] = new float3(0, 0, -8),
                    [idx++] = new float3(0, 0, -8),
                    [idx++] = new float3(0, 0, -8),
                    [idx++] = new float3(0, 0, -8),
                    [idx++] = new float3(-8, 0, 0),
                    [idx++] = new float3(-8, 0, 0),
                    [idx++] = new float3(-8, 0, 0),
                    [idx++] = new float3(-8, 0, 0)
                };
            }

            return(result);
        }
 public static void Initialize()
 {
     _data = HexpedData.Create();
 }