//-----------------------------------------------------------------------------------
// Bismillahirrahmanirrahim  
//-----------------------------------------------------------------------------------
//																					|
//               MOS 2D Engine ( MEYDANERĘ OpenGL Software Engine)					|
//																				    |
// ----------------------------------------------------------------------------------
//    Yapimci = Vedat Meydaneri														|
//     email = Chenmy1@yahoo.com													|
//     web = www.turkop.cjb.net														|
//-----------------------------------------------------------------------------------
// MOS 2D Engine (Vedat Meydaneri ) - Olusturma tarihi :10/ Temmuz /2003 saat: 15:00 |
//************************************************************************************
//************************************************************************************
//************************************************************************************
//------------------------------------------------------------------------------------  



#include "mossprite.h"
 extern PFNGLMULTITEXCOORD2FARBPROC		glMultiTexCoord2fARB;





MOSSprite::MOSSprite(void)
{
	r=1.0;
	g=1.0;
	b=1.0;
	alfa=1;
	 m_VelX=1;				
	 m_VelY=1;				
	 m_Frame=0;
	 m_Delay=0;
	 m_State=0;
	 m_Type=0;
	 tile =1;
	 cevirhiz=1;
	 xpos,ypos=0;
	 for(int i=0;i <3;i++)
	 {
	 u[i]=0;
	 v[i]=0;
	 }
}
MOSSprite::~MOSSprite(void)
{

}
bool MOSSprite::Olustur(MOSResim resim,int Y,char *textureadi,bool maske,char *maskname,int eni,int boyu,bool Texture2b,char *textureadi2)
{
	resim.TextureYapPack(texture,textureadi);
	if(maske==TRUE)
	{
	resim.TextureYapPack(mask,maskname);
	}
	if(Texture2b==TRUE)
	{
	resim.TextureYapPack(texture2l,textureadi2);
	}
	xpos,ypos=0;
	r=1.0;

	g=1.0;
	cevirhiz=1;
	b=1.0;
	en=eni;
	boy=boyu;
	alfa=1;
	 m_VelX=1;
	 m_VelY=1;
	 vx=1;
	 vy=1;
	 m_Frame=0;
	 m_Delay=0;
	 m_State=0;
	 m_Type=0;
	 tile =1;
	 EkranY =Y;
	 	 for(int i=0;i <3;i++)
	 {
	 u[i]=0;
	 v[i]=0;
	 }

	
	//g_log.bPrint("|----------->  sprite yuklendi...");


	return TRUE;
}
bool MOSSprite::Olustur(MOSTile *tiles)
{
	
    texture = tiles->texture;
	mask = tiles->mask;
	xpos,ypos=0;
	r=1.0;
	g=1.0;
	cevirhiz=1;
	b=1.0;
	en=tiles->en;
	boy=tiles->boy;
	alfa=1;
	 m_VelX=1;
	 m_VelY=1;
	 vx=1;
	 vy=1;
		texnum=tiles->texnum;
	maxtex=tiles->maxtex;
	 m_Frame=0;
	 m_Delay=tiles->delay;
	 m_State=0;
	 m_Type=0;
	 tile =1;
	 EkranY =tiles->EkranY;	 
	 for(int i=0;i <3;i++)
	 {
	 u[i]=0;
	 v[i]=0;
	 }
	return TRUE;
}
bool MOSSprite::OlusturEfek(MOSTile *tiles)
{
	for(int is=0;is < tiles->maxtex;is++)
	{
    maxtexture[is] = tiles->maxtexture[is];
	}
	mask = tiles->mask;
	xpos,ypos=0;
	r=1.0;
	g=1.0;
	cevirhiz=1;
	b=1.0;
	en=tiles->en;
	boy=tiles->boy;
	alfa=1;
	 m_VelX=1;
	 m_VelY=1;
	 vx=1;
	 vy=1;
		texnum=tiles->texnum;
	maxtex=tiles->maxtex;
	 m_Frame=0;
	 m_Delay=tiles->delay;
	 m_State=0;
	 m_Type=0;
	 tile =1;
	 EkranY =tiles->EkranY;	 
	 for(int i=0;i <3;i++)
	 {
	 u[i]=0;
	 v[i]=0;
	 }
	return TRUE;
}

void MOSSprite::Sprite(float x,float y,float e,float b)     
{
	

     glColor4f(r,g,b,alfa);

	 glBegin(GL_QUADS);
		glTexCoord2f(0, 1);
		glVertex3f( x, EkranY -y, 0);

		glTexCoord2f(1, 1);
		glVertex3f( e, EkranY -y, 0);

		glTexCoord2f(1, 0);
		glVertex3f(  e, EkranY -b, 0);

		glTexCoord2f(0, 0);
		glVertex3f( x, EkranY -b, 0);
	glEnd();
	

}
void MOSSprite::SpriteTile(float x,float y,float e,float b)     
{
	

     glColor4f(r,g,b,alfa);

	 glBegin(GL_QUADS);
		glTexCoord2f(0, 1*tile);
		glVertex3f( x, EkranY -y, 0);

		glTexCoord2f(1*tile, 1*tile);
		glVertex3f( e, EkranY -y, 0);

		glTexCoord2f(1*tile, 0*tile);
		glVertex3f(  e, EkranY -b, 0);

		glTexCoord2f(0, 0);
		glVertex3f( x, EkranY -b, 0);
	glEnd();
	

}
void MOSSprite::SpriteTileuvup(float x,float y,float e,float b)     
{
	
	static float b1 =0;

	b1+=0.001f*cevirhiz;
	if(b1 > 1.0)
	{
		b1 =0;
	}

     glColor4f(r,g,b,alfa);

	 glBegin(GL_QUADS);
		glTexCoord2f(0+b1, (1*tile)+b1);
		glVertex3f( x, EkranY -y, 0);

		glTexCoord2f((1*tile)+b1, (1*tile)+b1);
		glVertex3f( e, EkranY -y, 0);

		glTexCoord2f((1*tile)+b1, 0+b1);
		glVertex3f(  e, EkranY -b, 0);

		glTexCoord2f(0+b1, 0+b1);
		glVertex3f( x, EkranY -b, 0);
	glEnd();
	

}
void MOSSprite::SpriteTileuvdown(float x,float y,float e,float b)     
{
	
	static float c =1.0;

	c-=0.001f*cevirhiz;
	if(c < 0.0)
	{
		c =1.0;
	}

     glColor4f(r,g,b,alfa);

	 glBegin(GL_QUADS);
		glTexCoord2f(0+c, (1*tile)+c);
		glVertex3f( x, EkranY -y, 0);

		glTexCoord2f((1*tile)+c, (1*tile)+c);
		glVertex3f( e, EkranY -y, 0);

		glTexCoord2f((1*tile)+c, 0+c);
		glVertex3f(  e, EkranY -b, 0);

		glTexCoord2f(0+c, 0+c);
		glVertex3f( x, EkranY -b, 0);
	glEnd();
	

}
void MOSSprite::SpriteCevirUVleft(float x,float y,float e,float b)     
{
	
	static float a2 =1.0;

	a2-=0.001f*cevirhiz;
	if(a2 < 0)
	{
		a2 =1.0;
	}

     glColor4f(r,g,b,alfa);

	 glBegin(GL_QUADS);
		glTexCoord2f(0+a2, 1);
		glVertex3f( x, EkranY -y, 0);

		glTexCoord2f(1+a2, 1);
		glVertex3f( e, EkranY -y, 0);

		glTexCoord2f(1+a2, 0);
		glVertex3f(  e, EkranY -b, 0);

		glTexCoord2f(0+a2, 0);
		glVertex3f( x, EkranY -b, 0);
	glEnd();
	

}
void MOSSprite::SpriteCevirUVright(float x,float y,float e,float b)     
{
	
	static float a3 =0;

	a3+=0.001f*cevirhiz;
	if(a3 > 1.0)
	{
		a3 =0;
	}

     glColor4f(r,g,b,alfa);

	 glBegin(GL_QUADS);
		glTexCoord2f(0+a3, 1);
		glVertex3f( x, EkranY -y, 0);

		glTexCoord2f(1+a3, 1);
		glVertex3f( e, EkranY -y, 0);

		glTexCoord2f(1+a3, 0);
		glVertex3f(  e, EkranY -b, 0);

		glTexCoord2f(0+a3, 0);
		glVertex3f( x, EkranY -b, 0);
	glEnd();
	

}
void MOSSprite::SpriteCevirUVup(float x,float y,float e,float b)     
{
	
	static float a =0;

	a+=0.001f*cevirhiz;
	if(a > 1.0)
	{
		a =0;
	}

     glColor4f(r,g,b,alfa);

	 glBegin(GL_QUADS);
		glTexCoord2f(0+a, 1+a);
		glVertex3f( x, EkranY -y, 0);

		glTexCoord2f(1+a, 1+a);
		glVertex3f( e, EkranY -y, 0);

		glTexCoord2f(1+a, 0+a);
		glVertex3f(  e, EkranY -b, 0);

		glTexCoord2f(0+a, 0+a);
		glVertex3f( x, EkranY -b, 0);
	glEnd();
	

}
void MOSSprite::SpriteCevirUVdown(float x,float y,float e,float b)     
{
	
	static float a =1.0;

	a-=0.001f*cevirhiz;
	if(a < 0.0)
	{
		a =1.0;
	}

     glColor4f(r,g,b,alfa);

	 glBegin(GL_QUADS);
		glTexCoord2f(0+a, 1+a);
		glVertex3f( x, EkranY -y, 0);

		glTexCoord2f(1+a, 1+a);
		glVertex3f( e, EkranY -y, 0);

		glTexCoord2f(1+a, 0+a);
		glVertex3f(  e, EkranY -b, 0);

		glTexCoord2f(0+a, 0+a);
		glVertex3f( x, EkranY -b, 0);
	glEnd();
	

}
void MOSSprite::SpriteUV(float um[3],float uv[3],float x,float y,float e,float b)     
{
	

     glColor4f(r,g,b,alfa);

	 glBegin(GL_QUADS);
		glTexCoord2f(um[0], uv[0]);
		glVertex3f( x, EkranY -y, 0);

		glTexCoord2f(um[1], uv[1]);
		glVertex3f( e, EkranY -y, 0);

		glTexCoord2f(um[2], uv[2]);
		glVertex3f(  e, EkranY -b, 0);

		glTexCoord2f(um[3], uv[3]);
		glVertex3f( x, EkranY -b, 0);
	glEnd();
	

}

void MOSSprite::SpriteMask(float x,float y,float e,float b)     
{
	

     glColor4f(1,1,1,1);

	 glBegin(GL_QUADS);
		glTexCoord2f(0, 1);
		glVertex3f( x, EkranY -y, 0);

		glTexCoord2f(1, 1);
		glVertex3f( e, EkranY -y, 0);

		glTexCoord2f(1, 0);
		glVertex3f(  e, EkranY -b, 0);

		glTexCoord2f(0, 0);
		glVertex3f( x, EkranY -b, 0);
	glEnd();
	

}
void MOSSprite::DrawShader(DWORD Drawturu,bool blend,float um[3],float uv[3])
{
	
	glLoadIdentity();
	

		if(blend==TRUE)
		{
		glEnable(GL_BLEND);
		}

		switch(Drawturu)
		{
	
		    case GL_SPRITE_ALFA:
			{
	/*		
				glBlendFunc(GL_DST_COLOR,GL_ZERO);
				glBindTexture(GL_TEXTURE_2D, mask);
				SpriteMask(xpos,ypos,xpos+en,ypos+boy);
*/
				glBlendFunc(GL_DST_ALPHA, GL_ONE);
				glBindTexture(GL_TEXTURE_2D, texture);
			    SpriteUV(um,uv,xpos,ypos,xpos+en,ypos+boy);

			}
			break;
		case GL_SPRITE_TRANS:
			{	
			/*	glBlendFunc(GL_DST_COLOR,GL_ZERO);
				glBindTexture(GL_TEXTURE_2D, mask);
				SpriteMask(xpos,ypos,xpos+en,ypos+boy);
*/
				glBlendFunc(GL_ONE ,GL_ONE  );
				glBindTexture(GL_TEXTURE_2D, texture);
				//Sprite(xpos,ypos,xpos+en,ypos+boy);
				SpriteUV(um,uv,xpos,ypos,xpos+en,ypos+boy);
			}
			break;
            case GL_SPRITE_NORMAL:
			{
				glDisable(GL_BLEND);
				glBindTexture(GL_TEXTURE_2D, texture);
				 //Sprite(xpos,ypos,xpos+en,ypos+boy);
				SpriteUV(um,uv,xpos,ypos,xpos+en,ypos+boy);
			}
			break;

	
		}
		
	

		glDisable(GL_BLEND);
		

}

void MOSSprite::Draw(DWORD Drawturu,bool blend,bool maske)
{
	
	glLoadIdentity();
	
//glDisable(GL_BLEND);
//	glEnable(GL_TEXTURE_2D);
	
		if(blend==TRUE)
		{
	glDisable(GL_DEPTH_TEST);
	glBlendFunc(GL_SRC_ALPHA,GL_ONE);
	glEnable(GL_BLEND);
		}
		

		switch(Drawturu)
		{
	  
		
	    	case GL_SPRITE_ALFA_FAST:
			{
			
	         /* 	glBlendFunc(GL_DST_ALPHA, GL_ONE);
				glBindTexture(GL_TEXTURE_2D, texture);
			    Sprite(xpos,ypos,xpos+en,ypos+boy);
				
				glBlendFunc(GL_ONE ,GL_ONE  );
				glBindTexture(GL_TEXTURE_2D, texture);
				Sprite(xpos,ypos,xpos+en,ypos+boy);
              */
				//glBlendFunc(GL_ONE ,GL_ONE  );
				glBindTexture(GL_TEXTURE_2D, texture);
				Sprite(xpos,ypos,xpos+en,ypos+boy);
			}
			break;
		    case GL_SPRITE_ALFA:
			{
			
	           if(maske == TRUE)
				{
				glBlendFunc(GL_DST_COLOR,GL_ZERO);
				glBindTexture(GL_TEXTURE_2D, mask);
				SpriteMask(xpos,ypos,xpos+en,ypos+boy);
				}

				glBlendFunc(GL_DST_ALPHA, GL_ONE);
				glBindTexture(GL_TEXTURE_2D, texture);
			    Sprite(xpos,ypos,xpos+en,ypos+boy);

			}
			break;	
			case GL_SPRITE_TRANS_TILE_UV_DOWN:
			{		if(maske==TRUE)
				{
				glBlendFunc(GL_DST_COLOR,GL_ZERO);
				glBindTexture(GL_TEXTURE_2D, mask);
				SpriteMask(xpos,ypos,xpos+en,ypos+boy);
			}

				glBlendFunc(GL_ONE ,GL_ONE  );
				glBindTexture(GL_TEXTURE_2D, texture);
				SpriteTileuvdown(xpos,ypos,xpos+en,ypos+boy);
			}
			break;	
			case GL_SPRITE_TRANS_TILE_UV_UP:
			{		if(maske==TRUE)
				{
				glBlendFunc(GL_DST_COLOR,GL_ZERO);
				glBindTexture(GL_TEXTURE_2D, mask);
				SpriteMask(xpos,ypos,xpos+en,ypos+boy);
			}

				glBlendFunc(GL_ONE ,GL_ONE  );
				glBindTexture(GL_TEXTURE_2D, texture);
				SpriteTileuvup(xpos,ypos,xpos+en,ypos+boy);
			}
			break;
			case GL_SPRITE_TRANS_UV_LEFT:
			{	
				if(maske==TRUE)
				{
				glBlendFunc(GL_DST_COLOR,GL_ZERO);
				glBindTexture(GL_TEXTURE_2D, mask);
				SpriteMask(xpos,ypos,xpos+en,ypos+boy);
				}

				glBlendFunc(GL_ONE ,GL_ONE  );
				glBindTexture(GL_TEXTURE_2D, texture);
				SpriteCevirUVleft(xpos,ypos,xpos+en,ypos+boy);
			}
			break;	
			case GL_SPRITE_TRANS_UV_RIGHT:
			{	if(maske==TRUE)
				{
				glBlendFunc(GL_DST_COLOR,GL_ZERO);
				glBindTexture(GL_TEXTURE_2D, mask);
				SpriteMask(xpos,ypos,xpos+en,ypos+boy);
			}

				glBlendFunc(GL_ONE ,GL_ONE  );
				glBindTexture(GL_TEXTURE_2D, texture);
				SpriteCevirUVright(xpos,ypos,xpos+en,ypos+boy);
			}
			break;
			case GL_SPRITE_TRANS_UV_DOWN:
			{		if(maske==TRUE)
				{
				glBlendFunc(GL_DST_COLOR,GL_ZERO);
				glBindTexture(GL_TEXTURE_2D, mask);
				SpriteMask(xpos,ypos,xpos+en,ypos+boy);
			}

				glBlendFunc(GL_ONE ,GL_ONE  );
				glBindTexture(GL_TEXTURE_2D, texture);
				SpriteCevirUVdown(xpos,ypos,xpos+en,ypos+boy);
			}
			break;	
			case GL_SPRITE_TRANS_UV_UP:
			{			if(maske==TRUE)
				{
				glBlendFunc(GL_DST_COLOR,GL_ZERO);
				glBindTexture(GL_TEXTURE_2D, mask);
				SpriteMask(xpos,ypos,xpos+en,ypos+boy);
			}

				glBlendFunc(GL_ONE ,GL_ONE  );
				glBindTexture(GL_TEXTURE_2D, texture);
				SpriteCevirUVup(xpos,ypos,xpos+en,ypos+boy);
			}
			break;
		case GL_SPRITE_TRANS:
			{	
				if(maske == TRUE)
				{
				glBlendFunc(GL_DST_COLOR,GL_ZERO);
				glBindTexture(GL_TEXTURE_2D, mask);
				SpriteMask(xpos,ypos,xpos+en,ypos+boy);
				}
				glBlendFunc(GL_ONE ,GL_ONE  );
				glBindTexture(GL_TEXTURE_2D, texture);
				Sprite(xpos,ypos,xpos+en,ypos+boy);
			}
			break;

		case GL_SPRITE_TRANS_MULTI:
			{	
			

			}
			break;
            case GL_SPRITE_NORMAL:
			{
				glDisable(GL_BLEND);
				glBindTexture(GL_TEXTURE_2D, texture);
				 Sprite(xpos,ypos,xpos+en,ypos+boy);
			}
			break;  
			case GL_SPRITE_NORMAL_TILE:
			{
				glDisable(GL_BLEND);
				glBindTexture(GL_TEXTURE_2D, texture);
				SpriteTile(xpos,ypos,xpos+en,ypos+boy);
			}
			break; 	
			case GL_SPRITE_NORMAL_TILE_UV_UP:
			{
				glDisable(GL_BLEND);
				glBindTexture(GL_TEXTURE_2D, texture);
				SpriteTileuvup(xpos,ypos,xpos+en,ypos+boy);
			}
			break; 
			case GL_SPRITE_NORMAL_TILE_UV_DOWN:
			{
				glDisable(GL_BLEND);
				glBindTexture(GL_TEXTURE_2D, texture);
				SpriteTileuvdown(xpos,ypos,xpos+en,ypos+boy);
			}
			break;
			case GL_SPRITE_TRANSALFA:
			{
					glEnable(GL_BLEND);
		if(maske==TRUE)
				{
				glBlendFunc(GL_DST_COLOR,GL_ZERO);
				glBindTexture(GL_TEXTURE_2D, mask);
				SpriteMask(xpos,ypos,xpos+en,ypos+boy);
		}

				glBlendFunc(GL_SRC_COLOR ,GL_ONE  );
				glBindTexture(GL_TEXTURE_2D, texture);
				Sprite(xpos,ypos,xpos+en,ypos+boy);	

			
			}
			break;
/*
			GL_DST_COLOR
BlendDST1  GL_ONE
			*/
	
		}
		
	

		glDisable(GL_BLEND);
		
}
void MOSSprite::DrawEfek(DWORD Drawturu,bool blend,float hizi)
{
	
	glLoadIdentity();
	
//glDisable(GL_BLEND);
//	glEnable(GL_TEXTURE_2D);
	
		if(blend==TRUE)
		{
	glDisable(GL_DEPTH_TEST);
	glBlendFunc(GL_SRC_ALPHA,GL_ONE);
	glEnable(GL_BLEND);
		}

		static float delay = hizi;
		delay--;
		if(delay < 0)
		{
		  if(texnum < maxtex-1)
		  {
           texnum++;
		  }else
		  {
			  texnum=0;
			  m_Delay = 100;
		  }

			delay = hizi;
		}

		switch(Drawturu)
		{
	  
		
	    	
		case GL_SPRITE_TRANS:
			{	
			/*	if(maske == TRUE)
				{
				glBlendFunc(GL_DST_COLOR,GL_ZERO);
				glBindTexture(GL_TEXTURE_2D, mask);
				SpriteMask(xpos,ypos,xpos+en,ypos+boy);
				}*/

				glBlendFunc(GL_ONE ,GL_ONE  );
				
				glBindTexture(GL_TEXTURE_2D, maxtexture[texnum]);
				Sprite(xpos,ypos,xpos+en,ypos+boy);
			}
			break;

	
            case GL_SPRITE_NORMAL:
			{
				glDisable(GL_BLEND);
				glBindTexture(GL_TEXTURE_2D, texture);
				 Sprite(xpos,ypos,xpos+en,ypos+boy);
			}
			break;  
			
		 					
		}
		
	

		glDisable(GL_BLEND);
		
}
void MOSSprite::DrawUV(DWORD Drawturu,bool blend)
{
	
	glLoadIdentity();


		if(blend==TRUE)
		{
		glEnable(GL_BLEND);
		}

		switch(Drawturu)
		{
	
		    case GL_SPRITE_ALFA:
			{
			
				glBlendFunc(GL_DST_COLOR,GL_ZERO);
				glBindTexture(GL_TEXTURE_2D, mask);
				SpriteMask(xpos,ypos,xpos+en,ypos+boy);

				glBlendFunc(GL_DST_ALPHA, GL_ONE);
				glBindTexture(GL_TEXTURE_2D, texture);
			    SpriteUV(u,v,xpos,ypos,xpos+en,ypos+boy);

			}
			break;
		case GL_SPRITE_TRANS:
			{	
				glBlendFunc(GL_DST_COLOR,GL_ZERO);
				glBindTexture(GL_TEXTURE_2D, mask);
				SpriteMask(xpos,ypos,xpos+en,ypos+boy);

				glBlendFunc(GL_ONE ,GL_ONE  );
				glBindTexture(GL_TEXTURE_2D, texture);
				SpriteUV(u,v,xpos,ypos,xpos+en,ypos+boy);
			}
			break;
		
	
            case GL_SPRITE_NORMAL:
			{
				glDisable(GL_BLEND);
				glBindTexture(GL_TEXTURE_2D, texture);
				 SpriteUV(u,v,xpos,ypos,xpos+en,ypos+boy);
			}
			break;

	
		}
		
	

		glDisable(GL_BLEND);
		

}
void MOSSprite::SetPos(float x,float y)
{
	xpos= x;
	ypos = y;
}
float MOSSprite::GetPosX()
{
	return xpos;
}
float MOSSprite::GetPosY()
{
	return ypos;
}

void MOSSprite::SetRenk(float k,float y,float m)
{ 
	r = k;
	g=y;
	b=m;
}
void MOSSprite::SetAlfa(float alf)
{
	alfa = alf;
}
void MOSSprite::SetVel(float vx,float vy)
{
	m_VelX = vx;
	m_VelY = vy;
}
void MOSSprite::SetEnBoy(float eni,float boyu)
{
	en = eni;
	boy = boyu;
}
void MOSSprite::SetVelX(float vx)
{
	m_VelX = vx;

}
void MOSSprite::SetVelY(float vy)
{
	m_VelY = vy;

}
void MOSSprite::SetPosX(float px)
{
	xpos = px;

}
void MOSSprite::SetPosY(float py)
{
	ypos = py;

}
float MOSSprite::GetWidth() 
{
	return en;
}
float MOSSprite::GetHeight() 
{
	return boy;
}
float MOSSprite::GetVelX()
{
	return m_VelX;
}
float MOSSprite::GetVelY()
{
	return m_VelY;
}
int MOSSprite::GetFrame()
{
	return m_Frame;
}
int MOSSprite::GetDelay()
{
	return m_Delay;
}
int MOSSprite::GetState()
{
	return m_State;
}
int MOSSprite::GetType()
{
	return m_Type;
}
void MOSSprite::SetFrame(int frame)
{
	m_Frame = frame;
}
void MOSSprite::SetDelay(int delay)
{
	m_Delay = delay;
}
void MOSSprite::SetState(int state)
{
	m_State = state;
}
void MOSSprite::SetType(int Type)
{
	m_Type = Type;
}
void MOSSprite::SetUV(float um[3],float uv[3])
{
	for(int i=0;i<3;i++)
	{
		u[i] = um[i];
		v[i] = uv[i];
	}
	
}