Example #1
0
        public bool AddDrawSpritesNC(Vector3 pos, d3d_sprite_rects.rect _rect, int color, Vector2 offset2)
        {
            if (m_effect != null)
            {
                // 쉐이더사용
                add_sprite_to_vertex_buffer_shader(pos, _rect, 0, new Vector2(1, 1), color, offset2);
            }
            else
            {
                pos = goffsetscale(pos);
                Vector2 size = gscale(_rect.size);

                // 整수化
                pos.X  = (float)(int)pos.X;
                pos.Y  = (float)(int)pos.Y;
                pos.X += offset2.X;
                pos.Y += offset2.Y;

                pos.X += _rect.lefttop.X;
                pos.Y += _rect.lefttop.Y;

                // 추가
                add_sprite_to_vertex_buffer(pos, size, _rect, color);
            }
            if (m_sprite_count >= DRAW_SPRITE_ONCE)
            {
                draw_sprites();
            }
            return(true);
        }
Example #2
0
        public bool AddDrawSprites(Vector3 pos, d3d_sprite_rects.rect _rect, Vector2 scale, int color, Vector2 offset2)
        {
            if (m_effect != null)
            {
                // 쉐이더사용
                add_sprite_to_vertex_buffer_shader(pos, _rect, 0, scale, color, offset2);
            }
            else
            {
                pos = goffsetscale(pos);

                Vector2 offset = _rect.lefttop;
                Vector2 size   = gscale(_rect.size);

                offset.X *= scale.X;
                offset.Y *= scale.Y;
                size.X   *= scale.X;
                size.Y   *= scale.Y;

                // 整수化
                pos.X  = (float)(int)pos.X;
                pos.Y  = (float)(int)pos.Y;
                pos.X += offset2.X;
                pos.Y += offset2.Y;

                pos.X += offset.X;
                pos.Y += offset.Y;

                // 컬링
                if (pos.X >= m_d3d_device.Viewport.Width + m_d3d_device.Viewport.X)
                {
                    return(false);
                }
                if (pos.Y >= m_d3d_device.Viewport.Height + m_d3d_device.Viewport.Y)
                {
                    return(false);
                }
                if (pos.X + size.X < 0)
                {
                    return(false);
                }
                if (pos.Y + size.Y < 0)
                {
                    return(false);
                }

                // 추가
                add_sprite_to_vertex_buffer(pos, size, _rect, color);
            }
            if (m_sprite_count >= DRAW_SPRITE_ONCE)
            {
                draw_sprites();
            }
            return(true);
        }
Example #3
0
        /*-------------------------------------------------------------------------
         * 스프라이트の추가
         * vertex bufferに추가
         * ---------------------------------------------------------------------------*/
        private void add_sprite_to_vertex_buffer(Vector3 pos, Vector2 size, d3d_sprite_rects.rect _rect, int color)
        {
            int index = m_sprite_count * 6;

            pos.X -= 0.5f;
            pos.Y -= 0.5f;

            for (int i = 0; i < 6; i++)
            {
                m_vertex_list[index + i].X     = pos.X;
                m_vertex_list[index + i].Y     = pos.Y;
                m_vertex_list[index + i].Z     = pos.Z;
                m_vertex_list[index + i].Rhw   = 1;
                m_vertex_list[index + i].Color = color;
            }

            // 左상三角形
            m_vertex_list[index + 1].X += size.X;
            m_vertex_list[index + 2].Y += size.Y;

            //
            m_vertex_list[index + 0].Tu = _rect.uv[0].X;
            m_vertex_list[index + 0].Tv = _rect.uv[0].Y;
            m_vertex_list[index + 1].Tu = _rect.uv[1].X;
            m_vertex_list[index + 1].Tv = _rect.uv[1].Y;
            m_vertex_list[index + 2].Tu = _rect.uv[2].X;
            m_vertex_list[index + 2].Tv = _rect.uv[2].Y;

            // 右下三角形
            m_vertex_list[index + 3].X += size.X;
            m_vertex_list[index + 4].X += size.X;
            m_vertex_list[index + 4].Y += size.Y;
            m_vertex_list[index + 5].Y += size.Y;

            //
            m_vertex_list[index + 3].Tu = _rect.uv[1].X;
            m_vertex_list[index + 3].Tv = _rect.uv[1].Y;
            m_vertex_list[index + 4].Tu = _rect.uv[3].X;
            m_vertex_list[index + 4].Tv = _rect.uv[3].Y;
            m_vertex_list[index + 5].Tu = _rect.uv[2].X;
            m_vertex_list[index + 5].Tv = _rect.uv[2].Y;

            m_sprite_count++;
            m_draw_sprites_in_frame++;
        }
Example #4
0
        /*-------------------------------------------------------------------------
         * 스프라이트の추가
         * 쉐이더사용
         * ---------------------------------------------------------------------------*/
        private void add_sprite_to_vertex_buffer_shader(Vector3 pos, d3d_sprite_rects.rect _rect, float angle_rad, Vector2 scale, int color, Vector2 offset)
        {
            int index = m_sprite_count * 4;

            Vector3 param = new Vector3(scale.X, scale.Y, angle_rad);

            for (int i = 0; i < 4; i++)
            {
                m_vbo[index + i].color    = color;
                m_vbo[index + i].Position = pos;
                m_vbo[index + i].offset1  = _rect.offset[i];
                m_vbo[index + i].offset2  = offset;
                m_vbo[index + i].param    = param;
                m_vbo[index + i].uv       = _rect.uv[i];
            }

            m_sprite_count++;
            m_draw_sprites_in_frame++;
        }
Example #5
0
        public bool AddDrawSpritesNC(Vector3 pos, d3d_sprite_rects.rect _rect, Vector2 scale, int color, Vector2 offset2)
        {
            if (m_effect != null)
            {
                // シェーダ使用
                add_sprite_to_vertex_buffer_shader(pos, _rect, 0, scale, color, offset2);
            }
            else
            {
                pos = goffsetscale(pos);

                Vector2 offset = _rect.lefttop;
                Vector2 size   = gscale(_rect.size);

                offset.X *= scale.X;
                offset.Y *= scale.Y;
                size.X   *= scale.X;
                size.Y   *= scale.Y;

                pos.X += offset.X;
                pos.Y += offset.Y;
                // 整数化
                pos.X  = (float)(int)pos.X;
                pos.Y  = (float)(int)pos.Y;
                pos.X += offset2.X;
                pos.Y += offset2.Y;

                // 追加
                add_sprite_to_vertex_buffer(pos, size, _rect, color);
            }

            if (m_sprite_count >= DRAW_SPRITE_ONCE)
            {
                draw_sprites();
            }
            return(true);
        }
Example #6
0
        public bool AddDrawSpritesNC(Vector3 pos, d3d_sprite_rects.rect _rect, float angle_rad, Vector2 scale, int color, Vector2 offset2)
        {
            if (m_effect != null)
            {
                // 쉐이더사용
                add_sprite_to_vertex_buffer_shader(pos, _rect, angle_rad, scale, color, offset2);
            }
            else
            {
                pos = goffsetscale(pos);
                Vector2 scale2 = gscale(scale);

                Matrix mat = Matrix.RotationZ(angle_rad);                           // Z軸회전
                mat = Matrix.Scaling(scale2.X, scale2.Y, 1) * mat;                  // 拡대縮소

                Vector3 p0 = new Vector3(_rect.offset[0].X, _rect.offset[0].Y, 0);
                Vector3 p1 = new Vector3(_rect.offset[1].X, _rect.offset[1].Y, 0);
                Vector3 p2 = new Vector3(_rect.offset[2].X, _rect.offset[2].Y, 0);
                Vector3 p3 = new Vector3(_rect.offset[3].X, _rect.offset[3].Y, 0);

                // 좌표변환
                p0.TransformCoordinate(mat);
                p1.TransformCoordinate(mat);
                p2.TransformCoordinate(mat);
                p3.TransformCoordinate(mat);

                int index = m_sprite_count * 6;

                pos.X  = (int)pos.X;
                pos.Y  = (int)pos.Y;
                pos.X += offset2.X;
                pos.Y += offset2.Y;

                pos.X -= 0.5f;
                pos.Y -= 0.5f;

                for (int i = 0; i < 6; i++)
                {
                    m_vertex_list[index + i].X     = pos.X;
                    m_vertex_list[index + i].Y     = pos.Y;
                    m_vertex_list[index + i].Z     = pos.Z;
                    m_vertex_list[index + i].Rhw   = 1;
                    m_vertex_list[index + i].Color = color;
                }

                // 좌상단 삼각형
                m_vertex_list[index + 0].X += p0.X;
                m_vertex_list[index + 0].Y += p0.Y;
                m_vertex_list[index + 1].X += p1.X;
                m_vertex_list[index + 1].Y += p1.Y;
                m_vertex_list[index + 2].X += p2.X;
                m_vertex_list[index + 2].Y += p2.Y;

                //
                m_vertex_list[index + 0].Tu = _rect.uv[0].X;
                m_vertex_list[index + 0].Tv = _rect.uv[0].Y;
                m_vertex_list[index + 1].Tu = _rect.uv[1].X;
                m_vertex_list[index + 1].Tv = _rect.uv[1].Y;
                m_vertex_list[index + 2].Tu = _rect.uv[2].X;
                m_vertex_list[index + 2].Tv = _rect.uv[2].Y;

                // 우하단 삼각형
                m_vertex_list[index + 3].X += p1.X;
                m_vertex_list[index + 3].Y += p1.Y;
                m_vertex_list[index + 4].X += p3.X;
                m_vertex_list[index + 4].Y += p3.Y;
                m_vertex_list[index + 5].X += p2.X;
                m_vertex_list[index + 5].Y += p2.Y;

                //
                m_vertex_list[index + 3].Tu = _rect.uv[1].X;
                m_vertex_list[index + 3].Tv = _rect.uv[1].Y;
                m_vertex_list[index + 4].Tu = _rect.uv[3].X;
                m_vertex_list[index + 4].Tv = _rect.uv[3].Y;
                m_vertex_list[index + 5].Tu = _rect.uv[2].X;
                m_vertex_list[index + 5].Tv = _rect.uv[2].Y;

                m_sprite_count++;
                m_draw_sprites_in_frame++;
            }

            if (m_sprite_count >= DRAW_SPRITE_ONCE)
            {
                draw_sprites();
            }
            return(true);
        }
Example #7
0
 /*-------------------------------------------------------------------------
  * 스프라이트の그리기 추가
  * 스케일지정, 색지정, 회전지정
  * 각도はラジアン
  * 화면외컬링없음
  * 회전지정は화면외컬링없음のみ
  * ---------------------------------------------------------------------------*/
 public bool AddDrawSpritesNC(Vector3 pos, d3d_sprite_rects.rect _rect, float angle_rad, Vector2 scale, int color)
 {
     return(AddDrawSpritesNC(pos, _rect, angle_rad, scale, color, new Vector2(0, 0)));
 }
Example #8
0
 /*-------------------------------------------------------------------------
  * 스프라이트の그리기 추가
  * 색지정, 회전지정
  * 각도はラジアン
  * 화면외컬링없음
  * 회전지정は화면외컬링없음のみ
  * ---------------------------------------------------------------------------*/
 public bool AddDrawSpritesNC(Vector3 pos, d3d_sprite_rects.rect _rect, float angle_rad, int color)
 {
     return(AddDrawSpritesNC(pos, _rect, angle_rad, new Vector2(1, 1), color));
 }
Example #9
0
 /*-------------------------------------------------------------------------
  * 스프라이트の그리기 추가
  * 스케일지정, 회전지정
  * 각도はラジアン
  * 화면외컬링없음
  * 회전지정は화면외컬링없음のみ
  * ---------------------------------------------------------------------------*/
 public bool AddDrawSpritesNC(Vector3 pos, d3d_sprite_rects.rect _rect, float angle_rad, Vector2 scale)
 {
     return(AddDrawSpritesNC(pos, _rect, angle_rad, scale, -1));
 }
Example #10
0
 /*-------------------------------------------------------------------------
  * 스프라이트の그리기 추가
  * 등배, 색지정
  * 화면외컬링없음
  * ---------------------------------------------------------------------------*/
 public bool AddDrawSpritesNC(Vector3 pos, d3d_sprite_rects.rect _rect, int color)
 {
     return(AddDrawSpritesNC(pos, _rect, color, new Vector2(0, 0)));
 }
Example #11
0
        //#endif

        /*-------------------------------------------------------------------------
         * 스프라이트の그리기 추가
         * 등배, 白, 不투명
         * 화면외컬링없음
         * ---------------------------------------------------------------------------*/
        public bool AddDrawSpritesNC(Vector3 pos, d3d_sprite_rects.rect _rect)
        {
            return(AddDrawSpritesNC(pos, _rect, -1));
        }
Example #12
0
 /*-------------------------------------------------------------------------
  * 스프라이트の그리기 추가
  * 스케일지정
  * ---------------------------------------------------------------------------*/
 public bool AddDrawSprites(Vector3 pos, d3d_sprite_rects.rect _rect, Vector2 scale)
 {
     return(AddDrawSprites(pos, _rect, scale, -1));
 }