Esempio n. 1
0
        public virtual void transformTile(ccGridSize pos, float distance)
        {
            ccQuad3 _ccQuad3 = this.originalTile(pos);

            if (_ccQuad3 == null)
            {
                return;
            }
            CCPoint    step        = this.m_pTarget.Grid.Step;
            ccVertex3F _ccVertex3F = _ccQuad3.bl;

            _ccVertex3F.x = _ccVertex3F.x + step.x / 2f * (1f - distance);
            ccVertex3F _ccVertex3F1 = _ccQuad3.bl;

            _ccVertex3F1.y = _ccVertex3F1.y + step.y / 2f * (1f - distance);
            ccVertex3F _ccVertex3F2 = _ccQuad3.br;

            _ccVertex3F2.x = _ccVertex3F2.x - step.x / 2f * (1f - distance);
            ccVertex3F _ccVertex3F3 = _ccQuad3.br;

            _ccVertex3F3.y = _ccVertex3F3.y + step.y / 2f * (1f - distance);
            ccVertex3F _ccVertex3F4 = _ccQuad3.tl;

            _ccVertex3F4.x = _ccVertex3F4.x + step.x / 2f * (1f - distance);
            ccVertex3F _ccVertex3F5 = _ccQuad3.tl;

            _ccVertex3F5.y = _ccVertex3F5.y - step.y / 2f * (1f - distance);
            ccVertex3F _ccVertex3F6 = _ccQuad3.tr;

            _ccVertex3F6.x = _ccVertex3F6.x - step.x / 2f * (1f - distance);
            ccVertex3F _ccVertex3F7 = _ccQuad3.tr;

            _ccVertex3F7.y = _ccVertex3F7.y - step.y / 2f * (1f - distance);
            this.setTile(pos, _ccQuad3);
        }
Esempio n. 2
0
        /// <summary>
        /// sets a new tile
        /// </summary>
        public virtual void setTile(int x, int y, ccQuad3 coords)
        {
            int idx = (m_sGridSize.y * x + y);

            ccQuad3[] vertArray = m_pVertices;
            vertArray[idx] = coords;
        }
Esempio n. 3
0
        /// <summary>
        /// sets a new tile
        /// </summary>
        public virtual void setTile(ccGridSize pos, ccQuad3 coords)
        {
            int idx = (m_sGridSize.y * pos.x + pos.y);

            ccQuad3[] vertArray = m_pVertices;
            vertArray[idx] = coords;
        }
        public void turnOffTile(ccGridSize pos)
        {
            ccQuad3 coords = new ccQuad3();

            //memset(coords, 0, sizeof(ccQuad3));
            setTile(pos, coords);
        }
Esempio n. 5
0
        public override void update(float time)
        {
            int j;

            for (j = 0; j < m_sGridSize.y; ++j)
            {
                ccQuad3 coords = originalTile(0, j);
                if (coords == null)
                {
                    // Scene not ready yet
                    return;
                }
                float direction = 1;

                if ((j % 2) == 0)
                {
                    direction = -1;
                }

                coords.bl.x += direction * m_winSize.width * time;
                coords.br.x += direction * m_winSize.width * time;
                coords.tl.x += direction * m_winSize.width * time;
                coords.tr.x += direction * m_winSize.width * time;

                setTile(new ccGridSize(0, j), coords);
            }
        }
Esempio n. 6
0
        public void placeTile(int x, int y, Tile t)
        {
            ccQuad3 _ccQuad3 = this.originalTile(x, y);

            if (_ccQuad3 == null)
            {
                return;
            }
            CCPoint    step        = this.m_pTarget.Grid.Step;
            ccVertex3F _ccVertex3F = _ccQuad3.bl;

            _ccVertex3F.x = _ccVertex3F.x + (float)((int)(t.position.x * step.x));
            ccVertex3F _ccVertex3F1 = _ccQuad3.bl;

            _ccVertex3F1.y = _ccVertex3F1.y + (float)((int)(t.position.y * step.y));
            ccVertex3F _ccVertex3F2 = _ccQuad3.br;

            _ccVertex3F2.x = _ccVertex3F2.x + (float)((int)(t.position.x * step.x));
            ccVertex3F _ccVertex3F3 = _ccQuad3.br;

            _ccVertex3F3.y = _ccVertex3F3.y + (float)((int)(t.position.y * step.y));
            ccVertex3F _ccVertex3F4 = _ccQuad3.tl;

            _ccVertex3F4.x = _ccVertex3F4.x + (float)((int)(t.position.x * step.x));
            ccVertex3F _ccVertex3F5 = _ccQuad3.tl;

            _ccVertex3F5.y = _ccVertex3F5.y + (float)((int)(t.position.y * step.y));
            ccVertex3F _ccVertex3F6 = _ccQuad3.tr;

            _ccVertex3F6.x = _ccVertex3F6.x + (float)((int)(t.position.x * step.x));
            ccVertex3F _ccVertex3F7 = _ccQuad3.tr;

            _ccVertex3F7.y = _ccVertex3F7.y + (float)((int)(t.position.y * step.y));
            this.setTile(x, y, _ccQuad3);
        }
Esempio n. 7
0
        public void placeTile(int x, int y, Tile t)
        {
            ccQuad3 coords = originalTile(x, y);

            if (coords == null)
            {
                return;
            }

            CCPoint step = m_pTarget.Grid.Step;

            coords.bl.x += (int)(t.position.x * step.x);
            coords.bl.y += (int)(t.position.y * step.y);

            coords.br.x += (int)(t.position.x * step.x);
            coords.br.y += (int)(t.position.y * step.y);

            coords.tl.x += (int)(t.position.x * step.x);
            coords.tl.y += (int)(t.position.y * step.y);

            coords.tr.x += (int)(t.position.x * step.x);
            coords.tr.y += (int)(t.position.y * step.y);

            setTile(x, y, coords);
        }
Esempio n. 8
0
        public void turnOffTile(ccGridSize pos)
        {
            ccQuad3 coords = new ccQuad3();

            //memset(coords, 0, sizeof(ccQuad3));
            setTile(pos, coords);
        }
Esempio n. 9
0
        public override void Update(float time)
        {
            int i;

            for (i = 0; i < m_sGridSize.x; ++i)
            {
                ccQuad3 coords = originalTile(i, 0);
                if (coords == null)
                {
                    return;
                }
                float direction = 1;

                if ((i % 2) == 0)
                {
                    direction = -1;
                }

                coords.bl.y += direction * m_winSize.Height * time;
                coords.br.y += direction * m_winSize.Height * time;
                coords.tl.y += direction * m_winSize.Height * time;
                coords.tr.y += direction * m_winSize.Height * time;

                setTile(new ccGridSize(i, 0), coords);
            }
        }
Esempio n. 10
0
 public override void update(float time)
 {
     for (int i = 0; i < this.m_sGridSize.y; i++)
     {
         ccQuad3 _ccQuad3 = this.originalTile(0, i);
         if (_ccQuad3 == null)
         {
             return;
         }
         float single = 1f;
         if (i % 2 == 0)
         {
             single = -1f;
         }
         ccVertex3F mWinSize = _ccQuad3.bl;
         mWinSize.x = mWinSize.x + single * this.m_winSize.width * time;
         ccVertex3F _ccVertex3F = _ccQuad3.br;
         _ccVertex3F.x = _ccVertex3F.x + single * this.m_winSize.width * time;
         ccVertex3F mWinSize1 = _ccQuad3.tl;
         mWinSize1.x = mWinSize1.x + single * this.m_winSize.width * time;
         ccVertex3F _ccVertex3F1 = _ccQuad3.tr;
         _ccVertex3F1.x = _ccVertex3F1.x + single * this.m_winSize.width * time;
         this.setTile(new ccGridSize(0, i), _ccQuad3);
     }
 }
Esempio n. 11
0
        public override void calculateVertexPoints()
        {
            int   i;
            float contentSizeInPixels = this.m_pTexture.ContentSizeInPixels.width;
            float single = this.m_pTexture.ContentSizeInPixels.height;
            float contentSizeInPixels1 = this.m_pTexture.ContentSizeInPixels.height;
            int   mSGridSize           = this.m_sGridSize.x * this.m_sGridSize.y;

            this.m_pVertices         = new ccQuad3[mSGridSize];
            this.m_pOriginalVertices = new ccQuad3[mSGridSize];
            this.m_pTexCoordinates   = new ccQuad2[mSGridSize];
            this.m_pIndices          = new short[mSGridSize * 6];
            ccQuad3[] mPVertices       = this.m_pVertices;
            ccQuad2[] mPTexCoordinates = this.m_pTexCoordinates;
            short[]   mPIndices        = this.m_pIndices;
            int       num = 0;

            for (i = 0; i < this.m_sGridSize.x; i++)
            {
                for (int j = 0; j < this.m_sGridSize.y; j++)
                {
                    float mObStep  = (float)i * this.m_obStep.x;
                    float mObStep1 = mObStep + this.m_obStep.x;
                    float single1  = (float)j * this.m_obStep.y;
                    float mObStep2 = single1 + this.m_obStep.y;
                    mPVertices[num]    = new ccQuad3();
                    mPVertices[num].bl = new ccVertex3F(mObStep, single1, 0f);
                    mPVertices[num].br = new ccVertex3F(mObStep1, single1, 0f);
                    mPVertices[num].tl = new ccVertex3F(mObStep, mObStep2, 0f);
                    mPVertices[num].tr = new ccVertex3F(mObStep1, mObStep2, 0f);
                    float single2 = single1;
                    float single3 = mObStep2;
                    if (!this.m_bIsTextureFlipped)
                    {
                        single2 = contentSizeInPixels1 - single1;
                        single3 = contentSizeInPixels1 - mObStep2;
                    }
                    mPTexCoordinates[num]    = new ccQuad2();
                    mPTexCoordinates[num].bl = new ccVertex2F(mObStep / contentSizeInPixels, single2 / single);
                    mPTexCoordinates[num].br = new ccVertex2F(mObStep1 / contentSizeInPixels, single2 / single);
                    mPTexCoordinates[num].tl = new ccVertex2F(mObStep / contentSizeInPixels, single3 / single);
                    mPTexCoordinates[num].tr = new ccVertex2F(mObStep1 / contentSizeInPixels, single3 / single);
                    num++;
                }
            }
            for (i = 0; i < mSGridSize; i++)
            {
                mPIndices[i * 6]     = (short)(i * 4);
                mPIndices[i * 6 + 1] = (short)(i * 4 + 2);
                mPIndices[i * 6 + 2] = (short)(i * 4 + 1);
                mPIndices[i * 6 + 3] = (short)(i * 4 + 1);
                mPIndices[i * 6 + 4] = (short)(i * 4 + 2);
                mPIndices[i * 6 + 5] = (short)(i * 4 + 3);
            }
            Array.Copy(this.m_pVertices, this.m_pOriginalVertices, mSGridSize);
        }
Esempio n. 12
0
        public override void blit()
        {
            int           mSGridSize = this.m_sGridSize.x * this.m_sGridSize.y;
            CCApplication texture2D  = CCApplication.sharedApplication();

            CCDirector.sharedDirector().getWinSize();
            texture2D.basicEffect.Texture            = this.m_pTexture.getTexture2D();
            texture2D.basicEffect.TextureEnabled     = true;
            texture2D.GraphicsDevice.BlendState      = BlendState.AlphaBlend;
            texture2D.basicEffect.VertexColorEnabled = true;
            List <VertexPositionColorTexture> vertexPositionColorTextures = new List <VertexPositionColorTexture>();

            for (int i = 0; i < mSGridSize; i++)
            {
                ccQuad3 mPVertices       = this.m_pVertices[i];
                ccQuad2 mPTexCoordinates = this.m_pTexCoordinates[i];
                if (mPVertices != null)
                {
                    VertexPositionColorTexture vertexPositionColorTexture = new VertexPositionColorTexture()
                    {
                        Position          = new Vector3(mPVertices.bl.x, mPVertices.bl.y, mPVertices.bl.z),
                        Color             = Color.White,
                        TextureCoordinate = new Vector2(mPTexCoordinates.bl.x, mPTexCoordinates.bl.y)
                    };
                    vertexPositionColorTextures.Add(vertexPositionColorTexture);
                    vertexPositionColorTexture = new VertexPositionColorTexture()
                    {
                        Position          = new Vector3(mPVertices.br.x, mPVertices.br.y, mPVertices.br.z),
                        Color             = Color.White,
                        TextureCoordinate = new Vector2(mPTexCoordinates.br.x, mPTexCoordinates.br.y)
                    };
                    vertexPositionColorTextures.Add(vertexPositionColorTexture);
                    vertexPositionColorTexture = new VertexPositionColorTexture()
                    {
                        Position          = new Vector3(mPVertices.tl.x, mPVertices.tl.y, mPVertices.tl.z),
                        Color             = Color.White,
                        TextureCoordinate = new Vector2(mPTexCoordinates.tl.x, mPTexCoordinates.tl.y)
                    };
                    vertexPositionColorTextures.Add(vertexPositionColorTexture);
                    vertexPositionColorTexture = new VertexPositionColorTexture()
                    {
                        Position          = new Vector3(mPVertices.tr.x, mPVertices.tr.y, mPVertices.tr.z),
                        Color             = Color.White,
                        TextureCoordinate = new Vector2(mPTexCoordinates.tr.x, mPTexCoordinates.tr.y)
                    };
                    vertexPositionColorTextures.Add(vertexPositionColorTexture);
                }
            }
            foreach (EffectPass pass in texture2D.basicEffect.CurrentTechnique.Passes)
            {
                pass.Apply();
                texture2D.GraphicsDevice.DrawUserIndexedPrimitives <VertexPositionColorTexture>(PrimitiveType.TriangleList, vertexPositionColorTextures.ToArray(), 0, vertexPositionColorTextures.Count, this.m_pIndices, 0, (int)this.m_pIndices.Length / 3);
            }
        }
        /// <summary>
        /// sets a new tile to a certain position of the grid
        /// </summary>
        public virtual void setTile(int x, int y, ccQuad3 coords)
        {
            if (coords == null)
            {
                return;
            }
            CCTiledGrid3D g = (CCTiledGrid3D)m_pTarget.Grid;

            if (g != null)
            {
                g.setTile(x, y, coords);
            }
        }
Esempio n. 14
0
        /// <summary>
        /// returns the original tile (untransformed) at the given position
        /// </summary>
        public virtual ccQuad3 originalTile(int x, int y)
        {
            int idx = (m_sGridSize.y * x + y);
            ccQuad3[] vertArray = m_pOriginalVertices;

            ccQuad3 ret = new ccQuad3();
            ret.bl = new ccVertex3F(vertArray[idx].bl.x, vertArray[idx].bl.y, vertArray[idx].bl.z);
            ret.br = new ccVertex3F(vertArray[idx].br.x, vertArray[idx].br.y, vertArray[idx].br.z);
            ret.tl = new ccVertex3F(vertArray[idx].tl.x, vertArray[idx].tl.y, vertArray[idx].tl.z);
            ret.tr = new ccVertex3F(vertArray[idx].tr.x, vertArray[idx].tr.y, vertArray[idx].tr.z);

            return ret;
        }
Esempio n. 15
0
        /// <summary>
        /// returns the original tile (untransformed) at the given position
        /// </summary>
        public virtual ccQuad3 originalTile(int x, int y)
        {
            int idx = (m_sGridSize.y * x + y);

            ccQuad3[] vertArray = m_pOriginalVertices;

            ccQuad3 ret = new ccQuad3();

            ret.bl = new ccVertex3F(vertArray[idx].bl.x, vertArray[idx].bl.y, vertArray[idx].bl.z);
            ret.br = new ccVertex3F(vertArray[idx].br.x, vertArray[idx].br.y, vertArray[idx].br.z);
            ret.tl = new ccVertex3F(vertArray[idx].tl.x, vertArray[idx].tl.y, vertArray[idx].tl.z);
            ret.tr = new ccVertex3F(vertArray[idx].tr.x, vertArray[idx].tr.y, vertArray[idx].tr.z);

            return(ret);
        }
Esempio n. 16
0
        public virtual ccQuad3 tile(int x, int y)
        {
            int mSGridSize = this.m_sGridSize.y * x + y;

            ccQuad3[] mPVertices = this.m_pVertices;
            ccQuad3   _ccQuad3   = new ccQuad3()
            {
                bl = new ccVertex3F(mPVertices[mSGridSize].bl.x, mPVertices[mSGridSize].bl.y, mPVertices[mSGridSize].bl.z),
                br = new ccVertex3F(mPVertices[mSGridSize].br.x, mPVertices[mSGridSize].br.y, mPVertices[mSGridSize].br.z),
                tl = new ccVertex3F(mPVertices[mSGridSize].tl.x, mPVertices[mSGridSize].tl.y, mPVertices[mSGridSize].tl.z),
                tr = new ccVertex3F(mPVertices[mSGridSize].tr.x, mPVertices[mSGridSize].tr.y, mPVertices[mSGridSize].tr.z)
            };

            return(_ccQuad3);
        }
Esempio n. 17
0
 public override void update(float time)
 {
     if (!this.m_bOnce)
     {
         for (int i = 0; i < this.m_sGridSize.x; i++)
         {
             for (int j = 0; j < this.m_sGridSize.y; j++)
             {
                 ccQuad3 _ccQuad3 = this.originalTile(i, j);
                 if (_ccQuad3 == null)
                 {
                     return;
                 }
                 Random     random      = new Random();
                 ccVertex3F _ccVertex3F = _ccQuad3.bl;
                 _ccVertex3F.x = _ccVertex3F.x + (float)(random.Next() % (this.m_nRandrange * 2) - this.m_nRandrange);
                 ccVertex3F _ccVertex3F1 = _ccQuad3.br;
                 _ccVertex3F1.x = _ccVertex3F1.x + (float)(random.Next() % (this.m_nRandrange * 2) - this.m_nRandrange);
                 ccVertex3F _ccVertex3F2 = _ccQuad3.tl;
                 _ccVertex3F2.x = _ccVertex3F2.x + (float)(random.Next() % (this.m_nRandrange * 2) - this.m_nRandrange);
                 ccVertex3F _ccVertex3F3 = _ccQuad3.tr;
                 _ccVertex3F3.x = _ccVertex3F3.x + (float)(random.Next() % (this.m_nRandrange * 2) - this.m_nRandrange);
                 ccVertex3F _ccVertex3F4 = _ccQuad3.bl;
                 _ccVertex3F4.y = _ccVertex3F4.y + (float)(random.Next() % (this.m_nRandrange * 2) - this.m_nRandrange);
                 ccVertex3F _ccVertex3F5 = _ccQuad3.br;
                 _ccVertex3F5.y = _ccVertex3F5.y + (float)(random.Next() % (this.m_nRandrange * 2) - this.m_nRandrange);
                 ccVertex3F _ccVertex3F6 = _ccQuad3.tl;
                 _ccVertex3F6.y = _ccVertex3F6.y + (float)(random.Next() % (this.m_nRandrange * 2) - this.m_nRandrange);
                 ccVertex3F _ccVertex3F7 = _ccQuad3.tr;
                 _ccVertex3F7.y = _ccVertex3F7.y + (float)(random.Next() % (this.m_nRandrange * 2) - this.m_nRandrange);
                 if (this.m_bShatterZ)
                 {
                     ccVertex3F _ccVertex3F8 = _ccQuad3.bl;
                     _ccVertex3F8.z = _ccVertex3F8.z + (float)(random.Next() % (this.m_nRandrange * 2) - this.m_nRandrange);
                     ccVertex3F _ccVertex3F9 = _ccQuad3.br;
                     _ccVertex3F9.z = _ccVertex3F9.z + (float)(random.Next() % (this.m_nRandrange * 2) - this.m_nRandrange);
                     ccVertex3F _ccVertex3F10 = _ccQuad3.tl;
                     _ccVertex3F10.z = _ccVertex3F10.z + (float)(random.Next() % (this.m_nRandrange * 2) - this.m_nRandrange);
                     ccVertex3F _ccVertex3F11 = _ccQuad3.tr;
                     _ccVertex3F11.z = _ccVertex3F11.z + (float)(random.Next() % (this.m_nRandrange * 2) - this.m_nRandrange);
                 }
                 this.setTile(i, j, _ccQuad3);
             }
         }
         this.m_bOnce = true;
     }
 }
Esempio n. 18
0
        public override void transformTile(ccGridSize pos, float distance)
        {
            ccQuad3 coords = originalTile(pos);

            if (coords == null)
            {
                return;
            }
            CCPoint step = Target.Grid.Step;

            coords.bl.y += (step.Y / 2) * (1.0f - distance);
            coords.br.y += (step.Y / 2) * (1.0f - distance);
            coords.tl.y -= (step.Y / 2) * (1.0f - distance);
            coords.tr.y -= (step.Y / 2) * (1.0f - distance);

            setTile(pos, coords);
        }
        public override void update(float time)
        {
            int i, j;

            if (m_bOnce == false)
            {
                for (i = 0; i < m_sGridSize.x; ++i)
                {
                    for (j = 0; j < m_sGridSize.y; ++j)
                    {
                        ccQuad3 coords = originalTile(i, j);
                        if (coords == null)
                        {
                            // Always bail out here b/c the object is not setup correctly.
                            return;
                        }
                        Random rand = new Random();
                        // X
                        coords.bl.x += (rand.Next() % (m_nRandrange * 2)) - m_nRandrange;
                        coords.br.x += (rand.Next() % (m_nRandrange * 2)) - m_nRandrange;
                        coords.tl.x += (rand.Next() % (m_nRandrange * 2)) - m_nRandrange;
                        coords.tr.x += (rand.Next() % (m_nRandrange * 2)) - m_nRandrange;

                        // Y
                        coords.bl.y += (rand.Next() % (m_nRandrange * 2)) - m_nRandrange;
                        coords.br.y += (rand.Next() % (m_nRandrange * 2)) - m_nRandrange;
                        coords.tl.y += (rand.Next() % (m_nRandrange * 2)) - m_nRandrange;
                        coords.tr.y += (rand.Next() % (m_nRandrange * 2)) - m_nRandrange;

                        if (m_bShatterZ)
                        {
                            coords.bl.z += (rand.Next() % (m_nRandrange * 2)) - m_nRandrange;
                            coords.br.z += (rand.Next() % (m_nRandrange * 2)) - m_nRandrange;
                            coords.tl.z += (rand.Next() % (m_nRandrange * 2)) - m_nRandrange;
                            coords.tr.z += (rand.Next() % (m_nRandrange * 2)) - m_nRandrange;
                        }

                        setTile(i, j, coords);
                    }
                }

                m_bOnce = true;
            }
        }
Esempio n. 20
0
 public override void update(float time)
 {
     for (int i = 0; i < this.m_sGridSize.x; i++)
     {
         for (int j = 0; j < this.m_sGridSize.y; j++)
         {
             ccQuad3 _ccQuad3 = this.originalTile(i, j);
             if (_ccQuad3 == null)
             {
                 return;
             }
             _ccQuad3.bl.z = (float)Math.Sin((double)(time * 3.14159274f * (float)this.m_nWaves * 2f + (_ccQuad3.bl.y + _ccQuad3.bl.x) * 0.01f)) * this.m_fAmplitude * this.m_fAmplitudeRate;
             _ccQuad3.br.z = _ccQuad3.bl.z;
             _ccQuad3.tl.z = _ccQuad3.bl.z;
             _ccQuad3.tr.z = _ccQuad3.bl.z;
             this.setTile(i, j, _ccQuad3);
         }
     }
 }
Esempio n. 21
0
        public override void update(float time)
        {
            float      single      = (float)Math.Sin((double)(3.14159274f * time * (float)this.m_nJumps * 2f)) * this.m_fAmplitude * this.m_fAmplitudeRate;
            float      single1     = (float)(Math.Sin((double)(3.14159274f * (time * (float)this.m_nJumps * 2f + 1f))) * (double)this.m_fAmplitude * (double)this.m_fAmplitudeRate);
            ccGridSize _ccGridSize = new ccGridSize();

            for (int i = 0; i < this.m_sGridSize.x; i++)
            {
                for (int j = 0; j < this.m_sGridSize.y; j++)
                {
                    _ccGridSize.@set(i, j);
                    ccQuad3 _ccQuad3 = this.originalTile(i, j);
                    if (_ccQuad3 == null)
                    {
                        return;
                    }
                    if ((i + j) % 2 != 0)
                    {
                        ccVertex3F _ccVertex3F = _ccQuad3.bl;
                        _ccVertex3F.z = _ccVertex3F.z + single1;
                        ccVertex3F _ccVertex3F1 = _ccQuad3.br;
                        _ccVertex3F1.z = _ccVertex3F1.z + single1;
                        ccVertex3F _ccVertex3F2 = _ccQuad3.tl;
                        _ccVertex3F2.z = _ccVertex3F2.z + single1;
                        ccVertex3F _ccVertex3F3 = _ccQuad3.tr;
                        _ccVertex3F3.z = _ccVertex3F3.z + single1;
                    }
                    else
                    {
                        ccVertex3F _ccVertex3F4 = _ccQuad3.bl;
                        _ccVertex3F4.z = _ccVertex3F4.z + single;
                        ccVertex3F _ccVertex3F5 = _ccQuad3.br;
                        _ccVertex3F5.z = _ccVertex3F5.z + single;
                        ccVertex3F _ccVertex3F6 = _ccQuad3.tl;
                        _ccVertex3F6.z = _ccVertex3F6.z + single;
                        ccVertex3F _ccVertex3F7 = _ccQuad3.tr;
                        _ccVertex3F7.z = _ccVertex3F7.z + single;
                    }
                    this.setTile(i, j, _ccQuad3);
                }
            }
        }
Esempio n. 22
0
        public override void Update(float time)
        {
            int i, j;

            float sinz  = ((float)Math.Sin((float)Math.PI * time * m_nJumps * 2) * m_fAmplitude * m_fAmplitudeRate);
            float sinz2 = (float)(Math.Sin((float)Math.PI * (time * m_nJumps * 2 + 1)) * m_fAmplitude * m_fAmplitudeRate);

            ccGridSize gridPt = new ccGridSize();

            for (i = 0; i < m_sGridSize.x; i++)
            {
                for (j = 0; j < m_sGridSize.y; j++)
                {
                    gridPt.set(i, j);
                    ccQuad3 coords = originalTile(i, j);
                    if (coords == null)
                    {
                        return;
                    }

                    if (((i + j) % 2) == 0)
                    {
                        coords.bl.z += sinz;
                        coords.br.z += sinz;
                        coords.tl.z += sinz;
                        coords.tr.z += sinz;
                    }
                    else
                    {
                        coords.bl.z += sinz2;
                        coords.br.z += sinz2;
                        coords.tl.z += sinz2;
                        coords.tr.z += sinz2;
                    }

                    setTile(i, j, coords);
                }
            }
        }
Esempio n. 23
0
        public override void update(float time)
        {
            int i, j;

            for (i = 0; i < m_sGridSize.x; ++i)
            {
                for (j = 0; j < m_sGridSize.y; ++j)
                {
                    ccQuad3 coords = originalTile(i, j);
                    if (coords == null)
                    {
                        return;
                    }
                    Random rand = new Random();
                    // X
                    coords.bl.x += (rand.Next() % (m_nRandrange * 2)) - m_nRandrange;
                    coords.br.x += (rand.Next() % (m_nRandrange * 2)) - m_nRandrange;
                    coords.tl.x += (rand.Next() % (m_nRandrange * 2)) - m_nRandrange;
                    coords.tr.x += (rand.Next() % (m_nRandrange * 2)) - m_nRandrange;

                    // Y
                    coords.bl.y += (rand.Next() % (m_nRandrange * 2)) - m_nRandrange;
                    coords.br.y += (rand.Next() % (m_nRandrange * 2)) - m_nRandrange;
                    coords.tl.y += (rand.Next() % (m_nRandrange * 2)) - m_nRandrange;
                    coords.tr.y += (rand.Next() % (m_nRandrange * 2)) - m_nRandrange;

                    if (m_bShakeZ)
                    {
                        coords.bl.z += (rand.Next() % (m_nRandrange * 2)) - m_nRandrange;
                        coords.br.z += (rand.Next() % (m_nRandrange * 2)) - m_nRandrange;
                        coords.tl.z += (rand.Next() % (m_nRandrange * 2)) - m_nRandrange;
                        coords.tr.z += (rand.Next() % (m_nRandrange * 2)) - m_nRandrange;
                    }

                    setTile(i, j, coords);
                }
            }
        }
Esempio n. 24
0
        public override void Update(float time)
        {
            int i, j;

            for (i = 0; i < m_sGridSize.x; i++)
            {
                for (j = 0; j < m_sGridSize.y; j++)
                {
                    ccQuad3 coords = originalTile(i, j);
                    if (coords == null)
                    {
                        // Scene not ready yet
                        return;
                    }
                    coords.bl.z = ((float)Math.Sin(time * (float)Math.PI * m_nWaves * 2 +
                                                   (coords.bl.y + coords.bl.x) * .01f) * m_fAmplitude * m_fAmplitudeRate);
                    coords.br.z = coords.bl.z;
                    coords.tl.z = coords.bl.z;
                    coords.tr.z = coords.bl.z;

                    setTile(i, j, coords);
                }
            }
        }
Esempio n. 25
0
        public override void calculateVertexPoints()
        {
            float width = m_pTexture.ContentSizeInPixels.width;// (float)m_pTexture.PixelsWide;
            float height = m_pTexture.ContentSizeInPixels.height;// (float)m_pTexture.PixelsHigh;
            float imageH = m_pTexture.ContentSizeInPixels.height;

            int numQuads = m_sGridSize.x * m_sGridSize.y;

            m_pVertices = new ccQuad3[numQuads];
            m_pOriginalVertices = new ccQuad3[numQuads];
            m_pTexCoordinates = new ccQuad2[numQuads];
            m_pIndices = new short[numQuads * 6];

            ccQuad3[] vertArray = m_pVertices;
            ccQuad2[] texArray = m_pTexCoordinates;
            short[] idxArray = m_pIndices;

            int x, y;
            int index = 0;

            for (x = 0; x < m_sGridSize.x; x++)
            {
                for (y = 0; y < m_sGridSize.y; y++)
                {
                    float x1 = x * m_obStep.x;
                    float x2 = x1 + m_obStep.x;
                    float y1 = y * m_obStep.y;
                    float y2 = y1 + m_obStep.y;

                    vertArray[index] = new ccQuad3();
                    vertArray[index].bl = new ccVertex3F(x1, y1, 0);
                    vertArray[index].br = new ccVertex3F(x2, y1, 0);
                    vertArray[index].tl = new ccVertex3F(x1, y2, 0);
                    vertArray[index].tr = new ccVertex3F(x2, y2, 0);

                    float newY1 = y1;
                    float newY2 = y2;

                    if (!m_bIsTextureFlipped)
                    {
                        newY1 = imageH - y1;
                        newY2 = imageH - y2;
                    }

                    texArray[index] = new ccQuad2();
                    texArray[index].bl = new ccVertex2F(x1 / width, newY1 / height);
                    texArray[index].br = new ccVertex2F(x2 / width, newY1 / height);
                    texArray[index].tl = new ccVertex2F(x1 / width, newY2 / height);
                    texArray[index].tr = new ccVertex2F(x2 / width, newY2 / height);

                    index++;
                }
            }

            for (x = 0; x < numQuads; x++)
            {
                idxArray[x * 6 + 0] = (short)(x * 4 + 0);
                idxArray[x * 6 + 1] = (short)(x * 4 + 2);
                idxArray[x * 6 + 2] = (short)(x * 4 + 1);

                idxArray[x * 6 + 3] = (short)(x * 4 + 1);
                idxArray[x * 6 + 4] = (short)(x * 4 + 2);
                idxArray[x * 6 + 5] = (short)(x * 4 + 3);
            }

            Array.Copy(m_pVertices, m_pOriginalVertices, numQuads);
        }
 /// <summary>
 /// sets a new tile to a certain position of the grid
 /// </summary>
 public void setTile(ccGridSize pos, ccQuad3 coords)
 {
     CCTiledGrid3D g = (CCTiledGrid3D)m_pTarget.Grid;
     g.setTile(pos, coords);
 }
Esempio n. 27
0
 /// <summary>
 /// sets a new tile
 /// </summary>
 /// <param name="pos"></param>
 /// <param name="coords"></param>
 public void setTile(ccGridSize pos, ccQuad3 coords)
 {
     int idx = (m_sGridSize.y * pos.x + pos.y) * 4 * 3;
     float[] vertArray = m_pVertices;
     //memcpy(&vertArray[idx], &coords, sizeof(ccQuad3));
 }
Esempio n. 28
0
        /// <summary>
        ///  returns the tile at the given position
        /// </summary>
        /// <param name="pos"></param>
        /// <returns></returns>
        public ccQuad3 tile(ccGridSize pos)
        {
            int idx = (m_sGridSize.y * pos.x + pos.y) * 4 * 3;
            float[] vertArray = m_pVertices;

            ccQuad3 ret = new ccQuad3();
            //memcpy(&ret, &vertArray[idx], sizeof(ccQuad3));

            return ret;
        }
 /// <summary>
 /// sets a new tile to a certain position of the grid
 /// </summary>
 public virtual void setTile(int x, int y, ccQuad3 coords)
 {
     if (coords == null)
     {
         return;
     }
     CCTiledGrid3D g = (CCTiledGrid3D)m_pTarget.Grid;
     if (g != null)
     {
         g.setTile(x,y, coords);
     }
 }
 /// <summary>
 /// sets a new tile to a certain position of the grid
 /// </summary>
 public virtual void setTile(ccGridSize pos, ccQuad3 coords)
 {
     setTile(pos.x, pos.y, coords);
 }
Esempio n. 31
0
        public virtual void setTile(ccGridSize pos, ccQuad3 coords)
        {
            int mSGridSize = this.m_sGridSize.y * pos.x + pos.y;

            this.m_pVertices[mSGridSize] = coords;
        }
Esempio n. 32
0
 /// <summary>
 /// sets a new tile
 /// </summary>
 public virtual void setTile(int x, int y, ccQuad3 coords)
 {
     int idx = (m_sGridSize.y * x + y);
     ccQuad3[] vertArray = m_pVertices;
     vertArray[idx] = coords;
 }
Esempio n. 33
0
        public virtual void setTile(int x, int y, ccQuad3 coords)
        {
            int mSGridSize = this.m_sGridSize.y * x + y;

            this.m_pVertices[mSGridSize] = coords;
        }
Esempio n. 34
0
        public override void blit()
        {
            int n = m_sGridSize.x * m_sGridSize.y;

            // Default GL states: GL_TEXTURE_2D, GL_VERTEX_ARRAY, GL_COLOR_ARRAY, GL_TEXTURE_COORD_ARRAY
            // Needed states: GL_TEXTURE_2D, GL_VERTEX_ARRAY, GL_TEXTURE_COORD_ARRAY
            // Unneeded states: GL_COLOR_ARRAY
            //glDisableClientState(GL_COLOR_ARRAY);

            //glVertexPointer(3, GL_FLOAT, 0, m_pVertices);
            //glTexCoordPointer(2, GL_FLOAT, 0, m_pTexCoordinates);
            //glDrawElements(GL_TRIANGLES, (GLsizei)n * 6, GL_UNSIGNED_SHORT, m_pIndices);

            //// restore default GL state
            //glEnableClientState(GL_COLOR_ARRAY);


            CCApplication app  = CCApplication.sharedApplication();
            CCSize        size = CCDirector.sharedDirector().getWinSize();

            //app.basicEffect.World = app.worldMatrix *TransformUtils.CGAffineToMatrix( this.nodeToWorldTransform());
            app.basicEffect.Texture            = this.m_pTexture.getTexture2D();
            app.basicEffect.TextureEnabled     = true;
            app.GraphicsDevice.BlendState      = BlendState.AlphaBlend;
            app.basicEffect.VertexColorEnabled = true;

            List <VertexPositionColorTexture> vertices = new List <VertexPositionColorTexture>();

            for (int i = 0; i < n; i++)
            {
                ccQuad3 quad    = this.m_pVertices[i];
                ccQuad2 texQuad = this.m_pTexCoordinates[i];
                if (quad != null)
                {
                    VertexPositionColorTexture vt = new VertexPositionColorTexture();
                    vt.Position          = new Vector3(quad.bl.x, quad.bl.y, quad.bl.z);
                    vt.Color             = Color.White;
                    vt.TextureCoordinate = new Vector2(texQuad.bl.x, texQuad.bl.y);
                    vertices.Add(vt);

                    vt                   = new VertexPositionColorTexture();
                    vt.Position          = new Vector3(quad.br.x, quad.br.y, quad.br.z);
                    vt.Color             = Color.White;
                    vt.TextureCoordinate = new Vector2(texQuad.br.x, texQuad.br.y);
                    vertices.Add(vt);

                    vt                   = new VertexPositionColorTexture();
                    vt.Position          = new Vector3(quad.tl.x, quad.tl.y, quad.tl.z);
                    vt.Color             = Color.White;
                    vt.TextureCoordinate = new Vector2(texQuad.tl.x, texQuad.tl.y);
                    vertices.Add(vt);

                    vt                   = new VertexPositionColorTexture();
                    vt.Position          = new Vector3(quad.tr.x, quad.tr.y, quad.tr.z);
                    vt.Color             = Color.White;
                    vt.TextureCoordinate = new Vector2(texQuad.tr.x, texQuad.tr.y);
                    vertices.Add(vt);
                }
            }

            foreach (var pass in app.basicEffect.CurrentTechnique.Passes)
            {
                pass.Apply();

                app.GraphicsDevice.DrawUserIndexedPrimitives <VertexPositionColorTexture>(
                    PrimitiveType.TriangleList,
                    vertices.ToArray(), 0, vertices.Count,
                    this.m_pIndices, 0, this.m_pIndices.Length / 3);
            }
        }
Esempio n. 35
0
        public override void calculateVertexPoints()
        {
            float width  = m_pTexture.ContentSizeInPixels.width;  // (float)m_pTexture.PixelsWide;
            float height = m_pTexture.ContentSizeInPixels.height; // (float)m_pTexture.PixelsHigh;
            float imageH = m_pTexture.ContentSizeInPixels.height;

            int numQuads = m_sGridSize.x * m_sGridSize.y;

            m_pVertices         = new ccQuad3[numQuads];
            m_pOriginalVertices = new ccQuad3[numQuads];
            m_pTexCoordinates   = new ccQuad2[numQuads];
            m_pIndices          = new short[numQuads * 6];

            ccQuad3[] vertArray = m_pVertices;
            ccQuad2[] texArray  = m_pTexCoordinates;
            short[]   idxArray  = m_pIndices;

            int x, y;
            int index = 0;

            for (x = 0; x < m_sGridSize.x; x++)
            {
                for (y = 0; y < m_sGridSize.y; y++)
                {
                    float x1 = x * m_obStep.x;
                    float x2 = x1 + m_obStep.x;
                    float y1 = y * m_obStep.y;
                    float y2 = y1 + m_obStep.y;

                    vertArray[index]    = new ccQuad3();
                    vertArray[index].bl = new ccVertex3F(x1, y1, 0);
                    vertArray[index].br = new ccVertex3F(x2, y1, 0);
                    vertArray[index].tl = new ccVertex3F(x1, y2, 0);
                    vertArray[index].tr = new ccVertex3F(x2, y2, 0);

                    float newY1 = y1;
                    float newY2 = y2;

                    if (!m_bIsTextureFlipped)
                    {
                        newY1 = imageH - y1;
                        newY2 = imageH - y2;
                    }

                    texArray[index]    = new ccQuad2();
                    texArray[index].bl = new ccVertex2F(x1 / width, newY1 / height);
                    texArray[index].br = new ccVertex2F(x2 / width, newY1 / height);
                    texArray[index].tl = new ccVertex2F(x1 / width, newY2 / height);
                    texArray[index].tr = new ccVertex2F(x2 / width, newY2 / height);

                    index++;
                }
            }

            for (x = 0; x < numQuads; x++)
            {
                idxArray[x * 6 + 0] = (short)(x * 4 + 0);
                idxArray[x * 6 + 1] = (short)(x * 4 + 2);
                idxArray[x * 6 + 2] = (short)(x * 4 + 1);

                idxArray[x * 6 + 3] = (short)(x * 4 + 1);
                idxArray[x * 6 + 4] = (short)(x * 4 + 2);
                idxArray[x * 6 + 5] = (short)(x * 4 + 3);
            }

            Array.Copy(m_pVertices, m_pOriginalVertices, numQuads);
        }
Esempio n. 36
0
 /// <summary>
 /// sets a new tile
 /// </summary>
 public void setTile(ccGridSize pos, ccQuad3 coords)
 {
     int idx = (m_sGridSize.y * pos.x + pos.y);
     ccQuad3[] vertArray = m_pVertices;
     vertArray[idx] = coords;
 }
Esempio n. 37
0
        /// <summary>
        ///  returns the tile at the given position
        /// </summary>
        public ccQuad3 tile(ccGridSize pos)
        {
            int idx = (m_sGridSize.y * pos.x + pos.y);
            ccQuad3[] vertArray = m_pVertices;

            ccQuad3 ret = new ccQuad3();
            ret.bl = new ccVertex3F(vertArray[idx].bl.x, vertArray[idx].bl.y, vertArray[idx].bl.z);
            ret.br = new ccVertex3F(vertArray[idx].br.x, vertArray[idx].br.y, vertArray[idx].br.z);
            ret.tl = new ccVertex3F(vertArray[idx].tl.x, vertArray[idx].tl.y, vertArray[idx].tl.z);
            ret.tr = new ccVertex3F(vertArray[idx].tr.x, vertArray[idx].tr.y, vertArray[idx].tr.z);

            return ret;
        }
 /// <summary>
 /// sets a new tile to a certain position of the grid
 /// </summary>
 public virtual void setTile(ccGridSize pos, ccQuad3 coords)
 {
     setTile(pos.x, pos.y, coords);
 }