예제 #1
0
        /*
         * For Develop
         * Remove In Release
         * */
        protected void GetTransformUV(float w, float h)
        {
            CreateExtendEdgeBuffer();
            CreateDivEdgeBuffer();
            CreateCurveEdgeBuffer();
            JellyVector2[] tuv = new JellyVector2[_buffervertexcount];
            int            i   = 1;

            for (i = 1; i < _crvedgebuffer.Length; ++i)
            {
                tuv[i] = _crvedgebuffer[i - 1];
            }
            tuv[0] = _crvedgebuffer[i - 1];
            foreach (int id in _extverid)
            {
                tuv[i++] = _nodes[id].Position;
            }
            for (int j = 0; j < tuv.Length; ++j)
            {
                tuv[j].X /= w;
                tuv[j].Y /= h;
            }
            string s   = "";
            int    idi = 0;

            foreach (JellyVector2 jv in tuv)
            {
                s += "SetVertexUV(" + idi++ + "," + jv.X + "f," + jv.Y + "f);\n";
            }
        }
예제 #2
0
        public void Catch(int aplid, float u, float v, float w, JellyVector2 mpos)
        {
            if (aplid < _areprelinks.Length)
            {
                JellyVector2 target = _areprelinks[aplid].jva.Position * u + _areprelinks[aplid].jvb.Position * v + _areprelinks[aplid].jvc.Position * w;
                JellyVector2 diff   = new JellyVector2(mpos) - target;
                JellyVector2 tdiff  = diff * 40;
                JellyVector2 hdiff  = diff * 0.5f;

                /*foreach (JellyVertex jv in _nodes)
                 * {
                 *  jv.Position += hdiff;
                 *  jv.Velocity += tdiff;
                 *  jv.Force += tdiff;
                 *  jv.Velocity *= JellyWorld.Friciton;
                 * }*/

                /*_areprelinks[aplid].jva.Position += hdiff;
                *  _areprelinks[aplid].jvb.Position += hdiff;
                *  _areprelinks[aplid].jvc.Position += hdiff;*/

                _areprelinks[aplid].jva.Force += tdiff;
                _areprelinks[aplid].jvb.Force += tdiff;
                _areprelinks[aplid].jvc.Force += tdiff;

                _areprelinks[aplid].jva.Velocity *= JellyWorld.Friciton;
                _areprelinks[aplid].jvb.Velocity *= JellyWorld.Friciton;
                _areprelinks[aplid].jvc.Velocity *= JellyWorld.Friciton;

                PlayVoice();

                _face.Frame = 2;
            }
        }
예제 #3
0
        private static JellyVector2 ClosestPoint(JellyVector2 v, JellyVertex[] poly)
        {
            float        minlen = float.MaxValue;
            int          i = 0;
            JellyVector2 cpt = null, tcpt;
            float        len;

            while (i < poly.Length - 1)
            {
                tcpt = JellyMath.ClosestPointOnSegment(poly[i].Position, poly[i + 1].Position, v);
                ++i;
                len = (v - tcpt).Length();
                if (len < minlen)
                {
                    minlen = len;
                    cpt    = tcpt;
                }
            }
            tcpt = JellyMath.ClosestPointOnSegment(poly[i].Position, poly[0].Position, v);
            len  = (v - tcpt).Length();
            if (len < minlen)
            {
                minlen = len;
                cpt    = tcpt;
            }
            return(cpt);
        }
예제 #4
0
 public ArePreLink(JellyVertex a, JellyVertex b, JellyVertex c, float ka, JellyVector2 nab, JellyVector2 nbc, JellyVector2 nca)
 {
     jva           = a;
     jvb           = b;
     jvc           = c;
     KA            = ka;
     NorAB         = nab;
     NorBC         = nbc;
     NorCA         = nca;
     OrgDoubleArea = DoubleArea;
 }
예제 #5
0
 public void AddForceAt(int aplid, float u, float v, JellyVector2 mpos, float ks)
 {
     if (aplid < _areprelinks.Length)
     {
         float        w      = 1 - u - v;
         JellyVector2 target = _areprelinks[aplid].jva.Position * u + _areprelinks[aplid].jvb.Position * v + _areprelinks[aplid].jvc.Position * w;
         JellyVector2 diff   = new JellyVector2(mpos) - target;
         JellyVector2 force  = diff * ks;
         _areprelinks[aplid].jva.Force += force;
         _areprelinks[aplid].jvb.Force += force;
         _areprelinks[aplid].jvc.Force += force;
     }
 }
예제 #6
0
        public void AreaPreservation()
        {
            float delta = OrgDoubleArea - DoubleArea;
            float force = delta / OrgDoubleArea * KA;

            JellyVector2 forab = NorAB * force;
            JellyVector2 forbc = NorBC * force;
            JellyVector2 forca = NorCA * force;

            jva.Force += forab + forca;
            jvb.Force += forab + forbc;
            jvc.Force += forbc + forca;
        }
예제 #7
0
        internal void Integrate(float delay, float mass)
        {
            Velocity += Force * (delay / mass);
            //Limit Veloctiy Maximum
            if (Velocity.LengthSquared() > JellyWorld.MaximumVelocitySq)
            {
                Velocity.Normalize();
                Velocity *= JellyWorld.MaximumVelocity;
            }
            Position += Velocity * delay;

            FX = FY = 0;
        }
예제 #8
0
        public JellyDouble(GraphicsDevice gd, float mass, float size, Color color, JellyVector2 pos)
            : base(gd, mass, size, color, 6)
        {
            //nodes
            _nodes    = new JellyVertex[8];
            _nodes[0] = new JellyVertex(new JellyVector2(pos.X + -2 * size, pos.Y + 1 * size));
            _nodes[1] = new JellyVertex(new JellyVector2(pos.X + 0 * size, pos.Y + 1 * size));
            _nodes[2] = new JellyVertex(new JellyVector2(pos.X + 2 * size, pos.Y + 1 * size));
            _nodes[3] = new JellyVertex(new JellyVector2(pos.X + -1 * size, pos.Y + 0 * size));
            _nodes[4] = new JellyVertex(new JellyVector2(pos.X + 1 * size, pos.Y + 0 * size));
            _nodes[5] = new JellyVertex(new JellyVector2(pos.X + -2 * size, pos.Y + -1 * size));
            _nodes[6] = new JellyVertex(new JellyVector2(pos.X + 0 * size, pos.Y + -1 * size));
            _nodes[7] = new JellyVertex(new JellyVector2(pos.X + 2 * size, pos.Y + -1 * size));

            InitExceptNode();
        }
예제 #9
0
        internal JellyDouble(GraphicsDevice gd, float mass, float size, Color col, JellyVector2 a, JellyVector2 b)
            : base(gd, mass, size, col, 6)
        {
            //nodes
            _nodes = new JellyVertex[8];
            JellyVector2 mid = (a + b) * 0.5f;

            _nodes[0] = new JellyVertex(new JellyVector2(mid.X + -2 * size, mid.Y + 1 * size));
            _nodes[1] = new JellyVertex(new JellyVector2(mid.X + 0 * size, mid.Y + 1 * size));
            _nodes[2] = new JellyVertex(new JellyVector2(mid.X + 2 * size, mid.Y + 1 * size));
            _nodes[3] = new JellyVertex(new JellyVector2(mid.X + -1 * size, mid.Y + 0 * size));
            _nodes[4] = new JellyVertex(new JellyVector2(mid.X + 1 * size, mid.Y + 0 * size));
            _nodes[5] = new JellyVertex(new JellyVector2(mid.X + -2 * size, mid.Y + -1 * size));
            _nodes[6] = new JellyVertex(new JellyVector2(mid.X + 0 * size, mid.Y + -1 * size));
            _nodes[7] = new JellyVertex(new JellyVector2(mid.X + 2 * size, mid.Y + -1 * size));

            InitExceptNode();
        }
예제 #10
0
        public void DistancePreservation()
        {
            JellyVector2 diff = jva.Position - jvb.Position;

            float dis    = diff.Length();
            float invdis = dis == 0 ? 1 : 1.0f / dis;
            float delta  = dis - OrgDistance;

            JellyVector2 fab = diff * ((delta * KS + Vector2.Dot(jva.Velocity - jvb.Velocity, diff) * KD * invdis) * invdis);

            jva.Force -= fab;
            jvb.Force += fab;

            PosNormal.X = -diff.Y * invdis;
            PosNormal.Y = diff.X * invdis;
            NegNormal.X = -PosNormal.X;
            NegNormal.Y = -PosNormal.Y;
        }
예제 #11
0
        public bool Select(JellyVector2 mpos, out int id, out float u, out float v, out float w)
        {
            id = 0;
            foreach (ArePreLink apl in _areprelinks)
            {
                if (JellyMath.PointTriangle(mpos, apl.jva.Position, apl.jvb.Position, apl.jvc.Position, out u, out v, out w))
                {
                    _face.Frame = 1;
                    return(true);
                }
                else
                {
                    ++id;
                }
            }
            u  = -1;
            v  = -1;
            w  = -1;
            id = int.MaxValue;

            _face.Frame = 0;
            return(false);
        }
예제 #12
0
        private static void FindClosestPointThreshold(JellyVector2 c, JellyVector2 a, JellyVector2 b, double threshold, out JellyVector2 cpt, out bool inVex, out bool inTrd, out bool inBack)
        {
            float        lensq;
            JellyVector2 ab = b - a, ac = c - a, bc = c - b;

            float sarea = ac.X * bc.Y - ac.Y * bc.X;

            inBack = sarea < 0;

            float dacab = JellyVector2.Dot(ac, ab);

            if (dacab <= 0)
            {
                lensq = JellyVector2.Dot(ac, ac);
                inTrd = lensq < threshold;
                cpt   = new JellyVector2(a);
                inVex = true;
                return;
            }
            float dabab = JellyVector2.Dot(ab, ab);

            if (dacab >= dabab)
            {
                lensq = JellyVector2.Dot(bc, bc);
                cpt   = new JellyVector2(b);
                inVex = true;
                inTrd = lensq < threshold;
                return;
            }
            float t = dacab / dabab;

            lensq = JellyVector2.Dot(ac, ac) - dacab * t;
            cpt   = a + ab * t;
            inTrd = lensq < threshold;
            inVex = false;
        }
예제 #13
0
        public static void ProcessEdgeForce(JellyVertex[] polygon, JellyVertex jv)
        {
            if (JellyMath.PointInPolygon(polygon, jv.Position, new JellyVector2(-10000, -10000)))
            {
                jv.Velocity.X = -jv.Velocity.X * JellyWorld.Friciton;
                jv.Velocity.Y = -jv.Velocity.Y * JellyWorld.Friciton;
                jv.FX         = jv.FY = 0;
                jv.Position   = ClosestPoint(jv.Position, polygon);
            }
            else
            {
#if _DIS_RANGE_
                const float threshold = 44.7213595499958f;
#else
                const float threshold = 3162.27766016838f;
#endif
                const float  forcek = 100000;
                int          i      = 0;
                JellyVector2 cpt;
                bool         inVertex, inThreshold, inBack;
                while (i < polygon.Length - 1)
                {
                    FindClosestPointThreshold(jv.Position, polygon[i].Position, polygon[i + 1].Position, threshold * threshold,
                                              out cpt, out inVertex, out inThreshold, out inBack);
                    ++i;
                    if (!inBack && inThreshold)
                    {
                        JellyVector2 diff  = jv.Position - cpt;
                        float        dissq = diff.LengthSquared();
                        dissq = dissq == 0 ? 0.001f : dissq;
#if _DIS_RANGE_
                        float norsize = forcek / dissq - 50;
#else
                        float norsize = forcek / dissq;
#endif
                        norsize = norsize < 0 ? 0 : norsize;
                        if (inVertex)
                        {
                            norsize *= 0.5f;
                        }
                        diff.Normalize();
                        diff     *= norsize;
                        jv.Force += diff;
                    }
                }
                FindClosestPointThreshold(jv.Position, polygon[i].Position, polygon[0].Position, threshold * threshold,
                                          out cpt, out inVertex, out inThreshold, out inBack);
                if (!inBack && inThreshold)
                {
                    JellyVector2 diff  = jv.Position - cpt;
                    float        dissq = diff.LengthSquared();
                    dissq = dissq == 0 ? 0.001f : dissq;
#if _DIS_RANGE_
                    float norsize = forcek / dissq - 50;
#else
                    float norsize = forcek / dissq;
#endif
                    norsize = norsize < 0 ? 0 : norsize;
                    if (inVertex)
                    {
                        norsize *= 0.5f;
                    }
                    diff.Normalize();
                    diff     *= norsize;
                    jv.Force += diff;
                }
            }
        }
예제 #14
0
 public JellyVertex(JellyVector2 pos)
 {
     Position = pos;
 }
예제 #15
0
 public JellyVertex(Vector2 pos)
 {
     Position = new JellyVector2(pos.X, pos.Y);
 }
예제 #16
0
 public JellyVertex(JellyVertex jv)
 {
     Position = jv.Position;
     Velocity = jv.Velocity;
     Force    = jv.Force;
 }
예제 #17
0
 protected void SetVertexPosition(int id, JellyVector2 pos)
 {
     _vertexlist[id].Position.X = pos.X;
     _vertexlist[id].Position.Y = pos.Y;
 }
예제 #18
0
        public JellyTShape(GraphicsDevice gd, float mass, float size, Color color, JellyVector2 pos)
            : base(gd, mass, size, color, 10)
        {
            //nodes
            _nodes     = new JellyVertex[14];
            _nodes[0]  = new JellyVertex(new JellyVertex(pos.X + -1 * size, pos.Y + 2 * size));
            _nodes[1]  = new JellyVertex(new JellyVertex(pos.X + 1 * size, pos.Y + 2 * size));
            _nodes[2]  = new JellyVertex(new JellyVertex(pos.X + 0 * size, pos.Y + 1 * size));
            _nodes[3]  = new JellyVertex(new JellyVertex(pos.X + -3 * size, pos.Y + 0 * size));
            _nodes[4]  = new JellyVertex(new JellyVertex(pos.X + -1 * size, pos.Y + 0 * size));
            _nodes[5]  = new JellyVertex(new JellyVertex(pos.X + 1 * size, pos.Y + 0 * size));
            _nodes[6]  = new JellyVertex(new JellyVertex(pos.X + 3 * size, pos.Y + 0 * size));
            _nodes[7]  = new JellyVertex(new JellyVertex(pos.X + -2 * size, pos.Y + -1 * size));
            _nodes[8]  = new JellyVertex(new JellyVertex(pos.X + 0 * size, pos.Y + -1 * size));
            _nodes[9]  = new JellyVertex(new JellyVertex(pos.X + 2 * size, pos.Y + -1 * size));
            _nodes[10] = new JellyVertex(new JellyVertex(pos.X + -3 * size, pos.Y + -2 * size));
            _nodes[11] = new JellyVertex(new JellyVertex(pos.X + -1 * size, pos.Y + -2 * size));
            _nodes[12] = new JellyVertex(new JellyVertex(pos.X + 1 * size, pos.Y + -2 * size));
            _nodes[13] = new JellyVertex(new JellyVertex(pos.X + 3 * size, pos.Y + -2 * size));

            //distance links
            float KS = JellyWorld.KS;
            float KD = JellyWorld.KD;

            _disprelinks     = new DisPreLink[29];
            _disprelinks[0]  = new DisPreLink(_nodes[0], _nodes[1], KS, KD);
            _disprelinks[1]  = new DisPreLink(_nodes[1], _nodes[5], KS, KD);
            _disprelinks[2]  = new DisPreLink(_nodes[5], _nodes[6], KS, KD);
            _disprelinks[3]  = new DisPreLink(_nodes[6], _nodes[13], KS, KD);
            _disprelinks[4]  = new DisPreLink(_nodes[13], _nodes[12], KS, KD);
            _disprelinks[5]  = new DisPreLink(_nodes[12], _nodes[11], KS, KD);
            _disprelinks[6]  = new DisPreLink(_nodes[11], _nodes[10], KS, KD);
            _disprelinks[7]  = new DisPreLink(_nodes[10], _nodes[3], KS, KD);
            _disprelinks[8]  = new DisPreLink(_nodes[3], _nodes[4], KS, KD);
            _disprelinks[9]  = new DisPreLink(_nodes[4], _nodes[0], KS, KD);
            _disprelinks[10] = new DisPreLink(_nodes[5], _nodes[4], KS, KD);
            _disprelinks[11] = new DisPreLink(_nodes[5], _nodes[12], KS, KD);
            _disprelinks[12] = new DisPreLink(_nodes[4], _nodes[11], KS, KD);
            _disprelinks[13] = new DisPreLink(_nodes[2], _nodes[0], KS, KD);
            _disprelinks[14] = new DisPreLink(_nodes[2], _nodes[1], KS, KD);
            _disprelinks[15] = new DisPreLink(_nodes[2], _nodes[5], KS, KD);
            _disprelinks[16] = new DisPreLink(_nodes[2], _nodes[4], KS, KD);
            _disprelinks[17] = new DisPreLink(_nodes[8], _nodes[4], KS, KD);
            _disprelinks[18] = new DisPreLink(_nodes[8], _nodes[5], KS, KD);
            _disprelinks[19] = new DisPreLink(_nodes[8], _nodes[12], KS, KD);
            _disprelinks[20] = new DisPreLink(_nodes[8], _nodes[11], KS, KD);
            _disprelinks[21] = new DisPreLink(_nodes[7], _nodes[3], KS, KD);
            _disprelinks[22] = new DisPreLink(_nodes[7], _nodes[4], KS, KD);
            _disprelinks[23] = new DisPreLink(_nodes[7], _nodes[11], KS, KD);
            _disprelinks[24] = new DisPreLink(_nodes[7], _nodes[10], KS, KD);
            _disprelinks[25] = new DisPreLink(_nodes[9], _nodes[5], KS, KD);
            _disprelinks[26] = new DisPreLink(_nodes[9], _nodes[6], KS, KD);
            _disprelinks[27] = new DisPreLink(_nodes[9], _nodes[13], KS, KD);
            _disprelinks[28] = new DisPreLink(_nodes[9], _nodes[12], KS, KD);

            //area links
            float KA = JellyWorld.KA;

            _areprelinks     = new ArePreLink[16];
            _areprelinks[0]  = new ArePreLink(_nodes[2], _nodes[1], _nodes[0], KA, _disprelinks[14].PosNormal, _disprelinks[0].NegNormal, _disprelinks[13].NegNormal);
            _areprelinks[1]  = new ArePreLink(_nodes[2], _nodes[5], _nodes[1], KA, _disprelinks[15].PosNormal, _disprelinks[1].NegNormal, _disprelinks[14].NegNormal);
            _areprelinks[2]  = new ArePreLink(_nodes[2], _nodes[4], _nodes[5], KA, _disprelinks[16].PosNormal, _disprelinks[10].NegNormal, _disprelinks[15].NegNormal);
            _areprelinks[3]  = new ArePreLink(_nodes[2], _nodes[0], _nodes[4], KA, _disprelinks[13].PosNormal, _disprelinks[9].NegNormal, _disprelinks[16].NegNormal);
            _areprelinks[4]  = new ArePreLink(_nodes[7], _nodes[4], _nodes[3], KA, _disprelinks[22].PosNormal, _disprelinks[8].NegNormal, _disprelinks[21].NegNormal);
            _areprelinks[5]  = new ArePreLink(_nodes[7], _nodes[11], _nodes[4], KA, _disprelinks[23].PosNormal, _disprelinks[12].NegNormal, _disprelinks[22].NegNormal);
            _areprelinks[6]  = new ArePreLink(_nodes[7], _nodes[10], _nodes[11], KA, _disprelinks[24].PosNormal, _disprelinks[6].NegNormal, _disprelinks[23].NegNormal);
            _areprelinks[7]  = new ArePreLink(_nodes[7], _nodes[3], _nodes[10], KA, _disprelinks[21].PosNormal, _disprelinks[7].NegNormal, _disprelinks[24].NegNormal);
            _areprelinks[8]  = new ArePreLink(_nodes[8], _nodes[5], _nodes[4], KA, _disprelinks[18].PosNormal, _disprelinks[10].PosNormal, _disprelinks[17].NegNormal);
            _areprelinks[9]  = new ArePreLink(_nodes[8], _nodes[12], _nodes[5], KA, _disprelinks[19].PosNormal, _disprelinks[11].NegNormal, _disprelinks[18].NegNormal);
            _areprelinks[10] = new ArePreLink(_nodes[8], _nodes[11], _nodes[12], KA, _disprelinks[20].PosNormal, _disprelinks[5].NegNormal, _disprelinks[19].NegNormal);
            _areprelinks[11] = new ArePreLink(_nodes[8], _nodes[4], _nodes[11], KA, _disprelinks[17].PosNormal, _disprelinks[12].PosNormal, _disprelinks[20].NegNormal);
            _areprelinks[12] = new ArePreLink(_nodes[9], _nodes[6], _nodes[5], KA, _disprelinks[26].PosNormal, _disprelinks[2].NegNormal, _disprelinks[25].NegNormal);
            _areprelinks[13] = new ArePreLink(_nodes[9], _nodes[13], _nodes[6], KA, _disprelinks[27].PosNormal, _disprelinks[3].NegNormal, _disprelinks[26].NegNormal);
            _areprelinks[14] = new ArePreLink(_nodes[9], _nodes[12], _nodes[13], KA, _disprelinks[28].PosNormal, _disprelinks[4].NegNormal, _disprelinks[27].NegNormal);
            _areprelinks[15] = new ArePreLink(_nodes[9], _nodes[5], _nodes[12], KA, _disprelinks[25].PosNormal, _disprelinks[11].PosNormal, _disprelinks[28].NegNormal);

            //edges
            _edge[0] = _nodes[0];
            _edge[1] = _nodes[1];
            _edge[2] = _nodes[5];
            _edge[3] = _nodes[6];
            _edge[4] = _nodes[13];
            _edge[5] = _nodes[12];
            _edge[6] = _nodes[11];
            _edge[7] = _nodes[10];
            _edge[8] = _nodes[3];
            _edge[9] = _nodes[4];

            //edges' normals
            _edgenor[0] = _disprelinks[0].NegNormal;
            _edgenor[1] = _disprelinks[1].NegNormal;
            _edgenor[2] = _disprelinks[2].NegNormal;
            _edgenor[3] = _disprelinks[3].NegNormal;
            _edgenor[4] = _disprelinks[4].NegNormal;
            _edgenor[5] = _disprelinks[5].NegNormal;
            _edgenor[6] = _disprelinks[6].NegNormal;
            _edgenor[7] = _disprelinks[7].NegNormal;
            _edgenor[8] = _disprelinks[8].NegNormal;
            _edgenor[9] = _disprelinks[9].NegNormal;

            _cellNodes = new int[] { 2, 7, 8, 9 };
            _extverid  = new int[] { 2, 7, 8, 9 };

            short[] tri =
            {
                ExtVIdx(10, 0), ExtVIdx(10, 0),
                ExtVIdx(10, 3), ExtVIdx(10, 3),ExtVIdx(10,  3),
                ExtVIdx(10, 2),
                ExtVIdx(10, 1), ExtVIdx(10, 1),ExtVIdx(10,  1),
                ExtVIdx(10, 0)
            };
            short[] e_tri =
            {
                EgeVIdx(9), EgeVIdx(2), ExtVIdx(10, 0),
                EgeVIdx(9), EgeVIdx(2), ExtVIdx(10, 2),
                EgeVIdx(5), EgeVIdx(2), ExtVIdx(10, 2),
                EgeVIdx(5), EgeVIdx(2), ExtVIdx(10, 3),
                EgeVIdx(9), EgeVIdx(6), ExtVIdx(10, 2),
                EgeVIdx(9), EgeVIdx(6), ExtVIdx(10, 1)
            };

            //XNA
            InitXNA(4, tri, e_tri);

            SetupUV();

            _texture = ResourceManager.LoadImage("Jelly/Jelly_Base_1");

            _face_node_id = 8;
        }
예제 #19
0
        public JellyBox(GraphicsDevice gd, float mass, float size, Color color, JellyVector2 pos)
            : base(gd, mass, size, color, 4)
        {
            //nodes
            _nodes    = new JellyVertex[5];
            _nodes[0] = new JellyVertex(new JellyVector2(pos.X + -1 * size, pos.Y + 1 * size));
            _nodes[1] = new JellyVertex(new JellyVector2(pos.X + 1 * size, pos.Y + 1 * size));
            _nodes[2] = new JellyVertex(new JellyVector2(pos.X + 0 * size, pos.Y + 0 * size));
            _nodes[3] = new JellyVertex(new JellyVector2(pos.X + -1 * size, pos.Y + -1 * size));
            _nodes[4] = new JellyVertex(new JellyVector2(pos.X + 1 * size, pos.Y + -1 * size));

            //distance links
            float KS = JellyWorld.KS;
            float KD = JellyWorld.KD;

            _disprelinks    = new DisPreLink[8];
            _disprelinks[0] = new DisPreLink(_nodes[0], _nodes[1], KS, KD);
            _disprelinks[1] = new DisPreLink(_nodes[1], _nodes[4], KS, KD);
            _disprelinks[2] = new DisPreLink(_nodes[4], _nodes[3], KS, KD);
            _disprelinks[3] = new DisPreLink(_nodes[3], _nodes[0], KS, KD);
            _disprelinks[4] = new DisPreLink(_nodes[2], _nodes[0], KS, KD);
            _disprelinks[5] = new DisPreLink(_nodes[2], _nodes[1], KS, KD);
            _disprelinks[6] = new DisPreLink(_nodes[2], _nodes[4], KS, KD);
            _disprelinks[7] = new DisPreLink(_nodes[2], _nodes[3], KS, KD);

            //area links
            float KA = JellyWorld.KA;

            _areprelinks    = new ArePreLink[4];
            _areprelinks[0] = new ArePreLink(_nodes[2], _nodes[1], _nodes[0], KA, _disprelinks[5].PosNormal, _disprelinks[0].NegNormal, _disprelinks[4].NegNormal);
            _areprelinks[1] = new ArePreLink(_nodes[2], _nodes[4], _nodes[1], KA, _disprelinks[6].PosNormal, _disprelinks[1].NegNormal, _disprelinks[5].NegNormal);
            _areprelinks[2] = new ArePreLink(_nodes[2], _nodes[3], _nodes[4], KA, _disprelinks[7].PosNormal, _disprelinks[2].NegNormal, _disprelinks[6].NegNormal);
            _areprelinks[3] = new ArePreLink(_nodes[2], _nodes[0], _nodes[3], KA, _disprelinks[4].PosNormal, _disprelinks[3].NegNormal, _disprelinks[7].NegNormal);

            //edges
            _edge[0] = _nodes[0];
            _edge[1] = _nodes[1];
            _edge[2] = _nodes[4];
            _edge[3] = _nodes[3];

            //edges' normals
            _edgenor[0] = _disprelinks[0].NegNormal;
            _edgenor[1] = _disprelinks[1].NegNormal;
            _edgenor[2] = _disprelinks[2].NegNormal;
            _edgenor[3] = _disprelinks[3].NegNormal;

            _cellNodes = new int[] { 2 };
            _extverid  = new int[] { 2 };

            short[] tri =
            {
                ExtVIdx(4, 0), ExtVIdx(4, 0),
                ExtVIdx(4, 0), ExtVIdx(4, 0)
            };
            short[] e_tri = { };

            //XNA
            InitXNA(1, tri, e_tri);

            SetupUV();

            _texture = ResourceManager.LoadImage("Jelly/Jelly_Base_1");

            _face_node_id = 2;
        }